2022-05-18 10:39:11 +00:00
|
|
|
part of 'server_details_screen.dart';
|
2021-04-10 03:04:23 +00:00
|
|
|
|
|
|
|
class _TextDetails extends StatelessWidget {
|
|
|
|
@override
|
2022-06-05 22:40:34 +00:00
|
|
|
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) {
|
2022-06-05 22:40:34 +00:00
|
|
|
final data = details.serverInfo;
|
2022-09-18 13:24:17 +00:00
|
|
|
return FilledCard(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
child: Text(
|
2022-10-03 23:32:35 +00:00
|
|
|
'server.general_information'.tr(),
|
2022-09-18 13:24:17 +00:00
|
|
|
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
|
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
|
|
),
|
2021-04-10 03:04:23 +00:00
|
|
|
),
|
2022-09-18 13:24:17 +00:00
|
|
|
),
|
|
|
|
ListTileOnSurfaceVariant(
|
|
|
|
leadingIcon: Icons.numbers_outlined,
|
|
|
|
title: data.id.toString(),
|
2022-10-03 23:32:35 +00:00
|
|
|
subtitle: 'server.server_id'.tr(),
|
2022-09-18 13:24:17 +00:00
|
|
|
),
|
|
|
|
ListTileOnSurfaceVariant(
|
|
|
|
leadingIcon: Icons.mode_standby_outlined,
|
|
|
|
title: data.status.toString().split('.')[1].capitalize(),
|
2022-10-03 23:32:35 +00:00
|
|
|
subtitle: 'server.status'.tr(),
|
2022-09-18 13:24:17 +00:00
|
|
|
),
|
|
|
|
ListTileOnSurfaceVariant(
|
|
|
|
leadingIcon: Icons.memory_outlined,
|
2022-10-03 23:32:35 +00:00
|
|
|
title: 'server.core_count'.plural(data.serverType.cores),
|
|
|
|
subtitle: 'server.cpu'.tr(),
|
2022-09-18 13:24:17 +00:00
|
|
|
),
|
|
|
|
ListTileOnSurfaceVariant(
|
|
|
|
leadingIcon: Icons.memory_outlined,
|
|
|
|
title: '${data.serverType.memory.toString()} GB',
|
2022-10-03 23:32:35 +00:00
|
|
|
subtitle: 'server.ram'.tr(),
|
2022-09-18 13:24:17 +00:00
|
|
|
),
|
|
|
|
ListTileOnSurfaceVariant(
|
|
|
|
leadingIcon: Icons.euro_outlined,
|
|
|
|
title: data.serverType.prices[1].monthly.toStringAsFixed(2),
|
2022-10-03 23:32:35 +00:00
|
|
|
subtitle: 'server.monthly_cost'.tr(),
|
2022-09-18 13:24:17 +00:00
|
|
|
),
|
|
|
|
// Server location
|
|
|
|
ListTileOnSurfaceVariant(
|
|
|
|
leadingIcon: Icons.location_on_outlined,
|
|
|
|
title: '${data.location.city}, ${data.location.country}',
|
2022-10-03 23:32:35 +00:00
|
|
|
subtitle: 'server.location'.tr(),
|
2022-09-18 13:24:17 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2021-04-10 03:04:23 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
throw Exception('wrong state');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-05 22:40:34 +00:00
|
|
|
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
|
|
|
|
2022-06-05 22:40:34 +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,
|
2022-06-05 22:40:34 +00:00
|
|
|
});
|
2021-04-10 03:04:23 +00:00
|
|
|
|
|
|
|
final String message;
|
|
|
|
@override
|
2022-06-05 22:40:34 +00:00
|
|
|
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');
|