From b32ace22fbc5312153297d4b73538e11b66a4efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8F=98=E8=8F=98?= Date: Mon, 13 Sep 2021 21:28:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=84=AA=E5=8C=96=EF=BC=9A=E6=AA=A2=E6=B8=AC?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=A0=81=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Utility/Theme.dart | 4 +- lib/Utility/Updater.dart | 16 +++- lib/main.dart | 79 ++++++++++++------- pubspec.lock | 28 +++---- .../flutter/generated_plugin_registrant.cc | 6 +- 5 files changed, 80 insertions(+), 53 deletions(-) diff --git a/lib/Utility/Theme.dart b/lib/Utility/Theme.dart index 538ab7a8..07287640 100644 --- a/lib/Utility/Theme.dart +++ b/lib/Utility/Theme.dart @@ -18,8 +18,8 @@ class ThemeUtility { } } - static ThemeData getTheme() { - return Theme.of(_BuildContext); + static ThemeData getTheme([BuildContext? context]) { + return Theme.of(context ?? _BuildContext); } static void UpdateTheme(BuildContext context) { diff --git a/lib/Utility/Updater.dart b/lib/Utility/Updater.dart index 44d722b5..835e5b17 100644 --- a/lib/Utility/Updater.dart +++ b/lib/Utility/Updater.dart @@ -152,7 +152,8 @@ class Updater { } Future unzip() async { - Archive archive = ZipDecoder().decodeBytes(await updateFile.readAsBytes()); + Archive archive = + ZipDecoder().decodeBytes(await updateFile.readAsBytes()); for (ArchiveFile file in archive) { if (file.isFile) { @@ -182,8 +183,14 @@ class Updater { setState = _setState; return AlertDialog( title: Text("下載檔案中..."), - content: LinearProgressIndicator( - value: progress, + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + LinearProgressIndicator( + value: progress, + ), + Text("${(progress * 100).toStringAsFixed(2)}%"), + ], ), ); }); @@ -221,7 +228,8 @@ class VersionInfo { Updater.versionCodeCompareTo(_versionCode, int.parse(version_code)); if (mainVersionCheck || (mainVersionCheck && versionCodeCheck)) { String _changelog = VersionList[_version][_versionCode]['changelog']; - changelogs.add("\\- " + _changelog); + changelogs.add( + "\\- [$_changelog](https://github.com/RPMTW/RPMLauncher/compare/$_version.${int.parse(_versionCode) - 1}...$_version.$_versionCode)"); } }); }); diff --git a/lib/main.dart b/lib/main.dart index b0bda7b9..f9a997d7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -14,6 +14,7 @@ import 'package:io/io.dart'; import 'package:path/path.dart'; import 'package:rpmlauncher/Widget/OkClose.dart'; import 'package:split_view/split_view.dart'; +import 'package:url_launcher/url_launcher.dart'; import 'Launcher/GameRepository.dart'; import 'Launcher/InstanceRepository.dart'; @@ -173,37 +174,55 @@ class _HomePageState extends State { content: Column( mainAxisSize: MainAxisSize.min, children: [ - Text( - "偵測到您的 RPMLauncher 版本過舊,您是否需要更新,我們建議您更新以獲得更佳體驗\n", - style: TextStyle(fontSize: 18), - ), - Text( - "最新版本: ${info.version}.${info.versionCode}", - style: _title, - ), - Text( - "目前版本: ${LauncherInfo.getVersion()}.${LauncherInfo.getVersionCode()}", - style: _title, - ), - Text( - "變更日誌: ", - style: _title, - ), - Container( - width: MediaQuery.of(context).size.width / 2, - height: - MediaQuery.of(context).size.height / 3, - child: Markdown( - selectable: true, - styleSheet: MarkdownStyleSheet( - textAlign: WrapAlignment.center, - textScaleFactor: 1.5, - h1Align: WrapAlignment.center, - unorderedListAlign: WrapAlignment.center, + SelectableText.rich( + TextSpan( + children: [ + TextSpan( + text: + "偵測到您的 RPMLauncher 版本過舊,您是否需要更新,我們建議您更新以獲得更佳體驗\n", + style: TextStyle(fontSize: 18), + ), + TextSpan( + text: + "最新版本: ${info.version}.${info.versionCode}\n", + style: _title, + ), + TextSpan( + text: + "目前版本: ${LauncherInfo.getVersion()}.${LauncherInfo.getVersionCode()}\n", + style: _title, + ), + TextSpan( + text: "變更日誌: \n", + style: _title, + ), + ], ), - data: info.changelog.toString(), - ), - ) + textAlign: TextAlign.center, + toolbarOptions: ToolbarOptions( + copy: true, + selectAll: true, + cut: true)), + Container( + width: + MediaQuery.of(context).size.width / 2, + height: + MediaQuery.of(context).size.height / 3, + child: Markdown( + selectable: true, + styleSheet: MarkdownStyleSheet( + textAlign: WrapAlignment.center, + textScaleFactor: 1.5, + h1Align: WrapAlignment.center, + unorderedListAlign: + WrapAlignment.center), + data: info.changelog.toString(), + onTapLink: (text, url, title) { + if (url != null) { + launch(url); + } + }, + )) ], ), actions: [ diff --git a/pubspec.lock b/pubspec.lock index 9f54e1ae..eb7655ed 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -77,7 +77,7 @@ packages: name: cross_file url: "https://pub.dartlang.org" source: hosted - version: "0.3.1+4" + version: "0.3.1+5" crypto: dependency: "direct main" description: @@ -161,7 +161,7 @@ packages: name: file_selector_web url: "https://pub.dartlang.org" source: hosted - version: "0.8.1+1" + version: "0.8.1+2" file_selector_windows: dependency: "direct main" description: @@ -309,7 +309,7 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.3" path_provider_linux: dependency: transitive description: @@ -351,14 +351,14 @@ packages: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "4.2.0" + version: "4.3.0" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.2" plugin_platform_interface: dependency: transitive description: @@ -386,7 +386,7 @@ packages: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.0.6" + version: "2.0.7" shared_preferences_linux: dependency: transitive description: @@ -414,7 +414,7 @@ packages: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" shared_preferences_windows: dependency: transitive description: @@ -503,21 +503,21 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.9" + version: "6.0.10" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" url_launcher_platform_interface: dependency: transitive description: @@ -531,14 +531,14 @@ packages: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.4" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" uuid: dependency: transitive description: @@ -566,7 +566,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.2.5" + version: "2.2.9" xdg_directories: dependency: transitive description: @@ -582,5 +582,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.13.0 <3.0.0" + dart: ">=2.14.0 <3.0.0" flutter: ">=2.0.0" diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 8bd332a6..af9ae5db 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,11 +7,11 @@ #include "generated_plugin_registrant.h" #include -#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { FileSelectorPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("FileSelectorPlugin")); - UrlLauncherPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("UrlLauncherPlugin")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); }