2022-09-14 16:46:38 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
import 'package:selfprivacy/logic/models/service.dart';
|
2022-09-16 11:28:17 +00:00
|
|
|
import 'package:selfprivacy/logic/models/disk_status.dart';
|
2022-09-14 16:46:38 +00:00
|
|
|
|
|
|
|
class ServiceMigrationListItem extends StatelessWidget {
|
|
|
|
const ServiceMigrationListItem({
|
|
|
|
required this.service,
|
|
|
|
required this.diskStatus,
|
|
|
|
required this.selectedVolume,
|
|
|
|
required this.onChange,
|
2022-10-26 16:26:09 +00:00
|
|
|
super.key,
|
2022-09-14 16:46:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
final Service service;
|
|
|
|
final DiskStatus diskStatus;
|
|
|
|
final String selectedVolume;
|
|
|
|
final Function onChange;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(final BuildContext context) => Column(
|
|
|
|
children: [
|
2022-09-18 16:06:17 +00:00
|
|
|
ServiceConsumptionTitle(service: service),
|
2022-09-14 16:46:38 +00:00
|
|
|
const SizedBox(height: 16),
|
|
|
|
..._radioRows(context),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
2022-09-18 16:06:17 +00:00
|
|
|
List<Widget> _radioRows(final BuildContext context) {
|
|
|
|
final List<Widget> volumeRows = [];
|
|
|
|
|
|
|
|
for (final DiskVolume volume in diskStatus.diskVolumes) {
|
|
|
|
volumeRows.add(
|
|
|
|
RadioListTile(
|
|
|
|
title: Text(
|
|
|
|
volume.displayName,
|
|
|
|
),
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
activeColor: Theme.of(context).colorScheme.secondary,
|
|
|
|
dense: true,
|
|
|
|
value: volume.name,
|
|
|
|
groupValue: selectedVolume,
|
|
|
|
onChanged: (final value) {
|
|
|
|
onChange(value, service.id);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return volumeRows;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ServiceConsumptionTitle extends StatelessWidget {
|
|
|
|
const ServiceConsumptionTitle({
|
|
|
|
required this.service,
|
2022-10-26 16:26:09 +00:00
|
|
|
super.key,
|
2022-09-18 16:06:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
final Service service;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(final BuildContext context) => SizedBox(
|
2022-09-14 16:46:38 +00:00
|
|
|
height: 24,
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.topLeft,
|
|
|
|
child: SvgPicture.string(
|
|
|
|
service.svgIcon,
|
|
|
|
width: 24.0,
|
|
|
|
height: 24.0,
|
2023-04-12 05:42:33 +00:00
|
|
|
colorFilter: ColorFilter.mode(
|
|
|
|
Theme.of(context).colorScheme.onBackground,
|
|
|
|
BlendMode.srcIn,
|
|
|
|
),
|
2022-09-14 16:46:38 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(width: 16),
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.topLeft,
|
|
|
|
child: Text(
|
|
|
|
service.displayName,
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(width: 16),
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
child: Text(
|
|
|
|
service.storageUsage.used.toString(),
|
|
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|