UserPage.dart 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. import 'package:flutter/material.dart';
  2. import 'package:redux/redux.dart';
  3. import 'package:flutter_redux/flutter_redux.dart';
  4. import 'package:cached_network_image/cached_network_image.dart';
  5. import 'package:flutter/cupertino.dart';
  6. import '../redux/AppState.dart';
  7. import '../model/UserInfo.dart';
  8. import '../pages/MyWallet.dart';
  9. import '../pages/BindGame.dart';
  10. import '../pages/RecordList.dart';
  11. import '../net/HttpManager.dart';
  12. import '../net/Result.dart';
  13. import '../redux/UserRedux.dart';
  14. import '../pages/UserChange.dart';
  15. import '../pages/RoomCardList.dart';
  16. import '../pages/MyTeam.dart';
  17. import '../pages/MyCode.dart';
  18. import '../widget/LinearButton.dart';
  19. import 'Setting.dart';
  20. import 'ShoppingMall.dart';
  21. import 'OpenRoom.dart';
  22. class UserPage extends StatefulWidget {
  23. @override
  24. _UserPageState createState() => _UserPageState();
  25. }
  26. class _UserPageState extends State<UserPage> with WidgetsBindingObserver {
  27. Future<void> getUserInfo() async {
  28. Result res = await HttpManager.get('userInfo/getUserInfo');
  29. if (res.success) {
  30. print(res.data);
  31. StoreProvider.of<AppState>(context).dispatch(UpdateUserAction(UserInfo.fromJson(res.data)));
  32. } else {}
  33. }
  34. @override
  35. void initState() {
  36. super.initState();
  37. Future.delayed(Duration.zero, () => getUserInfo());
  38. }
  39. @override
  40. Widget build(BuildContext context) {
  41. return StoreConnector<AppState, UserInfo>(
  42. converter: (Store store) => store.state.userInfo,
  43. builder: (context, userInfo) {
  44. return Scaffold(
  45. body: Container(
  46. color: Color(0xFF2E3049),
  47. height: double.infinity,
  48. width: double.infinity,
  49. child: SingleChildScrollView(
  50. child: Column(
  51. children: <Widget>[
  52. Container(
  53. height: 250,
  54. decoration: BoxDecoration(image: DecorationImage(image: AssetImage('images/info_img_bg.png'), fit: BoxFit.cover)),
  55. child: SafeArea(
  56. child: Column(
  57. mainAxisAlignment: MainAxisAlignment.center,
  58. children: <Widget>[
  59. InkWell(
  60. child: ClipOval(
  61. child: CachedNetworkImage(
  62. imageUrl: userInfo.icon,
  63. width: 76,
  64. height: 76,
  65. fit: BoxFit.cover,
  66. )),
  67. onTap: () {
  68. Navigator.push(context, CupertinoPageRoute(builder: (context) => UserChange()));
  69. },
  70. ),
  71. Container(
  72. height: 4,
  73. ),
  74. Text(
  75. userInfo.nickname,
  76. style: TextStyle(fontSize: 20, color: Colors.white, fontWeight: FontWeight.w700),
  77. ),
  78. Container(
  79. height: 20,
  80. ),
  81. Row(
  82. mainAxisAlignment: MainAxisAlignment.spaceAround,
  83. children: <Widget>[
  84. Container(
  85. width: 165,
  86. child: LinearButton(
  87. btntext: '发起比赛',
  88. btnHeight: 38.0,
  89. colorList: [Colors.white, Colors.white],
  90. textColor: Color(0xFF252532),
  91. textSize: 13.0,
  92. onTapHomeMenu: () {
  93. Navigator.push(context, CupertinoPageRoute(builder: (context) => OpenRoom(roomFlag: '0')));
  94. },
  95. ),
  96. ),
  97. Container(
  98. width: 165,
  99. child: LinearButton(
  100. btntext: '充值参赛券',
  101. btnHeight: 38.0,
  102. textSize: 13.0,
  103. onTapHomeMenu: () {
  104. Navigator.push(context, CupertinoPageRoute(builder: (context) => ShoppingMall()));
  105. },
  106. ))
  107. ],
  108. )
  109. ],
  110. ),
  111. ),
  112. ),
  113. DrawerMenu(
  114. 'images/info1.png',
  115. '我的参赛券',
  116. tipValue: userInfo.moneyTicket,
  117. onTap: () {
  118. Navigator.push(context, CupertinoPageRoute(builder: (context) => MyWallet()));
  119. },
  120. ),
  121. Divder(),
  122. DrawerMenu(
  123. 'images/icon_fangka.png',
  124. '房卡人数',
  125. tipValue: userInfo.houseCard,
  126. onTap: () {
  127. Navigator.push(context, CupertinoPageRoute(builder: (context) => RoomCardList()));
  128. },
  129. ),
  130. Divder(),
  131. DrawerMenu('images/icon_zhanji.png', '我的赛事', onTap: () {
  132. Navigator.push(context, CupertinoPageRoute(builder: (context) => RecordList()));
  133. }),
  134. Divder(),
  135. DrawerMenu(
  136. 'images/icon_bangding.png',
  137. '游戏绑定',
  138. onTap: () {
  139. Navigator.push(context, CupertinoPageRoute(builder: (context) => BindGame()));
  140. },
  141. ),
  142. Divder(),
  143. DrawerMenu(
  144. 'images/icon_tuandui.png',
  145. '我的团队',
  146. onTap: () {
  147. Navigator.push(context, CupertinoPageRoute(builder: (context) => MyTeam()));
  148. },
  149. ),
  150. Divder(),
  151. DrawerMenu(
  152. 'images/icon_tuiguangma.png',
  153. '我的推广码',
  154. onTap: () {
  155. Navigator.push(context, CupertinoPageRoute(builder: (context) => MyCode()));
  156. },
  157. )
  158. ],
  159. ),
  160. ),
  161. ),
  162. floatingActionButton: Container(
  163. width: 53,
  164. height: 130,
  165. // color: Colors.white,
  166. padding: EdgeInsets.fromLTRB(0, 90, 10, 0),
  167. child: GestureDetector(
  168. onTap: () {
  169. Navigator.push(context, CupertinoPageRoute(builder: (context) => Setting()));
  170. },
  171. child: Image.asset('images/info_icon_shezhi.png'))),
  172. floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
  173. );
  174. });
  175. }
  176. }
  177. typedef void OnDrawerMenuTap();
  178. class Divder extends StatelessWidget {
  179. @override
  180. Widget build(BuildContext context) {
  181. return Container(
  182. height: 1,
  183. padding: EdgeInsets.fromLTRB(55, 0, 15, 0),
  184. child: Container(
  185. decoration: BoxDecoration(color: Color(0x2E000000)),
  186. ),
  187. );
  188. }
  189. }
  190. class DrawerMenu extends StatelessWidget {
  191. final String icon;
  192. final String title;
  193. final OnDrawerMenuTap onTap;
  194. final num tipValue;
  195. DrawerMenu(this.icon, this.title, {this.onTap, this.tipValue});
  196. @override
  197. Widget build(BuildContext context) {
  198. return Container(
  199. height: 60,
  200. padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
  201. child: GestureDetector(
  202. onTap: onTap,
  203. child: Row(
  204. children: <Widget>[
  205. Image.asset(icon),
  206. Expanded(
  207. flex: 1,
  208. child: Container(
  209. margin: EdgeInsets.only(left: 16),
  210. child: Text(
  211. title,
  212. style: TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w400),
  213. ),
  214. ),
  215. ),
  216. tipValue != null
  217. ? Text(
  218. tipValue.toString(),
  219. style: TextStyle(fontSize: 13, color: Theme.of(context).primaryColor,fontWeight: FontWeight.w600),
  220. )
  221. : Container(),
  222. Image.asset('images/icon_inter.png')
  223. ],
  224. ),
  225. ),
  226. );
  227. }
  228. }