This commit is contained in:
Alessandro Autiero
2022-09-24 20:17:30 +02:00
parent 1a0fbbdf30
commit 52af8ac646
18 changed files with 584 additions and 176 deletions

View File

@@ -1,5 +1,8 @@
import 'dart:ui';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:get_storage/get_storage.dart';
import 'package:reboot_launcher/src/page/info_page.dart';
import 'package:reboot_launcher/src/page/launcher_page.dart';
@@ -9,7 +12,10 @@ import 'package:reboot_launcher/src/widget/window_border.dart';
import 'package:window_manager/window_manager.dart';
import 'package:reboot_launcher/src/util/os.dart';
import 'package:reboot_launcher/src/util/reboot.dart';
import 'package:get/get.dart';
import '../controller/build_controller.dart';
import '../util/reboot.dart';
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@@ -67,18 +73,11 @@ class _HomePageState extends State<HomePage> with WindowListener {
trailing: WindowTitleBar(focused: _focused)),
content: FutureBuilder(
future: _future,
builder: (context, snapshot) {
if (snapshot.hasError) {
return Center(
child: Text(
"An error occurred while loading the launcher: ${snapshot.error}",
textAlign: TextAlign.center));
}
return NavigationBody(
builder: (context, snapshot) => NavigationBody(
index: _index,
children: _createPages(snapshot.hasData));
})
children: _createPages(snapshot)
)
)
),
if(_focused && isWin11)
@@ -87,30 +86,19 @@ class _HomePageState extends State<HomePage> with WindowListener {
);
}
List<Widget> _createPages(bool data) {
List<Widget> _createPages(AsyncSnapshot snapshot) {
return [
data ? const LauncherPage() : _createDownloadWarning(),
LauncherPage(
ready: snapshot.hasData,
error: snapshot.error,
stackTrace: snapshot.stackTrace
),
ServerPage(),
const InfoPage()
];
}
Widget _createDownloadWarning() {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
ProgressRing(),
SizedBox(height: 16.0),
Text("Updating Reboot DLL...")
],
),
],
);
}
PaneItem _createPane(String label, IconData icon) {
return PaneItem(icon: Icon(icon), title: Text(label));
}

View File

@@ -31,7 +31,7 @@ class InfoPage extends StatelessWidget {
),
const Expanded(
child: Align(
alignment: Alignment.bottomLeft, child: Text("Version 3.5${kDebugMode ? '-DEBUG' : ''}")))
alignment: Alignment.bottomLeft, child: Text("Version 3.6${kDebugMode ? '-DEBUG' : ''}")))
],
);
}

View File

@@ -1,19 +1,89 @@
import 'dart:io';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:reboot_launcher/src/controller/build_controller.dart';
import 'package:reboot_launcher/src/util/os.dart';
import 'package:reboot_launcher/src/widget/deployment_selector.dart';
import 'package:reboot_launcher/src/widget/launch_button.dart';
import 'package:reboot_launcher/src/widget/username_box.dart';
import 'package:get/get.dart';
import 'package:reboot_launcher/src/widget/version_selector.dart';
import 'package:url_launcher/url_launcher.dart';
class LauncherPage extends StatelessWidget {
const LauncherPage({Key? key}) : super(key: key);
import '../widget/warning_info.dart';
class LauncherPage extends StatefulWidget {
final bool ready;
final Object? error;
final StackTrace? stackTrace;
const LauncherPage(
{Key? key, required this.ready, required this.error, this.stackTrace})
: super(key: key);
@override
State<LauncherPage> createState() => _LauncherPageState();
}
class _LauncherPageState extends State<LauncherPage> {
final BuildController _buildController = Get.find<BuildController>();
bool shouldWriteError = true;
@override
void initState() {
_buildController.cancelledDownload
.listen((value) => value ? _onCancelWarning() : {});
super.initState();
}
void _onCancelWarning() {
WidgetsBinding.instance.addPostFrameCallback((_) {
showSnackbar(context,
const Snackbar(content: Text("Download cancelled")));
_buildController.cancelledDownload.value = false;
});
}
@override
Widget build(BuildContext context) {
if (!widget.ready && widget.error == null) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
ProgressRing(),
SizedBox(height: 16.0),
Text("Updating Reboot DLL...")
],
),
],
);
}
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if(widget.error != null)
WarningInfo(
text: "Cannot update Reboot DLL",
icon: FluentIcons.info,
severity: InfoBarSeverity.warning,
onPressed: () async {
if (shouldWriteError) {
await errorFile.writeAsString(
"Error: ${widget.error}\nStacktrace: ${widget.stackTrace}",
mode: FileMode.write
);
shouldWriteError = false;
}
launchUrl(errorFile.uri);
},
),
UsernameBox(),
VersionSelector(),
DeploymentSelector(enabled: true),

View File

@@ -1,7 +1,7 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:get/get.dart';
import 'package:reboot_launcher/src/controller/server_controller.dart';
import 'package:reboot_launcher/src/widget/lawin_warning.dart';
import 'package:reboot_launcher/src/widget/warning_info.dart';
import 'package:reboot_launcher/src/widget/local_server_switch.dart';
import 'package:reboot_launcher/src/widget/port_input.dart';
@@ -20,7 +20,9 @@ class ServerPage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if(_serverController.warning.value)
LawinWarning(
WarningInfo(
text: "The lawin server handles authentication and parties, not game hosting",
icon: FluentIcons.accept,
onPressed: () => _serverController.warning.value = false
),
HostInput(),