-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
116 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,4 @@ SPEC CHECKSUMS: | |
|
||
PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796 | ||
|
||
COCOAPODS: 1.12.1 | ||
COCOAPODS: 1.15.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'map_config.dart'; | ||
|
||
final collectOrderingSetting = MapConfig( | ||
valueName: { | ||
"-datetime_modifier": "收藏时间倒序", | ||
"datetime_modifier": "收藏时间正序", | ||
"-datetime_updated": "更新时间倒序", | ||
"datetime_updated": "更新时间正序", | ||
}, | ||
defaultValue: "-datetime_modifier", | ||
propertyKey: "collect_ordering", | ||
propertyName: "收藏排序", | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import 'package:event/event.dart'; | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:kobi/src/rust/api/api.dart'; | ||
|
||
import '../screens/components/commons.dart'; | ||
|
||
class MapConfig { | ||
late final Map<String, String> valueName; | ||
late final Map<String, String> nameValue; | ||
final String propertyName; | ||
final String propertyKey; | ||
late String value; | ||
late final Event changeEvent; | ||
final String defaultValue; | ||
|
||
MapConfig({ | ||
required Map<String, String> valueName, | ||
required this.defaultValue, | ||
required this.propertyKey, | ||
required this.propertyName, | ||
}) { | ||
this.valueName = valueName; | ||
this.nameValue = {}; | ||
valueName.forEach((key, value) { | ||
nameValue[value] = key; | ||
}); | ||
this.changeEvent = Event(); | ||
if (!valueName.containsKey(defaultValue)) { | ||
throw ArgumentError("defaultValue not in valueName"); | ||
} | ||
} | ||
|
||
Future initConfig() async { | ||
value = await loadProperty(k: propertyKey); | ||
if (!valueName.containsKey(value)) { | ||
value = defaultValue; | ||
await saveProperty(k: propertyKey, v: value); | ||
} | ||
} | ||
|
||
Widget configWidget(BuildContext context) { | ||
return StatefulBuilder( | ||
builder: (BuildContext context, void Function(void Function()) setState) { | ||
return ListTile( | ||
title: Text(propertyName), | ||
subtitle: Text(valueName[value] ?? ""), | ||
onTap: () async { | ||
String? result = await chooseMapDialog<String>( | ||
context, | ||
title: propertyName, | ||
values: nameValue, | ||
); | ||
if (result != null) { | ||
await saveProperty(k: propertyKey, v: result); | ||
value = result; | ||
setState(() {}); | ||
changeEvent.broadcast(); | ||
} | ||
}, | ||
); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters