Skip to content

Commit 7790d9d

Browse files
fix: color dispare on second choose (#90)
* fix: color dispare on second choose [BUG] 二次点击选项真误时颜色消失 Fixes #87 Signed-off-by: OctagonalStar <76486554+OctagonalStar@users.noreply.github.com> * build: update deps Signed-off-by: OctagonalStar <76486554+OctagonalStar@users.noreply.github.com> * fix: add /await to windows MSVC Signed-off-by: OctagonalStar <76486554+OctagonalStar@users.noreply.github.com> * fix: fix the await issue Signed-off-by: OctagonalStar <76486554+OctagonalStar@users.noreply.github.com> * fix: windows build Signed-off-by: OctagonalStar <76486554+OctagonalStar@users.noreply.github.com> --------- Signed-off-by: OctagonalStar <76486554+OctagonalStar@users.noreply.github.com>
1 parent 166dee7 commit 7790d9d

9 files changed

Lines changed: 160 additions & 109 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- 补全控制器销毁逻辑,避免内存泄露
2323
- 修复了网页端中无法通过文件导入数据的问题
2424
- 修复了单词推送不截止的问题
25+
- 修复了二次点击选项时真误颜色消失的问题
2526

2627
## v1.0.0 - 2026-3-18 - (100000)
2728

android/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ gradle-wrapper.jar
77
GeneratedPluginRegistrant.java
88
.cxx/
99
build/
10+
.kotlin/
1011

1112
# Remember to never publicly share your keystore.
1213
# See https://flutter.dev/to/reference-keystore

android/gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
22
android.useAndroidX=true
33
android.enableJetifier=true
4+
# This builtInKotlin flag was added automatically by Flutter migrator
5+
android.builtInKotlin=false
6+
# This newDsl flag was added automatically by Flutter migrator
7+
android.newDsl=false

lib/funcs/ui.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ class ChooseButtonBox extends StatefulWidget {
429429
}
430430
class _ChooseButtonBoxState extends State<ChooseButtonBox> {
431431
Color? color;
432+
bool isChoosed = false;
433+
432434
@override
433435
Widget build(BuildContext context) {
434436
color ??= widget.cl ?? Theme.of(context).colorScheme.primaryContainer.withAlpha(150);
@@ -443,6 +445,8 @@ class _ChooseButtonBoxState extends State<ChooseButtonBox> {
443445
child: ElevatedButton(
444446
onPressed: () {
445447
setState(() {
448+
if(isChoosed) return;
449+
isChoosed = true;
446450
bool? ans = widget.chose(widget.index);
447451
if(ans != null) {
448452
if(widget.isAnimated) {
@@ -464,7 +468,7 @@ class _ChooseButtonBoxState extends State<ChooseButtonBox> {
464468
}
465469
}
466470
} else {
467-
color = Theme.of(context).colorScheme.onPrimary.withAlpha(150);
471+
color = Theme.of(context).colorScheme.primaryContainer.withAlpha(150);
468472
}
469473
});
470474
},

lib/pages/setting_page.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,14 @@ class _SettingPage extends State<SettingPage> {
215215
),
216216
onPressed: () async {
217217
context.read<Global>().uiLogger.info("选择手动导入单词");
218-
FilePickerResult? result =
219-
await FilePicker.pickFiles(
220-
allowMultiple: false,
218+
PlatformFile? result =
219+
await FilePicker.pickFile(
221220
type: FileType.custom,
222221
allowedExtensions: ['json'],
223222
);
224223
if (result != null) {
225224
String jsonString;
226-
PlatformFile platformFile = result.files.first;
225+
PlatformFile platformFile = result;
227226
try {
228227
jsonString = await platformFile.xFile
229228
.readAsString();

lib/sub_pages_builder/setting_pages/sync_page.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,15 @@ class _DataSyncPage extends State<DataSyncPage> {
240240
ElevatedButton(
241241
onPressed: () async {
242242
context.read<Global>().uiLogger.info("导入软件数据");
243-
FilePickerResult? result = await FilePicker.pickFiles(
244-
allowMultiple: false,
243+
PlatformFile? result = await FilePicker.pickFile(
245244
type: FileType.custom,
246245
allowedExtensions: ['json'],
247246
);
248247
if (result != null) {
249248
String jsonString;
250-
PlatformFile platformFile = result.files.first;
251-
if (platformFile.bytes != null){
252-
jsonString = utf8.decode(platformFile.bytes!);
249+
PlatformFile platformFile = result;
250+
if ((await platformFile.readAsBytes()).isNotEmpty){
251+
jsonString = utf8.decode(await platformFile.readAsBytes());
253252
} else if (platformFile.path != null && !kIsWeb) {
254253
jsonString = await io.File(platformFile.path!).readAsString();
255254
} else {

0 commit comments

Comments
 (0)