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

131 lines
3.4 KiB
Dart
Raw Normal View History

part of 'server_details_screen.dart';
2021-03-26 13:38:39 +00:00
class _ServerSettings extends StatelessWidget {
const _ServerSettings({
Key? key,
required this.tabController,
}) : super(key: key);
final TabController tabController;
@override
Widget build(BuildContext context) {
2022-02-08 21:01:08 +00:00
var serverDetailsState = context.watch<ServerDetailsCubit>().state;
if (serverDetailsState is ServerDetailsNotReady) {
2022-05-24 18:55:39 +00:00
return const Text('not ready');
2022-02-08 21:01:08 +00:00
} else if (serverDetailsState is! Loaded) {
return BrandLoader.horizontal();
}
2021-03-26 13:38:39 +00:00
return ListView(
2021-05-25 21:53:54 +00:00
padding: paddingH15V0,
2021-03-26 13:38:39 +00:00
children: [
2022-05-24 18:55:39 +00:00
const SizedBox(height: 10),
2021-03-26 13:38:39 +00:00
Container(
height: 52,
alignment: Alignment.centerLeft,
2022-05-24 18:55:39 +00: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 13:38:39 +00:00
),
),
2022-05-24 18:55:39 +00:00
const BrandDivider(),
2021-03-26 13:38:39 +00:00
SwitcherBlock(
onChange: (_) {},
2022-05-24 18:55:39 +00:00
isActive: serverDetailsState.autoUpgradeSettings.enable,
child: const _TextColumn(
2021-03-26 13:38:39 +00:00
title: 'Allow Auto-upgrade',
value: 'Wether to allow automatic packages upgrades',
hasWarning: false,
2021-03-26 13:38:39 +00:00
),
),
SwitcherBlock(
onChange: (_) {},
2022-05-24 18:55:39 +00:00
isActive: serverDetailsState.autoUpgradeSettings.allowReboot,
child: const _TextColumn(
2021-03-26 13:38:39 +00:00
title: 'Reboot after upgrade',
value: 'Reboot without prompt after applying updates',
hasWarning: false,
2021-03-26 13:38:39 +00:00
),
),
_Button(
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
child: _TextColumn(
title: 'Server Timezone',
2022-02-08 21:01:08 +00:00
value: serverDetailsState.serverTimezone.timezone.name,
hasWarning: false,
2021-03-26 13:38:39 +00:00
),
),
],
);
}
}
class _Button extends StatelessWidget {
const _Button({
Key? key,
required this.onTap,
required this.child,
}) : super(key: key);
final Widget child;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Container(
2022-05-24 18:55:39 +00:00
padding: const EdgeInsets.only(top: 20, bottom: 5),
decoration: const BoxDecoration(
2021-03-26 13:38:39 +00:00
border: Border(
bottom: BorderSide(width: 1, color: BrandColors.dividerColor),
)),
child: child,
),
);
}
}
class _TextColumn extends StatelessWidget {
const _TextColumn({
Key? key,
required this.title,
required this.value,
this.hasWarning = false,
}) : super(key: key);
final String title;
final String value;
final bool hasWarning;
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
BrandText.body1(
title,
style: TextStyle(color: hasWarning ? BrandColors.warning : null),
),
2022-05-24 18:55:39 +00:00
const SizedBox(height: 5),
2021-03-26 13:38:39 +00:00
BrandText.body1(
value,
style: TextStyle(
fontSize: 13,
height: 1.53,
color: hasWarning ? BrandColors.warning : BrandColors.gray1,
),
),
],
);
}
}