select_estate_page.dart 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. import 'package:cpt_auth/modules/select_estate/select_estate_state.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:flutter/material.dart';
  6. import 'package:auto_route/auto_route.dart';
  7. import 'package:hooks_riverpod/hooks_riverpod.dart';
  8. import 'package:router/ext/auto_router_extensions.dart';
  9. import 'package:widgets/ext/ex_widget.dart';
  10. import 'package:widgets/my_appbar.dart';
  11. import 'package:widgets/my_button.dart';
  12. import 'package:widgets/my_load_image.dart';
  13. import 'package:widgets/my_text_field.dart';
  14. import 'package:widgets/my_text_view.dart';
  15. import 'package:widgets/widget_export.dart';
  16. import '../../router/page/auth_page_router.dart';
  17. import 'select_estate_view_model.dart';
  18. @RoutePage()
  19. class SelectEstatePage extends HookConsumerWidget {
  20. SelectEstatePage({Key? key}) : super(key: key);
  21. //启动当前页面
  22. static void startInstance({BuildContext? context}) {
  23. if (context != null) {
  24. context.router.push(SelectEstatePageRoute());
  25. } else {
  26. appRouter.push(SelectEstatePageRoute());
  27. }
  28. }
  29. @override
  30. Widget build(BuildContext context, WidgetRef ref) {
  31. final viewModel = ref.watch(selectEstateViewModelProvider.notifier);
  32. final state = ref.watch(selectEstateViewModelProvider);
  33. return Scaffold(
  34. appBar: MyAppBar.appBar(context, S.current.yy_home_accounts),
  35. backgroundColor: context.appColors.backgroundDefault,
  36. body: Container(
  37. padding: const EdgeInsets.symmetric(horizontal: 38),
  38. width: double.infinity,
  39. child: Column(
  40. mainAxisSize: MainAxisSize.max,
  41. crossAxisAlignment: CrossAxisAlignment.center,
  42. children: [
  43. SingleChildScrollView(
  44. scrollDirection: Axis.vertical,
  45. physics: const BouncingScrollPhysics(),
  46. child: Column(
  47. crossAxisAlignment: CrossAxisAlignment.center,
  48. children: [
  49. //顶部图片
  50. const MyAssetImage(
  51. Assets.authChooseEstateBuilding,
  52. width: 267,
  53. height: 158,
  54. ).marginOnly(top: 28, bottom: 38),
  55. MyTextView(
  56. S.current.estate_or_building_name,
  57. fontSize: 23,
  58. marginBottom: 20,
  59. textAlign: TextAlign.center,
  60. isFontMedium: true,
  61. textColor: context.appColors.textBlack,
  62. ),
  63. //输入资产的名称
  64. _buildInputLayout(
  65. context,
  66. state,
  67. "estate",
  68. textInputAction: TextInputAction.done,
  69. onSubmit: (formKey, value) {
  70. state.formData[formKey]!['focusNode'].unfocus();
  71. },
  72. ),
  73. MyTextView(
  74. S.current.estate_name_desc,
  75. fontSize: 15,
  76. marginTop: 19,
  77. isFontMedium: true,
  78. textColor: context.appColors.textBlack,
  79. ),
  80. ],
  81. )).expanded(),
  82. MyButton(
  83. onPressed: viewModel.submitEstate,
  84. text: S.current.next,
  85. textColor: Colors.white,
  86. backgroundColor: context.appColors.btnBgDefault,
  87. fontWeight: FontWeight.w500,
  88. type: ClickType.throttle,
  89. fontSize: 16,
  90. minHeight: 50,
  91. radius: 5,
  92. ).marginOnly(top: 50, bottom: 50),
  93. ],
  94. ),
  95. ),
  96. );
  97. }
  98. /// 输入框
  99. Widget _buildInputLayout(
  100. BuildContext context,
  101. SelectEstateState state,
  102. String formKey, {
  103. Key? key,
  104. double marginTop = 0,
  105. bool? showRightIcon = false, //是否展示右侧的布局
  106. Widget? rightWidget, //右侧的布局
  107. TextInputType textInputType = TextInputType.text,
  108. String? errorText,
  109. bool obscureText = false,
  110. TextInputAction textInputAction = TextInputAction.done,
  111. Function? onSubmit,
  112. }) {
  113. return IgnoreKeyboardDismiss(
  114. child: MyTextField(
  115. formKey,
  116. key: key,
  117. fillBackgroundColor: context.appColors.authFiledBG,
  118. state.formData[formKey]!['value'],
  119. hintText: state.formData[formKey]!['hintText'],
  120. hintStyle: TextStyle(
  121. color: context.appColors.authFiledHint,
  122. fontSize: 16.0,
  123. fontWeight: FontWeight.w500,
  124. ),
  125. controller: state.formData[formKey]!['controller'],
  126. focusNode: state.formData[formKey]!['focusNode'],
  127. margin: EdgeInsets.only(top: marginTop),
  128. padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 3),
  129. showDivider: false,
  130. height: 44,
  131. style: TextStyle(
  132. color: context.appColors.authFiledText,
  133. fontSize: 16.0,
  134. fontWeight: FontWeight.w500,
  135. ),
  136. inputType: textInputType,
  137. textInputAction: textInputAction,
  138. onSubmit: onSubmit,
  139. cursorColor: context.appColors.authFiledText,
  140. obscureText: obscureText,
  141. errorText: errorText,
  142. showLeftIcon: true,
  143. showRightIcon: showRightIcon,
  144. rightWidget: rightWidget,
  145. ),
  146. );
  147. }
  148. }