selfprivacy.org.app/lib/ui/pages/server_details/text_details.dart

88 lines
2.6 KiB
Dart
Raw Normal View History

part of 'server_details_screen.dart';
2021-04-10 03:04:23 +00:00
class _TextDetails extends StatelessWidget {
final Map<MetadataType, IconData> metadataToIcon = const {
MetadataType.id: Icons.numbers_outlined,
MetadataType.status: Icons.mode_standby_outlined,
MetadataType.cpu: Icons.memory_outlined,
MetadataType.ram: Icons.memory_outlined,
MetadataType.cost: Icons.euro_outlined,
MetadataType.location: Icons.location_on_outlined,
MetadataType.other: Icons.info_outlined,
};
2021-04-10 03:04:23 +00:00
@override
Widget build(final BuildContext context) {
final details = context.watch<ServerDetailsCubit>().state;
2021-04-10 03:04:23 +00:00
if (details is ServerDetailsLoading || details is ServerDetailsInitial) {
return _TempMessage(message: 'basis.loading'.tr());
} else if (details is ServerDetailsNotReady) {
return _TempMessage(message: 'basis.no_data'.tr());
} else if (details is Loaded) {
return FilledCard(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
'server.general_information'.tr(),
style: Theme.of(context).textTheme.titleMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
2021-04-10 03:04:23 +00:00
),
),
...details.metadata
.map(
(final metadata) => ListTileOnSurfaceVariant(
leadingIcon: metadataToIcon[metadata.type],
title: metadata.name,
subtitle: metadata.value,
),
)
.toList(),
],
),
2021-04-10 03:04:23 +00:00
);
} else {
throw Exception('wrong state');
}
}
Widget getRowTitle(final String title) => Padding(
padding: const EdgeInsets.only(right: 10),
child: BrandText.h5(
title,
textAlign: TextAlign.right,
),
);
2021-04-10 03:04:23 +00:00
Widget getRowValue(final String title, {final bool isBold = false}) =>
BrandText.body1(
title,
style: isBold
? const TextStyle(
fontWeight: NamedFontWeight.demiBold,
)
: null,
);
2021-04-10 03:04:23 +00:00
}
class _TempMessage extends StatelessWidget {
const _TempMessage({
required this.message,
});
2021-04-10 03:04:23 +00:00
final String message;
@override
Widget build(final BuildContext context) => SizedBox(
height: MediaQuery.of(context).size.height - 100,
child: Center(
child: BrandText.body2(message),
),
);
2021-04-10 03:04:23 +00:00
}
2022-02-16 07:28:29 +00:00
final DateFormat formatter = DateFormat('HH:mm:ss');