diff --git a/lib/pages/message_notice_page/message_notice_page.dart b/lib/pages/message_notice_page/message_notice_page.dart index f61d2c3..be51db4 100644 --- a/lib/pages/message_notice_page/message_notice_page.dart +++ b/lib/pages/message_notice_page/message_notice_page.dart @@ -113,9 +113,15 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine enablePullUp: true, child: ListView.builder( padding: const EdgeInsets.only(left: 12.5, right: 12.5, top: 8), - itemCount: styleModel?.main_notification?.length ?? 0, + itemCount: styleModel?.main_notification?.list?.length ?? 0, itemBuilder: (context, index) { - return _buildMessageCenterStyleWidget(styleModel?.main_notification[index], index, styleModel?.main_notification?.length); + return _buildMessageCenterStyleWidget( + styleModel?.main_notification?.list[index], + index, + styleModel?.main_notification?.list?.length, + styleModel?.main_notification?.unread_text_color, + styleModel?.main_notification?.unread_bg_color, + ); }), ), ); @@ -148,7 +154,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine } /// 消息中心样式 - Widget _buildMessageCenterStyleWidget(MainNotificationStyle styleModel, int index, int length) { + Widget _buildMessageCenterStyleWidget(MainNotificationStyleItem styleModel, int index, int length, String unreadTextColor, String unreadBgColor) { var borderRadius = index == 0 ? BorderRadius.only(topLeft: Radius.circular(7.5), topRight: Radius.circular(7.5)) : index == length - 1 ? BorderRadius.only(bottomRight: Radius.circular(7.5), bottomLeft: Radius.circular(7.5)) : BorderRadius.only(); @@ -163,7 +169,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine width: double.infinity, child: Row( children: [ - _buildCustomerAvatarWidget(icon: styleModel?.icon), + _buildCustomerAvatarWidget(icon: styleModel?.icon, unreadBgColor: unreadBgColor, unreadTextColor: unreadTextColor), const SizedBox(width: 10), Expanded( child: Column( @@ -415,7 +421,8 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine const SizedBox(height: 3), /// 内容 - Text('点击查看回复详情', maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(color: HexColor.fromHex(styleModel?.message_value_color ?? '#999999'), fontSize: 11)) + Text('点击查看回复详情', + maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(color: HexColor.fromHex(styleModel?.message_value_color ?? '#999999'), fontSize: 11)) ], ), ) @@ -423,7 +430,9 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine ), /// 时间 - Padding(padding: const EdgeInsets.only(top: 16), child: Text(styleModel?.time_color ?? '2020-06-23 01:00:06', style: TextStyle(color: HexColor.fromHex('#D8D8D8'), fontSize: 11))) + Padding( + padding: const EdgeInsets.only(top: 16), + child: Text(styleModel?.time_color ?? '2020-06-23 01:00:06', style: TextStyle(color: HexColor.fromHex('#D8D8D8'), fontSize: 11))) ], ), ); @@ -451,7 +460,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine } /// ================================= 自定义View ================================= /// - Widget _buildCustomerAvatarWidget({@required String icon, String value}) { + Widget _buildCustomerAvatarWidget({@required String icon, String value, String unreadTextColor, String unreadBgColor}) { return Container( // width: 30, // height: 30, @@ -476,12 +485,14 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine height: 12, padding: const EdgeInsets.only(left: 3, right: 3, top: 1, bottom: 1), alignment: Alignment.center, - decoration: - BoxDecoration(color: HexColor.fromHex('#FF4242'), borderRadius: BorderRadius.circular(6), border: Border.all(color: HexColor.fromHex('#FFFFFF'), width: 0.5)), + decoration: BoxDecoration( + color: HexColor.fromHex(unreadBgColor ?? '#FF4242'), + borderRadius: BorderRadius.circular(6), + border: Border.all(color: HexColor.fromHex('#FFFFFF'), width: 0.5)), child: Text( '18', textAlign: TextAlign.center, - style: TextStyle(fontSize: 9, color: HexColor.fromHex('#FFFFFF')), + style: TextStyle(fontSize: 9, color: HexColor.fromHex(unreadTextColor ?? '#FFFFFF')), ), ), ), diff --git a/lib/pages/message_notice_page/model/message_notice_style_model.dart b/lib/pages/message_notice_page/model/message_notice_style_model.dart index 28456da..1a890ac 100644 --- a/lib/pages/message_notice_page/model/message_notice_style_model.dart +++ b/lib/pages/message_notice_page/model/message_notice_style_model.dart @@ -3,7 +3,7 @@ class MessageNoticeStyleModel { String app_bar_bg_img; String app_bar_name; String app_bar_name_color; - List main_notification; + MainNotificationStyle main_notification; FeedbackNotificationStyle feedback_notification; OfficialActivityStyle official_activity; OfficialNotificationStyle official_notification; @@ -30,7 +30,7 @@ class MessageNoticeStyleModel { app_bar_name: json['app_bar_name'], app_bar_name_color: json['app_bar_name_color'], feedback_notification: json['feedback_notification'] != null ? FeedbackNotificationStyle.fromJson(json['feedback_notification']) : null, - main_notification: json['main'] != null ? (json['main'] as List).map((i) => MainNotificationStyle.fromJson(i)).toList() : null, + main_notification: json['main'] != null ? MainNotificationStyle.fromJson(json['main']) : null, official_activity: json['official_activity'] != null ? OfficialActivityStyle.fromJson(json['official_activity']) : null, official_notification: json['official_notification'] != null ? OfficialNotificationStyle.fromJson(json['official_notification']) : null, promotion_notification: json['promotion_notification'] != null ? PromotionNotificationStyle.fromJson(json['promotion_notification']) : null, @@ -48,7 +48,7 @@ class MessageNoticeStyleModel { data['feedback_notification'] = this.feedback_notification.toJson(); } if (this.main_notification != null) { - data['main'] = this.main_notification.map((v) => v.toJson()).toList(); + data['main'] = this.main_notification.toJson(); } if (this.official_activity != null) { data['official_activity'] = this.official_activity.toJson(); @@ -107,6 +107,32 @@ class FeedbackNotificationStyle { } class MainNotificationStyle { + List list; + String unread_bg_color; + String unread_text_color; + + MainNotificationStyle({this.list, this.unread_bg_color, this.unread_text_color}); + + factory MainNotificationStyle.fromJson(Map json) { + return MainNotificationStyle( + list: json['list'] != null ? (json['list'] as List).map((i) => MainNotificationStyleItem.fromJson(i)).toList() : null, + unread_bg_color: json['unread_bg_color'], + unread_text_color: json['unread_text_color'], + ); + } + + Map toJson() { + final Map data = new Map(); + data['unread_bg_color'] = this.unread_bg_color; + data['unread_text_color'] = this.unread_text_color; + if (this.list != null) { + data['list'] = this.list.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class MainNotificationStyleItem { String bg_color; String icon; String name; @@ -115,7 +141,7 @@ class MainNotificationStyle { String type; String value_color; - MainNotificationStyle({ + MainNotificationStyleItem({ this.bg_color, this.icon, this.name, @@ -125,8 +151,8 @@ class MainNotificationStyle { this.value_color, }); - factory MainNotificationStyle.fromJson(Map json) { - return MainNotificationStyle( + factory MainNotificationStyleItem.fromJson(Map json) { + return MainNotificationStyleItem( bg_color: json['bg_color'], icon: json['icon'], name: json['name'],