YSAboutUs.dart 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_wallet/generated/l10n.dart';
  4. import 'package:flutter_wallet/login/view/YSHelpView.dart';
  5. import 'package:flutter_wallet/setting/YSAgreement.dart';
  6. import 'package:flutter_wallet/tools/YSAlertView.dart';
  7. import 'package:flutter_wallet/tools/YSColors.dart';
  8. import 'package:flutter_wallet/tools/YSNetWork.dart';
  9. import 'package:flutter_wallet/tools/YSTools.dart';
  10. import 'package:package_info_plus/package_info_plus.dart';
  11. class YSAboutUs extends StatefulWidget {
  12. const YSAboutUs({Key? key}) : super(key: key);
  13. @override
  14. YSAboutUsState createState() => YSAboutUsState();
  15. }
  16. class YSAboutUsState extends State<YSAboutUs> {
  17. final List _array = [
  18. {'icon':'编组 78','index':1},
  19. {'icon':'编组 68','index':2},
  20. {'icon':'编组 58','index':3},
  21. {'icon':'编组 48','index':4},
  22. {'icon':'编组 98','index':5},
  23. {'icon':'编组 28','index':6},
  24. {'icon':'编组 38','index':7}
  25. ];
  26. String _version = '';
  27. bool _hasNew = false;
  28. Map _data = {};
  29. @override
  30. void initState() {
  31. _getData();
  32. _getVersionData();
  33. super.initState();
  34. }
  35. _getVersionData() async{
  36. YSNetWork.ysRequestHttp(context, type: RequestType.post, api: 'versions', parameter: {}, successSetter: (dict) async{
  37. List list = dict['data']['list'];
  38. if(list.isNotEmpty){
  39. _data = list.first;
  40. PackageInfo packageInfo = await PackageInfo.fromPlatform();
  41. _hasNew = int.parse(packageInfo.buildNumber)<_data['build'];
  42. setState(() {});
  43. }
  44. });
  45. }
  46. _getData() async{
  47. PackageInfo packageInfo = await PackageInfo.fromPlatform();
  48. _version = packageInfo.version;
  49. setState(() {});
  50. }
  51. @override
  52. Widget build(BuildContext context) {
  53. List _menuArray = [
  54. {'title':S.current.BANBENGENGXIN,'value':_hasNew?'有新版本':'','type':1},
  55. {'title':S.current.GENGXINRIZHI,'value':'','type':2},
  56. {'title':S.current.YONGHUXIEYI,'value':'','type':2}
  57. ];
  58. return Scaffold(
  59. body: Container(
  60. height: ysHeight(context),
  61. width: ysWidth(context),
  62. child: Stack(
  63. children: [
  64. const YSHeadView(),
  65. Padding(
  66. padding: EdgeInsets.only(top: ysTOP(context)+hsp(20),left: hsp(20),right: hsp(20)),
  67. child: Column(
  68. children: [
  69. Align(
  70. alignment: Alignment.centerLeft,
  71. child: GestureDetector(
  72. onTap: (){
  73. Navigator.pop(context);
  74. },
  75. child: Icon(Icons.chevron_left,size: hsp(30),color: Colors.white,)
  76. ),
  77. ),
  78. Padding(
  79. padding: EdgeInsets.only(top: hsp(50),bottom: hsp(30)),
  80. child: Image.asset(YSColors.imageStyle(context, '资源 2'),height: hsp(40),width: hsp(70),color: Colors.white,)
  81. ),
  82. Image.asset(
  83. YSColors.imageStyle(context, '资源 3'),
  84. width: hsp(150),
  85. height: hsp(30),
  86. color: Colors.white,
  87. ),
  88. Padding(
  89. padding: EdgeInsets.only(top: hsp(20),bottom: hsp(60)),
  90. child: Text('${S.current.DANGQIANBANBEN}:$_version',style: YSColors.subStyle(context),)
  91. ),
  92. Container(
  93. height: hsp(135),
  94. width: hsp(300),
  95. decoration: BoxDecoration(
  96. borderRadius: const BorderRadius.all(Radius.circular(10)),
  97. color: YSColors.containColor(context),
  98. boxShadow: [
  99. BoxShadow(color: YSColors.lineColor(context),blurRadius: 3)
  100. ],
  101. ),
  102. child: ListView.separated(
  103. itemBuilder: (context,index){
  104. Map item = _menuArray[index];
  105. return GestureDetector(
  106. onTap: (){
  107. if(index==0){
  108. if(_hasNew){
  109. getVersionData(context,_data);
  110. }else{
  111. ysFlutterToast('暂无新版本');
  112. }
  113. }else if(index==1||index==2){
  114. Navigator.of(context).push(
  115. CupertinoPageRoute(builder: (context){
  116. return YSAgreement(type: index);
  117. })
  118. );
  119. }
  120. },
  121. behavior: HitTestBehavior.opaque,
  122. child: SizedBox(
  123. height: hsp(45),
  124. child: Row(
  125. children: [
  126. SizedBox(
  127. width: hsp(200),
  128. child: Text(item['title'],style: YSColors.contentStyle(context),),
  129. ),
  130. Expanded(
  131. child: Container(
  132. width: hsp(70),
  133. alignment: Alignment.centerRight,
  134. child: Text(item['value'],style: YSColors.subStyle(context),),
  135. ),
  136. ),
  137. Icon(Icons.chevron_right,size: hsp(20),color: YSColors.shadowColor(context),)
  138. ],
  139. ),
  140. ),
  141. );
  142. },
  143. separatorBuilder: (context,index){
  144. return Divider(height: hsp(1),color: YSColors.lineColor(context),);
  145. },
  146. itemCount: _menuArray.length,
  147. padding: EdgeInsets.only(left: hsp(15),right: hsp(10)),
  148. ),
  149. ),
  150. Container(
  151. width: hsp(280),
  152. height: hsp(50),
  153. alignment: Alignment.centerLeft,
  154. child: Text(S.current.GUANFANGQUDAO,style: YSColors.contentStyle(context),),
  155. ),
  156. Container(
  157. width: hsp(300),
  158. decoration: BoxDecoration(
  159. borderRadius: const BorderRadius.all(Radius.circular(10)),
  160. color: YSColors.containColor(context),
  161. boxShadow: [
  162. BoxShadow(color: YSColors.lineColor(context),blurRadius: 3)
  163. ],
  164. ),
  165. child: GridView.builder(
  166. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  167. crossAxisCount: 4,
  168. mainAxisSpacing: hsp(20),
  169. crossAxisSpacing: hsp(20)
  170. ),
  171. itemBuilder: (context,index){
  172. Map item = _array[index];
  173. return GestureDetector(
  174. onTap: (){
  175. int index = item['index'];
  176. switch(index){
  177. case 1:{
  178. }break;
  179. case 2:{}break;
  180. case 3:{}break;
  181. case 4:{}break;
  182. case 5:{}break;
  183. case 6:{}break;
  184. case 7:{}break;
  185. }
  186. },
  187. child: Image.asset(YSColors.imageStyle(context, item['icon'])),
  188. );
  189. },
  190. itemCount: _array.length,
  191. padding: EdgeInsets.all(hsp(20)),
  192. shrinkWrap: true,
  193. physics: const NeverScrollableScrollPhysics(),
  194. ),
  195. )
  196. ],
  197. ),
  198. )
  199. ],
  200. ),
  201. ),
  202. );
  203. }
  204. }