diet-guard/app/lib/screens/log_meal_nav_mixin.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

70 lines
2.5 KiB
Dart

import 'package:diet_guard_app/screens/body_screen.dart';
import 'package:diet_guard_app/screens/calendar_screen.dart';
import 'package:diet_guard_app/screens/food_bank_screen.dart';
import 'package:diet_guard_app/screens/history_screen.dart';
import 'package:diet_guard_app/screens/settings_screen.dart';
import 'package:http/http.dart' as http;
import 'package:material_ui/material_ui.dart';
/// The five app-bar destinations reachable from [LogMealScreen].
///
/// Split out of `log_meal_screen.dart` for the repo's 250-line cap. The routes
/// are unchanged -- each pushes exactly the [MaterialPageRoute] it did before.
mixin LogMealNavMixin<T extends StatefulWidget> on State<T> {
/// The screen's injected HTTP client, forwarded to [SettingsScreen].
http.Client? get syncHttpClient;
/// Re-reads the meal schedule and today's logged slots.
///
/// Called when [SettingsScreen] pops, because the schedule editor lives
/// there: without it the slot row keeps rendering the schedule that was in
/// force when this screen was built, so switching from four meals to five
/// showed the old four checkpoints until the app was restarted. Verified on
/// the phone -- the settings preview and the reminder both updated while the
/// row behind them did not.
Future<void> onScheduleMayHaveChanged();
/// Pushes the entry history screen.
void onOpenHistory() {
Navigator.of(
context,
).push<void>(MaterialPageRoute(builder: (_) => const HistoryScreen()));
}
/// Pushes the adherence calendar screen.
void onOpenCalendar() {
Navigator.of(
context,
).push<void>(MaterialPageRoute(builder: (_) => const CalendarScreen()));
}
/// Pushes the Body screen (weight, BMI, calorie targets, week planner).
void onOpenBody() {
Navigator.of(
context,
).push<void>(MaterialPageRoute(builder: (_) => const BodyScreen()));
}
/// Pushes the food bank screen.
void onOpenFoodBank() {
Navigator.of(
context,
).push<void>(MaterialPageRoute(builder: (_) => const FoodBankScreen()));
}
/// Pushes the settings screen, forwarding the HTTP client.
///
/// Awaits the pop, unlike the other three: settings owns the meal-schedule
/// editor, so the slot row has to be rebuilt against whatever the user
/// chose there.
Future<void> onOpenSettings() async {
await Navigator.of(context).push<void>(
MaterialPageRoute(
builder: (_) => SettingsScreen(httpClient: syncHttpClient),
),
);
if (!mounted) return;
await onScheduleMayHaveChanged();
}
}