|
@@ -32,212 +32,164 @@ class SelectUnitPage extends HookConsumerWidget {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // 为需要测量的控件创建 GlobalKey
|
|
|
|
- final GlobalKey _appbarKey = GlobalKey();
|
|
|
|
- final GlobalKey _topImageKey = GlobalKey();
|
|
|
|
- final GlobalKey _inputKey = GlobalKey();
|
|
|
|
- final GlobalKey _description1Key = GlobalKey();
|
|
|
|
- final GlobalKey _description2Key = GlobalKey();
|
|
|
|
- final GlobalKey _description3Key = GlobalKey();
|
|
|
|
- final GlobalKey _buttonKey = GlobalKey();
|
|
|
|
-
|
|
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final viewModel = ref.watch(selectUnitViewModelProvider.notifier);
|
|
final viewModel = ref.watch(selectUnitViewModelProvider.notifier);
|
|
final state = ref.watch(selectUnitViewModelProvider);
|
|
final state = ref.watch(selectUnitViewModelProvider);
|
|
|
|
|
|
- // 获取屏幕高度
|
|
|
|
- final screenHeight = MediaQuery.of(context).size.height;
|
|
|
|
- final statusBarHeight = MediaQuery.of(context).padding.top;
|
|
|
|
- final navigationBarHeight = MediaQuery.of(context).padding.bottom;
|
|
|
|
-
|
|
|
|
- useEffect(() {
|
|
|
|
- double usedHeight = 0;
|
|
|
|
- // 组件挂载时执行,获取控件高度
|
|
|
|
- WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
- // 获取各个控件的高度
|
|
|
|
- usedHeight += _appbarKey.currentContext?.size?.height ?? 0;
|
|
|
|
- usedHeight += _topImageKey.currentContext?.size?.height ?? 0;
|
|
|
|
- usedHeight += _inputKey.currentContext?.size?.height ?? 0;
|
|
|
|
- usedHeight += _description1Key.currentContext?.size?.height ?? 0;
|
|
|
|
- usedHeight += _description2Key.currentContext?.size?.height ?? 0;
|
|
|
|
- usedHeight += _description3Key.currentContext?.size?.height ?? 0;
|
|
|
|
- usedHeight += _buttonKey.currentContext?.size?.height ?? 0;
|
|
|
|
-
|
|
|
|
- // 计算剩余空间
|
|
|
|
- double remainingSpace = screenHeight - statusBarHeight - navigationBarHeight - usedHeight - 28 - 18 - 25 - 20 - 20;
|
|
|
|
-
|
|
|
|
- Log.d("计算剩余空间:$remainingSpace");
|
|
|
|
-
|
|
|
|
- if (remainingSpace > 0) {
|
|
|
|
- // 设置一个状态来存储剩余空间的高度
|
|
|
|
- viewModel.setRemainingSpace(remainingSpace);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- return () {
|
|
|
|
- // 组件卸载时执行
|
|
|
|
- };
|
|
|
|
- }, []);
|
|
|
|
-
|
|
|
|
return Scaffold(
|
|
return Scaffold(
|
|
- appBar: MyAppBar.appBar(context, S.current.yy_home_accounts, key: _appbarKey),
|
|
|
|
|
|
+ appBar: MyAppBar.appBar(context, S.current.yy_home_accounts),
|
|
backgroundColor: context.appColors.backgroundDefault,
|
|
backgroundColor: context.appColors.backgroundDefault,
|
|
- body: SingleChildScrollView(
|
|
|
|
- scrollDirection: Axis.vertical,
|
|
|
|
- physics: const BouncingScrollPhysics(),
|
|
|
|
- child: Container(
|
|
|
|
- padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
|
- width: double.infinity,
|
|
|
|
- child: Column(
|
|
|
|
- mainAxisSize: MainAxisSize.max,
|
|
|
|
- crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
- children: [
|
|
|
|
- //顶部图片
|
|
|
|
- MyAssetImage(
|
|
|
|
- key: _topImageKey,
|
|
|
|
- Assets.authSignUpUnitImg,
|
|
|
|
- width: 266.5,
|
|
|
|
- height: 162,
|
|
|
|
- ).marginOnly(top: 28, bottom: 18),
|
|
|
|
-
|
|
|
|
- Row(
|
|
|
|
- key: _inputKey,
|
|
|
|
- mainAxisSize: MainAxisSize.min,
|
|
|
|
- children: [
|
|
|
|
- //街区
|
|
|
|
- Column(
|
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
- children: [
|
|
|
|
- MyTextView(
|
|
|
|
- S.current.block,
|
|
|
|
- marginBottom: 9,
|
|
|
|
- textColor: context.appColors.textBlack,
|
|
|
|
- fontSize: 16,
|
|
|
|
- isFontMedium: true,
|
|
|
|
- ),
|
|
|
|
-
|
|
|
|
- // 表单 - 街区
|
|
|
|
- _buildInputLayout(
|
|
|
|
- context,
|
|
|
|
- state,
|
|
|
|
- "block",
|
|
|
|
- textInputAction: TextInputAction.next,
|
|
|
|
- onSubmit: (formKey, value) {
|
|
|
|
- state.formData[formKey]!['focusNode'].unfocus();
|
|
|
|
- FocusScope.of(context).requestFocus(state.formData['unit']!['focusNode']);
|
|
|
|
- },
|
|
|
|
- ).constrained(width: 88),
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
-
|
|
|
|
- MyTextView(
|
|
|
|
- "#",
|
|
|
|
- marginTop: 20,
|
|
|
|
- marginLeft: 8.5,
|
|
|
|
- marginRight: 8.5,
|
|
|
|
- textColor: context.appColors.textBlack,
|
|
|
|
- fontSize: 16,
|
|
|
|
- isFontMedium: true,
|
|
|
|
- ),
|
|
|
|
-
|
|
|
|
- //单元
|
|
|
|
- Column(
|
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
- children: [
|
|
|
|
- MyTextView(
|
|
|
|
- S.current.unit_number,
|
|
|
|
- marginBottom: 9,
|
|
|
|
- textColor: context.appColors.textBlack,
|
|
|
|
- fontSize: 16,
|
|
|
|
- isFontMedium: true,
|
|
|
|
- ),
|
|
|
|
- Row(
|
|
|
|
- children: [
|
|
|
|
- // 表单 - 单元
|
|
|
|
- _buildInputLayout(
|
|
|
|
- context,
|
|
|
|
- state,
|
|
|
|
- "unit",
|
|
|
|
- textInputAction: TextInputAction.next,
|
|
|
|
- onSubmit: (formKey, value) {
|
|
|
|
- state.formData[formKey]!['focusNode'].unfocus();
|
|
|
|
- FocusScope.of(context).requestFocus(state.formData['room']!['focusNode']);
|
|
|
|
- },
|
|
|
|
- ).constrained(width: 83),
|
|
|
|
-
|
|
|
|
- MyTextView(
|
|
|
|
- "-",
|
|
|
|
- textColor: context.appColors.textBlack,
|
|
|
|
- marginLeft: 4,
|
|
|
|
- marginRight: 4,
|
|
|
|
- isFontMedium: true,
|
|
|
|
- ),
|
|
|
|
-
|
|
|
|
- // 表单 - 房号
|
|
|
|
- _buildInputLayout(
|
|
|
|
- context,
|
|
|
|
- state,
|
|
|
|
- "room",
|
|
|
|
- textInputAction: TextInputAction.done,
|
|
|
|
- onSubmit: (formKey, value) {
|
|
|
|
- state.formData[formKey]!['focusNode'].unfocus();
|
|
|
|
- },
|
|
|
|
- ).constrained(width: 83),
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
-
|
|
|
|
- MyTextView(
|
|
|
|
- key: _description1Key,
|
|
|
|
- S.current.block_desc,
|
|
|
|
- fontSize: 15,
|
|
|
|
- marginTop: 25,
|
|
|
|
- textAlign: TextAlign.center,
|
|
|
|
- isFontMedium: true,
|
|
|
|
- textColor: context.appColors.textBlack,
|
|
|
|
- ),
|
|
|
|
-
|
|
|
|
- MyTextView(
|
|
|
|
- key: _description2Key,
|
|
|
|
- S.current.block_example,
|
|
|
|
- fontSize: 15,
|
|
|
|
- marginTop: 20,
|
|
|
|
- textAlign: TextAlign.center,
|
|
|
|
- isFontMedium: true,
|
|
|
|
- textColor: context.appColors.textBlack,
|
|
|
|
- ),
|
|
|
|
-
|
|
|
|
- MyTextView(
|
|
|
|
- key: _description3Key,
|
|
|
|
- S.current.block_example_desc,
|
|
|
|
- fontSize: 15,
|
|
|
|
- marginTop: 20,
|
|
|
|
- textAlign: TextAlign.center,
|
|
|
|
- isFontMedium: true,
|
|
|
|
- textColor: context.appColors.textBlack,
|
|
|
|
- ),
|
|
|
|
-
|
|
|
|
- SizedBox(
|
|
|
|
- height: state.remainingSpace, // 使用剩余空间的值
|
|
|
|
- ),
|
|
|
|
-
|
|
|
|
- MyButton(
|
|
|
|
- key: _buttonKey,
|
|
|
|
- onPressed: viewModel.submitUnit,
|
|
|
|
- text: S.current.next,
|
|
|
|
- textColor: Colors.white,
|
|
|
|
- backgroundColor: context.appColors.btnBgDefault,
|
|
|
|
- fontWeight: FontWeight.w500,
|
|
|
|
- type: ClickType.throttle,
|
|
|
|
- fontSize: 16,
|
|
|
|
- minHeight: 50,
|
|
|
|
- radius: 5,
|
|
|
|
- ).marginOnly(top: 40, bottom: 30, left: 18, right: 18),
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
|
|
+ body: Container(
|
|
|
|
+ padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
|
+ width: double.infinity,
|
|
|
|
+ child: Column(
|
|
|
|
+ mainAxisSize: MainAxisSize.max,
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
+ children: [
|
|
|
|
+ SingleChildScrollView(
|
|
|
|
+ scrollDirection: Axis.vertical,
|
|
|
|
+ physics: const BouncingScrollPhysics(),
|
|
|
|
+ child: Column(
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
+ children: [
|
|
|
|
+ //顶部图片
|
|
|
|
+ const MyAssetImage(
|
|
|
|
+ Assets.authSignUpUnitImg,
|
|
|
|
+ width: 266.5,
|
|
|
|
+ height: 162,
|
|
|
|
+ ).marginOnly(top: 28, bottom: 18),
|
|
|
|
+
|
|
|
|
+ Row(
|
|
|
|
+ mainAxisSize: MainAxisSize.min,
|
|
|
|
+ children: [
|
|
|
|
+ //街区
|
|
|
|
+ Column(
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
+ children: [
|
|
|
|
+ MyTextView(
|
|
|
|
+ S.current.block,
|
|
|
|
+ marginBottom: 9,
|
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
|
+ fontSize: 16,
|
|
|
|
+ isFontMedium: true,
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ // 表单 - 街区
|
|
|
|
+ _buildInputLayout(
|
|
|
|
+ context,
|
|
|
|
+ state,
|
|
|
|
+ "block",
|
|
|
|
+ textInputAction: TextInputAction.next,
|
|
|
|
+ onSubmit: (formKey, value) {
|
|
|
|
+ state.formData[formKey]!['focusNode'].unfocus();
|
|
|
|
+ FocusScope.of(context).requestFocus(state.formData['unit']!['focusNode']);
|
|
|
|
+ },
|
|
|
|
+ ).constrained(width: 88),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ MyTextView(
|
|
|
|
+ "#",
|
|
|
|
+ marginTop: 20,
|
|
|
|
+ marginLeft: 8.5,
|
|
|
|
+ marginRight: 8.5,
|
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
|
+ fontSize: 16,
|
|
|
|
+ isFontMedium: true,
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ //单元
|
|
|
|
+ Column(
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
+ children: [
|
|
|
|
+ MyTextView(
|
|
|
|
+ S.current.unit_number,
|
|
|
|
+ marginBottom: 9,
|
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
|
+ fontSize: 16,
|
|
|
|
+ isFontMedium: true,
|
|
|
|
+ ),
|
|
|
|
+ Row(
|
|
|
|
+ children: [
|
|
|
|
+ // 表单 - 单元
|
|
|
|
+ _buildInputLayout(
|
|
|
|
+ context,
|
|
|
|
+ state,
|
|
|
|
+ "unit",
|
|
|
|
+ textInputAction: TextInputAction.next,
|
|
|
|
+ onSubmit: (formKey, value) {
|
|
|
|
+ state.formData[formKey]!['focusNode'].unfocus();
|
|
|
|
+ FocusScope.of(context).requestFocus(state.formData['room']!['focusNode']);
|
|
|
|
+ },
|
|
|
|
+ ).constrained(width: 83),
|
|
|
|
+
|
|
|
|
+ MyTextView(
|
|
|
|
+ "-",
|
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
|
+ marginLeft: 4,
|
|
|
|
+ marginRight: 4,
|
|
|
|
+ isFontMedium: true,
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ // 表单 - 房号
|
|
|
|
+ _buildInputLayout(
|
|
|
|
+ context,
|
|
|
|
+ state,
|
|
|
|
+ "room",
|
|
|
|
+ textInputAction: TextInputAction.done,
|
|
|
|
+ onSubmit: (formKey, value) {
|
|
|
|
+ state.formData[formKey]!['focusNode'].unfocus();
|
|
|
|
+ },
|
|
|
|
+ ).constrained(width: 83),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ MyTextView(
|
|
|
|
+ S.current.block_desc,
|
|
|
|
+ fontSize: 15,
|
|
|
|
+ marginTop: 25,
|
|
|
|
+ textAlign: TextAlign.center,
|
|
|
|
+ isFontMedium: true,
|
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ MyTextView(
|
|
|
|
+ S.current.block_example,
|
|
|
|
+ fontSize: 15,
|
|
|
|
+ marginTop: 20,
|
|
|
|
+ textAlign: TextAlign.center,
|
|
|
|
+ isFontMedium: true,
|
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ MyTextView(
|
|
|
|
+ S.current.block_example_desc,
|
|
|
|
+ fontSize: 15,
|
|
|
|
+ marginTop: 20,
|
|
|
|
+ textAlign: TextAlign.center,
|
|
|
|
+ isFontMedium: true,
|
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ )).expanded(),
|
|
|
|
+
|
|
|
|
+ MyButton(
|
|
|
|
+ onPressed: viewModel.submitUnit,
|
|
|
|
+ text: S.current.next,
|
|
|
|
+ textColor: Colors.white,
|
|
|
|
+ backgroundColor: context.appColors.btnBgDefault,
|
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
|
+ type: ClickType.throttle,
|
|
|
|
+ fontSize: 16,
|
|
|
|
+ minHeight: 50,
|
|
|
|
+ radius: 5,
|
|
|
|
+ ).marginOnly(top: 50, bottom: 50, left: 18, right: 18),
|
|
|
|
+ ],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
);
|