Browse Source

消息ui更改

dart3_last
wurong 2 years ago
parent
commit
772113ed15
  1. 324
      lib/message/system_message.dart

324
lib/message/system_message.dart

@ -28,13 +28,13 @@ class _SystemMessagePage extends State<SystemMessagePage> {
ApiService apiService; ApiService apiService;
int pageNum = 1; int pageNum = 1;
List<Message> messages = []; List<Message> messages = [];
Map <String,int> msgNumber = { Map<String, int> msgNumber = {
"1":0, "1": 0,
"2":0, "2": 0,
"3":0, "3": 0,
"4":0, "4": 0,
"5":0, "5": 0,
"6":0, "6": 0,
}; };
int state = 0; int state = 0;
@ -75,7 +75,7 @@ class _SystemMessagePage extends State<SystemMessagePage> {
List<Message> message = []; List<Message> message = [];
message.addAll(baseData.data.list); message.addAll(baseData.data.list);
message.forEach((element) { message.forEach((element) {
if(element.typed==2 || element.typed==3){ if (element.typed == 2 || element.typed == 3) {
messages.add(element); messages.add(element);
} }
}); });
@ -102,14 +102,15 @@ class _SystemMessagePage extends State<SystemMessagePage> {
token: value.getString("token"), token: value.getString("token"),
); );
} }
BaseData<List<MsgStats>> baseData = await apiService.stats().catchError((onError) {}); BaseData<List<MsgStats>> baseData =
await apiService.stats().catchError((onError) {});
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
setState(() { setState(() {
msgNumber.forEach((key, value) { msgNumber.forEach((key, value) {
msgNumber[key] = 0; msgNumber[key] = 0;
}); });
baseData.data.forEach((element) { baseData.data.forEach((element) {
if(msgNumber.containsKey(element.name)){ if (msgNumber.containsKey(element.name)) {
msgNumber[element.name] = element.number; msgNumber[element.name] = element.number;
} }
}); });
@ -125,34 +126,34 @@ class _SystemMessagePage extends State<SystemMessagePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: MyAppBar( // appBar: MyAppBar(
background: Colors.white, // background: Colors.white,
leadingColor: Colors.black, // leadingColor: Colors.black,
title: S.of(context).xiaoxi, // title: S.of(context).xiaoxi,
titleSize: 18.sp, // titleSize: 18.sp,
titleColor: Colors.black, // titleColor: Colors.black,
actions: [ // actions: [
Container( // Container(
margin: EdgeInsets.only(right: 16.w), // margin: EdgeInsets.only(right: 16.w),
alignment: Alignment.centerRight, // alignment: Alignment.centerRight,
child: GestureDetector( // child: GestureDetector(
onTap: () { // onTap: () {
setState(() { // setState(() {
queryMsgStats(); // queryMsgStats();
}); // });
}, // },
child: Text( // child: Text(
S.of(context).biaoweiyidu, // S.of(context).biaoweiyidu,
style: TextStyle( // style: TextStyle(
fontSize: 16.sp, // fontSize: 16.sp,
fontWeight:MyFontWeight.semi_bold, // fontWeight:MyFontWeight.semi_bold,
color: Color(0xFF353535), // color: Color(0xFF353535),
), // ),
), // ),
), // ),
), // ),
], // ],
), // ),
body: SmartRefresher( body: SmartRefresher(
enablePullDown: true, enablePullDown: true,
enablePullUp: true, enablePullUp: true,
@ -161,7 +162,7 @@ class _SystemMessagePage extends State<SystemMessagePage> {
footer: CustomFooter( footer: CustomFooter(
loadStyle: LoadStyle.ShowWhenLoading, loadStyle: LoadStyle.ShowWhenLoading,
builder: (BuildContext context, LoadStatus mode) { builder: (BuildContext context, LoadStatus mode) {
return (messages.length == 0)?Container():MyFooter(mode); return (messages.length == 0) ? Container() : MyFooter(mode);
}, },
), ),
controller: _refreshController, controller: _refreshController,
@ -177,35 +178,94 @@ class _SystemMessagePage extends State<SystemMessagePage> {
child: Container( child: Container(
child: Column( child: Column(
children: [ 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(), newsSurvey(),
SizedBox(height: 16.h,), SizedBox(
height: 16.h,
),
buildMessage(), buildMessage(),
], ],
), ),
), ),
), ),
), ),
), ),
); );
} }
Widget newsSurvey(){ Widget newsSurvey() {
return Container( return Container(
color: Colors.white, color: Colors.white,
padding: EdgeInsets.only(top: 16.h,bottom: 16.h), padding: EdgeInsets.only(top: 16.h, bottom: 16.h),
child: Row( child: Row(
children: [ children: [
Expanded(child: GestureDetector( Expanded(
onTap: (){ child: GestureDetector(
Navigator.of(context) onTap: () {
.pushNamed('/router/system_details',arguments: {"msgType":5}).then((value) { Navigator.of(context).pushNamed('/router/system_details',
arguments: {"msgType": 5}).then((value) {
setState(() { setState(() {
msgNumber["5"] = 0; msgNumber["5"] = 0;
}); });
}); });
}, },
child:Column( child: Column(
children: [ children: [
Stack( Stack(
children: [ children: [
@ -214,13 +274,13 @@ class _SystemMessagePage extends State<SystemMessagePage> {
width: 40, width: 40,
height: 40, height: 40,
), ),
if(msgNumber["5"].toString() != "0") if (msgNumber["5"].toString() != "0")
Container( Container(
width:48, width: 48,
alignment: Alignment.topRight, alignment: Alignment.topRight,
child:Container( child: Container(
width:20, width: 20,
height:17, height: 17,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100), borderRadius: BorderRadius.circular(100),
border: Border.all( border: Border.all(
@ -228,17 +288,16 @@ class _SystemMessagePage extends State<SystemMessagePage> {
color: Colors.white, color: Colors.white,
style: BorderStyle.solid, style: BorderStyle.solid,
), ),
color:Color(0xFFFF441A), color: Color(0xFFFF441A),
), ),
child:RoundButton( child: RoundButton(
text:msgNumber["5"].toString(), text: msgNumber["5"].toString(),
textColor: Colors.white, textColor: Colors.white,
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.regular,
backgroup: Color(0xFFFF441A), backgroup: Color(0xFFFF441A),
fontSize:8.sp, fontSize: 8.sp,
radius: 100, radius: 100,
) )),
),
) )
], ],
), ),
@ -247,19 +306,17 @@ class _SystemMessagePage extends State<SystemMessagePage> {
S.of(context).dianzan, S.of(context).dianzan,
style: TextStyle( style: TextStyle(
fontSize: 14.sp, fontSize: 14.sp,
fontWeight:MyFontWeight.medium, fontWeight: MyFontWeight.medium,
color: Color(0xFF060606), color: Color(0xFF060606),
), ),
) )
], ],
) ))),
) Expanded(
), child: GestureDetector(
Expanded(child: onTap: () {
GestureDetector( Navigator.of(context).pushNamed('/router/system_details',
onTap: (){ arguments: {"msgType": 6}).then((value) {
Navigator.of(context)
.pushNamed('/router/system_details',arguments: {"msgType":6}).then((value) {
setState(() { setState(() {
msgNumber["6"] = 0; msgNumber["6"] = 0;
}); });
@ -274,13 +331,13 @@ class _SystemMessagePage extends State<SystemMessagePage> {
width: 40, width: 40,
height: 40, height: 40,
), ),
if(msgNumber["6"].toString() != "0") if (msgNumber["6"].toString() != "0")
Container( Container(
width:48, width: 48,
alignment: Alignment.topRight, alignment: Alignment.topRight,
child:Container( child: Container(
width:16, width: 16,
height:16, height: 16,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100), borderRadius: BorderRadius.circular(100),
border: Border.all( border: Border.all(
@ -288,17 +345,16 @@ class _SystemMessagePage extends State<SystemMessagePage> {
color: Colors.white, color: Colors.white,
style: BorderStyle.solid, style: BorderStyle.solid,
), ),
color:Color(0xFFFF441A), color: Color(0xFFFF441A),
), ),
child:RoundButton( child: RoundButton(
text: msgNumber["6"].toString(), text: msgNumber["6"].toString(),
textColor: Colors.white, textColor: Colors.white,
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.regular,
backgroup: Color(0xFFFF441A), backgroup: Color(0xFFFF441A),
fontSize:8.sp, fontSize: 8.sp,
radius: 100, radius: 100,
) )),
),
) )
], ],
), ),
@ -307,24 +363,23 @@ class _SystemMessagePage extends State<SystemMessagePage> {
S.of(context).pinglun, S.of(context).pinglun,
style: TextStyle( style: TextStyle(
fontSize: 14.sp, fontSize: 14.sp,
fontWeight:MyFontWeight.medium, fontWeight: MyFontWeight.medium,
color: Color(0xFF060606), color: Color(0xFF060606),
), ),
), ),
], ],
) ))),
)), Expanded(
Expanded(child: child: GestureDetector(
GestureDetector( onTap: () {
onTap: (){ Navigator.of(context).pushNamed('/router/system_details',
Navigator.of(context) arguments: {"msgType": 4}).then((value) {
.pushNamed('/router/system_details',arguments: {"msgType":4}).then((value) {
setState(() { setState(() {
msgNumber["4"] = 0; msgNumber["4"] = 0;
}); });
}); });
}, },
child:Column( child: Column(
children: [ children: [
Stack( Stack(
children: [ children: [
@ -333,13 +388,13 @@ class _SystemMessagePage extends State<SystemMessagePage> {
width: 40, width: 40,
height: 40, height: 40,
), ),
if(msgNumber["4"].toString() != "0") if (msgNumber["4"].toString() != "0")
Container( Container(
width:48, width: 48,
alignment: Alignment.topRight, alignment: Alignment.topRight,
child:Container( child: Container(
width:16, width: 16,
height:16, height: 16,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100), borderRadius: BorderRadius.circular(100),
border: Border.all( border: Border.all(
@ -347,17 +402,16 @@ class _SystemMessagePage extends State<SystemMessagePage> {
color: Colors.white, color: Colors.white,
style: BorderStyle.solid, style: BorderStyle.solid,
), ),
color:Color(0xFFFF441A), color: Color(0xFFFF441A),
), ),
child:RoundButton( child: RoundButton(
text: msgNumber["4"].toString(), text: msgNumber["4"].toString(),
textColor: Colors.white, textColor: Colors.white,
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.regular,
backgroup: Color(0xFFFF441A), backgroup: Color(0xFFFF441A),
fontSize:8.sp, fontSize: 8.sp,
radius: 100, radius: 100,
) )),
),
) )
], ],
), ),
@ -366,25 +420,23 @@ class _SystemMessagePage extends State<SystemMessagePage> {
S.of(context).guanzhu, S.of(context).guanzhu,
style: TextStyle( style: TextStyle(
fontSize: 14.sp, fontSize: 14.sp,
fontWeight:MyFontWeight.medium, fontWeight: MyFontWeight.medium,
color: Color(0xFF060606), color: Color(0xFF060606),
), ),
), ),
], ],
) ))),
)
),
], ],
), ),
); );
} }
Widget buildMessage(){ Widget buildMessage() {
return Container( return Container(
color: Colors.white, color: Colors.white,
width: double.infinity, width: double.infinity,
padding: EdgeInsets.all(20.w), padding: EdgeInsets.all(20.w),
child:Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -392,7 +444,7 @@ class _SystemMessagePage extends State<SystemMessagePage> {
S.of(context).xitongxiaoxi, S.of(context).xitongxiaoxi,
style: TextStyle( style: TextStyle(
fontSize: 16.sp, fontSize: 16.sp,
fontWeight:MyFontWeight.semi_bold, fontWeight: MyFontWeight.semi_bold,
color: Colors.black, color: Colors.black,
), ),
), ),
@ -404,7 +456,7 @@ class _SystemMessagePage extends State<SystemMessagePage> {
fontSize: 16.sp, fontSize: 16.sp,
margin: EdgeInsets.only(top: 120.h), margin: EdgeInsets.only(top: 120.h),
) )
:ListView.builder( : ListView.builder(
padding: EdgeInsets.only(top: 16), padding: EdgeInsets.only(top: 16),
itemCount: messages.length, itemCount: messages.length,
shrinkWrap: true, shrinkWrap: true,
@ -412,16 +464,18 @@ class _SystemMessagePage extends State<SystemMessagePage> {
itemBuilder: (context, position) { itemBuilder: (context, position) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
if(messages[position].typed == 2) if (messages[position].typed == 2)
Navigator.of(context) Navigator.of(context).pushNamed(
.pushNamed('/router/system_details',arguments: {"msgType":2}).then((value) { '/router/system_details',
arguments: {"msgType": 2}).then((value) {
setState(() { setState(() {
msgNumber["2"] = 0; msgNumber["2"] = 0;
}); });
}); });
else if(messages[position].typed == 3) else if (messages[position].typed == 3)
Navigator.of(context) Navigator.of(context).pushNamed(
.pushNamed('/router/system_details',arguments: {"msgType":3}).then((value) { '/router/system_details',
arguments: {"msgType": 3}).then((value) {
setState(() { setState(() {
msgNumber["3"] = 0; msgNumber["3"] = 0;
}); });
@ -431,8 +485,7 @@ class _SystemMessagePage extends State<SystemMessagePage> {
); );
}), }),
], ],
) ));
);
} }
Widget buildMessageItem(Message message) { Widget buildMessageItem(Message message) {
@ -470,15 +523,17 @@ class _SystemMessagePage extends State<SystemMessagePage> {
height: 40.h, height: 40.h,
), ),
SizedBox( SizedBox(
width:12.w, width: 12.w,
), ),
Expanded(child:Column( Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( Row(
children: [ children: [
Expanded(child:Text( Expanded(
child: Text(
(message.typed == 1) (message.typed == 1)
? S.of(context).xitongtongzhi ? S.of(context).xitongtongzhi
: (message.typed == 2) : (message.typed == 2)
@ -499,54 +554,57 @@ class _SystemMessagePage extends State<SystemMessagePage> {
), ),
], ],
), ),
SizedBox(height:4.h,), SizedBox(
(message.typed != 3) ? height: 4.h,
Row( ),
(message.typed != 3)
? Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Expanded(child: Expanded(
Text( child: Text(
S.of(context).ninyouyigexindedingdan, S.of(context).ninyouyigexindedingdan,
style: TextStyle( style: TextStyle(
fontSize: 10.sp, fontSize: 10.sp,
color: Color(0xFF353535), color: Color(0xFF353535),
), ),
),), ),
if(msgNumber["2"].toString() != "0") ),
if (msgNumber["2"].toString() != "0")
RoundButton( RoundButton(
width: 16, width: 16,
height: 16, height: 16,
text:msgNumber["2"].toString(), text: msgNumber["2"].toString(),
textColor: Colors.white, textColor: Colors.white,
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.regular,
backgroup: Color(0xFFFF441A), backgroup: Color(0xFFFF441A),
fontSize:10.sp, fontSize: 10.sp,
radius: 100, radius: 100,
), ),
], ],
): )
Row( : Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Expanded(child: Expanded(
Text( child: Text(
message.content, message.content,
style: TextStyle( style: TextStyle(
fontSize: 10.sp, fontSize: 10.sp,
color: Color(0xFF353535), color: Color(0xFF353535),
), ),
)), )),
if(msgNumber["3"].toString() != "0") if (msgNumber["3"].toString() != "0")
RoundButton( RoundButton(
width: 16, width: 16,
height: 16, height: 16,
text:msgNumber["3"].toString(), text: msgNumber["3"].toString(),
textColor: Colors.white, textColor: Colors.white,
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.regular,
backgroup: Color(0xFFFF441A), backgroup: Color(0xFFFF441A),
fontSize:10.sp, fontSize: 10.sp,
radius: 100, radius: 100,
), ),
], ],
@ -556,7 +614,7 @@ class _SystemMessagePage extends State<SystemMessagePage> {
], ],
), ),
Container( Container(
margin: EdgeInsets.only(top: 16.h,bottom:8.h), margin: EdgeInsets.only(top: 16.h, bottom: 8.h),
height: 1.h, height: 1.h,
width: double.infinity, width: double.infinity,
color: Color(0xFFF7F7F7), color: Color(0xFFF7F7F7),

Loading…
Cancel
Save