Files
pipelines/app/lib/features/settings/health/health_header.dart
T

64 lines
2.0 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../settings_theme.dart';
import 'health_models.dart';
import 'health_widgets.dart';
class HealthHeader extends StatelessWidget {
const HealthHeader({
super.key,
required this.host,
required this.sampled,
required this.busy,
required this.autoRefresh,
required this.onRefresh,
required this.onAutoRefresh,
});
final JsonMap host;
final Object? sampled;
final bool busy, autoRefresh;
final VoidCallback onRefresh;
final ValueChanged<bool> onAutoRefresh;
@override
Widget build(BuildContext context) => HealthCard(
title: healthText(host['hostname']),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (host['error'] case final String error) Text(error),
Text(
'${healthText(host['platform'])} ${healthText(host['platform_version'])} · ${healthText(host['os'])}',
),
Text(
'Uptime ${healthDuration(host['uptime_seconds'])} · ${healthAge(sampled, DateTime.now())}',
),
Wrap(
alignment: WrapAlignment.spaceBetween,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
HealthAction(label: 'Refresh', onPressed: busy ? null : onRefresh),
Row(
mainAxisSize: MainAxisSize.min,
children: [
const Text('Auto-refresh'),
const SizedBox(width: 8),
Semantics(
label: 'Auto-refresh',
child: usesCupertinoControls(context)
? CupertinoSwitch(
value: autoRefresh,
onChanged: onAutoRefresh,
)
: Switch(value: autoRefresh, onChanged: onAutoRefresh),
),
],
),
],
),
],
),
);
}