修改评论通知评分样式

分离 messageProvieder
评论消息和系统消息添加已读
hmxc
张萌 3 years ago
parent 115e2d9dc1
commit 58c6279b09

@ -343,4 +343,10 @@ class _Message {
///id ///id
String get getSystemByDispatchId => '/user/message/findRepairByRepairId'; String get getSystemByDispatchId => '/user/message/findRepairByRepairId';
///()
String get allReadCommentMes => '/user/message/allReadComment';
///()
String get allReadSysMes => '/user/message/allReadSys';
} }

@ -1,4 +1,6 @@
// Flutter imports: // Flutter imports:
import 'package:aku_community_manager/provider/message_provider.dart';
import 'package:aku_community_manager/tools/user_tool.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -30,8 +32,7 @@ void main() async {
print("flutter onReceiveNotification: $message"); print("flutter onReceiveNotification: $message");
LoggerData.addData(message); LoggerData.addData(message);
await JpushMessageParse(message!).shot(); await JpushMessageParse(message!).shot();
final appProvider = Provider.of<AppProvider>(Get.context!, listen: false); UserTool.messageProvider.updateMessage();
appProvider.updateMessage();
}, },
// //
onOpenNotification: (Map<String, dynamic>? message) async { onOpenNotification: (Map<String, dynamic>? message) async {
@ -62,13 +63,7 @@ class MyApp extends StatelessWidget {
providers: [ providers: [
ChangeNotifierProvider(create: (context) => UserProvider()), ChangeNotifierProvider(create: (context) => UserProvider()),
ChangeNotifierProvider(create: (context) => AppProvider()), ChangeNotifierProvider(create: (context) => AppProvider()),
// ChangeNotifierProvider(create: (context) => FixProvider()), ChangeNotifierProvider(create: (context) => MessageProvider()),
// ChangeNotifierProvider(create: (context) => GreenManageProvider()),
// ChangeNotifierProvider(
// create: (context) => InspectionManageProvider()),
// ChangeNotifierProvider(create: (context) => GreenManageProvider()),
// ChangeNotifierProvider(
// create: (context) => InspectionManageProvider()),
], ],
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {

@ -21,4 +21,19 @@ class SystemMessageDetailModel {
data['type'] = this.type; data['type'] = this.type;
return data; return data;
} }
String get sysMesTypeString {
switch (this.type) {
case 1:
return '报事报修';
case 2:
return '装修';
case 3:
return '绿化任务';
case 4:
return '卫生任务';
default:
return '未知';
} }
}
}

@ -5,12 +5,9 @@ import 'package:flutter/material.dart';
// Package imports: // Package imports:
import 'package:amap_flutter_location/amap_flutter_location.dart'; import 'package:amap_flutter_location/amap_flutter_location.dart';
import 'package:amap_flutter_location/amap_location_option.dart'; import 'package:amap_flutter_location/amap_location_option.dart';
import 'package:dio/dio.dart';
// Project imports: // Project imports:
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/ui/home/application/applications_page.dart'; import 'package:aku_community_manager/ui/home/application/applications_page.dart';
import 'package:aku_community_manager/utils/network/net_util.dart';
enum WORKCLOCK { enum WORKCLOCK {
/// ///
@ -68,19 +65,7 @@ class AppProvider extends ChangeNotifier {
_flutterLocation.destroy(); _flutterLocation.destroy();
} }
int _sysMessage = 0;
int _commentMessage = 0;
bool get hasMessage => _sysMessage != 0 || _commentMessage != 0;
int get sysMessage => _sysMessage;
int get commentMessage => _commentMessage;
updateMessage() async {
Response response = await NetUtil().dio!.get(API.message.messageCenter);
if (response.data == null) return;
_sysMessage = response.data['sysCount'] ?? 0;
_commentMessage = response.data['commentCount'] ?? 0;
notifyListeners();
}
WORKCLOCK _clockStatus = WORKCLOCK.NOTIN; WORKCLOCK _clockStatus = WORKCLOCK.NOTIN;
DateTime? _clockInTime; DateTime? _clockInTime;

@ -0,0 +1,46 @@
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/utils/network/net_util.dart';
import 'package:common_utils/common_utils.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
class MessageProvider extends ChangeNotifier {
int _sysMessage = 0;
int _commentMessage = 0;
String _sysDate = '';
String _commentDate = '';
bool get hasMessage => _sysMessage != 0 || _commentMessage != 0;
int get sysMessage => _sysMessage;
int get commentMessage => _commentMessage;
String get sysDate =>
DateUtil.formatDateStr(_sysDate, format: 'yyyy-MM-dd HH:mm');
String get commentDate =>
DateUtil.formatDateStr(_commentDate, format: 'yyyy-MM-dd HH:mm');
int _sysMesType = 0;
String get sysMesTypeString {
switch (_sysMesType) {
case 1:
return '报事报修';
case 2:
return '装修';
case 3:
return '绿化任务';
case 4:
return '卫生任务';
default:
return '未知';
}
}
updateMessage() async {
Response response = await NetUtil().dio!.get(API.message.messageCenter);
if (response.data == null) return;
_sysMessage = response.data['sysCount'] ?? 0;
_commentMessage = response.data['commentCount'] ?? 0;
_sysMesType = response.data['sysType'] ?? 0;
_sysDate = response.data['sysDate'] ?? '';
_commentDate = response.data['commentDate'] ?? '';
notifyListeners();
}
}

@ -3,6 +3,7 @@ import 'dart:io';
// Flutter imports: // Flutter imports:
import 'package:aku_community_manager/models/user/user_info_model.dart'; import 'package:aku_community_manager/models/user/user_info_model.dart';
import 'package:aku_community_manager/provider/message_provider.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
@ -14,7 +15,6 @@ import 'package:provider/provider.dart';
// Project imports: // Project imports:
import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/models/user/user_profile_model.dart'; import 'package:aku_community_manager/models/user/user_profile_model.dart';
import 'package:aku_community_manager/provider/app_provider.dart';
import 'package:aku_community_manager/utils/hive_store.dart'; import 'package:aku_community_manager/utils/hive_store.dart';
import 'package:aku_community_manager/utils/network/base_file_model.dart'; import 'package:aku_community_manager/utils/network/base_file_model.dart';
import 'package:aku_community_manager/utils/network/base_model.dart'; import 'package:aku_community_manager/utils/network/base_model.dart';
@ -48,8 +48,8 @@ class UserProvider extends ChangeNotifier {
///profile ///profile
Future<UserProfileModel?> updateProfile() async { Future<UserProfileModel?> updateProfile() async {
final appProvider = Provider.of<AppProvider>(Get.context!, listen: false); final messageProvider = Provider.of<MessageProvider>(Get.context!,listen: false);
appProvider.updateMessage(); messageProvider.updateMessage();
BaseModel? model = await NetUtil().get(API.user.profile); BaseModel? model = await NetUtil().get(API.user.profile);
if (model.data == null) if (model.data == null)
return null; return null;

@ -1,4 +1,5 @@
// Package imports: // Package imports:
import 'package:aku_community_manager/provider/message_provider.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -16,5 +17,8 @@ class UserTool {
static UserProvider get userProvider => static UserProvider get userProvider =>
Provider.of<UserProvider>(Get.context!, listen: false); Provider.of<UserProvider>(Get.context!, listen: false);
///
static MessageProvider get messageProvider => Provider.of<MessageProvider>(Get.context!,listen: false);
UserTool(); UserTool();
} }

@ -1,6 +1,7 @@
// Flutter imports: // Flutter imports:
import 'dart:async'; import 'dart:async';
import 'package:aku_community_manager/provider/message_provider.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_button.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_button.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_material_button.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_material_button.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -178,7 +179,8 @@ class _HomePageState extends State<HomePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final userProvider = Provider.of<UserProvider>(context); final userProvider = Provider.of<UserProvider>(context);
final appProvider = Provider.of<AppProvider>(context);
final messageProvider = Provider.of<MessageProvider>(Get.context!);
var loadingWidget = Center( var loadingWidget = Center(
// child: CircularProgressIndicator(), // child: CircularProgressIndicator(),
); );
@ -306,7 +308,7 @@ class _HomePageState extends State<HomePage> {
top: 4, top: 4,
end: 4, end: 4,
), ),
showBadge: appProvider.hasMessage, showBadge: messageProvider.hasMessage,
child: Container( child: Container(
margin: EdgeInsets.only(top: 5.w, bottom: 5.w), margin: EdgeInsets.only(top: 5.w, bottom: 5.w),
child: AkuMaterialButton( child: AkuMaterialButton(

@ -1,6 +1,7 @@
// Flutter imports: // Flutter imports:
import 'package:aku_community_manager/ui/widgets/common/aku_button.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_button.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
// Package imports: // Package imports:
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -17,7 +18,8 @@ import 'package:aku_community_manager/utils/network/net_util.dart';
class CommentMessageCard extends StatefulWidget { class CommentMessageCard extends StatefulWidget {
final CommentMessageItemModel itemModel; final CommentMessageItemModel itemModel;
CommentMessageCard({Key? key, /*required*/ required this.itemModel}) : super(key: key); CommentMessageCard({Key? key, /*required*/ required this.itemModel})
: super(key: key);
@override @override
_CommentMessageCardState createState() => _CommentMessageCardState(); _CommentMessageCardState createState() => _CommentMessageCardState();
@ -288,10 +290,21 @@ class _CommentMessageCardState extends State<CommentMessageCard> {
color: AppStyle.minorTextColor, color: AppStyle.minorTextColor,
fontSize: 28.sp)), fontSize: 28.sp)),
Spacer(), Spacer(),
Text(getComment(model.level!), // Text(getComment(model.level!),
style: TextStyle( // style: TextStyle(
color: AppStyle.primaryTextColor, // color: AppStyle.primaryTextColor,
fontSize: 28.sp)), // fontSize: 28.sp)),
RatingBar.builder(
initialRating: model.level!.toDouble(),
itemSize: 40.w,
allowHalfRating: true,
itemBuilder: (context, index) {
return Image.asset(
R.ASSETS_MESSAGE_IC_STAR_PNG,
color: kPrimaryColor,
);
},
onRatingUpdate: (rate) {})
], ],
).pSymmetric(h: 24.w), ).pSymmetric(h: 24.w),
SizedBox(height: 16.w), SizedBox(height: 16.w),

@ -1,5 +1,9 @@
// Flutter imports: // Flutter imports:
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/provider/message_provider.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_button.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_button.dart';
import 'package:aku_community_manager/utils/network/base_model.dart';
import 'package:aku_community_manager/utils/network/net_util.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
@ -12,7 +16,6 @@ import 'package:provider/provider.dart';
// Project imports: // Project imports:
import 'package:aku_community_manager/const/resource.dart'; import 'package:aku_community_manager/const/resource.dart';
import 'package:aku_community_manager/provider/app_provider.dart';
import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/ui/home/messages/comment_message.dart'; import 'package:aku_community_manager/ui/home/messages/comment_message.dart';
import 'package:aku_community_manager/ui/home/messages/system_message.dart'; import 'package:aku_community_manager/ui/home/messages/system_message.dart';
@ -132,7 +135,8 @@ class _MessageState extends State<Message> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final appProvider = Provider.of<AppProvider>(context); final messageProvider =
Provider.of<MessageProvider>(Get.context!, listen: false);
return AkuScaffold( return AkuScaffold(
title: '消息', title: '消息',
titleStyle: AppStyle().barTitleStyle, titleStyle: AppStyle().barTitleStyle,
@ -140,33 +144,43 @@ class _MessageState extends State<Message> {
controller: _refreshController, controller: _refreshController,
firstRefresh: true, firstRefresh: true,
onRefresh: () async { onRefresh: () async {
await appProvider.updateMessage(); await messageProvider.updateMessage();
}, },
header: MaterialHeader(), header: MaterialHeader(),
child: ListView( child: ListView(
padding: EdgeInsets.only(top: 16.w), padding: EdgeInsets.only(top: 16.w),
children: [ children: [
_messageListTile( _messageListTile(
'', messageProvider.sysDate,
_messageTypeImage('系统消息'), _messageTypeImage('系统消息'),
'系统消息', '系统消息',
'你有一条新的报事报修待处理', '你有一条新的${messageProvider.sysMesTypeString}待处理',
appProvider.sysMessage, messageProvider.sysMessage,
onpressed: () { onpressed: () async {
BaseModel baseModel =
await NetUtil().get(API.message.allReadSysMes);
if (baseModel.status ?? false) {
messageProvider.updateMessage();
Get.to(() => SystemMessage()); Get.to(() => SystemMessage());
}
}, },
), ),
Divider( Divider(
height: 1.w, height: 1.w,
), ),
_messageListTile( _messageListTile(
'', messageProvider.commentDate,
_messageTypeImage('评论消息'), _messageTypeImage('评论消息'),
'评论消息', '评论消息',
'你有一条新的评论回复', '你有一条新的评论回复',
appProvider.commentMessage, messageProvider.commentMessage,
onpressed: () { onpressed: () async {
BaseModel baseModel =
await NetUtil().get(API.message.allReadCommentMes);
if (baseModel.status ?? false) {
messageProvider.updateMessage();
Get.to(() => CommentMessage()); Get.to(() => CommentMessage());
}
}, },
), ),
], ],

@ -224,7 +224,7 @@ class _SystemMessageCardState extends State<SystemMessageCard> {
SizedBox(height: 8.w), SizedBox(height: 8.w),
]), ]),
Text( Text(
'你有一条新的报事报修,请立即处理', '你有一条新的${model.sysMesTypeString},请立即处理',
style: TextStyle( style: TextStyle(
color: AppStyle.primaryTextColor, color: AppStyle.primaryTextColor,
fontSize: 28.sp, fontSize: 28.sp,

Loading…
Cancel
Save