|
@@ -2,7 +2,6 @@ import 'dart:io';
|
2
|
2
|
import 'dart:typed_data';
|
3
|
3
|
|
4
|
4
|
import 'package:cached_network_image/cached_network_image.dart';
|
5
|
|
-import 'package:dio/dio.dart';
|
6
|
5
|
import 'package:flutter/material.dart';
|
7
|
6
|
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
|
8
|
7
|
import 'package:image_gallery_saver/image_gallery_saver.dart';
|
|
@@ -144,6 +143,8 @@ class _ReapSampleTaskPageState extends BaseLifecycleState<ReapSampleTaskPage> wi
|
144
|
143
|
];
|
145
|
144
|
}
|
146
|
145
|
|
|
146
|
+ GlobalKey ewmKey = GlobalKey();
|
|
147
|
+
|
147
|
148
|
/// 查看二维码
|
148
|
149
|
void startQRCode() {
|
149
|
150
|
UrlItem picInfo = pageStatus.value.data!.ewmfilePictureList!.first;
|
|
@@ -158,25 +159,35 @@ class _ReapSampleTaskPageState extends BaseLifecycleState<ReapSampleTaskPage> wi
|
158
|
159
|
child: Column(
|
159
|
160
|
mainAxisSize: MainAxisSize.min,
|
160
|
161
|
children: [
|
161
|
|
- CachedNetworkImage(
|
162
|
|
- width: double.infinity,
|
163
|
|
- fit: BoxFit.cover,
|
164
|
|
- imageUrl: picInfo.url!,
|
165
|
|
- placeholder: (_, __) => const Center(child: CircularProgressIndicator()),
|
166
|
|
- errorWidget: (context, url, error) => const Center(child: Icon(Icons.error)),
|
167
|
|
- ),
|
168
|
|
- Padding(
|
169
|
|
- padding: const EdgeInsets.symmetric(vertical: 16),
|
170
|
|
- child: Text(
|
171
|
|
- picInfo.name ?? '',
|
172
|
|
- style: const TextStyle(fontSize: 16, color: MyColor.c_333333),
|
|
162
|
+ RepaintBoundary(
|
|
163
|
+ key: ewmKey,
|
|
164
|
+ child: Container(
|
|
165
|
+ color: Colors.white,
|
|
166
|
+ child: Column(
|
|
167
|
+ children: [
|
|
168
|
+ CachedNetworkImage(
|
|
169
|
+ width: double.infinity,
|
|
170
|
+ fit: BoxFit.cover,
|
|
171
|
+ imageUrl: picInfo.url!,
|
|
172
|
+ placeholder: (_, __) => const Center(child: CircularProgressIndicator()),
|
|
173
|
+ errorWidget: (context, url, error) => const Center(child: Icon(Icons.error)),
|
|
174
|
+ ),
|
|
175
|
+ Padding(
|
|
176
|
+ padding: const EdgeInsets.symmetric(vertical: 16),
|
|
177
|
+ child: Text(
|
|
178
|
+ picInfo.name ?? '',
|
|
179
|
+ style: const TextStyle(fontSize: 18, color: MyColor.c_333333),
|
|
180
|
+ ),
|
|
181
|
+ ),
|
|
182
|
+ ],
|
|
183
|
+ ),
|
173
|
184
|
),
|
174
|
185
|
),
|
175
|
186
|
Row(
|
176
|
187
|
children: [
|
177
|
188
|
const Expanded(child: MyButton('打印')),
|
178
|
189
|
const SizedBox(width: 16),
|
179
|
|
- Expanded(child: MyButton('保存图片', onTap: savePic)),
|
|
190
|
+ Expanded(child: MyButton('保存图片', onTap: () => savePic(picInfo.name))),
|
180
|
191
|
],
|
181
|
192
|
),
|
182
|
193
|
],
|
|
@@ -185,12 +196,15 @@ class _ReapSampleTaskPageState extends BaseLifecycleState<ReapSampleTaskPage> wi
|
185
|
196
|
);
|
186
|
197
|
}
|
187
|
198
|
|
188
|
|
- void savePic() async {
|
|
199
|
+ void savePic(String? name) async {
|
189
|
200
|
MyNavigator.showLoading(msg: '保存中...');
|
190
|
|
- var response = await Dio().get(
|
191
|
|
- 'https://gd-hbimg.huaban.com/c7a22fb15d70a0a976e20fb810c048ec11c76fc31ac08-hajElf_fw658webp',
|
192
|
|
- options: Options(responseType: ResponseType.bytes));
|
193
|
|
- final result = await ImageGallerySaver.saveImage(Uint8List.fromList(response.data), quality: 60, name: "hello");
|
|
201
|
+ Uint8List? bytes = await FileUtils.getBitmapFromContext(ewmKey.currentContext);
|
|
202
|
+ if (bytes == null) {
|
|
203
|
+ MyNavigator.dismiss();
|
|
204
|
+ MyNavigator.showToast('保存失败');
|
|
205
|
+ return;
|
|
206
|
+ }
|
|
207
|
+ final result = await ImageGallerySaver.saveImage(bytes, quality: 60, name: name);
|
194
|
208
|
MyNavigator.dismiss();
|
195
|
209
|
if (result['isSuccess']) {
|
196
|
210
|
MyNavigator.showToast('保存成功');
|
|
@@ -338,13 +352,14 @@ class _ReapSampleTaskPageState extends BaseLifecycleState<ReapSampleTaskPage> wi
|
338
|
352
|
|
339
|
353
|
Widget buildButton() {
|
340
|
354
|
Widget child;
|
341
|
|
- EdgeInsets margin = EdgeInsets.only(left: 16, right: 16, top: 12, bottom: getBottomPadding(12));
|
|
355
|
+ EdgeInsets margin = EdgeInsets.only(left: 8, right: 8, top: 12, bottom: getBottomPadding(12));
|
|
356
|
+ Widget ewmWidget = (pageStatus.value.data?.ewmfilePictureList ?? []).isEmpty
|
|
357
|
+ ? const SizedBox.shrink()
|
|
358
|
+ : Expanded(child: MyButton('查看二维码', onTap: startQRCode, margin: margin));
|
342
|
359
|
if (args.detail) {
|
343
|
360
|
child = Row(
|
344
|
361
|
children: [
|
345
|
|
- (pageStatus.value.data?.ewmfilePictureList ?? []).isEmpty
|
346
|
|
- ? const SizedBox.shrink()
|
347
|
|
- : Expanded(child: MyButton('查看二维码', onTap: startQRCode, margin: margin)),
|
|
362
|
+ ewmWidget,
|
348
|
363
|
Expanded(child: MyButton('重新录入', onTap: startEdit, margin: margin)),
|
349
|
364
|
],
|
350
|
365
|
);
|
|
@@ -357,7 +372,7 @@ class _ReapSampleTaskPageState extends BaseLifecycleState<ReapSampleTaskPage> wi
|
357
|
372
|
return Row(
|
358
|
373
|
children: [
|
359
|
374
|
Expanded(child: MyButton('上一步', onTap: previous, margin: margin)),
|
360
|
|
- const SizedBox(width: 32),
|
|
375
|
+ ewmWidget,
|
361
|
376
|
Expanded(child: MyButton('提交', onTap: submit, margin: margin)),
|
362
|
377
|
],
|
363
|
378
|
);
|
|
@@ -365,7 +380,6 @@ class _ReapSampleTaskPageState extends BaseLifecycleState<ReapSampleTaskPage> wi
|
365
|
380
|
return Row(
|
366
|
381
|
children: [
|
367
|
382
|
Expanded(child: MyButton('上一步', onTap: previous, margin: margin)),
|
368
|
|
- const SizedBox(width: 32),
|
369
|
383
|
Expanded(child: MyButton('下一步', onTap: next, margin: margin)),
|
370
|
384
|
],
|
371
|
385
|
);
|
|
@@ -373,6 +387,7 @@ class _ReapSampleTaskPageState extends BaseLifecycleState<ReapSampleTaskPage> wi
|
373
|
387
|
}
|
374
|
388
|
return Container(
|
375
|
389
|
color: const Color(0xFFF1F7F6),
|
|
390
|
+ padding: const EdgeInsets.symmetric(horizontal: 8),
|
376
|
391
|
child: child,
|
377
|
392
|
);
|
378
|
393
|
}
|