selfprivacy.org.app/lib/ui/pages/more/more.dart

148 lines
4.8 KiB
Dart
Raw Normal View History

import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart';
2020-12-02 09:16:23 +00:00
import 'package:flutter/material.dart';
2021-09-02 19:32:07 +00:00
import 'package:ionicons/ionicons.dart';
2020-12-02 09:16:23 +00:00
import 'package:selfprivacy/config/brand_theme.dart';
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
2020-12-02 09:16:23 +00:00
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
2024-01-31 10:57:12 +00:00
import 'package:selfprivacy/ui/components/cards/filled_card.dart';
import 'package:selfprivacy/ui/router/router.dart';
2024-01-31 10:57:12 +00:00
import 'package:selfprivacy/utils/breakpoints.dart';
2020-12-06 07:46:12 +00:00
@RoutePage()
2020-12-02 09:16:23 +00:00
class MorePage extends StatelessWidget {
const MorePage({super.key});
2020-12-02 09:16:23 +00:00
@override
2022-06-05 19:36:32 +00:00
Widget build(final BuildContext context) {
final bool isReady = context.watch<ServerInstallationCubit>().state
2022-05-30 23:06:08 +00:00
is ServerInstallationFinished;
2020-12-03 16:52:53 +00:00
return Scaffold(
appBar: Breakpoints.small.isActive(context)
? PreferredSize(
preferredSize: const Size.fromHeight(52),
child: BrandHeader(
title: 'basis.more'.tr(),
),
)
: null,
2020-12-03 16:52:53 +00:00
body: ListView(
children: [
Padding(
2021-05-25 21:53:54 +00:00
padding: paddingH15V0,
2020-12-03 16:52:53 +00:00
child: Column(
children: [
2022-05-30 23:06:08 +00:00
if (!isReady)
_MoreMenuItem(
title: 'more_page.configuration_wizard'.tr(),
2022-05-30 23:06:08 +00:00
iconData: Icons.change_history_outlined,
goTo: () => const InitializingRoute(),
2022-05-30 23:06:08 +00:00
subtitle: 'not_ready_card.in_menu'.tr(),
accent: true,
),
if (isReady)
_MoreMenuItem(
title: 'more_page.create_ssh_key'.tr(),
iconData: Ionicons.key_outline,
goTo: () => UserDetailsRoute(
login: 'root',
),
),
2022-05-30 23:06:08 +00:00
if (isReady)
_MoreMenuItem(
iconData: Icons.password_outlined,
goTo: () => const RecoveryKeyRoute(),
2022-05-30 23:06:08 +00:00
title: 'recovery_key.key_main_header'.tr(),
),
2022-05-31 14:30:44 +00:00
if (isReady)
_MoreMenuItem(
iconData: Icons.devices_outlined,
goTo: () => const DevicesRoute(),
2022-05-31 14:30:44 +00:00
title: 'devices.main_screen.header'.tr(),
),
2022-05-30 23:06:08 +00:00
_MoreMenuItem(
title: 'application_settings.title'.tr(),
2022-05-30 23:06:08 +00:00
iconData: Icons.settings_outlined,
goTo: () => const AppSettingsRoute(),
2020-12-03 16:52:53 +00:00
),
2022-05-30 23:06:08 +00:00
_MoreMenuItem(
title: 'about_application_page.title'.tr(),
2021-03-18 07:26:54 +00:00
iconData: BrandIcons.fire,
goTo: () => const AboutApplicationRoute(),
longGoTo: const DeveloperSettingsRoute(),
2020-12-03 16:52:53 +00:00
),
2022-05-30 23:06:08 +00:00
if (!isReady)
_MoreMenuItem(
title: 'more_page.onboarding'.tr(),
2022-05-30 23:06:08 +00:00
iconData: BrandIcons.start,
goTo: () => const OnboardingRoute(),
2022-05-30 23:06:08 +00:00
),
_MoreMenuItem(
title: 'console_page.title'.tr(),
2021-03-18 07:26:54 +00:00
iconData: BrandIcons.terminal,
goTo: () => const ConsoleRoute(),
2021-01-14 21:48:05 +00:00
),
2020-12-03 16:52:53 +00:00
],
),
),
2020-12-03 16:52:53 +00:00
],
),
2020-12-02 09:16:23 +00:00
);
}
2021-09-02 19:32:07 +00:00
}
class _MoreMenuItem extends StatelessWidget {
const _MoreMenuItem({
required this.iconData,
required this.title,
required this.goTo,
2022-05-30 23:06:08 +00:00
this.subtitle,
this.longGoTo,
2022-05-30 23:06:08 +00:00
this.accent = false,
2022-06-05 19:36:32 +00:00
});
2021-09-02 19:32:07 +00:00
final IconData iconData;
final String title;
final PageRouteInfo Function() goTo;
final PageRouteInfo? longGoTo;
2022-05-30 23:06:08 +00:00
final String? subtitle;
final bool accent;
2021-09-02 19:32:07 +00:00
@override
2022-06-05 19:36:32 +00:00
Widget build(final BuildContext context) {
final Color color = accent
2022-05-30 23:06:08 +00:00
? Theme.of(context).colorScheme.onTertiaryContainer
: Theme.of(context).colorScheme.onSurface;
return FilledCard(
2022-05-30 23:06:08 +00:00
tertiary: accent,
child: ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
onTap: () => context.pushRoute(goTo()),
onLongPress:
longGoTo != null ? () => context.pushRoute(longGoTo!) : null,
2022-05-30 23:06:08 +00:00
leading: Icon(
iconData,
size: 24,
color: color,
2020-12-02 09:16:23 +00:00
),
2022-05-30 23:06:08 +00:00
title: Text(
title,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
color: color,
),
),
subtitle: subtitle != null
? Text(
subtitle!,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: color,
),
)
: null,
2020-12-02 09:16:23 +00:00
),
);
}
}