2022-03-03 17:38:30 +00:00
|
|
|
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';
|
2022-05-18 09:07:14 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
2022-09-14 16:46:38 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_volumes/server_volume_cubit.dart';
|
|
|
|
import 'package:selfprivacy/logic/cubit/services/services_cubit.dart';
|
2022-09-15 16:57:26 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_cards/filled_card.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';
|
2022-05-31 14:30:44 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/devices/devices.dart';
|
2022-05-30 13:55:52 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/recovery_key/recovery_key.dart';
|
2022-09-16 13:49:53 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/server_storage/binds_migration/data_to_binds_migration.dart';
|
2022-05-10 20:42:33 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/setup/initializing.dart';
|
2021-01-06 17:35:57 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/onboarding/onboarding.dart';
|
2022-05-25 12:21:56 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/root_route.dart';
|
2022-09-08 15:13:18 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/users/users.dart';
|
2020-12-02 09:16:23 +00:00
|
|
|
import 'package:selfprivacy/utils/route_transitions/basic.dart';
|
|
|
|
|
2022-06-05 19:36:32 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/more/about/about.dart';
|
|
|
|
import 'package:selfprivacy/ui/pages/more/app_settings/app_setting.dart';
|
|
|
|
import 'package:selfprivacy/ui/pages/more/console/console.dart';
|
|
|
|
import 'package:selfprivacy/ui/pages/more/info/info.dart';
|
2020-12-06 07:46:12 +00:00
|
|
|
|
2020-12-02 09:16:23 +00:00
|
|
|
class MorePage extends StatelessWidget {
|
2022-06-05 22:40:34 +00:00
|
|
|
const MorePage({final 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;
|
|
|
|
|
2022-09-14 16:46:38 +00:00
|
|
|
final bool? usesBinds =
|
|
|
|
context.watch<ApiServerVolumeCubit>().state.usesBinds;
|
|
|
|
|
2020-12-03 16:52:53 +00:00
|
|
|
return Scaffold(
|
|
|
|
appBar: PreferredSize(
|
2022-05-24 18:55:39 +00:00
|
|
|
preferredSize: const Size.fromHeight(52),
|
2021-09-02 19:32:07 +00:00
|
|
|
child: BrandHeader(
|
|
|
|
title: 'basis.more'.tr(),
|
|
|
|
),
|
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-09-14 16:46:38 +00:00
|
|
|
if (isReady && usesBinds != null && !usesBinds)
|
|
|
|
_MoreMenuItem(
|
|
|
|
title: 'providers.storage.start_migration_button'.tr(),
|
|
|
|
iconData: Icons.drive_file_move_outline,
|
2022-09-16 13:49:53 +00:00
|
|
|
goTo: DataToBindsMigrationPage(
|
2022-09-16 13:36:51 +00:00
|
|
|
diskStatus: context
|
|
|
|
.watch<ApiServerVolumeCubit>()
|
|
|
|
.state
|
|
|
|
.diskStatus,
|
2022-09-14 16:46:38 +00:00
|
|
|
services: context
|
|
|
|
.read<ServicesCubit>()
|
|
|
|
.state
|
|
|
|
.services
|
|
|
|
.where(
|
|
|
|
(final service) =>
|
|
|
|
service.id == 'bitwarden' ||
|
|
|
|
service.id == 'gitea' ||
|
|
|
|
service.id == 'pleroma' ||
|
|
|
|
service.id == 'mailserver' ||
|
|
|
|
service.id == 'nextcloud',
|
|
|
|
)
|
|
|
|
.toList(),
|
|
|
|
),
|
|
|
|
subtitle: 'not_ready_card.in_menu'.tr(),
|
|
|
|
accent: true,
|
|
|
|
),
|
2022-05-30 23:06:08 +00:00
|
|
|
if (!isReady)
|
|
|
|
_MoreMenuItem(
|
|
|
|
title: 'more.configuration_wizard'.tr(),
|
|
|
|
iconData: Icons.change_history_outlined,
|
|
|
|
goTo: const InitializingPage(),
|
|
|
|
subtitle: 'not_ready_card.in_menu'.tr(),
|
|
|
|
accent: true,
|
|
|
|
),
|
|
|
|
if (isReady)
|
|
|
|
_MoreMenuItem(
|
2022-06-05 22:40:34 +00:00
|
|
|
title: 'more.create_ssh_key'.tr(),
|
|
|
|
iconData: Ionicons.key_outline,
|
2022-09-08 15:13:18 +00:00
|
|
|
goTo: const UserDetails(
|
|
|
|
login: 'root',
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
|
|
|
),
|
2022-05-30 23:06:08 +00:00
|
|
|
if (isReady)
|
|
|
|
_MoreMenuItem(
|
|
|
|
iconData: Icons.password_outlined,
|
|
|
|
goTo: const RecoveryKey(),
|
|
|
|
title: 'recovery_key.key_main_header'.tr(),
|
|
|
|
),
|
2022-05-31 14:30:44 +00:00
|
|
|
if (isReady)
|
|
|
|
_MoreMenuItem(
|
|
|
|
iconData: Icons.devices_outlined,
|
|
|
|
goTo: const DevicesScreen(),
|
|
|
|
title: 'devices.main_screen.header'.tr(),
|
|
|
|
),
|
2022-05-30 23:06:08 +00:00
|
|
|
_MoreMenuItem(
|
2021-03-25 08:32:00 +00:00
|
|
|
title: 'more.settings.title'.tr(),
|
2022-05-30 23:06:08 +00:00
|
|
|
iconData: Icons.settings_outlined,
|
2022-05-24 18:55:39 +00:00
|
|
|
goTo: const AppSettingsPage(),
|
2020-12-03 16:52:53 +00:00
|
|
|
),
|
2022-05-30 23:06:08 +00:00
|
|
|
_MoreMenuItem(
|
2021-03-15 15:39:44 +00:00
|
|
|
title: 'more.about_project'.tr(),
|
2021-03-18 07:26:54 +00:00
|
|
|
iconData: BrandIcons.engineer,
|
2022-05-24 18:55:39 +00:00
|
|
|
goTo: const AboutPage(),
|
2020-12-03 16:52:53 +00:00
|
|
|
),
|
2022-05-30 23:06:08 +00:00
|
|
|
_MoreMenuItem(
|
2021-03-15 15:39:44 +00:00
|
|
|
title: 'more.about_app'.tr(),
|
2021-03-18 07:26:54 +00:00
|
|
|
iconData: BrandIcons.fire,
|
2022-05-24 18:55:39 +00:00
|
|
|
goTo: const InfoPage(),
|
2020-12-03 16:52:53 +00:00
|
|
|
),
|
2022-05-30 23:06:08 +00:00
|
|
|
if (!isReady)
|
|
|
|
_MoreMenuItem(
|
|
|
|
title: 'more.onboarding'.tr(),
|
|
|
|
iconData: BrandIcons.start,
|
|
|
|
goTo: const OnboardingPage(nextPage: RootPage()),
|
|
|
|
),
|
|
|
|
_MoreMenuItem(
|
2021-03-15 15:39:44 +00:00
|
|
|
title: 'more.console'.tr(),
|
2021-03-18 07:26:54 +00:00
|
|
|
iconData: BrandIcons.terminal,
|
2022-05-24 18:55:39 +00:00
|
|
|
goTo: const Console(),
|
2021-01-14 21:48:05 +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,
|
2022-05-30 23:06:08 +00:00
|
|
|
this.subtitle,
|
|
|
|
this.goTo,
|
|
|
|
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;
|
2022-05-30 23:06:08 +00:00
|
|
|
final Widget? goTo;
|
|
|
|
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;
|
2022-09-15 16:57:26 +00:00
|
|
|
return FilledCard(
|
2022-05-30 23:06:08 +00:00
|
|
|
tertiary: accent,
|
|
|
|
child: ListTile(
|
|
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
|
|
onTap: goTo != null
|
|
|
|
? () => Navigator.of(context).push(materialRoute(goTo!))
|
|
|
|
: null,
|
|
|
|
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
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|