YSMessage.dart 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_wallet/base/YSBase.dart';
  4. import 'package:flutter_wallet/generated/l10n.dart';
  5. import 'package:flutter_wallet/tools/YSAlertView.dart';
  6. import 'package:flutter_wallet/tools/YSColors.dart';
  7. import 'package:flutter_wallet/tools/YSNetWork.dart';
  8. import 'package:flutter_wallet/tools/YSRefrehLoad.dart';
  9. import 'package:flutter_wallet/tools/YSTools.dart';
  10. import 'YSTansDetail.dart';
  11. class YSMessage extends StatefulWidget {
  12. const YSMessage({Key? key}) : super(key: key);
  13. @override
  14. YSMessageState createState() => YSMessageState();
  15. }
  16. class YSMessageState extends State<YSMessage> with SingleTickerProviderStateMixin{
  17. final List _titleArray = [
  18. {'title': S.current.ZHUANZHANGTONGZHI,'type':1},
  19. {'title': S.current.XITONGXIAOXI,'type':2}
  20. ];
  21. late TabController _tabController;
  22. @override
  23. void initState() {
  24. _tabController = TabController(
  25. vsync: this,
  26. length: _titleArray.length,
  27. );
  28. super.initState();
  29. }
  30. _postRead() async{
  31. Map request = {};
  32. request['address'] = YSData().wallet['public'];
  33. request['chain_id'] = YSData().typeId;
  34. // request['type'] = 1;
  35. Map dict = await YSNetWork.ysRequestHttpNOSet(context, type: RequestType.get, api: 'settransnotice', parameter: request);
  36. if(dict.isNotEmpty){
  37. refreshKey3.currentState!.refresh(request: {});
  38. }
  39. }
  40. @override
  41. Widget build(BuildContext context) {
  42. return YSBase(
  43. ysTitle: S.current.XIAOXIZHONGXIN,
  44. ysRightWidget: GestureDetector(
  45. onTap: (){
  46. ysShowCenterAlertView(context, YSTipsAlertView(valueSetter: (value){
  47. if(value){
  48. _postRead();
  49. }
  50. },tipsStr: '是否全部设为已读?',));
  51. },
  52. child: Text(S.current.QUANBUYIDU,style: YSColors.content2Style(context),),
  53. ),
  54. ysChild: SizedBox(
  55. width: ysWidth(context),
  56. height: ysHeight(context)-ysTOP(context)-60,
  57. child: DefaultTabController(
  58. length: _titleArray.length,
  59. child: Column(
  60. children: [
  61. SizedBox(
  62. height: hsp(50),
  63. child: TabBar(
  64. controller: _tabController,
  65. indicatorWeight: hsp(1),
  66. labelColor: Colors.black,
  67. tabs: _titleArray.map((f) {
  68. return Tab(
  69. child: Stack(
  70. children: [
  71. Text(f['title']),
  72. // Container(
  73. // height: hsp(5),
  74. // width: hsp(5),
  75. // decoration: const BoxDecoration(
  76. // color: Colors.red,
  77. // borderRadius: BorderRadius.all(Radius.circular(50))
  78. // ),
  79. // margin: EdgeInsets.only(left: hsp(60),top: hsp(5)),
  80. // )
  81. ],
  82. ),
  83. );
  84. }).toList(),
  85. ),
  86. ),
  87. Expanded(
  88. child: TabBarView(
  89. controller: _tabController,
  90. children: _titleArray.map((f) {
  91. return f['type']==1?const YSMessageTransferDataView():const YSMessageSystemDataView();
  92. }).toList(),
  93. )
  94. )
  95. ],
  96. ),
  97. ),
  98. ),
  99. );
  100. }
  101. }
  102. class YSMessageTransferDataView extends StatefulWidget {
  103. const YSMessageTransferDataView({Key? key}) : super(key: key);
  104. @override
  105. YSMessageTransferDataViewState createState() => YSMessageTransferDataViewState();
  106. }
  107. class YSMessageTransferDataViewState extends State<YSMessageTransferDataView> {
  108. List _dataArray = [];
  109. @override
  110. void initState() {
  111. networkDelay((){
  112. _postSyntransnotice();
  113. });
  114. super.initState();
  115. }
  116. _postSyntransnotice() async{
  117. Map request = {};
  118. request['page'] = 1;
  119. request['count'] = 10;
  120. request['address'] = YSData().wallet['public'];
  121. request['chain_id'] = YSData().typeId;
  122. Map dict = await YSNetWork.ysRequestHttpNOSet(context, type: RequestType.post, api: 'gettransnotice', parameter: request);
  123. if(dict.isNotEmpty){
  124. // Map dict = await YSNetWork.ysRequestHttpNOSet(context, type: RequestType.post, api: 'gettransnotice', parameter: request);
  125. }
  126. }
  127. @override
  128. Widget build(BuildContext context) {
  129. return YSRefreshLoad(
  130. key: refreshKey3,
  131. url: 'gettransnotice',
  132. request: {'address':YSData().wallet['public'],'chain_id':YSData().typeId},
  133. postData: (value) {
  134. _dataArray = value;
  135. setState(() {});
  136. },
  137. child: SingleChildScrollView(
  138. child: ListView.separated(
  139. itemBuilder: (context,index){
  140. Map item = _dataArray[index];
  141. String value = '${item['value']??''}';
  142. if(value.isEmpty){
  143. value = '0';
  144. }
  145. return GestureDetector(
  146. onTap: (){
  147. Navigator.of(context).push(
  148. CupertinoPageRoute(builder: (context){
  149. return YSTansDetail2(item: item,);
  150. })
  151. ).then((value) {
  152. refreshKey3.currentState!.refresh(request: {});
  153. });
  154. },
  155. behavior: HitTestBehavior.opaque,
  156. child: Container(
  157. padding: EdgeInsets.only(top: hsp(10),bottom: hsp(10),left: hsp(15),right: hsp(15)),
  158. child: Row(
  159. children: [
  160. if(item['Status']==0)Container(
  161. height: hsp(5),
  162. width: hsp(5),
  163. decoration: const BoxDecoration(
  164. color: Colors.red,
  165. borderRadius: BorderRadius.all(Radius.circular(50))
  166. ),
  167. margin: EdgeInsets.only(right: hsp(5)),
  168. ),
  169. item['TxStatus']==1?Icon(Icons.check_circle,size: hsp(30),color: Colors.green,):Icon(Icons.error,size: hsp(30),color: Colors.red,),
  170. Container(
  171. padding: EdgeInsets.only(left: hsp(10),right: hsp(10)),
  172. width: (ysWidth(context)-hsp(70))*0.7,
  173. child: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [
  174. Padding(
  175. padding: EdgeInsets.only(bottom: hsp(5)),
  176. child: Text('${item['Symbol']??''}:${toDecimalFlex(item['Amount'],decimal: item['Decimal'],range: 6)}',style: YSColors.contentStyle(context),),
  177. ),
  178. Text('发送地址:${ysTextCut(item['ToAddress'])}',style: YSColors.subStyle(context),)
  179. ],)),
  180. Container(
  181. padding: EdgeInsets.only(left: hsp(10),right: hsp(10)),
  182. width: (ysWidth(context)-hsp(70))*0.3,
  183. child: Column(crossAxisAlignment: CrossAxisAlignment.end,children: [
  184. Padding(
  185. padding: EdgeInsets.only(bottom: hsp(5)),
  186. child: Text(item['CreateTime'],style: YSColors.subStyle(context),),
  187. ),
  188. Text(item['Symbol']??'',style: YSColors.subStyle(context),)
  189. ],))
  190. ],
  191. ),
  192. ),
  193. );
  194. },
  195. separatorBuilder: (context,index){
  196. return Divider(height: hsp(1),thickness: hsp(1),color: YSColors.lineColor(context),);
  197. },
  198. itemCount: _dataArray.length,
  199. padding: const EdgeInsets.all(0),
  200. shrinkWrap: true,
  201. physics: const NeverScrollableScrollPhysics(),
  202. ),
  203. ),
  204. );
  205. }
  206. }
  207. class YSMessageSystemDataView extends StatefulWidget {
  208. const YSMessageSystemDataView({Key? key}) : super(key: key);
  209. @override
  210. YSMessageSystemDataViewState createState() => YSMessageSystemDataViewState();
  211. }
  212. class YSMessageSystemDataViewState extends State<YSMessageSystemDataView> {
  213. List _dataArray = [];
  214. @override
  215. Widget build(BuildContext context) {
  216. return YSRefreshLoad(
  217. url: 'notices',
  218. request: const {'type':'0'},
  219. postData: (value){
  220. _dataArray = value;
  221. setState(() {});
  222. },
  223. child: SingleChildScrollView(
  224. child: ListView.separated(
  225. itemBuilder: (context,index){
  226. Map item = _dataArray[index];
  227. return Container(
  228. padding: EdgeInsets.only(top: hsp(10),bottom: hsp(10),left: hsp(15),right: hsp(15)),
  229. child: Column(
  230. crossAxisAlignment: CrossAxisAlignment.start,
  231. children: [
  232. Padding(
  233. padding: EdgeInsets.only(bottom: hsp(5)),
  234. child: Row(
  235. children: [
  236. Expanded(child: Text(item['title']??'',style: YSColors.contentStyle(context),),),
  237. Container(
  238. width: hsp(150),
  239. alignment: Alignment.centerRight,
  240. child: Text(item['CreateTime']??'',style: YSColors.subStyle(context),),
  241. )
  242. ],
  243. )
  244. ),
  245. Text(item['txt']??''.fixAutoLines(),style: YSColors.subStyle(context),)
  246. ],
  247. ),
  248. );
  249. },
  250. separatorBuilder: (context,index){
  251. return Divider(height: hsp(1),thickness: hsp(1),color: YSColors.lineColor(context),);
  252. },
  253. itemCount: _dataArray.length,
  254. padding: const EdgeInsets.all(0),
  255. shrinkWrap: true,
  256. physics: const NeverScrollableScrollPhysics(),
  257. ),
  258. )
  259. );;
  260. }
  261. }