|
@@ -1,9 +1,22 @@
|
|
|
-
|
|
|
+import 'package:cs_resources/generated/l10n.dart';
|
|
|
+import 'package:cs_resources/theme/app_colors_theme.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:auto_route/auto_route.dart';
|
|
|
+import 'package:flutter_hooks/flutter_hooks.dart';
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
+import 'package:plugin_platform/engine/toast/toast_engine.dart';
|
|
|
import 'package:router/ext/auto_router_extensions.dart';
|
|
|
+import 'package:widgets/ext/ex_widget.dart';
|
|
|
+import 'package:widgets/my_appbar.dart';
|
|
|
+import 'package:widgets/my_button.dart';
|
|
|
+import 'package:widgets/my_text_field.dart';
|
|
|
+import 'package:widgets/my_text_view.dart';
|
|
|
+import 'package:widgets/shatter/form_require_text.dart';
|
|
|
+import 'package:widgets/shatter/picker_container.dart';
|
|
|
+import 'package:widgets/widget_export.dart';
|
|
|
import '../../router/page/form_page_router.dart';
|
|
|
+import 'vm/apply_view_model.dart';
|
|
|
+
|
|
|
@RoutePage()
|
|
|
class GuestVehiclePage extends HookConsumerWidget {
|
|
|
const GuestVehiclePage({Key? key}) : super(key: key);
|
|
@@ -19,11 +32,237 @@ class GuestVehiclePage extends HookConsumerWidget {
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
+ final viewModel = ref.watch(applyViewModelProvider.notifier);
|
|
|
+ final state = ref.watch(applyViewModelProvider);
|
|
|
+
|
|
|
+ // 使用 useState 来持久化 TextEditingController 和 FocusNode
|
|
|
+ final TextEditingController vehicleNumController = useTextEditingController();
|
|
|
+ final TextEditingController vehicleInfoController = useTextEditingController();
|
|
|
+ final TextEditingController guestNameController = useTextEditingController();
|
|
|
+ final TextEditingController guestPhoneController = useTextEditingController();
|
|
|
+ final FocusNode vehicleNumFocusNode = useFocusNode();
|
|
|
+ final FocusNode vehicleInfoFocusNode = useFocusNode();
|
|
|
+ final FocusNode guestNameFocusNode = useFocusNode();
|
|
|
+ final FocusNode guestPhoneFocusNode = useFocusNode();
|
|
|
+
|
|
|
+ useEffect(() {
|
|
|
+ //赋值State的值
|
|
|
+ Future.microtask(() {});
|
|
|
+
|
|
|
+ return () {
|
|
|
+ // 释放控制器资源
|
|
|
+ vehicleNumController.dispose();
|
|
|
+ vehicleInfoController.dispose();
|
|
|
+ guestNameController.dispose();
|
|
|
+ guestPhoneController.dispose();
|
|
|
+ vehicleNumFocusNode.dispose();
|
|
|
+ vehicleInfoFocusNode.dispose();
|
|
|
+ guestNameFocusNode.dispose();
|
|
|
+ guestPhoneFocusNode.dispose();
|
|
|
+ };
|
|
|
+ }, []);
|
|
|
+
|
|
|
+ return WillPopScope(
|
|
|
+ child: Scaffold(
|
|
|
+ appBar: MyAppBar.appBar(context, state.applyDetail?['title']),
|
|
|
+ backgroundColor: context.appColors.whiteBG,
|
|
|
+ body: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ SingleChildScrollView(
|
|
|
+ scrollDirection: Axis.vertical,
|
|
|
+ physics: const BouncingScrollPhysics(),
|
|
|
+ child: Container(
|
|
|
+ width: double.infinity,
|
|
|
+ child: Column(
|
|
|
+ mainAxisSize: MainAxisSize.max,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ //下拉选 - 访问时间
|
|
|
+ MyTextView(
|
|
|
+ S.current.date_of_entry,
|
|
|
+ fontSize: 17,
|
|
|
+ marginTop: 30,
|
|
|
+ marginLeft: 15,
|
|
|
+ marginBottom: 16,
|
|
|
+ isFontMedium: true,
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
+ ),
|
|
|
+
|
|
|
+ PickerContainer(
|
|
|
+ hint: S.current.choose_date,
|
|
|
+ onClick: () {
|
|
|
+ viewModel.pickDate(null, (date) {
|
|
|
+ ToastEngine.show("选择的日期:$date");
|
|
|
+ });
|
|
|
+ },
|
|
|
+ ).marginOnly(left: 15, right: 15),
|
|
|
+
|
|
|
+ //输入框 - 车牌号
|
|
|
+ FormRequireText(
|
|
|
+ text: S.current.vehicle_number,
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
+ fontSize: 17,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ ).marginOnly(top: 14, bottom: 16, left: 15, right: 15),
|
|
|
+
|
|
|
+ // 表单
|
|
|
+ _buildInputLayout(
|
|
|
+ context,
|
|
|
+ "vehicle_num",
|
|
|
+ textInputType: TextInputType.text,
|
|
|
+ textInputAction: TextInputAction.next,
|
|
|
+ controller: vehicleNumController,
|
|
|
+ focusNode: vehicleNumFocusNode,
|
|
|
+ onSubmit: (formKey, value) {
|
|
|
+ vehicleNumFocusNode.unfocus();
|
|
|
+ FocusScope.of(context).requestFocus(vehicleInfoFocusNode);
|
|
|
+ },
|
|
|
+ ),
|
|
|
+
|
|
|
+ //输入框 - 车辆信息
|
|
|
+ FormRequireText(
|
|
|
+ text: S.current.vehicle_make_model_colour,
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
+ fontSize: 17,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ ).marginOnly(top: 14, bottom: 16, left: 15, right: 15),
|
|
|
+
|
|
|
+ // 表单
|
|
|
+ _buildInputLayout(
|
|
|
+ context,
|
|
|
+ "vehicle_info",
|
|
|
+ textInputType: TextInputType.text,
|
|
|
+ textInputAction: TextInputAction.next,
|
|
|
+ controller: vehicleInfoController,
|
|
|
+ focusNode: vehicleInfoFocusNode,
|
|
|
+ onSubmit: (formKey, value) {
|
|
|
+ vehicleInfoFocusNode.unfocus();
|
|
|
+ FocusScope.of(context).requestFocus(guestNameFocusNode);
|
|
|
+ },
|
|
|
+ ),
|
|
|
+
|
|
|
+ //输入框 - 访客姓名
|
|
|
+ FormRequireText(
|
|
|
+ text: S.current.guest_name,
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
+ fontSize: 17,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ ).marginOnly(top: 14, bottom: 16, left: 15, right: 15),
|
|
|
+
|
|
|
+ // 表单
|
|
|
+ _buildInputLayout(
|
|
|
+ context,
|
|
|
+ "guest_name",
|
|
|
+ textInputType: TextInputType.text,
|
|
|
+ textInputAction: TextInputAction.next,
|
|
|
+ controller: guestNameController,
|
|
|
+ focusNode: guestNameFocusNode,
|
|
|
+ onSubmit: (formKey, value) {
|
|
|
+ guestNameFocusNode.unfocus();
|
|
|
+ FocusScope.of(context).requestFocus(guestPhoneFocusNode);
|
|
|
+ },
|
|
|
+ ),
|
|
|
+
|
|
|
+ //输入框 - 访客电话
|
|
|
+ FormRequireText(
|
|
|
+ text: S.current.guest_mobile_number,
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
+ fontSize: 17,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ ).marginOnly(top: 14, bottom: 16, left: 15, right: 15),
|
|
|
+
|
|
|
+ // 表单
|
|
|
+ _buildInputLayout(
|
|
|
+ context,
|
|
|
+ "guest_phone",
|
|
|
+ textInputType: TextInputType.phone,
|
|
|
+ textInputAction: TextInputAction.done,
|
|
|
+ controller: guestPhoneController,
|
|
|
+ focusNode: guestPhoneFocusNode,
|
|
|
+ onSubmit: (formKey, value) {
|
|
|
+ guestPhoneFocusNode.unfocus();
|
|
|
+ },
|
|
|
+ ),
|
|
|
+
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ).expanded(),
|
|
|
+
|
|
|
+ //底部按钮
|
|
|
+ MyButton(
|
|
|
+ onPressed: () {
|
|
|
+ vehicleNumFocusNode.unfocus();
|
|
|
+ vehicleInfoFocusNode.unfocus();
|
|
|
+ guestNameFocusNode.unfocus();
|
|
|
+ guestPhoneFocusNode.unfocus();
|
|
|
+
|
|
|
+ viewModel.gotoNextPage();
|
|
|
+ },
|
|
|
+ text: S.current.next,
|
|
|
+ textColor: Colors.white,
|
|
|
+ backgroundColor: context.appColors.btnBgDefault,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ type: ClickType.throttle,
|
|
|
+ fontSize: 16,
|
|
|
+ minHeight: 50,
|
|
|
+ radius: 0,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ )),
|
|
|
+ onWillPop: () async {
|
|
|
+ viewModel.handlePopAction();
|
|
|
+ return true;
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- return Scaffold(
|
|
|
- appBar: AppBar(title: Text("GuestVehiclePage")),
|
|
|
- body: Center(
|
|
|
- child: Text("GuestVehiclePage"),
|
|
|
+ Widget _buildInputLayout(
|
|
|
+ BuildContext context,
|
|
|
+ String key, {
|
|
|
+ double marginTop = 0,
|
|
|
+ bool? showRightIcon = false, //是否展示右侧的布局
|
|
|
+ Widget? rightWidget, //右侧的布局
|
|
|
+ TextInputType textInputType = TextInputType.text,
|
|
|
+ String? errorText,
|
|
|
+ bool obscureText = false,
|
|
|
+ required TextEditingController controller,
|
|
|
+ required FocusNode focusNode,
|
|
|
+ bool enable = true,
|
|
|
+ TextInputAction textInputAction = TextInputAction.done,
|
|
|
+ Function? onSubmit,
|
|
|
+ }) {
|
|
|
+ return IgnoreKeyboardDismiss(
|
|
|
+ child: MyTextField(
|
|
|
+ key,
|
|
|
+ fillBackgroundColor: context.appColors.authFiledBG,
|
|
|
+ "",
|
|
|
+ hintStyle: TextStyle(
|
|
|
+ color: context.appColors.authFiledHint,
|
|
|
+ fontSize: 16.0,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ ),
|
|
|
+ controller: controller,
|
|
|
+ focusNode: focusNode,
|
|
|
+ margin: EdgeInsets.only(top: marginTop, left: 15, right: 15),
|
|
|
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 3),
|
|
|
+ showDivider: false,
|
|
|
+ height: 44,
|
|
|
+ enabled: enable,
|
|
|
+ style: TextStyle(
|
|
|
+ color: context.appColors.authFiledText,
|
|
|
+ fontSize: 16.0,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ ),
|
|
|
+ inputType: textInputType,
|
|
|
+ textInputAction: textInputAction,
|
|
|
+ onSubmit: onSubmit,
|
|
|
+ cursorColor: context.appColors.authFiledText,
|
|
|
+ obscureText: obscureText,
|
|
|
+ errorText: errorText,
|
|
|
+ showLeftIcon: true,
|
|
|
+ showRightIcon: showRightIcon,
|
|
|
+ rightWidget: rightWidget,
|
|
|
),
|
|
|
);
|
|
|
}
|