From 772113ed15bcb4d73cdf7964aa0800b3801cc74a Mon Sep 17 00:00:00 2001 From: wurong <953969641@qq.com> Date: Wed, 1 Mar 2023 13:57:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AFui=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/message/system_message.dart | 702 +++++++++++++++++--------------- 1 file changed, 380 insertions(+), 322 deletions(-) diff --git a/lib/message/system_message.dart b/lib/message/system_message.dart index d4325106..b8631255 100644 --- a/lib/message/system_message.dart +++ b/lib/message/system_message.dart @@ -28,13 +28,13 @@ class _SystemMessagePage extends State { ApiService apiService; int pageNum = 1; List messages = []; - Map msgNumber = { - "1":0, - "2":0, - "3":0, - "4":0, - "5":0, - "6":0, + Map msgNumber = { + "1": 0, + "2": 0, + "3": 0, + "4": 0, + "5": 0, + "6": 0, }; int state = 0; @@ -75,7 +75,7 @@ class _SystemMessagePage extends State { List message = []; message.addAll(baseData.data.list); message.forEach((element) { - if(element.typed==2 || element.typed==3){ + if (element.typed == 2 || element.typed == 3) { messages.add(element); } }); @@ -102,14 +102,15 @@ class _SystemMessagePage extends State { token: value.getString("token"), ); } - BaseData> baseData = await apiService.stats().catchError((onError) {}); + BaseData> baseData = + await apiService.stats().catchError((onError) {}); if (baseData != null && baseData.isSuccess) { setState(() { msgNumber.forEach((key, value) { msgNumber[key] = 0; }); baseData.data.forEach((element) { - if(msgNumber.containsKey(element.name)){ + if (msgNumber.containsKey(element.name)) { msgNumber[element.name] = element.number; } }); @@ -125,34 +126,34 @@ class _SystemMessagePage extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: MyAppBar( - background: Colors.white, - leadingColor: Colors.black, - title: S.of(context).xiaoxi, - titleSize: 18.sp, - titleColor: Colors.black, - actions: [ - Container( - margin: EdgeInsets.only(right: 16.w), - alignment: Alignment.centerRight, - child: GestureDetector( - onTap: () { - setState(() { - queryMsgStats(); - }); - }, - child: Text( - S.of(context).biaoweiyidu, - style: TextStyle( - fontSize: 16.sp, - fontWeight:MyFontWeight.semi_bold, - color: Color(0xFF353535), - ), - ), - ), - ), - ], - ), + // appBar: MyAppBar( + // background: Colors.white, + // leadingColor: Colors.black, + // title: S.of(context).xiaoxi, + // titleSize: 18.sp, + // titleColor: Colors.black, + // actions: [ + // Container( + // margin: EdgeInsets.only(right: 16.w), + // alignment: Alignment.centerRight, + // child: GestureDetector( + // onTap: () { + // setState(() { + // queryMsgStats(); + // }); + // }, + // child: Text( + // S.of(context).biaoweiyidu, + // style: TextStyle( + // fontSize: 16.sp, + // fontWeight:MyFontWeight.semi_bold, + // color: Color(0xFF353535), + // ), + // ), + // ), + // ), + // ], + // ), body: SmartRefresher( enablePullDown: true, enablePullUp: true, @@ -161,7 +162,7 @@ class _SystemMessagePage extends State { footer: CustomFooter( loadStyle: LoadStyle.ShowWhenLoading, builder: (BuildContext context, LoadStatus mode) { - return (messages.length == 0)?Container():MyFooter(mode); + return (messages.length == 0) ? Container() : MyFooter(mode); }, ), controller: _refreshController, @@ -177,262 +178,314 @@ class _SystemMessagePage extends State { child: Container( child: Column( children: [ + Container( + color: Colors.white, + padding: EdgeInsets.only( + top: MediaQuery.of(context).padding.top + 10.h, + bottom: 15.h,right: 16.w), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + Navigator.of(context).pop(); + }, + child: Container( + alignment: Alignment.centerRight, + margin: EdgeInsets.only(left: 12,), + padding: EdgeInsets.all(6), + child: Icon( + Icons.arrow_back_ios, + color: Colors.black, + size: 24, + ), + ), + ), + Spacer(), + Expanded( + child: Text( + S.of(context).xiaoxi, + style: TextStyle( + color: Colors.black, + fontSize: 16.sp, + fontWeight: MyFontWeight.regular, + ), + )), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + queryMsgStats(); + }); + }, + child: Container( + padding: EdgeInsets.symmetric(horizontal: 10.w), + child: Text( + S.of(context).biaoweiyidu, + style: TextStyle( + color: Colors.black, + fontSize: 16.sp, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + ], + ), + ), newsSurvey(), - SizedBox(height: 16.h,), + SizedBox( + height: 16.h, + ), buildMessage(), ], ), ), ), ), - ), ); } - Widget newsSurvey(){ + Widget newsSurvey() { return Container( color: Colors.white, - padding: EdgeInsets.only(top: 16.h,bottom: 16.h), + padding: EdgeInsets.only(top: 16.h, bottom: 16.h), child: Row( children: [ - Expanded(child: GestureDetector( - onTap: (){ - Navigator.of(context) - .pushNamed('/router/system_details',arguments: {"msgType":5}).then((value) { - setState(() { - msgNumber["5"] = 0; + Expanded( + child: GestureDetector( + onTap: () { + Navigator.of(context).pushNamed('/router/system_details', + arguments: {"msgType": 5}).then((value) { + setState(() { + msgNumber["5"] = 0; + }); }); - }); - }, - child:Column( - children: [ - Stack( - children: [ - Image.asset( - "assets/image/icon_z.webp", - width: 40, - height: 40, - ), - if(msgNumber["5"].toString() != "0") - Container( - width:48, - alignment: Alignment.topRight, - child:Container( - width:20, - height:17, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(100), - border: Border.all( - width: 1, - color: Colors.white, - style: BorderStyle.solid, - ), - color:Color(0xFFFF441A), + }, + child: Column( + children: [ + Stack( + children: [ + Image.asset( + "assets/image/icon_z.webp", + width: 40, + height: 40, ), - child:RoundButton( - text:msgNumber["5"].toString(), - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFFFF441A), - fontSize:8.sp, - radius: 100, - ) + if (msgNumber["5"].toString() != "0") + Container( + width: 48, + alignment: Alignment.topRight, + child: Container( + width: 20, + height: 17, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(100), + border: Border.all( + width: 1, + color: Colors.white, + style: BorderStyle.solid, + ), + color: Color(0xFFFF441A), + ), + child: RoundButton( + text: msgNumber["5"].toString(), + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFFFF441A), + fontSize: 8.sp, + radius: 100, + )), + ) + ], ), - ) - ], - ), - SizedBox(height: 6.h), - Text( - S.of(context).dianzan, - style: TextStyle( - fontSize: 14.sp, - fontWeight:MyFontWeight.medium, - color: Color(0xFF060606), - ), - ) - ], - ) - ) - ), - Expanded(child: - GestureDetector( - onTap: (){ - Navigator.of(context) - .pushNamed('/router/system_details',arguments: {"msgType":6}).then((value) { - setState(() { - msgNumber["6"] = 0; - }); - }); - }, - child: Column( - children: [ - Stack( - children: [ - Image.asset( - "assets/image/icon_pl.webp", - width: 40, - height: 40, + SizedBox(height: 6.h), + Text( + S.of(context).dianzan, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF060606), ), - if(msgNumber["6"].toString() != "0") - Container( - width:48, - alignment: Alignment.topRight, - child:Container( - width:16, - height:16, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(100), - border: Border.all( - width: 1, - color: Colors.white, - style: BorderStyle.solid, - ), - color:Color(0xFFFF441A), - ), - child:RoundButton( - text: msgNumber["6"].toString(), - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFFFF441A), - fontSize:8.sp, - radius: 100, - ) + ) + ], + ))), + Expanded( + child: GestureDetector( + onTap: () { + Navigator.of(context).pushNamed('/router/system_details', + arguments: {"msgType": 6}).then((value) { + setState(() { + msgNumber["6"] = 0; + }); + }); + }, + child: Column( + children: [ + Stack( + children: [ + Image.asset( + "assets/image/icon_pl.webp", + width: 40, + height: 40, ), - ) - ], - ), - SizedBox(height: 6.h), - Text( - S.of(context).pinglun, - style: TextStyle( - fontSize: 14.sp, - fontWeight:MyFontWeight.medium, - color: Color(0xFF060606), + if (msgNumber["6"].toString() != "0") + Container( + width: 48, + alignment: Alignment.topRight, + child: Container( + width: 16, + height: 16, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(100), + border: Border.all( + width: 1, + color: Colors.white, + style: BorderStyle.solid, + ), + color: Color(0xFFFF441A), + ), + child: RoundButton( + text: msgNumber["6"].toString(), + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFFFF441A), + fontSize: 8.sp, + radius: 100, + )), + ) + ], ), - ), - ], - ) - )), - Expanded(child: - GestureDetector( - onTap: (){ - Navigator.of(context) - .pushNamed('/router/system_details',arguments: {"msgType":4}).then((value) { - setState(() { - msgNumber["4"] = 0; - }); - }); - }, - child:Column( - children: [ - Stack( - children: [ - Image.asset( - "assets/image/icon_gz.webp", - width: 40, - height: 40, + SizedBox(height: 6.h), + Text( + S.of(context).pinglun, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF060606), ), - if(msgNumber["4"].toString() != "0") - Container( - width:48, - alignment: Alignment.topRight, - child:Container( - width:16, - height:16, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(100), - border: Border.all( - width: 1, - color: Colors.white, - style: BorderStyle.solid, - ), - color:Color(0xFFFF441A), - ), - child:RoundButton( - text: msgNumber["4"].toString(), - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFFFF441A), - fontSize:8.sp, - radius: 100, - ) + ), + ], + ))), + Expanded( + child: GestureDetector( + onTap: () { + Navigator.of(context).pushNamed('/router/system_details', + arguments: {"msgType": 4}).then((value) { + setState(() { + msgNumber["4"] = 0; + }); + }); + }, + child: Column( + children: [ + Stack( + children: [ + Image.asset( + "assets/image/icon_gz.webp", + width: 40, + height: 40, ), - ) - ], - ), - SizedBox(height: 6.h), - Text( - S.of(context).guanzhu, - style: TextStyle( - fontSize: 14.sp, - fontWeight:MyFontWeight.medium, - color: Color(0xFF060606), + if (msgNumber["4"].toString() != "0") + Container( + width: 48, + alignment: Alignment.topRight, + child: Container( + width: 16, + height: 16, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(100), + border: Border.all( + width: 1, + color: Colors.white, + style: BorderStyle.solid, + ), + color: Color(0xFFFF441A), + ), + child: RoundButton( + text: msgNumber["4"].toString(), + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFFFF441A), + fontSize: 8.sp, + radius: 100, + )), + ) + ], ), - ), - ], - ) - ) - ), + SizedBox(height: 6.h), + Text( + S.of(context).guanzhu, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF060606), + ), + ), + ], + ))), ], ), ); } - Widget buildMessage(){ + Widget buildMessage() { return Container( - color: Colors.white, - width: double.infinity, + color: Colors.white, + width: double.infinity, padding: EdgeInsets.all(20.w), - child:Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - S.of(context).xitongxiaoxi, - style: TextStyle( - fontSize: 16.sp, - fontWeight:MyFontWeight.semi_bold, - color: Colors.black, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + S.of(context).xitongxiaoxi, + style: TextStyle( + fontSize: 16.sp, + fontWeight: MyFontWeight.semi_bold, + color: Colors.black, + ), ), - ), - (messages == null || messages.length == 0) - ? NoDataView( - src: "assets/image/icon_empty.webp", - isShowBtn: false, - text: S.of(context).haimeiyouxiaoxi, - fontSize: 16.sp, - margin: EdgeInsets.only(top: 120.h), - ) - :ListView.builder( - padding: EdgeInsets.only(top: 16), - itemCount: messages.length, - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemBuilder: (context, position) { - return GestureDetector( - onTap: () { - if(messages[position].typed == 2) - Navigator.of(context) - .pushNamed('/router/system_details',arguments: {"msgType":2}).then((value) { - setState(() { - msgNumber["2"] = 0; - }); - }); - else if(messages[position].typed == 3) - Navigator.of(context) - .pushNamed('/router/system_details',arguments: {"msgType":3}).then((value) { - setState(() { - msgNumber["3"] = 0; - }); - }); - }, - child: buildMessageItem(messages[position]), - ); - }), - ], - ) - ); + (messages == null || messages.length == 0) + ? NoDataView( + src: "assets/image/icon_empty.webp", + isShowBtn: false, + text: S.of(context).haimeiyouxiaoxi, + fontSize: 16.sp, + margin: EdgeInsets.only(top: 120.h), + ) + : ListView.builder( + padding: EdgeInsets.only(top: 16), + itemCount: messages.length, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, position) { + return GestureDetector( + onTap: () { + if (messages[position].typed == 2) + Navigator.of(context).pushNamed( + '/router/system_details', + arguments: {"msgType": 2}).then((value) { + setState(() { + msgNumber["2"] = 0; + }); + }); + else if (messages[position].typed == 3) + Navigator.of(context).pushNamed( + '/router/system_details', + arguments: {"msgType": 3}).then((value) { + setState(() { + msgNumber["3"] = 0; + }); + }); + }, + child: buildMessageItem(messages[position]), + ); + }), + ], + )); } Widget buildMessageItem(Message message) { @@ -464,26 +517,28 @@ class _SystemMessagePage extends State { (message.typed == 1) ? "assets/image/icon_system_message.webp" : (message.typed == 2) - ? "assets/image/icon_system_message.webp" - : "assets/image/c_z.webp", + ? "assets/image/icon_system_message.webp" + : "assets/image/c_z.webp", width: 40.w, height: 40.h, ), SizedBox( - width:12.w, + width: 12.w, ), - Expanded(child:Column( + Expanded( + child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ - Expanded(child:Text( + Expanded( + child: Text( (message.typed == 1) ? S.of(context).xitongtongzhi : (message.typed == 2) - ? S.of(context).dingdanxiaoxi - : S.of(context).chongzhixiaoxi, + ? S.of(context).dingdanxiaoxi + : S.of(context).chongzhixiaoxi, style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.semi_bold, @@ -499,64 +554,67 @@ class _SystemMessagePage extends State { ), ], ), - SizedBox(height:4.h,), - (message.typed != 3) ? - Row( - mainAxisAlignment: MainAxisAlignment.center, - // crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded(child: - Text( - S.of(context).ninyouyigexindedingdan, - style: TextStyle( - fontSize: 10.sp, - color: Color(0xFF353535), - ), - ),), - if(msgNumber["2"].toString() != "0") - RoundButton( - width: 16, - height: 16, - text:msgNumber["2"].toString(), - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFFFF441A), - fontSize:10.sp, - radius: 100, - ), - ], - ): - Row( - mainAxisAlignment: MainAxisAlignment.center, - // crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded(child: - Text( - message.content, - style: TextStyle( - fontSize: 10.sp, - color: Color(0xFF353535), - ), - )), - if(msgNumber["3"].toString() != "0") - RoundButton( - width: 16, - height: 16, - text:msgNumber["3"].toString(), - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFFFF441A), - fontSize:10.sp, - radius: 100, - ), - ], + SizedBox( + height: 4.h, ), + (message.typed != 3) + ? Row( + mainAxisAlignment: MainAxisAlignment.center, + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + S.of(context).ninyouyigexindedingdan, + style: TextStyle( + fontSize: 10.sp, + color: Color(0xFF353535), + ), + ), + ), + if (msgNumber["2"].toString() != "0") + RoundButton( + width: 16, + height: 16, + text: msgNumber["2"].toString(), + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFFFF441A), + fontSize: 10.sp, + radius: 100, + ), + ], + ) + : Row( + mainAxisAlignment: MainAxisAlignment.center, + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + message.content, + style: TextStyle( + fontSize: 10.sp, + color: Color(0xFF353535), + ), + )), + if (msgNumber["3"].toString() != "0") + RoundButton( + width: 16, + height: 16, + text: msgNumber["3"].toString(), + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFFFF441A), + fontSize: 10.sp, + radius: 100, + ), + ], + ), ], )), ], ), Container( - margin: EdgeInsets.only(top: 16.h,bottom:8.h), + margin: EdgeInsets.only(top: 16.h, bottom: 8.h), height: 1.h, width: double.infinity, color: Color(0xFFF7F7F7),