import 'package:flutter/material.dart'; import '../../../core/api_gateway.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 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: Switch(value: autoRefresh, onChanged: onAutoRefresh), ), ], ), ], ), ], ), ); }