Before Width: | Height: | Size: 702 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 666 B |
Before Width: | Height: | Size: 606 B After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 172 B After Width: | Height: | Size: 766 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 400 B |
After Width: | Height: | Size: 798 B |
After Width: | Height: | Size: 790 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 870 B |
After Width: | Height: | Size: 724 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 808 B |
Before Width: | Height: | Size: 96 B After Width: | Height: | Size: 600 B |
Before Width: | Height: | Size: 340 B After Width: | Height: | Size: 892 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 806 B |
@ -0,0 +1,323 @@
|
||||
import 'dart:convert'; |
||||
|
||||
import 'package:dio/dio.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
||||
import 'package:huixiang/generated/l10n.dart'; |
||||
import 'package:huixiang/retrofit/data/base_data.dart'; |
||||
import 'package:huixiang/retrofit/data/message.dart'; |
||||
import 'package:huixiang/retrofit/data/page.dart'; |
||||
import 'package:huixiang/retrofit/retrofit_api.dart'; |
||||
import 'package:huixiang/utils/font_weight.dart'; |
||||
import 'package:huixiang/view_widget/classic_header.dart'; |
||||
import 'package:huixiang/view_widget/custom_image.dart'; |
||||
import 'package:huixiang/view_widget/my_appbar.dart'; |
||||
import 'package:huixiang/view_widget/my_footer.dart'; |
||||
import 'package:huixiang/view_widget/no_data_view.dart'; |
||||
import 'package:huixiang/view_widget/round_button.dart'; |
||||
import 'package:pull_to_refresh/pull_to_refresh.dart'; |
||||
import 'package:shared_preferences/shared_preferences.dart'; |
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
|
||||
class SystemNotice extends StatefulWidget { |
||||
|
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _SystemNotice(); |
||||
} |
||||
} |
||||
|
||||
class _SystemNotice extends State<SystemNotice> { |
||||
ApiService apiService; |
||||
int pageNum = 1; |
||||
List<Message> messages = []; |
||||
int msgType = 0; |
||||
|
||||
// String parenId = "0"; |
||||
var commentFocus = FocusNode(); |
||||
String hintText = S.current.liuxianinjingcaidepinglunba; |
||||
bool isKeyBoardShow = false; |
||||
final GlobalKey commentKey = GlobalKey(); |
||||
final GlobalKey inputKey = GlobalKey(); |
||||
final TextEditingController commentTextController = TextEditingController(); |
||||
int indexMsg = 0; |
||||
|
||||
@override |
||||
void initState() { |
||||
super.initState(); |
||||
// msgType = widget.arguments["msgType"]; |
||||
|
||||
SharedPreferences.getInstance().then((value) { |
||||
apiService = |
||||
ApiService(Dio(), token: value.getString("token"), context: context); |
||||
queryMessage(); |
||||
}); |
||||
} |
||||
|
||||
_refresh() { |
||||
pageNum = 1; |
||||
queryMessage(); |
||||
} |
||||
|
||||
queryMessage() async { |
||||
BaseData<PageInfo<Message>> baseData = await apiService.msgList({ |
||||
"pageNum": pageNum, |
||||
"pageSize": 10, |
||||
"searchKey": "", |
||||
"state": "", |
||||
"typed": "" |
||||
}).catchError((onError) { |
||||
_refreshController.loadFailed(); |
||||
_refreshController.refreshFailed(); |
||||
}); |
||||
|
||||
if (baseData != null && baseData.isSuccess) { |
||||
if (pageNum == 1) { |
||||
messages.clear(); |
||||
} |
||||
List<Message> message = []; |
||||
message.addAll(baseData.data.list); |
||||
message.forEach((element) { |
||||
if (element.typed == 2 || element.typed == 3) { |
||||
messages.add(element); |
||||
} |
||||
}); |
||||
_refreshController.loadComplete(); |
||||
_refreshController.refreshCompleted(); |
||||
if (mounted) setState(() {}); |
||||
if (pageNum * 10 > int.tryParse(baseData.data.total)) { |
||||
_refreshController.loadNoData(); |
||||
} else { |
||||
pageNum += 1; |
||||
} |
||||
} else { |
||||
_refreshController.loadFailed(); |
||||
_refreshController.refreshFailed(); |
||||
} |
||||
} |
||||
|
||||
RefreshController _refreshController = RefreshController(); |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Scaffold( |
||||
body: SmartRefresher( |
||||
enablePullDown: true, |
||||
enablePullUp: true, |
||||
header: MyHeader(), |
||||
physics: BouncingScrollPhysics(), |
||||
footer: CustomFooter( |
||||
loadStyle: LoadStyle.ShowWhenLoading, |
||||
builder: (BuildContext context, LoadStatus mode) { |
||||
return (messages.length == 0) ? Container() : MyFooter(mode); |
||||
}, |
||||
), |
||||
controller: _refreshController, |
||||
onRefresh: _refresh, |
||||
onLoading: () { |
||||
queryMessage(); |
||||
}, |
||||
child: Container( |
||||
child: SingleChildScrollView( |
||||
physics: BouncingScrollPhysics(), |
||||
child: Container( |
||||
child: Column( |
||||
children: [ |
||||
Container( |
||||
color: Colors.white, |
||||
padding: EdgeInsets.only( |
||||
top: MediaQuery.of(context).padding.top + 10.h, |
||||
bottom: 10.h, |
||||
right: 16.w), |
||||
child: Row( |
||||
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, |
||||
), |
||||
), |
||||
), |
||||
Text( |
||||
"消息通知", |
||||
style: TextStyle( |
||||
color: Colors.black, |
||||
fontSize: 18.sp, |
||||
fontWeight: MyFontWeight.bold, |
||||
), |
||||
), |
||||
], |
||||
), |
||||
), |
||||
buildMessage() |
||||
], |
||||
), |
||||
), |
||||
), |
||||
), |
||||
), |
||||
); |
||||
} |
||||
|
||||
Widget buildMessage() { |
||||
return Container( |
||||
color: Colors.white, |
||||
width: double.infinity, |
||||
child: Column( |
||||
mainAxisAlignment: MainAxisAlignment.spaceAround, |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
(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( |
||||
behavior: HitTestBehavior.opaque, |
||||
onTap: () { |
||||
if (messages[position].typed == 2) |
||||
Navigator.of(context).pushNamed( |
||||
'/router/system_details', |
||||
arguments: {"msgType": 2}); |
||||
else if (messages[position].typed == 3) |
||||
Navigator.of(context).pushNamed( |
||||
'/router/system_details', |
||||
arguments: {"msgType": 3}); |
||||
}, |
||||
child: buildMessageItem(messages[position]), |
||||
); |
||||
}), |
||||
], |
||||
)); |
||||
} |
||||
|
||||
Widget buildMessageItem(Message message) { |
||||
return Container( |
||||
margin: EdgeInsets.only(top: 8.h, bottom: 8.h,left: 16.w,right: 17.w), |
||||
child: Column( |
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
Row( |
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
Image.asset( |
||||
(message.typed == 1) |
||||
? "assets/image/icon_order.webp" |
||||
: (message.typed == 2) |
||||
? "assets/image/icon_order.webp" |
||||
: "assets/image/icon_cz.webp", |
||||
width: 24.w, |
||||
height: 24.h, |
||||
), |
||||
SizedBox( |
||||
width: 8.w, |
||||
), |
||||
Expanded( |
||||
child: Column( |
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
Row( |
||||
children: [ |
||||
Expanded( |
||||
child: Text( |
||||
(message.typed == 1) |
||||
? S.of(context).xitongtongzhi |
||||
: (message.typed == 2) |
||||
? S.of(context).dingdanxiaoxi |
||||
: S.of(context).chongzhixiaoxi, |
||||
style: TextStyle( |
||||
fontSize: 14.sp, |
||||
fontWeight: MyFontWeight.semi_bold, |
||||
color: Color(0xFF060606), |
||||
), |
||||
)), |
||||
Text( |
||||
message.updateTime, |
||||
style: TextStyle( |
||||
fontSize: 10.sp, |
||||
color: Color(0xFFA29E9E), |
||||
), |
||||
), |
||||
], |
||||
), |
||||
SizedBox( |
||||
height: 24.h, |
||||
), |
||||
(message.typed != 3) |
||||
? Row( |
||||
mainAxisAlignment: MainAxisAlignment.center, |
||||
// crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
Expanded( |
||||
child: Text( |
||||
S.of(context).ninyouyigexindedingdan, |
||||
style: TextStyle( |
||||
fontSize: 12.sp, |
||||
color: Color(0xFF353535), |
||||
), |
||||
), |
||||
), |
||||
Icon( |
||||
Icons.keyboard_arrow_right, |
||||
size: 24, |
||||
), |
||||
], |
||||
) |
||||
: Row( |
||||
mainAxisAlignment: MainAxisAlignment.center, |
||||
crossAxisAlignment: CrossAxisAlignment.end, |
||||
children: [ |
||||
Expanded( |
||||
child: Text( |
||||
message.content, |
||||
style: TextStyle( |
||||
fontSize: 12.sp, |
||||
color: Color(0xFF353535), |
||||
), |
||||
)), |
||||
|
||||
Icon( |
||||
Icons.keyboard_arrow_right, |
||||
size: 24, |
||||
), |
||||
], |
||||
), |
||||
Container( |
||||
margin: EdgeInsets.only(top: 16.h, bottom: 8.h), |
||||
height: 1.h, |
||||
width: double.infinity, |
||||
color: Color(0xFFF7F7F7), |
||||
), |
||||
], |
||||
), |
||||
), |
||||
], |
||||
), |
||||
], |
||||
), |
||||
); |
||||
} |
||||
} |