fix: Hide memory metrics card when there are none

This commit is contained in:
Inex Code 2024-07-30 15:32:04 +03:00
parent e065463ffb
commit 751de80840

View file

@ -39,49 +39,51 @@ class _Chart extends StatelessWidget {
),
),
const SizedBox(height: 8),
FilledCard(
clipped: false,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'resource_chart.memory'.tr(),
style: Theme.of(context).textTheme.titleMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
const SizedBox(height: 16),
Stack(
alignment: Alignment.center,
children: [
if (state is MetricsLoaded && state.memoryMetrics != null)
getMemoryChart(state),
AnimatedOpacity(
duration: const Duration(milliseconds: 200),
opacity: state is MetricsLoading ? 1 : 0,
child: const _GraphLoadingCardContent(),
),
],
),
const Divider(),
ListTile(
title: Text('resource_chart.view_usage_by_service'.tr()),
leading: Icon(
Icons.area_chart_outlined,
color: Theme.of(context).colorScheme.onSurfaceVariant,
if (!(state is MetricsLoaded && state.memoryMetrics == null))
FilledCard(
clipped: false,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'resource_chart.memory'.tr(),
style: Theme.of(context).textTheme.titleMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
onTap: () {
context.pushRoute(
const MemoryUsageByServiceRoute(),
);
},
),
],
const SizedBox(height: 16),
Stack(
alignment: Alignment.center,
children: [
if (state is MetricsLoaded && state.memoryMetrics != null)
getMemoryChart(state),
AnimatedOpacity(
duration: const Duration(milliseconds: 200),
opacity: state is MetricsLoading ? 1 : 0,
child: const _GraphLoadingCardContent(),
),
],
),
const Divider(),
ListTile(
title: Text('resource_chart.view_usage_by_service'.tr()),
leading: Icon(
Icons.area_chart_outlined,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
onTap: () {
context.pushRoute(
const MemoryUsageByServiceRoute(),
);
},
enabled: state is MetricsLoaded,
),
],
),
),
),
),
const SizedBox(height: 8),
FilledCard(
clipped: false,