mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-27 11:16:45 +00:00
Add animation for graph loading
This commit is contained in:
parent
41efde80b2
commit
61d049118f
|
@ -106,6 +106,7 @@
|
||||||
"in": "In",
|
"in": "In",
|
||||||
"out": "Out"
|
"out": "Out"
|
||||||
},
|
},
|
||||||
|
"resource_usage": "Resource usage",
|
||||||
"settings": {
|
"settings": {
|
||||||
"allow_autoupgrade": "Allow auto-upgrade",
|
"allow_autoupgrade": "Allow auto-upgrade",
|
||||||
"allow_autoupgrade_hint": "Allow automatic packages upgrades on server",
|
"allow_autoupgrade_hint": "Allow automatic packages upgrades on server",
|
||||||
|
|
|
@ -11,7 +11,6 @@ class SimpleBlocObserver extends BlocObserver {
|
||||||
final Object error,
|
final Object error,
|
||||||
final StackTrace stackTrace,
|
final StackTrace stackTrace,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
getIt<NavigationService>().showSnackBar(
|
getIt<NavigationService>().showSnackBar(
|
||||||
'Bloc error: ${error.toString()}',
|
'Bloc error: ${error.toString()}',
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,15 +7,7 @@ class _Chart extends StatelessWidget {
|
||||||
final Period period = cubit.state.period;
|
final Period period = cubit.state.period;
|
||||||
final HetznerMetricsState state = cubit.state;
|
final HetznerMetricsState state = cubit.state;
|
||||||
List<Widget> charts;
|
List<Widget> charts;
|
||||||
if (state is HetznerMetricsLoading) {
|
if (state is HetznerMetricsLoaded || state is HetznerMetricsLoading) {
|
||||||
charts = [
|
|
||||||
Container(
|
|
||||||
height: 200,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: Text('basis.loading'.tr()),
|
|
||||||
)
|
|
||||||
];
|
|
||||||
} else if (state is HetznerMetricsLoaded) {
|
|
||||||
charts = [
|
charts = [
|
||||||
FilledCard(
|
FilledCard(
|
||||||
clipped: false,
|
clipped: false,
|
||||||
|
@ -31,7 +23,17 @@ class _Chart extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
getCpuChart(state),
|
Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
if (state is HetznerMetricsLoaded) getCpuChart(state),
|
||||||
|
AnimatedOpacity(
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
opacity: state is HetznerMetricsLoading ? 1 : 0,
|
||||||
|
child: const _GraphLoadingCardContent(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -56,16 +58,28 @@ class _Chart extends StatelessWidget {
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
Legend(
|
Legend(
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
text: 'providers.server.chart.in'.tr()),
|
text: 'providers.server.chart.in'.tr(),
|
||||||
|
),
|
||||||
const SizedBox(width: 5),
|
const SizedBox(width: 5),
|
||||||
Legend(
|
Legend(
|
||||||
color: Theme.of(context).colorScheme.tertiary,
|
color: Theme.of(context).colorScheme.tertiary,
|
||||||
text: 'providers.server.chart.out'.tr()),
|
text: 'providers.server.chart.out'.tr(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
getBandwidthChart(state),
|
Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
if (state is HetznerMetricsLoaded) getBandwidthChart(state),
|
||||||
|
AnimatedOpacity(
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
opacity: state is HetznerMetricsLoading ? 1 : 0,
|
||||||
|
child: const _GraphLoadingCardContent(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -136,6 +150,16 @@ class _Chart extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _GraphLoadingCardContent extends StatelessWidget {
|
||||||
|
const _GraphLoadingCardContent();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(final BuildContext context) => const SizedBox(
|
||||||
|
height: 200,
|
||||||
|
child: Center(child: CircularProgressIndicator()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
class Legend extends StatelessWidget {
|
class Legend extends StatelessWidget {
|
||||||
const Legend({
|
const Legend({
|
||||||
required this.color,
|
required this.color,
|
||||||
|
|
|
@ -88,11 +88,17 @@ class _ServerDetailsScreenState extends State<ServerDetailsScreen>
|
||||||
context.read<ApiProviderVolumeCubit>().state.volumes,
|
context.read<ApiProviderVolumeCubit>().state.volumes,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const Divider(height: 32),
|
||||||
|
Text(
|
||||||
|
'providers.server.resource_usage'.tr(),
|
||||||
|
style: Theme.of(context).textTheme.titleLarge,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (final context) => HetznerMetricsCubit()..restart(),
|
create: (final context) => HetznerMetricsCubit()..restart(),
|
||||||
child: _Chart(),
|
child: _Chart(),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const Divider(height: 32),
|
||||||
_TextDetails(),
|
_TextDetails(),
|
||||||
const _ServerSettings(),
|
const _ServerSettings(),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue