修改评论通知评分样式

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

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

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

@ -21,4 +21,19 @@ class SystemMessageDetailModel {
data['type'] = this.type;
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:
import 'package:amap_flutter_location/amap_flutter_location.dart';
import 'package:amap_flutter_location/amap_location_option.dart';
import 'package:dio/dio.dart';
// 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/utils/network/net_util.dart';
enum WORKCLOCK {
///
@ -68,19 +65,7 @@ class AppProvider extends ChangeNotifier {
_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;
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:
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';
// Package imports:
@ -14,7 +15,6 @@ import 'package:provider/provider.dart';
// Project imports:
import 'package:aku_community_manager/const/api.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/network/base_file_model.dart';
import 'package:aku_community_manager/utils/network/base_model.dart';
@ -48,8 +48,8 @@ class UserProvider extends ChangeNotifier {
///profile
Future<UserProfileModel?> updateProfile() async {
final appProvider = Provider.of<AppProvider>(Get.context!, listen: false);
appProvider.updateMessage();
final messageProvider = Provider.of<MessageProvider>(Get.context!,listen: false);
messageProvider.updateMessage();
BaseModel? model = await NetUtil().get(API.user.profile);
if (model.data == null)
return null;

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

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

@ -1,6 +1,7 @@
// Flutter imports:
import 'package:aku_community_manager/ui/widgets/common/aku_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
// Package imports:
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 {
final CommentMessageItemModel itemModel;
CommentMessageCard({Key? key, /*required*/ required this.itemModel}) : super(key: key);
CommentMessageCard({Key? key, /*required*/ required this.itemModel})
: super(key: key);
@override
_CommentMessageCardState createState() => _CommentMessageCardState();
@ -288,10 +290,21 @@ class _CommentMessageCardState extends State<CommentMessageCard> {
color: AppStyle.minorTextColor,
fontSize: 28.sp)),
Spacer(),
Text(getComment(model.level!),
style: TextStyle(
color: AppStyle.primaryTextColor,
fontSize: 28.sp)),
// Text(getComment(model.level!),
// style: TextStyle(
// color: AppStyle.primaryTextColor,
// 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),
SizedBox(height: 16.w),

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

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

Loading…
Cancel
Save