HomePageDrawer.dart 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_habit/common/I18N.dart';
  3. import 'package:flutter_habit/common/components/PopMenus.dart';
  4. import 'package:flutter_habit/provider/DataProvider.dart';
  5. import 'package:flutter_habit/provider/UserProvider.dart';
  6. import 'package:flutter_habit/view/drawer/community/FollowedPage.dart';
  7. import 'package:flutter_habit/view/drawer/community/RankingListPage.dart';
  8. import 'package:flutter_habit/view/drawer/community/SearchUserPage.dart';
  9. import 'package:flutter_habit/view/drawer/setting/SettingPage.dart';
  10. import 'package:flutter_habit/view/drawer/shop/ShopPage.dart';
  11. import 'package:flutter_habit/view/drawer/user/UserPage.dart';
  12. import 'package:provider/provider.dart';
  13. class HomePageDrawer extends StatelessWidget {
  14. @override
  15. Widget build(BuildContext context) {
  16. UserProvider userProvider = Provider.of<UserProvider>(context);
  17. DataProvider dataProvider = Provider.of<DataProvider>(context);
  18. return Drawer(
  19. child: Column(
  20. crossAxisAlignment: CrossAxisAlignment.center,
  21. children: <Widget>[
  22. Container(
  23. color: Theme.of(context).primaryColor,
  24. padding: EdgeInsets.only(top: 36, bottom: 10, left: 16, right: 16),
  25. child: Column(
  26. children: <Widget>[
  27. Row(
  28. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  29. crossAxisAlignment: CrossAxisAlignment.start,
  30. children: <Widget>[
  31. Column(
  32. crossAxisAlignment: CrossAxisAlignment.start,
  33. children: <Widget>[
  34. Text(
  35. I18N.of("欢迎"),
  36. style: Theme.of(context).textTheme.displayLarge!.copyWith(
  37. color: Theme.of(context).colorScheme.onPrimary),
  38. ),
  39. Text(
  40. I18N.of("来到"),
  41. style: TextStyle(
  42. color: Theme.of(context).colorScheme.onPrimary),
  43. ),
  44. Text(
  45. "Habit",
  46. style: Theme.of(context)
  47. .textTheme
  48. .titleLarge!
  49. .copyWith(
  50. color: Theme.of(context).colorScheme.onPrimary),
  51. ),
  52. ],
  53. ),
  54. Column(
  55. crossAxisAlignment: CrossAxisAlignment.center,
  56. children: <Widget>[
  57. userProvider.photo == null
  58. ? Icon(
  59. Icons.account_circle,
  60. size: 70,
  61. color: Theme.of(context).colorScheme.onPrimary,
  62. )
  63. : ClipOval(
  64. child: Image.memory(
  65. userProvider.photo!,
  66. width: 70,
  67. height: 70,
  68. ),
  69. ),
  70. Container(height: 10),
  71. Text(
  72. userProvider.userName != null &&
  73. userProvider.userName != null
  74. ? userProvider.userName!
  75. : I18N.of("未登录"),
  76. style: TextStyle(
  77. color: Theme.of(context).colorScheme.onPrimary),
  78. ),
  79. Row(
  80. children: <Widget>[
  81. Text(
  82. "${I18N.of("今日状态")}: ",
  83. style: Theme.of(context)
  84. .textTheme
  85. .titleMedium!
  86. .copyWith(
  87. color: Theme.of(context)
  88. .colorScheme
  89. .onPrimary),
  90. ),
  91. Icon(
  92. dataProvider.todayEvaluate <= 4
  93. ? Icons.sentiment_dissatisfied
  94. : dataProvider.todayEvaluate <= 9
  95. ? Icons.sentiment_neutral
  96. : Icons.sentiment_satisfied,
  97. color: Theme.of(context).colorScheme.onPrimary,
  98. size: 20,
  99. )
  100. ],
  101. ),
  102. ],
  103. ),
  104. ],
  105. ),
  106. ],
  107. ),
  108. ),
  109. Expanded(
  110. flex: 3,
  111. child: Column(
  112. children: <Widget>[
  113. ListTile(
  114. leading: Icon(Icons.account_box),
  115. title: Text(I18N.of("用户")),
  116. onTap: () {
  117. Navigator.of(context).pop();
  118. Navigator.of(context)
  119. .push(MaterialPageRoute(builder: (_) => UserPage()));
  120. },
  121. ),
  122. ListTile(
  123. leading: Icon(Icons.trending_up),
  124. title: Text(I18N.of("排行榜")),
  125. onTap: () {
  126. Navigator.of(context).pop();
  127. Navigator.of(context).push(
  128. MaterialPageRoute(builder: (_) => RankingListPage()));
  129. },
  130. ),
  131. userProvider.token == null
  132. ? Container()
  133. : ListTile(
  134. leading: Icon(Icons.face),
  135. title: Text(I18N.of("我的关注")),
  136. onTap: () {
  137. Navigator.of(context).pop();
  138. Navigator.of(context).push(MaterialPageRoute(
  139. builder: (_) => FollowedPage()));
  140. },
  141. ),
  142. userProvider.token == null
  143. ? Container()
  144. : ListTile(
  145. leading: Icon(Icons.search),
  146. title: Text(I18N.of("搜索用户")),
  147. onTap: () {
  148. Navigator.of(context).pop();
  149. Navigator.of(context).push(MaterialPageRoute(
  150. builder: (_) => SearchUserPage()));
  151. },
  152. ),
  153. ListTile(
  154. leading: Icon(Icons.store),
  155. title: Text(I18N.of("商城")),
  156. onTap: () {
  157. Navigator.of(context).pop();
  158. Navigator.of(context)
  159. .push(MaterialPageRoute(builder: (_) => ShopPage()));
  160. },
  161. ),
  162. ListTile(
  163. leading: Icon(Icons.settings),
  164. title: Text(I18N.of("设置")),
  165. onTap: () async {
  166. Navigator.of(context).pop();
  167. await Navigator.of(context)
  168. .push(MaterialPageRoute(builder: (_) => SettingPage()));
  169. },
  170. ),
  171. ],
  172. ),
  173. ),
  174. Padding(
  175. padding: EdgeInsets.only(bottom: 5),
  176. child: InkWell(
  177. child: Text(
  178. "@2020 ZXZhang All rights reserved.",
  179. style: Theme.of(context).textTheme.bodySmall,
  180. ),
  181. onTap: () {
  182. PopMenus.baseMenu(
  183. context: context,
  184. title: Text("About"),
  185. children: <Widget>[
  186. Padding(
  187. padding: EdgeInsets.all(25),
  188. child: Text(
  189. "本软件由张子玄独立设计、开发完成\n移动端使用Flutter开发\n后端使用SpringBoot开发\n使用docker在阿里云部署",
  190. ),
  191. ),
  192. Padding(
  193. padding: EdgeInsets.only(bottom: 10),
  194. child: Center(
  195. child: Text(
  196. "@2020 ZXZhang All rights reserved.",
  197. style: Theme.of(context).textTheme.bodySmall,
  198. ),
  199. ),
  200. ),
  201. ],
  202. );
  203. },
  204. )),
  205. ],
  206. ),
  207. );
  208. }
  209. }