HomeDrawer.dart 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. import 'package:flutter/material.dart';
  2. import 'package:redux/redux.dart';
  3. import 'package:flutter_redux/flutter_redux.dart';
  4. import 'package:flutter/cupertino.dart';
  5. import '../redux/AppState.dart';
  6. import '../model/UserInfo.dart';
  7. import '../pages/MyWallet.dart'; //我的钱包
  8. class HomeDrawer extends StatelessWidget {
  9. @override
  10. Widget build(BuildContext context) {
  11. return StoreConnector<AppState, UserInfo>(
  12. converter: (Store store) => store.state.userInfo,
  13. builder: (context, userInfo) {
  14. return Drawer(
  15. child: Container(
  16. decoration: BoxDecoration(
  17. gradient: LinearGradient(
  18. begin: Alignment.bottomRight,
  19. colors: [Color(0xFF3D3E6C), Color(0xFF626C85)],
  20. )),
  21. child: Column(
  22. children: <Widget>[
  23. Container(
  24. height: 210,
  25. decoration: BoxDecoration(color: Color(0x4D000000)),
  26. child: SafeArea(
  27. child: Row(
  28. mainAxisAlignment: MainAxisAlignment.center,
  29. children: <Widget>[
  30. ClipOval(
  31. child: Image.network(
  32. userInfo.icon,
  33. width: 86,
  34. height: 86,
  35. fit: BoxFit.cover,
  36. ),
  37. ),
  38. Container(
  39. margin: EdgeInsets.only(left: 16),
  40. child: Column(
  41. mainAxisAlignment: MainAxisAlignment.center,
  42. crossAxisAlignment: CrossAxisAlignment.start,
  43. children: <Widget>[
  44. Text(
  45. userInfo.nickname,
  46. style: TextStyle(
  47. fontSize: 27,
  48. color: Colors.white,
  49. fontWeight: FontWeight.w700),
  50. ),
  51. Row(
  52. mainAxisAlignment: MainAxisAlignment.center,
  53. children: <Widget>[
  54. Container(
  55. margin: EdgeInsets.only(right: 4),
  56. child: SizedBox(
  57. width: 20,
  58. height: 20,
  59. child: Image.asset(
  60. "images/icon_jinbi_da_bai.png"),
  61. ),
  62. ),
  63. Text(
  64. userInfo.moneyCoin.toString(),
  65. style: TextStyle(
  66. fontSize: 16,
  67. color: Colors.white,
  68. fontWeight: FontWeight.w700),
  69. )
  70. ],
  71. ),
  72. ],
  73. ),
  74. )
  75. ],
  76. ),
  77. ),
  78. ),
  79. Expanded(
  80. flex: 1,
  81. child: Container(
  82. padding: EdgeInsets.only(top: 10),
  83. child: Column(
  84. children: <Widget>[
  85. DrawerMenu(
  86. "images/icon_qianbao.png",
  87. "我的钱包",
  88. onTap: () {
  89. Navigator.push(
  90. context,
  91. new CupertinoPageRoute(
  92. builder: (context) => new MyWallet()));
  93. },
  94. ),
  95. Divder(),
  96. DrawerMenu("images/icon_zhanji.png", "我的战绩"),
  97. Divder(),
  98. DrawerMenu("images/icon_bangding.png", "游戏绑定")
  99. ],
  100. ),
  101. ),
  102. )
  103. ],
  104. ),
  105. ));
  106. },
  107. );
  108. }
  109. }
  110. typedef void OnDrawerMenuTap();
  111. class Divder extends StatelessWidget {
  112. @override
  113. Widget build(BuildContext context) {
  114. return Container(
  115. height: 1,
  116. padding: EdgeInsets.fromLTRB(30, 0, 30, 0),
  117. child: Container(
  118. decoration: BoxDecoration(color: Color(0x2E000000)),
  119. ),
  120. );
  121. }
  122. }
  123. class DrawerMenu extends StatelessWidget {
  124. final String icon;
  125. final String title;
  126. final OnDrawerMenuTap onTap;
  127. DrawerMenu(this.icon, this.title, {this.onTap});
  128. @override
  129. Widget build(BuildContext context) {
  130. return Container(
  131. height: 60,
  132. padding: EdgeInsets.fromLTRB(30, 0, 28, 0),
  133. child: GestureDetector(
  134. onTap: onTap,
  135. child: Row(
  136. children: <Widget>[
  137. Image.asset(icon),
  138. Expanded(
  139. flex: 1,
  140. child: Container(
  141. margin: EdgeInsets.only(left: 16),
  142. child: Text(
  143. title,
  144. style: TextStyle(
  145. color: Colors.white,
  146. fontSize: 15,
  147. fontWeight: FontWeight.w700),
  148. ),
  149. ),
  150. ),
  151. Image.asset("images/icon_inter.png")
  152. ],
  153. ),
  154. ),
  155. );
  156. }
  157. }