selfprivacy.org.app/lib/ui/pages/server_details/server_settings.dart

112 lines
3.5 KiB
Dart
Raw Normal View History

part of 'server_details_screen.dart';
2021-03-26 13:38:39 +00:00
class _ServerSettings extends StatefulWidget {
const _ServerSettings();
2021-03-26 13:38:39 +00:00
@override
State<_ServerSettings> createState() => _ServerSettingsState();
}
class _ServerSettingsState extends State<_ServerSettings> {
bool? allowAutoUpgrade;
bool? rebootAfterUpgrade;
2021-03-26 13:38:39 +00:00
@override
Widget build(final BuildContext context) {
final serverDetailsState = context.watch<ServerDetailsCubit>().state;
2022-02-08 21:01:08 +00:00
if (serverDetailsState is ServerDetailsNotReady) {
2022-09-12 17:38:22 +00:00
return Text('basis.loading'.tr());
2022-02-08 21:01:08 +00:00
} else if (serverDetailsState is! Loaded) {
return BrandLoader.horizontal();
}
if (allowAutoUpgrade == null || rebootAfterUpgrade == null) {
allowAutoUpgrade = serverDetailsState.autoUpgradeSettings.enable;
rebootAfterUpgrade = serverDetailsState.autoUpgradeSettings.allowReboot;
}
return Column(
2021-03-26 13:38:39 +00:00
children: [
SwitchListTile(
value: allowAutoUpgrade ?? false,
onChanged: (final switched) {
context.read<JobsCubit>().addJob(
ChangeAutoUpgradeSettingsJob(
allowReboot: rebootAfterUpgrade ?? false,
enable: switched,
),
);
setState(() {
allowAutoUpgrade = switched;
});
},
title: Text(
'server.allow_autoupgrade'.tr(),
style: TextStyle(
fontStyle: allowAutoUpgrade !=
serverDetailsState.autoUpgradeSettings.enable
? FontStyle.italic
: FontStyle.normal,
),
),
subtitle: Text(
'server.allow_autoupgrade_hint'.tr(),
style: TextStyle(
fontStyle: allowAutoUpgrade !=
serverDetailsState.autoUpgradeSettings.enable
? FontStyle.italic
: FontStyle.normal,
),
2021-03-26 13:38:39 +00:00
),
activeColor: Theme.of(context).colorScheme.primary,
2021-03-26 13:38:39 +00:00
),
SwitchListTile(
value: rebootAfterUpgrade ?? false,
onChanged: (final switched) {
context.read<JobsCubit>().addJob(
ChangeAutoUpgradeSettingsJob(
allowReboot: switched,
enable: allowAutoUpgrade ?? false,
),
);
setState(() {
rebootAfterUpgrade = switched;
});
},
title: Text(
'server.reboot_after_upgrade'.tr(),
style: TextStyle(
fontStyle: rebootAfterUpgrade !=
serverDetailsState.autoUpgradeSettings.allowReboot
? FontStyle.italic
: FontStyle.normal,
),
),
subtitle: Text(
'server.reboot_after_upgrade_hint'.tr(),
style: TextStyle(
fontStyle: rebootAfterUpgrade !=
serverDetailsState.autoUpgradeSettings.allowReboot
? FontStyle.italic
: FontStyle.normal,
),
2021-03-26 13:38:39 +00:00
),
activeColor: Theme.of(context).colorScheme.primary,
2021-03-26 13:38:39 +00:00
),
ListTile(
title: Text('server.server_timezone'.tr()),
subtitle: Text(
serverDetailsState.serverTimezone.toString(),
),
2022-01-25 17:00:47 +00:00
onTap: () {
Navigator.of(context).push(
materialRoute(
const SelectTimezone(),
),
);
2022-01-25 17:00:47 +00:00
},
2021-03-26 13:38:39 +00:00
),
],
);
}
}