2023-02-24 16:45:32 +00:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
2024-01-31 05:14:23 +00:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2020-12-01 19:08:19 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:selfprivacy/config/brand_theme.dart';
|
2024-07-26 14:43:57 +00:00
|
|
|
import 'package:selfprivacy/logic/bloc/outdated_server_checker/outdated_server_checker_bloc.dart';
|
2024-01-29 15:57:22 +00:00
|
|
|
import 'package:selfprivacy/logic/bloc/services/services_bloc.dart';
|
2024-01-31 10:57:12 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
2024-11-06 00:22:30 +00:00
|
|
|
import 'package:selfprivacy/ui/atoms/icons/brand_icons.dart';
|
|
|
|
import 'package:selfprivacy/ui/molecules/cards/server_outdated_card.dart';
|
2024-11-11 01:36:18 +00:00
|
|
|
import 'package:selfprivacy/ui/molecules/cards/services_page_card.dart';
|
2024-11-11 01:00:33 +00:00
|
|
|
import 'package:selfprivacy/ui/molecules/placeholders/empty_page_placeholder.dart';
|
2024-11-06 00:22:30 +00:00
|
|
|
import 'package:selfprivacy/ui/organisms/headers/brand_header.dart';
|
2023-02-23 14:49:14 +00:00
|
|
|
import 'package:selfprivacy/utils/breakpoints.dart';
|
2020-12-01 19:08:19 +00:00
|
|
|
|
2023-03-22 11:38:18 +00:00
|
|
|
@RoutePage()
|
2020-12-01 19:08:19 +00:00
|
|
|
class ServicesPage extends StatefulWidget {
|
2022-10-26 16:26:09 +00:00
|
|
|
const ServicesPage({super.key});
|
2020-12-01 19:08:19 +00:00
|
|
|
|
|
|
|
@override
|
2022-05-25 12:21:56 +00:00
|
|
|
State<ServicesPage> createState() => _ServicesPageState();
|
2020-12-01 19:08:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class _ServicesPageState extends State<ServicesPage> {
|
|
|
|
@override
|
2022-06-05 22:40:34 +00:00
|
|
|
Widget build(final BuildContext context) {
|
|
|
|
final isReady = context.watch<ServerInstallationCubit>().state
|
2022-05-17 13:31:34 +00:00
|
|
|
is ServerInstallationFinished;
|
2021-01-06 17:35:57 +00:00
|
|
|
|
2024-07-26 14:43:57 +00:00
|
|
|
final OutdatedServerCheckerState outdatedServerCheckerState =
|
|
|
|
context.watch<OutdatedServerCheckerBloc>().state;
|
|
|
|
|
2024-01-29 15:57:22 +00:00
|
|
|
final services = [...context.watch<ServicesBloc>().state.services];
|
2022-12-31 05:08:25 +00:00
|
|
|
services
|
|
|
|
.sort((final a, final b) => a.status.index.compareTo(b.status.index));
|
|
|
|
|
2020-12-01 19:08:19 +00:00
|
|
|
return Scaffold(
|
2023-02-23 14:49:14 +00:00
|
|
|
appBar: Breakpoints.small.isActive(context)
|
2024-05-15 16:01:27 +00:00
|
|
|
? BrandHeader(
|
|
|
|
title: 'basis.services'.tr(),
|
2023-02-23 14:49:14 +00:00
|
|
|
)
|
|
|
|
: null,
|
2023-09-24 01:17:54 +00:00
|
|
|
body: !isReady
|
|
|
|
? EmptyPagePlaceholder(
|
|
|
|
showReadyCard: true,
|
|
|
|
title: 'service_page.nothing_here'.tr(),
|
|
|
|
description: 'basis.please_connect'.tr(),
|
2023-09-26 17:20:13 +00:00
|
|
|
iconData: BrandIcons.box,
|
2023-03-27 17:02:44 +00:00
|
|
|
)
|
2023-09-24 01:17:54 +00:00
|
|
|
: RefreshIndicator(
|
2024-01-31 11:14:37 +00:00
|
|
|
onRefresh: context.read<ServicesBloc>().awaitReload,
|
2023-09-24 01:17:54 +00:00
|
|
|
child: ListView(
|
2024-11-11 01:00:33 +00:00
|
|
|
padding: paddingH16V0,
|
2023-09-24 01:17:54 +00:00
|
|
|
children: [
|
2024-07-26 14:43:57 +00:00
|
|
|
if (outdatedServerCheckerState
|
|
|
|
is OutdatedServerCheckerOutdated) ...[
|
|
|
|
ServerOutdatedCard(
|
|
|
|
requiredVersion:
|
|
|
|
outdatedServerCheckerState.requiredVersion.toString(),
|
|
|
|
currentVersion:
|
|
|
|
outdatedServerCheckerState.currentVersion.toString(),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
],
|
2023-09-24 01:17:54 +00:00
|
|
|
Text(
|
|
|
|
'basis.services_title'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.bodyLarge,
|
|
|
|
),
|
2024-11-11 01:36:18 +00:00
|
|
|
const SizedBox(height: 16),
|
2023-09-24 01:17:54 +00:00
|
|
|
...services.map(
|
|
|
|
(final service) => Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
2024-11-11 01:36:18 +00:00
|
|
|
bottom: 16,
|
2023-09-24 01:17:54 +00:00
|
|
|
),
|
2024-11-11 01:36:18 +00:00
|
|
|
child: ServicesPageCard(service: service),
|
2023-09-24 01:17:54 +00:00
|
|
|
),
|
2023-11-06 13:15:38 +00:00
|
|
|
),
|
2023-09-24 01:17:54 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2020-12-01 19:08:19 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|