select_unit_page.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. import 'package:cs_resources/generated/assets.dart';
  2. import 'package:cs_resources/generated/l10n.dart';
  3. import 'package:cs_resources/theme/app_colors_theme.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:auto_route/auto_route.dart';
  6. import 'package:hooks_riverpod/hooks_riverpod.dart';
  7. import 'package:router/ext/auto_router_extensions.dart';
  8. import 'package:widgets/ext/ex_widget.dart';
  9. import 'package:widgets/my_appbar.dart';
  10. import 'package:widgets/my_button.dart';
  11. import 'package:widgets/my_load_image.dart';
  12. import 'package:widgets/my_text_field.dart';
  13. import 'package:widgets/my_text_view.dart';
  14. import 'package:widgets/shatter/picker_container.dart';
  15. import 'package:widgets/widget_export.dart';
  16. import '../../router/page/auth_page_router.dart';
  17. import 'select_unit_state.dart';
  18. import 'select_unit_view_model.dart';
  19. @RoutePage()
  20. class SelectUnitPage extends HookConsumerWidget {
  21. const SelectUnitPage({Key? key,}) : super(key: key);
  22. //启动当前页面
  23. static void startInstance({BuildContext? context}) {
  24. if (context != null) {
  25. context.router.push(const SelectUnitPageRoute());
  26. } else {
  27. appRouter.push(const SelectUnitPageRoute());
  28. }
  29. }
  30. @override
  31. Widget build(BuildContext context, WidgetRef ref) {
  32. final viewModel = ref.watch(selectUnitViewModelProvider.notifier);
  33. final state = ref.watch(selectUnitViewModelProvider);
  34. return Scaffold(
  35. appBar: MyAppBar.appBar(context, S.current.yy_home_accounts),
  36. backgroundColor: context.appColors.backgroundDefault,
  37. body: Container(
  38. padding: const EdgeInsets.symmetric(horizontal: 20),
  39. width: double.infinity,
  40. child: Column(
  41. mainAxisSize: MainAxisSize.max,
  42. crossAxisAlignment: CrossAxisAlignment.center,
  43. children: [
  44. SingleChildScrollView(
  45. scrollDirection: Axis.vertical,
  46. physics: const BouncingScrollPhysics(),
  47. child: Column(
  48. crossAxisAlignment: CrossAxisAlignment.center,
  49. children: [
  50. //顶部图片
  51. const MyAssetImage(
  52. Assets.authSignUpUnitImg,
  53. width: 266.5,
  54. height: 162,
  55. ).marginOnly(top: 28, bottom: 18),
  56. // Row(
  57. // mainAxisSize: MainAxisSize.min,
  58. // children: [
  59. // //街区
  60. // Column(
  61. // crossAxisAlignment: CrossAxisAlignment.start,
  62. // children: [
  63. // MyTextView(
  64. // S.current.block,
  65. // marginBottom: 9,
  66. // textColor: context.appColors.textBlack,
  67. // fontSize: 16,
  68. // isFontMedium: true,
  69. // ),
  70. //
  71. // // 表单 - 街区
  72. // _buildInputLayout(
  73. // context,
  74. // state,
  75. // "block",
  76. // textInputType: TextInputType.text,
  77. // textInputAction: TextInputAction.next,
  78. // onSubmit: (formKey, value) {
  79. // state.formData[formKey]!['focusNode'].unfocus();
  80. // FocusScope.of(context).requestFocus(state.formData['unit']!['focusNode']);
  81. // },
  82. // ).constrained(width: 88),
  83. // ],
  84. // ),
  85. //
  86. // MyTextView(
  87. // "#",
  88. // marginTop: 20,
  89. // marginLeft: 8.5,
  90. // marginRight: 8.5,
  91. // textColor: context.appColors.textBlack,
  92. // fontSize: 16,
  93. // isFontMedium: true,
  94. // ),
  95. //
  96. // //单元
  97. // Column(
  98. // crossAxisAlignment: CrossAxisAlignment.start,
  99. // children: [
  100. // MyTextView(
  101. // S.current.unit_number,
  102. // marginBottom: 9,
  103. // textColor: context.appColors.textBlack,
  104. // fontSize: 16,
  105. // isFontMedium: true,
  106. // ),
  107. // Row(
  108. // children: [
  109. // // 表单 - 单元
  110. // _buildInputLayout(
  111. // context,
  112. // state,
  113. // "unit",
  114. // textInputAction: TextInputAction.next,
  115. // onSubmit: (formKey, value) {
  116. // state.formData[formKey]!['focusNode'].unfocus();
  117. // FocusScope.of(context).requestFocus(state.formData['room']!['focusNode']);
  118. // },
  119. // ).constrained(width: 83),
  120. //
  121. // MyTextView(
  122. // "-",
  123. // textColor: context.appColors.textBlack,
  124. // marginLeft: 4,
  125. // marginRight: 4,
  126. // isFontMedium: true,
  127. // ),
  128. //
  129. // // 表单 - 房号
  130. // _buildInputLayout(
  131. // context,
  132. // state,
  133. // "room",
  134. // textInputAction: TextInputAction.done,
  135. // onSubmit: (formKey, value) {
  136. // state.formData[formKey]!['focusNode'].unfocus();
  137. // },
  138. // ).constrained(width: 83),
  139. // ],
  140. // ),
  141. // ],
  142. // ),
  143. // ],
  144. // ),
  145. //选择
  146. Column(
  147. crossAxisAlignment: CrossAxisAlignment.start,
  148. children: [
  149. MyTextView(
  150. S.current.unit_number,
  151. marginBottom: 9,
  152. marginLeft: 17,
  153. textColor: context.appColors.textBlack,
  154. fontSize: 16,
  155. isFontMedium: true,
  156. ),
  157. PickerContainer(
  158. hint: 'Please Select',
  159. enable: true,
  160. content: state.selectedUnitName ?? "",
  161. onClick: (context) {
  162. viewModel.pickUnit(context);
  163. },
  164. ).marginOnly(left: 17, right: 17),
  165. ],
  166. ),
  167. MyTextView(
  168. S.current.block_desc,
  169. fontSize: 15,
  170. marginTop: 25,
  171. textAlign: TextAlign.center,
  172. isFontMedium: true,
  173. textColor: context.appColors.textBlack,
  174. ),
  175. MyTextView(
  176. S.current.block_example,
  177. fontSize: 15,
  178. marginTop: 20,
  179. textAlign: TextAlign.center,
  180. isFontMedium: true,
  181. textColor: context.appColors.textBlack,
  182. ),
  183. MyTextView(
  184. S.current.block_example_desc,
  185. fontSize: 15,
  186. marginTop: 20,
  187. textAlign: TextAlign.center,
  188. isFontMedium: true,
  189. textColor: context.appColors.textBlack,
  190. ),
  191. ],
  192. )).expanded(),
  193. MyButton(
  194. onPressed: (){
  195. viewModel.submitUnit();
  196. },
  197. text: S.current.next,
  198. textColor: Colors.white,
  199. backgroundColor: context.appColors.btnBgDefault,
  200. fontWeight: FontWeight.w500,
  201. type: ClickType.throttle,
  202. fontSize: 16,
  203. minHeight: 50,
  204. radius: 5,
  205. ).marginOnly(top: 50, bottom: 50, left: 18, right: 18),
  206. ],
  207. ),
  208. ),
  209. );
  210. }
  211. // /// 输入框
  212. // Widget _buildInputLayout(
  213. // BuildContext context,
  214. // SelectUnitState state,
  215. // String key, {
  216. // double marginTop = 0,
  217. // bool? showRightIcon = false, //是否展示右侧的布局
  218. // Widget? rightWidget, //右侧的布局
  219. // TextInputType textInputType = TextInputType.number,
  220. // String? errorText,
  221. // bool obscureText = false,
  222. // TextInputAction textInputAction = TextInputAction.done,
  223. // Function? onSubmit,
  224. // }) {
  225. // return IgnoreKeyboardDismiss(
  226. // child: MyTextField(
  227. // key,
  228. // fillBackgroundColor: context.appColors.authFiledBG,
  229. // state.formData[key]!['value'],
  230. // hintText: state.formData[key]!['hintText'],
  231. // hintStyle: TextStyle(
  232. // color: context.appColors.authFiledHint,
  233. // fontSize: 16.0,
  234. // fontWeight: FontWeight.w500,
  235. // ),
  236. // controller: state.formData[key]!['controller'],
  237. // focusNode: state.formData[key]!['focusNode'],
  238. // margin: EdgeInsets.only(top: marginTop),
  239. // padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 3),
  240. // showDivider: false,
  241. // height: 44,
  242. // style: TextStyle(
  243. // color: context.appColors.authFiledText,
  244. // fontSize: 16.0,
  245. // fontWeight: FontWeight.w500,
  246. // ),
  247. // inputType: textInputType,
  248. // textInputAction: textInputAction,
  249. // onSubmit: onSubmit,
  250. // cursorColor: context.appColors.authFiledText,
  251. // obscureText: obscureText,
  252. // errorText: errorText,
  253. // showLeftIcon: true,
  254. // showRightIcon: showRightIcon,
  255. // rightWidget: rightWidget,
  256. // ),
  257. // );
  258. // }
  259. }