Minor fixes

This commit is contained in:
Alessandro Autiero
2023-06-04 11:47:23 +02:00
parent 282716a9e9
commit 61ab3c446d

View File

@@ -147,13 +147,7 @@ class _GamePageState extends State<_GamePage> {
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(() => !isLocalHost(_settingsController.matchmakingIp.text) || _gameController.password.text.isNotEmpty ? Container( content: !isLocalHost(_settingsController.matchmakingIp.text) || _gameController.password.text.isNotEmpty ? _disabledAutoGameServerSwitch : _autoGameServerSwitch,
foregroundDecoration: const BoxDecoration(
color: Colors.grey,
backgroundBlendMode: BlendMode.saturation,
),
child: _autoGameServerSwitch,
) : _autoGameServerSwitch),
isChild: true isChild: true
), ),
SettingTile( SettingTile(
@@ -211,8 +205,16 @@ class _GamePageState extends State<_GamePage> {
], ],
); );
ToggleSwitch get _autoGameServerSwitch => ToggleSwitch( Widget get _disabledAutoGameServerSwitch => Container(
checked: isLocalHost(_settingsController.matchmakingIp.text) && _gameController.password.text.isEmpty && _gameController.autoStartGameServer(), 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) { onChanged: (value) {
if(!isLocalHost(_settingsController.matchmakingIp.text)){ if(!isLocalHost(_settingsController.matchmakingIp.text)){
showMessage("This option isn't available when the matchmaker isn't set to 127.0.0.1"); 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; _gameController.autoStartGameServer.value = value;
} }
); ));
} }