Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

Commit

Permalink
優化:檢測更新頁面
Browse files Browse the repository at this point in the history
  • Loading branch information
SiongSng committed Sep 13, 2021
1 parent e381864 commit b32ace2
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 53 deletions.
4 changes: 2 additions & 2 deletions lib/Utility/Theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 12 additions & 4 deletions lib/Utility/Updater.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)}%"),
],
),
);
});
Expand Down Expand Up @@ -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)");
}
});
});
Expand Down
79 changes: 49 additions & 30 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -173,37 +174,55 @@ class _HomePageState extends State<HomePage> {
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: [
Expand Down
28 changes: 14 additions & 14 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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"
6 changes: 3 additions & 3 deletions windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#include "generated_plugin_registrant.h"

#include <file_selector_windows/file_selector_plugin.h>
#include <url_launcher_windows/url_launcher_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>

void RegisterPlugins(flutter::PluginRegistry* registry) {
FileSelectorPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSelectorPlugin"));
UrlLauncherPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
}

0 comments on commit b32ace2

Please sign in to comment.