Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
fix: 修复 Z60U 中文本生图中点击历史记录无法显示弹窗的问题;Z60U 在账单年度统计切换年时无法显示弹窗的问题;doc: 更新 …
Browse files Browse the repository at this point in the history
…readme 文件
  • Loading branch information
Sanotsu committed Jun 27, 2024
1 parent 0d9fecc commit 94a38e2
Show file tree
Hide file tree
Showing 12 changed files with 749 additions and 491 deletions.
464 changes: 129 additions & 335 deletions README.md

Large diffs are not rendered by default.

424 changes: 424 additions & 0 deletions _md_pics/development_records.md

Large diffs are not rendered by default.

Binary file added _md_pics/智能助手.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _md_pics/极简记账.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 68 additions & 59 deletions lib/common/components/tool_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,66 +81,75 @@ buildNetworkImageViewGrid(
mainAxisSpacing: 5.sp,
crossAxisSpacing: 5.sp,
physics: const NeverScrollableScrollPhysics(),
children: List.generate(urls.length, (index) {
return GridTile(
child: GestureDetector(
// 单击预览
onTap: () {
showDialog(
context: context,
builder: (BuildContext context) {
return Dialog(
backgroundColor: Colors.transparent, // 设置背景透明
child: PhotoView(
imageProvider: NetworkImage(urls[index]),
// 设置图片背景为透明
backgroundDecoration: const BoxDecoration(
color: Colors.transparent,
),
// 可以旋转
// enableRotation: true,
// 缩放的最大最小限制
minScale: PhotoViewComputedScale.contained * 0.8,
maxScale: PhotoViewComputedScale.covered * 2,
errorBuilder: (context, url, error) =>
const Icon(Icons.error),
children: buildImageList(style, urls, context),
);
}

// 2024-06-27 在小米6中此放在上面imageViewGrid没问题,但Z60U就报错;因为无法调试,错误原因不知
// 所以在文生图历史记录中点击某个记录时,不使用上面那个,而使用这个
buildImageList(String style, List<String> urls, BuildContext context) {
return List.generate(urls.length, (index) {
return GridTile(
child: GestureDetector(
// 单击预览
onTap: () {
showDialog(
context: context,
builder: (BuildContext context) {
return Dialog(
backgroundColor: Colors.transparent, // 设置背景透明
child: PhotoView(
imageProvider: NetworkImage(urls[index]),
// 设置图片背景为透明
backgroundDecoration: const BoxDecoration(
color: Colors.transparent,
),
);
},
);
},
// 长按保存到相册
onLongPress: () async {
if (Platform.isAndroid) {
final deviceInfoPlugin = DeviceInfoPlugin();
final deviceInfo = await deviceInfoPlugin.androidInfo;
final sdkInt = deviceInfo.version.sdkInt;

// Android9对应sdk是28,<=28就不显示保存按钮
if (sdkInt > 28) {
// 点击预览或者下载
var response = await Dio().get(urls[index],
options: Options(responseType: ResponseType.bytes));

print(response.data);

// 安卓9及以下好像无法保存
final result = await ImageGallerySaver.saveImage(
Uint8List.fromList(response.data),
quality: 100,
name: "${style}_${DateTime.now().millisecondsSinceEpoch}",
);
if (result["isSuccess"] == true) {
EasyLoading.showToast("图片已保存到相册!");
} else {
EasyLoading.showToast("无法保存图片!");
}
// 可以旋转
// enableRotation: true,
// 缩放的最大最小限制
minScale: PhotoViewComputedScale.contained * 0.8,
maxScale: PhotoViewComputedScale.covered * 2,
errorBuilder: (context, url, error) =>
const Icon(Icons.error),
),
);
},
);
},
// 长按保存到相册
onLongPress: () async {
if (Platform.isAndroid) {
final deviceInfoPlugin = DeviceInfoPlugin();
final deviceInfo = await deviceInfoPlugin.androidInfo;
final sdkInt = deviceInfo.version.sdkInt;

// Android9对应sdk是28,<=28就不显示保存按钮
if (sdkInt > 28) {
// 点击预览或者下载
var response = await Dio().get(urls[index],
options: Options(responseType: ResponseType.bytes));

print(response.data);

// 安卓9及以下好像无法保存
final result = await ImageGallerySaver.saveImage(
Uint8List.fromList(response.data),
quality: 100,
name: "${style}_${DateTime.now().millisecondsSinceEpoch}",
);
if (result["isSuccess"] == true) {
EasyLoading.showToast("图片已保存到相册!");
} else {
EasyLoading.showToast("Android 9 及以下版本无法长按保存到相册!");
EasyLoading.showToast("无法保存图片!");
}
} else {
EasyLoading.showToast("Android 9 及以下版本无法长按保存到相册!");
}
},
// 默认缓存展示
}
},
// 默认缓存展示
child: SizedBox(
height: 0.2.sw,
child: CachedNetworkImage(
imageUrl: urls[index],
fit: BoxFit.cover,
Expand All @@ -157,9 +166,9 @@ buildNetworkImageViewGrid(
errorWidget: (context, url, error) => const Icon(Icons.error),
),
),
);
}),
);
),
);
}).toList();
}

/// 构建图片预览,可点击放大
Expand Down
59 changes: 46 additions & 13 deletions lib/views/accounting/bill_report/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter_date_pickers/flutter_date_pickers.dart' as dp;
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:intl/intl.dart';
import 'package:month_picker_dialog/month_picker_dialog.dart';
Expand Down Expand Up @@ -383,22 +384,54 @@ class _BillReportIndexState extends State<BillReportIndex>
builder: (BuildContext context) {
return AlertDialog(
title: const Text("选择年份"),
// content: SizedBox(
// // 需要显示弹窗正文的大小(直接设宽度没什么用,但高度有效)
// height: 300.sp,
// child: YearPicker(
// firstDate: billPeriod.minDate,
// lastDate: billPeriod.maxDate,
// selectedDate:
// DateTime.tryParse("$selectedYear-01-01"),
// onChanged: (DateTime dateTime) {
// // 选中年份之后关闭弹窗,并开始查询年度数据
// Navigator.pop(context);
// setState(() {
// selectedYear = dateTime.year.toString();
// handleSelectedYearChange();
// });
// },
// ),
// ),
content: SizedBox(
// 需要显示弹窗正文的大小(直接设宽度没什么用,但高度有效)
height: 300.sp,
child: YearPicker(
firstDate: billPeriod.minDate,
lastDate: billPeriod.maxDate,
selectedDate:
DateTime.tryParse("$selectedYear-01-01"),
onChanged: (DateTime dateTime) {
// 选中年份之后关闭弹窗,并开始查询年度数据
Navigator.pop(context);
setState(() {
selectedYear = dateTime.year.toString();
handleSelectedYearChange();
});
},
child: Expanded(
child: dp.YearPicker.single(
selectedDate: DateTime.tryParse(
"$selectedYear-01-01") ??
DateTime.now(),
onChanged: (DateTime dateTime) {
// 选中年份之后关闭弹窗,并开始查询年度数据
Navigator.pop(context);
setState(() {
selectedYear = dateTime.year.toString();
handleSelectedYearChange();
});
},
firstDate: billPeriod.minDate,
lastDate: billPeriod.maxDate,
// datePickerStyles: dp.DatePickerStyles(
// selectedDateStyle: Theme.of(context)
// .textTheme
// .bodyLarge
// ?.copyWith(color: Colors.blue),
// selectedSingleDateDecoration:
// const BoxDecoration(
// color: Colors.red,
// shape: BoxShape.circle,
// ),
// ),
),
),
),
);
Expand Down
19 changes: 1 addition & 18 deletions lib/views/accounting/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import '../../common/components/tool_widget.dart';
import '../../common/constants.dart';
import '../../common/db_tools/db_helper.dart';
import '../../models/brief_accounting_state.dart';
import '../user_and_settings/backup_and_restore/index.dart';

import 'bill_item_modify/index.dart';
import 'bill_report/index.dart';

import 'mock_data/index.dart';
import 'widgets/bottom_sheet_option_picker.dart';

Expand Down Expand Up @@ -471,22 +470,6 @@ class _BillItemIndexState extends State<BillItemIndex> {
// onPressed: showBottomSheet,
// child: const Text('demo'),
// ),
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const BackupAndRestore(),
),
).then((value) {
handleSearch();
});
},
icon: Icon(
Icons.backup_outlined,
color: Theme.of(context).primaryColor,
),
),
IconButton(
onPressed: () {
Navigator.push(
Expand Down
84 changes: 47 additions & 37 deletions lib/views/agi_llm_sample/aliyun_text2image_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -437,44 +437,54 @@ class _AliyunText2ImageScreenState extends State<AliyunText2ImageScreen>
builder: (context) {
return AlertDialog(
title: Text("文本生成图片信息", style: TextStyle(fontSize: 18.sp)),
content: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
"正向提示词:",
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(
e.prompt,
style: TextStyle(fontSize: 12.sp),
),
const Text(
"反向提示词:",
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(
e.negativePrompt ?? "无",
style: TextStyle(fontSize: 12.sp),
),
Divider(height: 5.sp),

/// 点击按钮去浏览器下载查看
Row(
children: List.generate(
e.imageUrls?.length ?? 0,
(index) => ElevatedButton(
// 假设url一定存在的
onPressed: () => _launchUrl(e.imageUrls![index]),
child: Text('图片${index + 1}'),
content: SizedBox(
height: 300.sp,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
"正向提示词:",
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(
e.prompt,
style: TextStyle(fontSize: 12.sp),
),
const Text(
"反向提示词:",
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(
e.negativePrompt ?? "无",
style: TextStyle(fontSize: 12.sp),
),
Divider(height: 5.sp),

/// 点击按钮去浏览器下载查看
Wrap(
children: List.generate(
e.imageUrls?.length ?? 0,
(index) => ElevatedButton(
// 假设url一定存在的
onPressed: () => _launchUrl(e.imageUrls![index]),
child: Text('图片${index + 1}'),
),
).toList(),
),

/// 图片预览,点击可放大,长按保存到相册
/// 2024-06-27 ??? 为什么Z60U上不行??
if (e.imageUrls != null && e.imageUrls!.isNotEmpty)
Wrap(
children: buildImageList(
e.style,
e.imageUrls!,
context,
),
),
).toList(),
),

/// 图片预览,点击可放大,长按保存到相册
if (e.imageUrls != null && e.imageUrls!.isNotEmpty)
buildNetworkImageViewGrid(e.style, e.imageUrls!, context),
],
],
),
),
),
actions: [
Expand Down
4 changes: 2 additions & 2 deletions lib/views/agi_llm_sample/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ class _AgiLlmSampleState extends State<AgiLlmSample> {
),
),
),
Divider(height: 20.sp),
Divider(height: 50.sp),
// 入口按钮
SizedBox(
height: 0.25.sh,
height: 0.32.sh,
child: GridView.count(
primary: false,
padding: EdgeInsets.symmetric(horizontal: 20.sp),
Expand Down
7 changes: 5 additions & 2 deletions lib/views/user_and_settings/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,10 @@ class _UserAndSettingsState extends State<UserAndSettings> {

_buildBakAndRestoreAndMoreSettingRow() {
return Column(
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
SizedBox(
height: 100.sp,
child: NewCusSettingCard(
leadingIcon: Icons.backup_outlined,
title: "备份恢复",
Expand All @@ -222,7 +224,8 @@ class _UserAndSettingsState extends State<UserAndSettings> {
},
),
),
Expanded(
SizedBox(
height: 100.sp,
child: NewCusSettingCard(
leadingIcon: Icons.question_mark,
title: '常见问题(TBD)',
Expand Down
Loading

0 comments on commit 94a38e2

Please sign in to comment.