me_page.dart 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. import 'package:cpt_main/modules/demo_page.dart';
  2. import 'package:cs_resources/generated/assets.dart';
  3. import 'package:cs_resources/generated/l10n.dart';
  4. import 'package:cs_resources/theme/app_colors_theme.dart';
  5. import 'package:cs_resources/theme/theme_config.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:auto_route/auto_route.dart';
  8. import 'package:hooks_riverpod/hooks_riverpod.dart';
  9. import 'package:widgets/ext/ex_widget.dart';
  10. import 'package:widgets/my_appbar.dart';
  11. import 'package:widgets/my_load_image.dart';
  12. import 'package:widgets/my_text_view.dart';
  13. import 'package:widgets/shatter/setting_item_container.dart';
  14. import 'me_view_model.dart';
  15. @RoutePage()
  16. class MePage extends HookConsumerWidget {
  17. const MePage({Key? key}) : super(key: key);
  18. @override
  19. Widget build(BuildContext context, WidgetRef ref) {
  20. final viewModel = ref.watch(meViewModelProvider.notifier);
  21. return Scaffold(
  22. appBar: MyAppBar.appBar(
  23. context,
  24. "",
  25. showBackButton: false,
  26. backgroundColor: context.appColors.btnBgDefault,
  27. systemUiOverlayStyle: ThemeConfig.systemUiOverlayStyleLightThemeWhite,
  28. ),
  29. backgroundColor: context.appColors.backgroundDark,
  30. body: SingleChildScrollView(
  31. scrollDirection: Axis.vertical,
  32. physics: const BouncingScrollPhysics(),
  33. child: SizedBox(
  34. width: double.infinity,
  35. child: Column(
  36. mainAxisSize: MainAxisSize.max,
  37. crossAxisAlignment: CrossAxisAlignment.center,
  38. children: [
  39. //顶部信息
  40. _buildTopProfile(context, ref),
  41. //关注与粉丝
  42. _buildFollower(context, ref),
  43. //我的发布
  44. SettingItemContainer(
  45. title: S.current.my_post,
  46. iconPath: Assets.mainMeMyPostIcon,
  47. isShowMoreIcon: true,
  48. rightWidget: MyTextView(
  49. "265",
  50. textColor: context.appColors.textPrimary,
  51. fontSize: 20,
  52. isFontMedium: true,
  53. ),
  54. ).onTap(viewModel.gotoMyPostPage).marginOnly(top: 10),
  55. //家庭
  56. SettingItemContainer(
  57. title: S.current.household,
  58. iconPath: Assets.mainMeHouseholdIcon,
  59. isShowMoreIcon: true,
  60. rightWidget: MyTextView(
  61. "2",
  62. textColor: context.appColors.textPrimary,
  63. fontSize: 20,
  64. isFontMedium: true,
  65. ),
  66. ).onTap(viewModel.gotoMyHouseholdPage),
  67. //房产
  68. SettingItemContainer(
  69. title: S.current.estate,
  70. iconPath: Assets.mainMeEstateIcon,
  71. isShowMoreIcon: true,
  72. rightWidget: MyTextView(
  73. "2",
  74. textColor: context.appColors.textPrimary,
  75. fontSize: 20,
  76. isFontMedium: true,
  77. ),
  78. ).onTap(viewModel.gotoMyEstatePage),
  79. //设置
  80. SettingItemContainer(
  81. title: S.current.settings,
  82. iconPath: Assets.mainMeSettingIcon,
  83. isShowMoreIcon: true,
  84. ).onTap(viewModel.gotoSettingPage),
  85. ],
  86. ),
  87. ),
  88. ),
  89. );
  90. }
  91. //编辑顶部的关注与粉丝数量
  92. Widget _buildFollower(BuildContext context, WidgetRef ref) {
  93. final viewModel = ref.watch(meViewModelProvider.notifier);
  94. return Container(
  95. color: context.appColors.whiteSecondBG,
  96. width: double.infinity,
  97. height: 50,
  98. child: Row(
  99. children: [
  100. //关注
  101. Row(
  102. mainAxisSize: MainAxisSize.min,
  103. mainAxisAlignment: MainAxisAlignment.center,
  104. crossAxisAlignment: CrossAxisAlignment.center,
  105. children: [
  106. MyTextView(
  107. S.current.following,
  108. isFontBold: true,
  109. fontSize: 16,
  110. textColor: context.appColors.textBlack,
  111. ),
  112. MyTextView(
  113. "(26)",
  114. isFontBold: true,
  115. fontSize: 16,
  116. textColor: context.appColors.textPrimary,
  117. ),
  118. ],
  119. ).onTap(viewModel.gotoFollowingPage).expanded(),
  120. Container(
  121. width: 0.5,
  122. height: 50,
  123. color: context.appColors.dividerDefault,
  124. ),
  125. //粉丝
  126. Row(
  127. mainAxisSize: MainAxisSize.min,
  128. mainAxisAlignment: MainAxisAlignment.center,
  129. crossAxisAlignment: CrossAxisAlignment.center,
  130. children: [
  131. MyTextView(
  132. S.current.followers,
  133. isFontBold: true,
  134. fontSize: 16,
  135. textColor: context.appColors.textBlack,
  136. ),
  137. MyTextView(
  138. "(12)",
  139. isFontBold: true,
  140. fontSize: 16,
  141. textColor: context.appColors.textPrimary,
  142. ),
  143. ],
  144. ).onTap(viewModel.gotoFollowerPage).expanded(),
  145. ],
  146. ),
  147. );
  148. }
  149. // 编辑顶部的个人信息
  150. Widget _buildTopProfile(BuildContext context, WidgetRef ref) {
  151. final viewModel = ref.watch(meViewModelProvider.notifier);
  152. return Container(
  153. color: context.appColors.btnBgDefault,
  154. width: double.infinity,
  155. padding: const EdgeInsets.only(left: 26, right: 20, top: 5),
  156. height: 120,
  157. child: Row(
  158. mainAxisSize: MainAxisSize.max,
  159. crossAxisAlignment: CrossAxisAlignment.start,
  160. children: [
  161. MyLoadImage(
  162. "https://img1.baidu.com/it/u=1656098746,3560654086&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800",
  163. width: 80,
  164. height: 80,
  165. isCircle: true,
  166. ),
  167. Column(
  168. mainAxisSize: MainAxisSize.min,
  169. mainAxisAlignment: MainAxisAlignment.start,
  170. crossAxisAlignment: CrossAxisAlignment.start,
  171. children: [
  172. Row(
  173. children: [
  174. MyTextView(
  175. "Wu Bing Bing",
  176. textColor: Colors.white,
  177. fontSize: 18,
  178. isFontMedium: true,
  179. ).expanded(),
  180. const MyAssetImage(
  181. Assets.mainMeEditIcon,
  182. width: 20.5,
  183. height: 20,
  184. ).onTap(viewModel.gotoEditProfilePage, padding: 5),
  185. ],
  186. ),
  187. //电话
  188. MyTextView(
  189. "+86 12345678901",
  190. textColor: Colors.white,
  191. fontSize: 15,
  192. isFontRegular: true,
  193. ),
  194. //住宅
  195. MyTextView(
  196. "Owner135 #08-29",
  197. marginTop: 12,
  198. textColor: Colors.white,
  199. fontSize: 15,
  200. isFontRegular: true,
  201. ),
  202. ],
  203. ).marginOnly(left: 11).expanded(),
  204. ],
  205. ),
  206. );
  207. }
  208. }