diff --git a/ci/version.code.txt b/ci/version.code.txt index ad90322..4ad3c62 100644 --- a/ci/version.code.txt +++ b/ci/version.code.txt @@ -1 +1 @@ -v1.7.5 \ No newline at end of file +v1.7.6 \ No newline at end of file diff --git a/ci/version.info.txt b/ci/version.info.txt index e0695bc..21be885 100644 --- a/ci/version.info.txt +++ b/ci/version.info.txt @@ -1,4 +1,2 @@ -v1.7.5 -- [x] ♻️ 评论回复的长按复制 -- [x] ♻️ 优化PAT入会 -- [x] ♻️ 优化了一个设置项 +v1.7.6 +- [x] ♻️ 优化发电 diff --git a/lib/basic/Method.dart b/lib/basic/Method.dart index 635d2f0..c5afe91 100644 --- a/lib/basic/Method.dart +++ b/lib/basic/Method.dart @@ -1029,4 +1029,12 @@ class Method { Future clearPat() { return _flatInvoke("clearPat", ""); } + + Future getProServerName() async { + return await _flatInvoke("getProServerName", ""); + } + + Future setProServerName(String serverName) { + return _flatInvoke("setProServerName", serverName); + } } diff --git a/lib/screens/ProScreen.dart b/lib/screens/ProScreen.dart index 1a46c70..3dff64c 100644 --- a/lib/screens/ProScreen.dart +++ b/lib/screens/ProScreen.dart @@ -118,6 +118,8 @@ class _ProScreenState extends State { }, ), const Divider(), + const ProServerNameWidget(), + const Divider(), ...patPro(), const Divider(), const Divider(), @@ -262,3 +264,59 @@ class _ProScreenState extends State { defaultToast(context, "Success"); } } + +class ProServerNameWidget extends StatefulWidget { + const ProServerNameWidget({Key? key}) : super(key: key); + + @override + State createState() => _ProServerNameWidgetState(); +} + +class _ProServerNameWidgetState extends State { + String _serverName = ""; + + @override + void initState() { + method.getProServerName().then((value) { + setState(() { + _serverName = value; + }); + }); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return ListTile( + title: const Text("发电方式"), + subtitle: Text(_loadServerName()), + onTap: () async { + final serverName = await chooseMapDialog( + context, + { + "风力发电": "HK", + "水力发电": "US", + }, + "选择发电方式", + ); + if (serverName != null && serverName.isNotEmpty) { + await method.setProServerName(serverName); + setState(() { + _serverName = serverName; + }); + } + }, + ); + } + + String _loadServerName() { + switch (_serverName) { + case "HK": + return "风力发电"; + case "US": + return "水力发电"; + default: + return ""; + } + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 87c1215..2bcad55 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.7.4+19 +version: 1.7.6+20 environment: sdk: ">=2.12.0 <3.0.0"