소스 검색

优化地图选择器定位异常显示

chengc 1 일 전
부모
커밋
f14884bdca
2개의 변경된 파일27개의 추가작업 그리고 15개의 파일을 삭제
  1. 13 14
      lib/features/overtime/overtime_apply_create_page.dart
  2. 14 1
      lib/shared/widgets/location_picker.dart

+ 13 - 14
lib/features/overtime/overtime_apply_create_page.dart

@@ -297,11 +297,11 @@ class _OvertimeApplyCreatePageState
                   : '',
               startTime: d.startTime != null
                   ? '${d.startTime!.year}-${d.startTime!.month.toString().padLeft(2, '0')}-${d.startTime!.day.toString().padLeft(2, '0')} '
-                      '${d.startTime!.hour.toString().padLeft(2, '0')}:${d.startTime!.minute.toString().padLeft(2, '0')}'
+                        '${d.startTime!.hour.toString().padLeft(2, '0')}:${d.startTime!.minute.toString().padLeft(2, '0')}'
                   : '',
               endTime: d.endTime != null
                   ? '${d.endTime!.year}-${d.endTime!.month.toString().padLeft(2, '0')}-${d.endTime!.day.toString().padLeft(2, '0')} '
-                      '${d.endTime!.hour.toString().padLeft(2, '0')}:${d.endTime!.minute.toString().padLeft(2, '0')}'
+                        '${d.endTime!.hour.toString().padLeft(2, '0')}:${d.endTime!.minute.toString().padLeft(2, '0')}'
                   : '',
               jbHours: d.jbHours,
               jbDays: d.jbDays,
@@ -346,9 +346,7 @@ class _OvertimeApplyCreatePageState
               dep: d.dep,
               depName: d.depName,
               jbType: d.jbType,
-              jbDate: d.jbDate.isNotEmpty
-                  ? DateTime.tryParse(d.jbDate)
-                  : null,
+              jbDate: d.jbDate.isNotEmpty ? DateTime.tryParse(d.jbDate) : null,
               startTime: d.startTime.isNotEmpty
                   ? DateTime.tryParse(d.startTime)
                   : null,
@@ -545,9 +543,7 @@ class _OvertimeApplyCreatePageState
                               '${l10n.get('jbDate')}: ${d.jbDate}',
                               colors,
                               trailing: _weekdayLabel(d.jbDate, l10n) != null
-                                  ? _weekdayTag(
-                                      _weekdayLabel(d.jbDate, l10n)!,
-                                    )
+                                  ? _weekdayTag(_weekdayLabel(d.jbDate, l10n)!)
                                   : null,
                             ),
                           ],
@@ -723,7 +719,11 @@ class _OvertimeApplyCreatePageState
     }
   }
 
-  Widget _detailLabel(String text, AppColorsExtension colors, {Widget? trailing}) {
+  Widget _detailLabel(
+    String text,
+    AppColorsExtension colors, {
+    Widget? trailing,
+  }) {
     return Padding(
       padding: const EdgeInsets.only(top: 2),
       child: Row(
@@ -739,10 +739,7 @@ class _OvertimeApplyCreatePageState
               ),
             ),
           ),
-          if (trailing != null) ...[
-            const SizedBox(width: 6),
-            trailing,
-          ],
+          if (trailing != null) ...[const SizedBox(width: 6), trailing],
         ],
       ),
     );
@@ -856,12 +853,14 @@ class _OvertimeApplyCreatePageState
         }
       },
       onRightTap: () async {
+        // 点提交先收键盘清焦点,避免输入框残留焦点导致键盘自动弹出
+        FocusManager.instance.primaryFocus?.unfocus();
+        FocusScope.of(context).unfocus();
         final err = _validate(l10n);
         if (err.isNotEmpty) {
           TDToast.showText(err.first, context: context);
           return;
         }
-        FocusScope.of(context).unfocus();
         LoadingDialog.show(context, text: l10n.get('submitting'));
         try {
           final data = _buildSubmitData();

+ 14 - 1
lib/shared/widgets/location_picker.dart

@@ -220,7 +220,20 @@ class _LocationPickerState extends State<LocationPicker> {
 
   void _showLocateError(BuildContext context) {
     final l10n = AppLocalizations.of(context);
-    TDToast.showFail(l10n.get('locateFailed'), context: context);
+    final colors = Theme.of(context).extension<AppColorsExtension>()!;
+    showDialog(
+      context: context,
+      useRootNavigator: true,
+      builder: (ctx) => TDAlertDialog(
+        content: l10n.get('locateFailed'),
+        buttonStyle: TDDialogButtonStyle.text,
+        rightBtn: TDDialogButtonOptions(
+          title: l10n.get('confirm'),
+          titleColor: colors.primary,
+          action: () => Navigator.pop(ctx),
+        ),
+      ),
+    );
   }
 
   void _confirm() {