Minor fixes

This commit is contained in:
Alessandro Autiero
2023-06-04 02:15:19 +02:00
parent 0d16c232c4
commit b02b0c37a9
2 changed files with 28 additions and 7 deletions

View File

@@ -80,7 +80,7 @@ class _RebootApplicationState extends State<RebootApplication> {
@override @override
Widget build(BuildContext context) => FluentApp( Widget build(BuildContext context) => FluentApp(
title: "Reboot Launcher", title: "Reboot Launcher",
themeMode: ThemeMode.system, themeMode: ThemeMode.light,
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
color: SystemTheme.accentColor.accent.toAccentColor(), color: SystemTheme.accentColor.accent.toAccentColor(),
darkTheme: _createTheme(Brightness.dark), darkTheme: _createTheme(Brightness.dark),

View File

@@ -7,6 +7,7 @@ import 'package:flutter/material.dart' show Icons;
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:reboot_launcher/src/ui/controller/game_controller.dart'; import 'package:reboot_launcher/src/ui/controller/game_controller.dart';
import 'package:reboot_launcher/src/ui/controller/settings_controller.dart'; import 'package:reboot_launcher/src/ui/controller/settings_controller.dart';
import 'package:reboot_launcher/src/ui/dialog/snackbar.dart';
import 'package:reboot_launcher/src/ui/page/browse_page.dart'; import 'package:reboot_launcher/src/ui/page/browse_page.dart';
import 'package:reboot_launcher/src/ui/widget/home/launch_button.dart'; import 'package:reboot_launcher/src/ui/widget/home/launch_button.dart';
import 'package:reboot_launcher/src/ui/widget/home/version_selector.dart'; import 'package:reboot_launcher/src/ui/widget/home/version_selector.dart';
@@ -73,6 +74,7 @@ class _GamePageState extends State<_GamePage> {
@override @override
void initState() { void initState() {
_gameController.password.addListener(() => _matchmakingStream.add(null));
_settingsController.matchmakingIp.addListener(() => _matchmakingStream.add(null)); _settingsController.matchmakingIp.addListener(() => _matchmakingStream.add(null));
super.initState(); super.initState();
} }
@@ -140,16 +142,18 @@ class _GamePageState extends State<_GamePage> {
validator: checkMatchmaking, validator: checkMatchmaking,
autovalidateMode: AutovalidateMode.always autovalidateMode: AutovalidateMode.always
), ),
expandedContentSpacing: isLocalHost(_settingsController.matchmakingIp.text) ? SettingTile.kDefaultSpacing : 0,
expandedContent: [ expandedContent: [
!isLocalHost(_settingsController.matchmakingIp.text) ? const SizedBox() : SettingTile( SettingTile(
title: "Automatically start game server", title: "Automatically start game server",
subtitle: "This option is available when the matchmaker is set to localhost", subtitle: "This option is available when the matchmaker is set to localhost",
contentWidth: null, contentWidth: null,
content: Obx(() => ToggleSwitch( content: Obx(() => !isLocalHost(_settingsController.matchmakingIp.text) || _gameController.password.text.isNotEmpty ? Container(
checked: _gameController.autoStartGameServer(), foregroundDecoration: const BoxDecoration(
onChanged: (value) => _gameController.autoStartGameServer.value = value color: Colors.grey,
)), backgroundBlendMode: BlendMode.saturation,
),
child: _autoGameServerSwitch,
) : _autoGameServerSwitch),
isChild: true isChild: true
), ),
SettingTile( SettingTile(
@@ -206,4 +210,21 @@ class _GamePageState extends State<_GamePage> {
) )
], ],
); );
ToggleSwitch get _autoGameServerSwitch => ToggleSwitch(
checked: isLocalHost(_settingsController.matchmakingIp.text) && _gameController.password.text.isEmpty && _gameController.autoStartGameServer(),
onChanged: (value) {
if(!isLocalHost(_settingsController.matchmakingIp.text)){
showMessage("This option isn't available when the matchmaker isn't set to 127.0.0.1");
return;
}
if(_gameController.password.text.isNotEmpty){
showMessage("This option isn't available when the password isn't empty(LawinV2)");
return;
}
_gameController.autoStartGameServer.value = value;
}
);
} }