From 61ab3c446d07988558e9b83fe5ca240bdb916d84 Mon Sep 17 00:00:00 2001 From: Alessandro Autiero Date: Sun, 4 Jun 2023 11:47:23 +0200 Subject: [PATCH] Minor fixes --- lib/src/ui/page/launcher_page.dart | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/src/ui/page/launcher_page.dart b/lib/src/ui/page/launcher_page.dart index 4c039cb..9c3f05a 100644 --- a/lib/src/ui/page/launcher_page.dart +++ b/lib/src/ui/page/launcher_page.dart @@ -147,13 +147,7 @@ class _GamePageState extends State<_GamePage> { title: "Automatically start game server", subtitle: "This option is available when the matchmaker is set to localhost", contentWidth: null, - content: Obx(() => !isLocalHost(_settingsController.matchmakingIp.text) || _gameController.password.text.isNotEmpty ? Container( - foregroundDecoration: const BoxDecoration( - color: Colors.grey, - backgroundBlendMode: BlendMode.saturation, - ), - child: _autoGameServerSwitch, - ) : _autoGameServerSwitch), + content: !isLocalHost(_settingsController.matchmakingIp.text) || _gameController.password.text.isNotEmpty ? _disabledAutoGameServerSwitch : _autoGameServerSwitch, isChild: true ), SettingTile( @@ -211,8 +205,16 @@ class _GamePageState extends State<_GamePage> { ], ); - ToggleSwitch get _autoGameServerSwitch => ToggleSwitch( - checked: isLocalHost(_settingsController.matchmakingIp.text) && _gameController.password.text.isEmpty && _gameController.autoStartGameServer(), + Widget get _disabledAutoGameServerSwitch => Container( + foregroundDecoration: const BoxDecoration( + color: Colors.grey, + backgroundBlendMode: BlendMode.saturation, + ), + child: _autoGameServerSwitch, + ); + + Widget get _autoGameServerSwitch => Obx(() => ToggleSwitch( + checked: _gameController.autoStartGameServer() && isLocalHost(_settingsController.matchmakingIp.text) && _gameController.password.text.isEmpty, onChanged: (value) { if(!isLocalHost(_settingsController.matchmakingIp.text)){ showMessage("This option isn't available when the matchmaker isn't set to 127.0.0.1"); @@ -226,5 +228,5 @@ class _GamePageState extends State<_GamePage> { _gameController.autoStartGameServer.value = value; } - ); + )); } \ No newline at end of file