mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 00:51:20 +00:00
refactor(ui): Extract cards from ProvidersPage
This commit is contained in:
parent
d83f8b4723
commit
4b3a6685f6
|
@ -1,3 +1,3 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
const EdgeInsets paddingH15V0 = EdgeInsets.symmetric(horizontal: 15);
|
||||
const EdgeInsets paddingH16V0 = EdgeInsets.symmetric(horizontal: 16);
|
||||
|
|
72
lib/ui/molecules/cards/provider_screen_card.dart
Normal file
72
lib/ui/molecules/cards/provider_screen_card.dart
Normal file
|
@ -0,0 +1,72 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:selfprivacy/logic/models/state_types.dart';
|
||||
import 'package:selfprivacy/ui/atoms/masks/icon_status_mask.dart';
|
||||
|
||||
class ProviderScreenCard extends StatelessWidget {
|
||||
const ProviderScreenCard({
|
||||
required this.state,
|
||||
required this.icon,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
this.onTap,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final Function()? onTap;
|
||||
final StateType state;
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final String subtitle;
|
||||
|
||||
@override
|
||||
Widget build(final BuildContext context) => Card(
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: InkResponse(
|
||||
highlightShape: BoxShape.rectangle,
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
IconStatusMask(
|
||||
status: state,
|
||||
icon: Icon(icon, size: 32, color: Colors.white),
|
||||
),
|
||||
const Gap(8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
),
|
||||
if (state != StateType.uninitialized)
|
||||
IconStatusMask(
|
||||
status: state,
|
||||
icon: Icon(
|
||||
state == StateType.stable
|
||||
? Icons.check_circle_outline
|
||||
: state == StateType.warning
|
||||
? Icons.warning_amber_outlined
|
||||
: Icons.error_outline,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
if (state != StateType.uninitialized)
|
||||
Text(
|
||||
subtitle,
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
|
@ -108,7 +108,7 @@ class JobsContent extends StatelessWidget {
|
|||
}
|
||||
return ListView(
|
||||
controller: controller,
|
||||
padding: paddingH15V0,
|
||||
padding: paddingH16V0,
|
||||
children: [
|
||||
const Gap(16),
|
||||
Center(
|
||||
|
|
|
@ -28,7 +28,7 @@ class MorePage extends StatelessWidget {
|
|||
body: ListView(
|
||||
children: [
|
||||
Padding(
|
||||
padding: paddingH15V0,
|
||||
padding: paddingH16V0,
|
||||
child: Column(
|
||||
children: [
|
||||
if (!isReady)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:selfprivacy/config/brand_theme.dart';
|
||||
import 'package:selfprivacy/logic/bloc/backups/backups_bloc.dart';
|
||||
import 'package:selfprivacy/logic/bloc/outdated_server_checker/outdated_server_checker_bloc.dart';
|
||||
|
@ -10,8 +9,8 @@ import 'package:selfprivacy/logic/cubit/dns_records/dns_records_cubit.dart';
|
|||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||
import 'package:selfprivacy/logic/models/state_types.dart';
|
||||
import 'package:selfprivacy/ui/atoms/icons/brand_icons.dart';
|
||||
import 'package:selfprivacy/ui/atoms/masks/icon_status_mask.dart';
|
||||
import 'package:selfprivacy/ui/molecules/cards/not_ready_card.dart';
|
||||
import 'package:selfprivacy/ui/molecules/cards/provider_screen_card.dart';
|
||||
import 'package:selfprivacy/ui/molecules/cards/server_outdated_card.dart';
|
||||
import 'package:selfprivacy/ui/organisms/headers/brand_header.dart';
|
||||
import 'package:selfprivacy/ui/router/router.dart';
|
||||
|
@ -75,7 +74,7 @@ class _ProvidersPageState extends State<ProvidersPage> {
|
|||
)
|
||||
: null,
|
||||
body: ListView(
|
||||
padding: paddingH15V0,
|
||||
padding: paddingH16V0,
|
||||
children: [
|
||||
if (!isReady) ...[
|
||||
const NotReadyCard(),
|
||||
|
@ -90,7 +89,7 @@ class _ProvidersPageState extends State<ProvidersPage> {
|
|||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
_Card(
|
||||
ProviderScreenCard(
|
||||
state: getServerStatus(),
|
||||
icon: BrandIcons.server,
|
||||
title: 'server.card_title'.tr(),
|
||||
|
@ -102,7 +101,7 @@ class _ProvidersPageState extends State<ProvidersPage> {
|
|||
: null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_Card(
|
||||
ProviderScreenCard(
|
||||
state: getDnsStatus(),
|
||||
icon: BrandIcons.globe,
|
||||
title: 'domain.screen_title'.tr(),
|
||||
|
@ -114,7 +113,7 @@ class _ProvidersPageState extends State<ProvidersPage> {
|
|||
: null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_Card(
|
||||
ProviderScreenCard(
|
||||
state: isBackupInitialized
|
||||
? StateType.stable
|
||||
: StateType.uninitialized,
|
||||
|
@ -130,70 +129,3 @@ class _ProvidersPageState extends State<ProvidersPage> {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Card extends StatelessWidget {
|
||||
const _Card({
|
||||
required this.state,
|
||||
required this.icon,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
this.onTap,
|
||||
});
|
||||
|
||||
final Function()? onTap;
|
||||
final StateType state;
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final String subtitle;
|
||||
|
||||
@override
|
||||
Widget build(final BuildContext context) => Card(
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: InkResponse(
|
||||
highlightShape: BoxShape.rectangle,
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
IconStatusMask(
|
||||
status: state,
|
||||
icon: Icon(icon, size: 30, color: Colors.white),
|
||||
),
|
||||
const Gap(8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
),
|
||||
if (state != StateType.uninitialized)
|
||||
IconStatusMask(
|
||||
status: state,
|
||||
icon: Icon(
|
||||
state == StateType.stable
|
||||
? Icons.check_circle_outline
|
||||
: state == StateType.warning
|
||||
? Icons.warning_amber_outlined
|
||||
: Icons.error_outline,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
if (state != StateType.uninitialized)
|
||||
Text(
|
||||
subtitle,
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ import 'package:selfprivacy/logic/cubit/metrics/metrics_cubit.dart';
|
|||
import 'package:selfprivacy/logic/models/disk_size.dart';
|
||||
import 'package:selfprivacy/ui/atoms/buttons/segmented_buttons.dart';
|
||||
import 'package:selfprivacy/ui/atoms/icons/brand_icons.dart';
|
||||
import 'package:selfprivacy/ui/molecules/placeholders/empty_page_placeholder.dart';
|
||||
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
|
||||
import 'package:selfprivacy/ui/molecules/placeholders/empty_page_placeholder.dart';
|
||||
|
||||
@RoutePage()
|
||||
class MemoryUsageByServiceScreen extends StatelessWidget {
|
||||
|
|
|
@ -11,8 +11,8 @@ import 'package:selfprivacy/logic/models/service.dart';
|
|||
import 'package:selfprivacy/logic/models/state_types.dart';
|
||||
import 'package:selfprivacy/ui/atoms/icons/brand_icons.dart';
|
||||
import 'package:selfprivacy/ui/atoms/masks/icon_status_mask.dart';
|
||||
import 'package:selfprivacy/ui/molecules/placeholders/empty_page_placeholder.dart';
|
||||
import 'package:selfprivacy/ui/molecules/cards/server_outdated_card.dart';
|
||||
import 'package:selfprivacy/ui/molecules/placeholders/empty_page_placeholder.dart';
|
||||
import 'package:selfprivacy/ui/organisms/headers/brand_header.dart';
|
||||
import 'package:selfprivacy/ui/router/router.dart';
|
||||
import 'package:selfprivacy/utils/breakpoints.dart';
|
||||
|
@ -56,7 +56,7 @@ class _ServicesPageState extends State<ServicesPage> {
|
|||
: RefreshIndicator(
|
||||
onRefresh: context.read<ServicesBloc>().awaitReload,
|
||||
child: ListView(
|
||||
padding: paddingH15V0,
|
||||
padding: paddingH16V0,
|
||||
children: [
|
||||
if (outdatedServerCheckerState
|
||||
is OutdatedServerCheckerOutdated) ...[
|
||||
|
|
|
@ -36,7 +36,7 @@ class ResetPassword extends StatelessWidget {
|
|||
),
|
||||
const SizedBox(width: 14),
|
||||
Padding(
|
||||
padding: paddingH15V0,
|
||||
padding: paddingH16V0,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
|
|
|
@ -14,7 +14,7 @@ class _User extends StatelessWidget {
|
|||
context.pushRoute(UserDetailsRoute(login: user.login));
|
||||
},
|
||||
child: Container(
|
||||
padding: paddingH15V0,
|
||||
padding: paddingH16V0,
|
||||
height: 48,
|
||||
child: Row(
|
||||
children: [
|
||||
|
|
|
@ -314,7 +314,7 @@ class NewSshKey extends StatelessWidget {
|
|||
),
|
||||
const SizedBox(width: 14),
|
||||
Padding(
|
||||
padding: paddingH15V0,
|
||||
padding: paddingH16V0,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
|
|
|
@ -19,10 +19,10 @@ import 'package:selfprivacy/ui/atoms/buttons/outlined_button.dart';
|
|||
import 'package:selfprivacy/ui/atoms/cards/filled_card.dart';
|
||||
import 'package:selfprivacy/ui/atoms/icons/brand_icons.dart';
|
||||
import 'package:selfprivacy/ui/atoms/list_tiles/list_tile_on_surface_variant.dart';
|
||||
import 'package:selfprivacy/ui/molecules/placeholders/empty_page_placeholder.dart';
|
||||
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
|
||||
import 'package:selfprivacy/ui/molecules/cards/server_outdated_card.dart';
|
||||
import 'package:selfprivacy/ui/molecules/info_box/info_box.dart';
|
||||
import 'package:selfprivacy/ui/molecules/placeholders/empty_page_placeholder.dart';
|
||||
import 'package:selfprivacy/ui/organisms/headers/brand_header.dart';
|
||||
import 'package:selfprivacy/ui/router/router.dart';
|
||||
import 'package:selfprivacy/utils/breakpoints.dart';
|
||||
|
|
Loading…
Reference in a new issue