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

118 lines
3.3 KiB
Dart
Raw Normal View History

part of 'server_details_screen.dart';
2021-03-26 15:38:39 +02:00
class _ServerSettings extends StatelessWidget {
const _ServerSettings({
required this.tabController,
});
2021-03-26 15:38:39 +02:00
final TabController tabController;
@override
Widget build(final BuildContext context) {
final serverDetailsState = context.watch<ServerDetailsCubit>().state;
2022-02-08 23:01:08 +02:00
if (serverDetailsState is ServerDetailsNotReady) {
2022-09-12 20:38:22 +03:00
return Text('basis.loading'.tr());
2022-02-08 23:01:08 +02:00
} else if (serverDetailsState is! Loaded) {
return BrandLoader.horizontal();
}
2021-03-26 15:38:39 +02:00
return ListView(
2021-05-26 00:53:54 +03:00
padding: paddingH15V0,
2021-03-26 15:38:39 +02:00
children: [
2022-05-24 21:55:39 +03:00
const SizedBox(height: 10),
2021-03-26 15:38:39 +02:00
Container(
height: 52,
alignment: Alignment.centerLeft,
2022-05-24 21:55:39 +03:00
padding: const EdgeInsets.only(left: 1),
child: Row(
children: [
IconButton(
icon: const Icon(BrandIcons.arrowLeft),
onPressed: () => tabController.animateTo(0),
),
const SizedBox(width: 10),
BrandText.h4('basis.settings'.tr()),
],
2021-03-26 15:38:39 +02:00
),
),
2022-05-24 21:55:39 +03:00
const BrandDivider(),
2021-03-26 15:38:39 +02:00
SwitcherBlock(
onChange: (final _) {},
2022-05-24 21:55:39 +03:00
isActive: serverDetailsState.autoUpgradeSettings.enable,
2022-09-12 20:38:22 +03:00
child: _TextColumn(
title: 'providers.server.settings.allow_autoupgrade'.tr(),
value: 'providers.server.settings.allow_autoupgrade_hint'.tr(),
2021-03-26 15:38:39 +02:00
),
),
SwitcherBlock(
onChange: (final _) {},
2022-05-24 21:55:39 +03:00
isActive: serverDetailsState.autoUpgradeSettings.allowReboot,
2022-09-12 20:38:22 +03:00
child: _TextColumn(
title: 'providers.server.settings.reboot_after_upgrade'.tr(),
value: 'providers.server.settings.reboot_after_upgrade_hint'.tr(),
2021-03-26 15:38:39 +02:00
),
),
_Button(
2022-01-25 19:00:47 +02:00
onTap: () {
Navigator.of(context).push(materialRoute(const SelectTimezone()));
2022-01-25 19:00:47 +02:00
},
2021-03-26 15:38:39 +02:00
child: _TextColumn(
2022-09-12 20:38:22 +03:00
title: 'providers.server.settings.server_timezone'.tr(),
value: serverDetailsState.serverTimezone.toString(),
2021-03-26 15:38:39 +02:00
),
),
],
);
}
}
class _Button extends StatelessWidget {
const _Button({
required this.onTap,
required this.child,
});
2021-03-26 15:38:39 +02:00
final Widget child;
final VoidCallback onTap;
@override
Widget build(final BuildContext context) => InkWell(
onTap: onTap,
child: Container(
padding: const EdgeInsets.only(top: 20, bottom: 5),
decoration: const BoxDecoration(
2021-03-26 15:38:39 +02:00
border: Border(
bottom: BorderSide(width: 1, color: BrandColors.dividerColor),
),
),
child: child,
),
);
2021-03-26 15:38:39 +02:00
}
class _TextColumn extends StatelessWidget {
const _TextColumn({
required this.title,
required this.value,
this.hasWarning = false,
});
2021-03-26 15:38:39 +02:00
final String title;
final String value;
final bool hasWarning;
@override
Widget build(final BuildContext context) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
BrandText.body1(
title,
2022-09-12 20:38:22 +03:00
style: Theme.of(context).textTheme.bodyLarge,
2021-03-26 15:38:39 +02:00
),
const SizedBox(height: 5),
BrandText.body1(
value,
2022-09-12 20:38:22 +03:00
style: Theme.of(context).textTheme.bodyMedium,
),
],
);
2021-03-26 15:38:39 +02:00
}