feat: add route to service cards in storage page (#446)
continuous-integration/drone/push Build is passing Details

Co-authored-by: Inex Code <inex.code@selfprivacy.org>
Reviewed-on: #446
Co-authored-by: dettlaff <dettlaff@riseup.net>
Co-committed-by: dettlaff <dettlaff@riseup.net>
pull/461/head
dettlaff 2024-04-11 13:04:22 +03:00 committed by Inex Code
parent a4737e9f05
commit 0dc281a4f6
1 changed files with 43 additions and 27 deletions

View File

@ -43,8 +43,8 @@ class _ServerStoragePageState extends State<ServerStoragePage> {
return BrandHeroScreen( return BrandHeroScreen(
hasBackButton: true, hasBackButton: true,
heroTitle: 'storage.card_title'.tr(), heroTitle: 'storage.card_title'.tr(),
bodyPadding: const EdgeInsets.symmetric(vertical: 16.0),
children: [ children: [
// ...sections,
...widget.diskStatus.diskVolumes.map( ...widget.diskStatus.diskVolumes.map(
(final volume) => Column( (final volume) => Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@ -87,24 +87,35 @@ class ServerStorageSection extends StatelessWidget {
Widget build(final BuildContext context) => Column( Widget build(final BuildContext context) => Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
ServerStorageListItem( Padding(
volume: volume, padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ServerStorageListItem(
volume: volume,
),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
...services.map( ...services.map(
(final service) => ServerConsumptionListTile( (final service) => ServerConsumptionListTile(
service: service, service: service,
volume: volume, volume: volume,
onTap: () {
context.pushRoute(
ServiceRoute(serviceId: service.id),
);
},
), ),
), ),
if (volume.isResizable) ...[ if (volume.isResizable) ...[
const SizedBox(height: 16), const SizedBox(height: 16),
BrandOutlinedButton( Padding(
title: 'storage.extend_volume_button.title'.tr(), padding: const EdgeInsets.symmetric(horizontal: 16.0),
onPressed: () => context.pushRoute( child: BrandOutlinedButton(
ExtendingVolumeRoute( title: 'storage.extend_volume_button.title'.tr(),
diskVolumeToResize: volume, onPressed: () => context.pushRoute(
diskStatus: diskStatus, ExtendingVolumeRoute(
diskVolumeToResize: volume,
diskStatus: diskStatus,
),
), ),
), ),
), ),
@ -117,33 +128,38 @@ class ServerConsumptionListTile extends StatelessWidget {
const ServerConsumptionListTile({ const ServerConsumptionListTile({
required this.service, required this.service,
required this.volume, required this.volume,
required this.onTap,
super.key, super.key,
}); });
final Service service; final Service service;
final DiskVolume volume; final DiskVolume volume;
final VoidCallback onTap;
@override @override
Widget build(final BuildContext context) => Padding( Widget build(final BuildContext context) => InkWell(
padding: const EdgeInsets.symmetric(vertical: 8), onTap: onTap,
child: ConsumptionListItem( child: Padding(
title: service.displayName, padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
icon: SvgPicture.string( child: ConsumptionListItem(
service.svgIcon, title: service.displayName,
width: 24.0, icon: SvgPicture.string(
height: 24.0, service.svgIcon,
colorFilter: ColorFilter.mode( width: 22.0,
Theme.of(context).colorScheme.onBackground, height: 24.0,
BlendMode.srcIn, colorFilter: ColorFilter.mode(
Theme.of(context).colorScheme.onBackground,
BlendMode.srcIn,
),
), ),
rightSideText: service.storageUsage.used.toString(),
percentage: service.storageUsage.used.byte / volume.sizeTotal.byte,
color: volume.root
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.secondary,
backgroundColor: Theme.of(context).colorScheme.surfaceVariant,
dense: true,
), ),
rightSideText: service.storageUsage.used.toString(),
percentage: service.storageUsage.used.byte / volume.sizeTotal.byte,
color: volume.root
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.secondary,
backgroundColor: Theme.of(context).colorScheme.surfaceVariant,
dense: true,
), ),
); );
} }