mirror of
https://github.com/Auties00/Reboot-Launcher.git
synced 2026-01-14 03:32:23 +01:00
Finished Launcher
Everything is smooth and the UI is perfect
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import 'package:bitsdojo_window/bitsdojo_window.dart' hide WindowBorder;
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:reboot_launcher/src/page/info_page.dart';
|
||||
import 'package:reboot_launcher/src/page/launcher_page.dart';
|
||||
import 'package:reboot_launcher/src/page/server_page.dart';
|
||||
import 'package:reboot_launcher/src/widget/window_buttons.dart';
|
||||
import 'package:reboot_launcher/src/widget/window_border.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
import '../util/os.dart';
|
||||
import '../util/reboot.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
@@ -13,51 +17,92 @@ class HomePage extends StatefulWidget {
|
||||
State<HomePage> createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
final List<Widget> _children = [LauncherPage(), ServerPage(), const InfoPage()];
|
||||
class _HomePageState extends State<HomePage> with WindowListener {
|
||||
late final Future _future;
|
||||
bool _focused = true;
|
||||
int _index = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
windowManager.addListener(this);
|
||||
_future = downloadRebootDll();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
windowManager.removeListener(this);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowFocus() {
|
||||
setState(() => _focused = true);
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowBlur() {
|
||||
setState(() => _focused = false);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return NavigationView(
|
||||
pane: NavigationPane(
|
||||
selected: _index,
|
||||
onChanged: (index) => setState(() => _index = index),
|
||||
displayMode: PaneDisplayMode.top,
|
||||
indicator: const EndNavigationIndicator(),
|
||||
items: [
|
||||
_createPane("Launcher", FluentIcons.game),
|
||||
_createPane("Server", FluentIcons.server_enviroment),
|
||||
_createPane("Info", FluentIcons.info),
|
||||
],
|
||||
trailing: const WindowTitleBar()),
|
||||
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 Stack(
|
||||
children: [
|
||||
NavigationView(
|
||||
pane: NavigationPane(
|
||||
selected: _index,
|
||||
onChanged: (index) => setState(() => _index = index),
|
||||
displayMode: PaneDisplayMode.top,
|
||||
indicator: const EndNavigationIndicator(),
|
||||
items: [
|
||||
_createPane("Launcher", FluentIcons.game),
|
||||
_createPane("Server", FluentIcons.server_enviroment),
|
||||
_createPane("Info", FluentIcons.info),
|
||||
],
|
||||
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(
|
||||
index: _index,
|
||||
children: _createPages(snapshot.hasData));
|
||||
})
|
||||
),
|
||||
|
||||
if (!snapshot.hasData) {
|
||||
return const Center(child: ProgressRing());
|
||||
}
|
||||
if(_focused && isWin11)
|
||||
const WindowBorder()
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return NavigationBody(
|
||||
index: _index,
|
||||
children: _children
|
||||
);
|
||||
}
|
||||
)
|
||||
List<Widget> _createPages(bool data) {
|
||||
return [
|
||||
data ? LauncherPage() : _createDownloadWarning(),
|
||||
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...")
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
const String _discordLink = "https://discord.gg/rTzBQH3N";
|
||||
@@ -30,7 +31,7 @@ class InfoPage extends StatelessWidget {
|
||||
),
|
||||
const Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.bottomLeft, child: Text("Version 2.2")))
|
||||
alignment: Alignment.bottomLeft, child: Text("Version 2.3${kDebugMode ? '-DEBUG' : ''}")))
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user