2022-07-29 05:38:21 +00:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2022-08-24 05:35:49 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
2022-07-29 05:38:21 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/providers/providers_cubit.dart';
|
|
|
|
import 'package:selfprivacy/ui/components/brand_cards/brand_cards.dart';
|
|
|
|
import 'package:selfprivacy/ui/components/icon_status_mask/icon_status_mask.dart';
|
2022-07-31 23:10:37 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/server_storage/disk_status.dart';
|
|
|
|
import 'package:selfprivacy/ui/pages/server_storage/server_storage.dart';
|
2022-08-24 05:35:49 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/server_storage/server_storage_list_item.dart';
|
2022-07-31 23:10:37 +00:00
|
|
|
import 'package:selfprivacy/utils/route_transitions/basic.dart';
|
2022-07-29 05:38:21 +00:00
|
|
|
|
|
|
|
class StorageCard extends StatelessWidget {
|
2022-08-24 05:35:49 +00:00
|
|
|
const StorageCard({
|
|
|
|
required final this.diskStatus,
|
|
|
|
final super.key,
|
|
|
|
});
|
2022-07-29 05:38:21 +00:00
|
|
|
|
2022-08-24 05:35:49 +00:00
|
|
|
final DiskStatus diskStatus;
|
2022-07-29 05:38:21 +00:00
|
|
|
|
|
|
|
@override
|
2022-07-31 23:10:37 +00:00
|
|
|
Widget build(final BuildContext context) {
|
2022-07-29 05:38:21 +00:00
|
|
|
final List<Widget> sections = [];
|
|
|
|
for (final DiskVolume volume in diskStatus.diskVolumes) {
|
|
|
|
sections.add(
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
);
|
|
|
|
sections.add(
|
2022-08-24 05:35:49 +00:00
|
|
|
ServerStorageListItem(
|
|
|
|
volume: volume,
|
|
|
|
dense: true,
|
|
|
|
showIcon: false,
|
2022-07-29 05:38:21 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-08-24 05:35:49 +00:00
|
|
|
StateType state = context.watch<ServerInstallationCubit>().state
|
|
|
|
is ServerInstallationFinished
|
|
|
|
? StateType.stable
|
|
|
|
: StateType.uninitialized;
|
|
|
|
|
|
|
|
if (state == StateType.stable && !diskStatus.isDiskOkay) {
|
|
|
|
state = StateType.error;
|
|
|
|
}
|
|
|
|
|
2022-07-29 05:38:21 +00:00
|
|
|
return GestureDetector(
|
2022-07-31 23:10:37 +00:00
|
|
|
onTap: () => Navigator.of(context).push(
|
|
|
|
materialRoute(
|
|
|
|
ServerStoragePage(
|
|
|
|
diskStatus: diskStatus,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-07-29 05:38:21 +00:00
|
|
|
child: BrandCards.big(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
2022-08-24 05:35:49 +00:00
|
|
|
IconStatusMask(
|
|
|
|
status: state,
|
|
|
|
child: const Icon(
|
2022-07-29 05:38:21 +00:00
|
|
|
Icons.storage_outlined,
|
|
|
|
size: 30,
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
),
|
2022-08-24 05:35:49 +00:00
|
|
|
if (state != StateType.uninitialized)
|
|
|
|
IconStatusMask(
|
|
|
|
status: state,
|
|
|
|
child: Icon(
|
|
|
|
diskStatus.isDiskOkay
|
|
|
|
? Icons.check_circle_outline
|
|
|
|
: Icons.error_outline,
|
|
|
|
size: 24,
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
2022-07-29 05:38:21 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
Text(
|
|
|
|
'providers.storage.card_title'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.titleLarge,
|
|
|
|
),
|
2022-08-24 05:35:49 +00:00
|
|
|
if (state != StateType.uninitialized)
|
|
|
|
Text(
|
|
|
|
diskStatus.isDiskOkay
|
|
|
|
? 'providers.storage.status_ok'.tr()
|
|
|
|
: 'providers.storage.status_error'.tr(),
|
|
|
|
style: Theme.of(context).textTheme.bodyLarge,
|
|
|
|
),
|
2022-07-29 05:38:21 +00:00
|
|
|
...sections,
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|