Browse Source

修改扫一扫入口icon、修改扫一扫页面UI,收获扦样单乡镇村改为编辑框;

maqiang 10 months ago
parent
commit
7174a8a37a

+ 22 - 0
android/app/src/main/res/layout/toast_custom.xml

@@ -0,0 +1,22 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:tools="http://schemas.android.com/tools"
4
+    android:layout_width="wrap_content"
5
+    android:layout_height="wrap_content"
6
+    android:layout_gravity="center_horizontal"
7
+    android:layout_marginStart="50dp"
8
+    android:layout_marginEnd="50dp">
9
+
10
+    <TextView
11
+        android:id="@+id/text"
12
+        android:layout_width="wrap_content"
13
+        android:layout_height="wrap_content"
14
+        android:background="#CC000000"
15
+        android:paddingStart="16dp"
16
+        android:paddingTop="10dp"
17
+        android:paddingEnd="16dp"
18
+        android:paddingBottom="10dp"
19
+        android:textStyle="bold"
20
+        android:textColor="#FFFFFF"
21
+        tools:text="Toast should be short." />
22
+</FrameLayout>

BIN
assets/images/home_scan.webp


BIN
assets/images/scan_back.webp


BIN
assets/images/scan_flash.webp


BIN
assets/images/scan_scanning.webp


+ 9 - 0
lib/config/pics.dart

@@ -23,6 +23,8 @@ const String imgHomeListBg = 'assets/images/home_list_bg.webp';
23 23
 const String imgHomeListPzjc = 'assets/images/home_list_pzjc.webp';
24 24
 // 首页列表整仓检验
25 25
 const String imgHomeListZcjy = 'assets/images/home_list_zcjy.webp';
26
+// 首页扫一扫
27
+const String imgHomeScan = 'assets/images/home_scan.webp';
26 28
 
27 29
 // 用户中心账户
28 30
 const String imgUserCenterAccount = 'assets/images/user_center_account.webp';
@@ -33,3 +35,10 @@ const String imgUserCenterSetting = 'assets/images/user_center_setting.webp';
33 35
 const String imgItemArrowRight = 'assets/images/item_arrow_right.webp';
34 36
 // 列表项下箭头
35 37
 const String imgItemArrowDown = 'assets/images/item_arrow_down.webp';
38
+
39
+// 扫一扫 返回
40
+const String imgScanBack = 'assets/images/scan_back.webp';
41
+// 扫一扫 闪光灯
42
+const String imgScanFlash= 'assets/images/scan_flash.webp';
43
+// 扫一扫 扫描中
44
+const String imgScanScanning= 'assets/images/scan_scanning.webp';

+ 1 - 1
lib/page/filter/filter_page.dart

@@ -140,7 +140,7 @@ class _FilterPageState extends BaseState<FilterPage> {
140 140
             ),
141 141
             CardWidgets.buildMenu(
142 142
               false,
143
-              '样品级',
143
+              '样品级',
144 144
               ypdjList,
145 145
               ypdj,
146 146
               (_, sel) {},

+ 1 - 1
lib/page/home/home_page.dart

@@ -74,7 +74,7 @@ class _HomePageState extends BaseState<HomePage> with AutomaticKeepAliveClientMi
74 74
       child: Container(
75 75
         padding: const EdgeInsets.symmetric(horizontal: 16),
76 76
         alignment: Alignment.center,
77
-        child: const Text('扫一扫', style: TextStyle(fontSize: 14, color: Colors.white)),
77
+        child: Image.asset(imgHomeScan, height: 24,width: 24),
78 78
       ),
79 79
     );
80 80
   }

+ 90 - 16
lib/page/qrcode_scan/qrcode_scan_page.dart

@@ -1,6 +1,9 @@
1 1
 import 'dart:io';
2 2
 
3
+import 'package:flutter/cupertino.dart';
3 4
 import 'package:flutter/material.dart';
5
+import 'package:flutter/services.dart';
6
+import 'package:flutter/widgets.dart';
4 7
 import 'package:lszlgl/page/sample_task/reap_sample_detail/reap_sample_task_page.dart';
5 8
 import 'package:qr_code_scanner/qr_code_scanner.dart';
6 9
 
@@ -14,10 +17,12 @@ class QrCodeScanPage extends StatefulWidget {
14 17
   State<QrCodeScanPage> createState() => _QrCodeScanPageState();
15 18
 }
16 19
 
17
-class _QrCodeScanPageState extends BaseLifecycleState<QrCodeScanPage> {
20
+class _QrCodeScanPageState extends BaseLifecycleState<QrCodeScanPage> with SingleTickerProviderStateMixin {
18 21
   final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
19 22
   Barcode? result;
20 23
   QRViewController? controller;
24
+  late AnimationController _ctrl;
25
+  late Animation<Offset> animation;
21 26
 
22 27
   void _onQRViewCreated(QRViewController controller) {
23 28
     this.controller = controller;
@@ -90,28 +95,89 @@ class _QrCodeScanPageState extends BaseLifecycleState<QrCodeScanPage> {
90 95
   @override
91 96
   void dispose() {
92 97
     controller?.dispose();
98
+    _ctrl.dispose();
93 99
     super.dispose();
94 100
   }
95 101
 
96 102
   @override
103
+  void initState() {
104
+    super.initState();
105
+    // 创建动画控制器
106
+    _ctrl = AnimationController(
107
+      vsync: this,
108
+      duration: const Duration(seconds: 2),
109
+    );
110
+    animation = Tween<Offset>(
111
+      begin: const Offset(0, -0.25),
112
+      end: const Offset(0, 0.25),
113
+    ).animate(_ctrl);
114
+    _ctrl.repeat();
115
+  }
116
+
117
+  @override
97 118
   Widget build(BuildContext context) {
98 119
     return myScaffold(child: buildBody());
99 120
   }
100 121
 
101 122
   Widget buildBody() {
102
-    return Column(
103
-      children: [
104
-        myAppBar(
105
-          title: '扫一扫',
106
-          actions: [buildFlash()],
107
-        ),
108
-        Expanded(
109
-          child: QRView(
110
-            key: qrKey,
111
-            onQRViewCreated: _onQRViewCreated,
123
+    return AnnotatedRegion<SystemUiOverlayStyle>(
124
+      value: SystemUiOverlayStyle.light,
125
+      child: Stack(
126
+        fit: StackFit.expand,
127
+        children: [
128
+          // myAppBar(
129
+          //   title: '扫一扫',
130
+          //   actions: [buildFlash()],
131
+          // ),
132
+          Positioned.fill(
133
+            child: QRView(
134
+              key: qrKey,
135
+              onQRViewCreated: _onQRViewCreated,
136
+            ),
112 137
           ),
113
-        ),
114
-      ],
138
+          Positioned(
139
+            top: 0,
140
+            left: 0,
141
+            right: 0,
142
+            child: buildAppBar(),
143
+          ),
144
+          SlideTransition(
145
+            position: animation,
146
+            child: Image.asset(imgScanScanning, width: double.infinity),
147
+          ),
148
+        ],
149
+      ),
150
+    );
151
+  }
152
+
153
+  Widget buildAppBar() {
154
+    return Padding(
155
+      padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
156
+      child: Stack(
157
+        alignment: Alignment.center,
158
+        children: [
159
+          Positioned(left: 0, child: buildBack()),
160
+          const Text(
161
+            '扫一扫',
162
+            textAlign: TextAlign.center,
163
+            style: TextStyle(color: Colors.white, fontSize: 20),
164
+          ),
165
+          Positioned(
166
+            right: 0,
167
+            child: buildFlash(),
168
+          ),
169
+        ],
170
+      ),
171
+    );
172
+  }
173
+
174
+  Widget buildBack() {
175
+    return GestureDetector(
176
+      onTap: () => MyNavigator.pop(),
177
+      child: Padding(
178
+        padding: const EdgeInsets.symmetric(horizontal: 16),
179
+        child: Image.asset(imgScanBack, width: 24, height: 24),
180
+      ),
115 181
     );
116 182
   }
117 183
 
@@ -119,10 +185,18 @@ class _QrCodeScanPageState extends BaseLifecycleState<QrCodeScanPage> {
119 185
     return GestureDetector(
120 186
       onTap: () => controller?.toggleFlash(),
121 187
       behavior: HitTestBehavior.opaque,
122
-      child: Container(
188
+      child: Padding(
123 189
         padding: const EdgeInsets.symmetric(horizontal: 16),
124
-        alignment: Alignment.center,
125
-        child: const Text('闪光灯', style: TextStyle(fontSize: 14, color: Colors.white)),
190
+        child: Row(
191
+          children: [
192
+            Image.asset(imgScanFlash, width: 24, height: 24),
193
+            const Text(
194
+              '闪光灯',
195
+              textAlign: TextAlign.center,
196
+              style: TextStyle(color: Colors.white, fontSize: 14),
197
+            ),
198
+          ],
199
+        ),
126 200
       ),
127 201
     );
128 202
   }

+ 57 - 44
lib/page/sample_task/reap_sample_detail/reap_sample_basic_detail_page.dart

@@ -34,8 +34,7 @@ class ReapSampleBasicDetailPage extends StatefulWidget {
34 34
   State<ReapSampleBasicDetailPage> createState() => _ReapSampleBasicDetailPageState();
35 35
 }
36 36
 
37
-class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasicDetailPage>
38
-    with AutomaticKeepAliveClientMixin {
37
+class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasicDetailPage> with AutomaticKeepAliveClientMixin {
39 38
   SampleTaskItem? data;
40 39
   late bool isDetail;
41 40
 
@@ -46,8 +45,8 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
46 45
   final sheng = null.notifier<CardMenuData?>();
47 46
   final shi = null.notifier<CardMenuData?>();
48 47
   final qu = null.notifier<CardMenuData?>();
49
-  final xian = null.notifier<CardMenuData?>();
50
-  final cun = null.notifier<CardMenuData?>();
48
+  final TextEditingController xian = TextEditingController();
49
+  final TextEditingController cun = TextEditingController();
51 50
 
52 51
   final trxxList = <CardMenuData>[].notifier<List<CardMenuData>>();
53 52
   final trxx = null.notifier<CardMenuData?>();
@@ -99,38 +98,38 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
99 98
     MyNavigator.dismissLoading();
100 99
   }
101 100
 
102
-  /// 选中行政区划
103
-  void onSelectXzqh(ValueNotifier<CardMenuData?> selNotifier, CardMenuData selData) {
104
-    num level = 100;
105
-    if (selNotifier == xian) {
106
-      level = 4;
107
-      data?.xiangXzqh = selData.value;
108
-      data?.cunXzqh = null;
109
-      cun.value = null;
110
-      cunList.value = [];
111
-    } else if (selNotifier == cun) {
112
-      level = 5;
113
-      data?.cunXzqh = selData.value;
114
-    }
115
-    if (level < 5) {
116
-      // 获取下一个等级的菜单数据
117
-      getDistrictList(level + 1, id: selData.value ?? 0);
118
-    }
119
-  }
120
-
121
-  /// 获取编辑数据
122
-  void getEditData() async {
123
-    MyNavigator.showLoading();
124
-    // 县
125
-    if (data?.quXzqh != null) {
126
-      await getDistrictList(4, id: data?.quXzqh, showLoading: false);
127
-    }
128
-    // 村
129
-    if (data?.xiangXzqh != null) {
130
-      await getDistrictList(5, id: data?.xiangXzqh, showLoading: false);
131
-    }
132
-    MyNavigator.dismissLoading();
133
-  }
101
+  // /// 选中行政区划
102
+  // void onSelectXzqh(ValueNotifier<CardMenuData?> selNotifier, CardMenuData selData) {
103
+  //   num level = 100;
104
+  //   if (selNotifier == xian) {
105
+  //     level = 4;
106
+  //     data?.xiangXzqh = selData.value;
107
+  //     data?.cunXzqh = null;
108
+  //     cun.value = null;
109
+  //     cunList.value = [];
110
+  //   } else if (selNotifier == cun) {
111
+  //     level = 5;
112
+  //     data?.cunXzqh = selData.value;
113
+  //   }
114
+  //   if (level < 5) {
115
+  //     // 获取下一个等级的菜单数据
116
+  //     getDistrictList(level + 1, id: selData.value ?? 0);
117
+  //   }
118
+  // }
119
+
120
+  // /// 获取编辑数据
121
+  // void getEditData() async {
122
+  //   MyNavigator.showLoading();
123
+  //   // 县
124
+  //   if (data?.quXzqh != null) {
125
+  //     await getDistrictList(4, id: data?.quXzqh, showLoading: false);
126
+  //   }
127
+  //   // 村
128
+  //   if (data?.xiangXzqh != null) {
129
+  //     await getDistrictList(5, id: data?.xiangXzqh, showLoading: false);
130
+  //   }
131
+  //   MyNavigator.dismissLoading();
132
+  // }
134 133
 
135 134
   void getPersonData() async {
136 135
     try {
@@ -191,9 +190,9 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
191 190
       shi.value = null;
192 191
       qu.value = null;
193 192
       data?.xiangXzqhName = null;
194
-      xian.value = null;
193
+      xian.text = '';
195 194
       data?.cunXzqhName = null;
196
-      cun.value = null;
195
+      cun.text = '';
197 196
 
198 197
       MyNavigator.showLoading();
199 198
       bool stepSuccess = false;
@@ -242,8 +241,8 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
242 241
               // 乡、村
243 242
               data?.xiangXzqhName = street;
244 243
               data?.cunXzqhName = streetNumber;
245
-              xian.value = CardMenuData(street, null);
246
-              cun.value = CardMenuData(streetNumber, null);
244
+              xian.text = street;
245
+              cun.text = streetNumber;
247 246
             }
248 247
           }
249 248
         }
@@ -402,8 +401,8 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
402 401
     if (data?.sheng != null) sheng.value = CardMenuData(data?.sheng, data?.shengXzqh);
403 402
     if (data?.shi != null) shi.value = CardMenuData(data?.shi, data?.shiXzqh);
404 403
     if (data?.qu != null) qu.value = CardMenuData(data?.qu, data?.quXzqh);
405
-    if (data?.xian != null) xian.value = CardMenuData(data?.xian, data?.xiangXzqh);
406
-    if (data?.cun != null) cun.value = CardMenuData(data?.cun, data?.cunXzqh);
404
+    if (data?.xiangXzqhName != null) xian.text = data!.xiangXzqhName!;
405
+    if (data?.cunXzqhName != null) cun.text = data!.cunXzqhName!;
407 406
     qyddjwd.value = data?.qyddjwd;
408 407
     if ((data?.dgryName ?? '0') == '0') {
409 408
       data?.dgryName = UserService.get().getUser()?.nickname;
@@ -447,8 +446,22 @@ class _ReapSampleBasicDetailPageState extends BaseLifecycleState<ReapSampleBasic
447 446
         sheng.builder((v) => CardItemWidget('省份', rightText: v?.name, bottomLine: true)),
448 447
         shi.builder((v) => CardItemWidget('市/州', rightText: v?.name, bottomLine: true)),
449 448
         qu.builder((v) => CardItemWidget('区县', rightText: v?.name, bottomLine: true)),
450
-        xian.builder((v) => CardItemWidget('乡镇', rightText: v?.name, bottomLine: true)),
451
-        cun.builder((v) => CardItemWidget('村', rightText: v?.name, bottomLine: true)),
449
+        // xian.builder((v) => CardItemWidget('乡镇', rightText: v?.name, bottomLine: true)),
450
+        // cun.builder((v) => CardItemWidget('村', rightText: v?.name, bottomLine: true)),
451
+        CardWidgets.buildEdit(
452
+          isDetail,
453
+          ctrl: xian,
454
+          '乡镇',
455
+          data?.xiangXzqhName?.toString(),
456
+          onChanged: (value) => data?.xiangXzqhName = value.isEmpty ? null : value,
457
+        ),
458
+        CardWidgets.buildEdit(
459
+          isDetail,
460
+          ctrl: cun,
461
+          '村',
462
+          data?.cunXzqhName?.toString(),
463
+          onChanged: (value) => data?.cunXzqhName = value.isEmpty ? null : value,
464
+        ),
452 465
         qyddjwd.builder(
453 466
           (v) => CardItemWidget(
454 467
             '扦样地点经纬度',

+ 11 - 15
lib/page/sample_task/reap_sample_detail/reap_sample_task_page.dart

@@ -147,6 +147,10 @@ class _ReapSampleTaskPageState extends BaseLifecycleState<ReapSampleTaskPage> wi
147 147
 
148 148
   /// 查看二维码
149 149
   void showQRCode() {
150
+    if (pageStatus.value.data?.ewmfilePictureList?.isEmpty ?? true) {
151
+      MyNavigator.showToast('没有二维码');
152
+      return;
153
+    }
150 154
     UrlItem picInfo = pageStatus.value.data!.ewmfilePictureList!.first;
151 155
     MyNavigator.showDialog(
152 156
       builder: (_) => Container(
@@ -351,15 +355,12 @@ class _ReapSampleTaskPageState extends BaseLifecycleState<ReapSampleTaskPage> wi
351 355
   }
352 356
 
353 357
   Widget buildButton() {
354
-    Widget child;
358
+    if (args.detail) return const SizedBox.shrink();
355 359
     EdgeInsets margin = EdgeInsets.only(left: 4, right: 4, top: 12, bottom: getBottomPadding(12));
356
-    Widget ewmWidget = (pageStatus.value.data?.ewmfilePictureList ?? []).isEmpty
357
-        ? const SizedBox.shrink()
358
-        : Expanded(child: MyButton('查看二维码', onTap: showQRCode, margin: margin));
359
-    if (args.detail) {
360
-      child = Row(children: [ewmWidget]);
361
-    } else {
362
-      child = tabIndex.builder((v) {
360
+    return Container(
361
+      color: const Color(0xFFF1F7F6),
362
+      padding: const EdgeInsets.symmetric(horizontal: 8),
363
+      child: tabIndex.builder((v) {
363 364
         // 第一页
364 365
         if (v == 0) return MyButton('下一步', onTap: next, margin: margin);
365 366
         // 最后一页
@@ -367,7 +368,7 @@ class _ReapSampleTaskPageState extends BaseLifecycleState<ReapSampleTaskPage> wi
367 368
           return Row(
368 369
             children: [
369 370
               Expanded(child: MyButton('上一步', onTap: previous, margin: margin)),
370
-              ewmWidget,
371
+              Expanded(child: MyButton('查看二维码', onTap: showQRCode, margin: margin)),
371 372
               Expanded(child: MyButton('提交', onTap: submit, margin: margin)),
372 373
             ],
373 374
           );
@@ -378,12 +379,7 @@ class _ReapSampleTaskPageState extends BaseLifecycleState<ReapSampleTaskPage> wi
378 379
             Expanded(child: MyButton('下一步', onTap: next, margin: margin)),
379 380
           ],
380 381
         );
381
-      });
382
-    }
383
-    return Container(
384
-      color: const Color(0xFFF1F7F6),
385
-      padding: const EdgeInsets.symmetric(horizontal: 8),
386
-      child: child,
382
+      }),
387 383
     );
388 384
   }
389 385
 }

+ 1 - 1
lib/page/sample_task/reap_sample_detail/reap_sample_variety_detail_page.dart

@@ -181,7 +181,7 @@ class _ReapSampleVarietyDetailPageState extends BaseLifecycleState<ReapSampleVar
181 181
     return Column(
182 182
       children: [
183 183
         CardItemWidget('采样品种', rightText: data?.cypzName, bottomLine: true),
184
-        CardItemWidget('样品级', rightText: DictService.getLabel(DictType.ypdj, value: data?.ypdj), bottomLine: true),
184
+        CardItemWidget('样品级', rightText: DictService.getLabel(DictType.ypdj, value: data?.ypdj), bottomLine: true),
185 185
         CardWidgets.buildMenu(
186 186
           isDetail,
187 187
           '粮食品类',

+ 1 - 1
lib/router/my_navigator.dart

@@ -355,7 +355,7 @@ class MyNavigator {
355 355
         msg,
356 356
         controller: controller,
357 357
         displayTime: displayTime,
358
-        alignment: alignment,
358
+        alignment: alignment ?? Alignment.center,
359 359
         clickMaskDismiss: clickMaskDismiss,
360 360
         animationType: null,
361 361
         nonAnimationTypes: null,

+ 1 - 1
lib/widget/card_item.dart

@@ -308,7 +308,7 @@ class CardWidgets {
308 308
       title,
309 309
       rightChild: TextFormField(
310 310
         controller: ctrl,
311
-        initialValue: value,
311
+        initialValue: ctrl == null ? value : null,
312 312
         keyboardType: inputType,
313 313
         textAlign: TextAlign.right,
314 314
         decoration: InputDecoration(