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

Commit

Permalink
perf: load instances (#267)
Browse files Browse the repository at this point in the history
透過快取機制,改進了載入大量安裝檔的效能 (#267)
  • Loading branch information
SiongSng authored Jul 5, 2022
2 parents 33b9f6e + 87c7c8a commit 77000c4
Show file tree
Hide file tree
Showing 16 changed files with 377 additions and 357 deletions.
2 changes: 1 addition & 1 deletion lib/launcher/Forge/ForgeClient.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:rpmlauncher/model/Game/MinecraftMeta.dart';
import 'package:rpmlauncher/model/IO/DownloadInfo.dart';
import 'package:rpmlauncher/model/Game/instance.dart';
import 'package:rpmlauncher/model/Game/Libraries.dart';
import 'package:rpmlauncher/screen/HomePage.dart';
import 'package:rpmlauncher/screen/home_page.dart';
import 'package:rpmlauncher/util/I18n.dart';
import 'package:rpmlauncher/widget/dialog/UnSupportedForgeVersion.dart';
import 'package:rpmlauncher/widget/rpmtw_design/OkClose.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/route/GenerateRoute.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:rpmlauncher/route/PushTransitions.dart';
import 'package:rpmlauncher/route/RPMRouteSettings.dart';
import 'package:rpmlauncher/screen/Account.dart';
import 'package:rpmlauncher/screen/HomePage.dart';
import 'package:rpmlauncher/screen/home_page.dart';
import 'package:rpmlauncher/screen/Settings.dart';
import 'package:rpmlauncher/screen/Edit.dart';
import 'package:rpmlauncher/screen/Log.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/screen/Account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:rpmlauncher/account/mojang_account_handler.dart';
import 'package:rpmlauncher/launcher/GameRepository.dart';
import 'package:rpmlauncher/model/account/Account.dart';
import 'package:rpmlauncher/route/PushTransitions.dart';
import 'package:rpmlauncher/screen/HomePage.dart';
import 'package:rpmlauncher/screen/home_page.dart';
import 'package:rpmlauncher/util/I18n.dart';
import 'package:rpmlauncher/widget/dialog/CheckDialog.dart';
import 'package:flutter/material.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/screen/DownloadCurseModPack.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:rpmlauncher/model/Game/instance.dart';
import 'package:rpmlauncher/model/Game/MinecraftMeta.dart';
import 'package:rpmlauncher/model/Game/MinecraftSide.dart';
import 'package:rpmlauncher/route/PushTransitions.dart';
import 'package:rpmlauncher/screen/HomePage.dart';
import 'package:rpmlauncher/screen/home_page.dart';
import 'package:rpmlauncher/util/I18n.dart';
import 'package:archive/archive.dart';
import 'package:flutter/material.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/screen/FTBModPack.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:rpmlauncher/model/Game/instance.dart';
import 'package:rpmlauncher/model/Game/MinecraftMeta.dart';
import 'package:rpmlauncher/model/Game/MinecraftSide.dart';
import 'package:rpmlauncher/route/PushTransitions.dart';
import 'package:rpmlauncher/screen/HomePage.dart';
import 'package:rpmlauncher/screen/home_page.dart';
import 'package:rpmlauncher/util/I18n.dart';
import 'package:flutter/material.dart';
import 'package:path/path.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/screen/Log.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'package:rpmlauncher/model/Game/instance.dart';
import 'package:rpmlauncher/model/Game/MinecraftSide.dart';
import 'package:rpmlauncher/model/IO/Properties.dart';
import 'package:rpmlauncher/route/PushTransitions.dart';
import 'package:rpmlauncher/screen/HomePage.dart';
import 'package:rpmlauncher/screen/home_page.dart';
import 'package:rpmlauncher/util/Process.dart';
import 'package:rpmlauncher/util/Config.dart';
import 'package:rpmlauncher/mod/mod_loader.dart';
Expand Down
57 changes: 31 additions & 26 deletions lib/screen/HomePage.dart → lib/screen/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import 'package:rpmlauncher/util/RPMHttpClient.dart';
import 'package:rpmlauncher/util/launcher_path.dart';
import 'package:rpmlauncher/util/updater.dart';
import 'package:rpmlauncher/util/util.dart';
import 'package:rpmlauncher/view/InstanceView.dart';
import 'package:rpmlauncher/view/instance_view.dart';
import 'package:rpmlauncher/view/MinecraftNewsView.dart';
import 'package:rpmlauncher/view/RowScrollView.dart';
import 'package:rpmlauncher/widget/AccountManageAction.dart';
import 'package:rpmlauncher/widget/dialog/quick_setup.dart';
import 'package:rpmlauncher/widget/dialog/UpdaterDialog.dart';
import 'package:rpmlauncher/widget/keep_alive_wrapper.dart';
import 'package:rpmlauncher/widget/rpmtw_design/NewFeaturesWidget.dart';
import 'package:rpmlauncher/widget/rpmtw_design/OkClose.dart';
import 'package:rpmlauncher/widget/RWLLoading.dart';
Expand Down Expand Up @@ -74,28 +75,28 @@ class _HomePageState extends State<HomePage> {
mainAxisAlignment: MainAxisAlignment.start,
children: [
IconButton(
tooltip: I18n.format("homepage.website"),
tooltip: I18n.format('homepage.website'),
onPressed: () {
Util.openUri(LauncherInfo.homePageUrl);
},
icon: Image.asset("assets/images/Logo.png", scale: 4),
icon: Image.asset('assets/images/Logo.png', scale: 4),
),
IconButton(
tooltip: I18n.format("gui.settings"),
tooltip: I18n.format('gui.settings'),
icon: const Icon(Icons.settings),
onPressed: () {
navigator.pushNamed(SettingScreen.route);
},
),
IconButton(
tooltip: I18n.format("homepage.data.folder.open"),
tooltip: I18n.format('homepage.data.folder.open'),
icon: const Icon(Icons.folder),
onPressed: () {
Util.openFileManager(LauncherPath.currentDataHome);
},
),
IconButton(
tooltip: I18n.format("homepage.about"),
tooltip: I18n.format('homepage.about'),
icon: const Icon(Icons.info),
onPressed: () {
Navigator.push(
Expand All @@ -107,11 +108,11 @@ class _HomePageState extends State<HomePage> {
IconButton(
icon: const Icon(Icons.bug_report),
onPressed: () => LauncherInfo.feedback(context),
tooltip: I18n.format("homepage.bug_report"),
tooltip: I18n.format('homepage.bug_report'),
),
IconButton(
icon: const Icon(Icons.change_circle),
tooltip: I18n.format("homepage.update"),
tooltip: I18n.format('homepage.update'),
onPressed: () {
showDialog(
context: context,
Expand All @@ -129,7 +130,7 @@ class _HomePageState extends State<HomePage> {
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
I18nText("updater.check.none"),
I18nText('updater.check.none'),
const Icon(Icons.done_outlined,
size: 30),
],
Expand All @@ -143,7 +144,7 @@ class _HomePageState extends State<HomePage> {
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
I18nText("updater.check.checking"),
I18nText('updater.check.checking'),
const SizedBox(
width: 30.0,
height: 30.0,
Expand Down Expand Up @@ -179,20 +180,24 @@ class _HomePageState extends State<HomePage> {
),
body: TabBarView(
children: [
const InstanceView(side: MinecraftSide.client),
const InstanceView(side: MinecraftSide.server),
FutureBuilder(
future: RPMHttpClient().get(minecraftNewsRSS),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
Response response = snapshot.data;
XmlDocument xmlDocument = XmlDocument.parse(response.data);
MinecraftNews news = MinecraftNews.fromXml(xmlDocument);
return MinecraftNewsView(news: news);
} else {
return const RWLLoading();
}
},
const KeepAliveWrapper(
child: InstanceView(side: MinecraftSide.client)),
const KeepAliveWrapper(
child: InstanceView(side: MinecraftSide.server)),
KeepAliveWrapper(
child: FutureBuilder(
future: RPMHttpClient().get(minecraftNewsRSS),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
Response response = snapshot.data;
XmlDocument xmlDocument = XmlDocument.parse(response.data);
MinecraftNews news = MinecraftNews.fromXml(xmlDocument);
return MinecraftNewsView(news: news);
} else {
return const RWLLoading();
}
},
),
),
],
),
Expand Down Expand Up @@ -237,7 +242,7 @@ class _FloatingActionState extends State<_FloatingAction> {
side: MinecraftSide.client,
)));
},
tooltip: I18n.format("version.list.instance.add"),
tooltip: I18n.format('version.list.instance.add'),
child: const Icon(Icons.add),
);
} else if (index == 1) {
Expand All @@ -251,7 +256,7 @@ class _FloatingActionState extends State<_FloatingAction> {
side: MinecraftSide.server,
)));
},
tooltip: I18n.format("version.list.instance.add.server"),
tooltip: I18n.format('version.list.instance.add.server'),
child: const Icon(Icons.add),
);
} else {
Expand Down
Loading

0 comments on commit 77000c4

Please sign in to comment.