diet-guard/app/lib/widgets/sync_health_banner.dart
Krzysztof kuhy Rudnicki 49144a2c49 Move the app to material_ui for Flutter 3.50
Flutter 3.50 deprecates package:flutter/material.dart; 73 deprecation
infos failed flutter analyze --fatal-infos, and four Dart pins were
behind (crdt_sync_flutter 0.8.2, flutter_local_notifications 23.0.2,
github_device_auth 0.5.0, sync_settings_ui 0.8.2). Those UI packages
now sit on material_ui, so the app has to as well or their widgets lose
MaterialLocalizations.

Imports swap one-for-one and dart fix re-sorted the directives; no
behaviour change. analyze is clean and all six test shards pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
2026-11-16 09:25:34 +01:00

64 lines
2.4 KiB
Dart

/// The "not syncing" banner for the log screen.
library;
import 'package:diet_guard_app/services/sync_health.dart';
import 'package:diet_guard_app/ui/theme.dart';
import 'package:material_ui/material_ui.dart';
/// Warns, in place, that meals logged here are not reaching other devices.
///
/// Renders nothing at all unless [SyncHealthStatus.isStalled], so a healthy
/// device never pays for it. This is deliberately on the log screen rather
/// than buried in Settings: the whole failure mode being guarded against is
/// one that stayed invisible while the user kept logging meals that went
/// nowhere.
class SyncHealthBanner extends StatelessWidget {
/// Creates a [SyncHealthBanner] for [status].
const SyncHealthBanner({required this.status, super.key});
/// The health to render, or null before the first read.
final SyncHealthStatus? status;
@override
Widget build(BuildContext context) {
final message = status?.message;
if (message == null) return const SizedBox.shrink();
final theme = Theme.of(context);
// Null-safe lookup, matching slot_selector_row/day_status_calendar: a
// widget test that pumps a bare MaterialApp has no theme extension, and
// `!` there is a crash rather than a missing colour.
final warning =
(theme.extension<AppStatusColors>() ?? AppStatusColors.dark).warning;
return Container(
margin: const EdgeInsets.only(bottom: 12),
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
decoration: BoxDecoration(
// A tinted fill plus a border, no shadow: the unified design system
// allows only one depth technique per surface, and shadows are out
// entirely in dark UI.
color: warning.withValues(alpha: 0.12),
border: Border.all(color: warning.withValues(alpha: 0.5)),
borderRadius: BorderRadius.circular(8),
),
// A glyph and, once an hour or more has passed, the elapsed time as a
// numeral (`2d`). The sentence survives only as the spoken label.
child: Row(
children: [
Icon(
Icons.cloud_off,
size: 18,
color: warning,
semanticLabel: message,
),
const SizedBox(width: 8),
if (status?.agoShort case final ago?)
Text(
ago,
style: theme.textTheme.bodySmall?.copyWith(color: warning),
),
],
),
);
}
}