mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-22 15:42:19 +01:00
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
68 lines
2.4 KiB
Dart
68 lines
2.4 KiB
Dart
import 'package:diet_guard_app/models/food_suggestion.dart';
|
|
import 'package:diet_guard_app/models/nutrition.dart';
|
|
import 'package:diet_guard_app/screens/log_meal_progress.dart';
|
|
import 'package:diet_guard_app/widgets/macro_input_row.dart';
|
|
import 'package:material_ui/material_ui.dart';
|
|
|
|
/// Writes [suggestion]'s name and macros into the log form's controllers.
|
|
///
|
|
/// Split out of `log_meal_screen.dart` for the repo's 250-line cap, mirroring
|
|
/// `log_meal_kuchnia_mixin.dart`'s `fillControllersFromDish`.
|
|
void fillControllersFromSuggestion(
|
|
FoodSuggestion suggestion,
|
|
TextEditingController desc,
|
|
MacroControllers macros,
|
|
) {
|
|
desc.text = suggestion.name;
|
|
macros.fillFrom(suggestion.nutrition);
|
|
}
|
|
|
|
/// Builds the [Nutrition] for a submit from the form's macro controllers.
|
|
///
|
|
/// Split out of `log_meal_screen.dart` for the repo's 250-line cap. Pure over
|
|
/// its inputs, so the per-portion scaling is testable without a widget.
|
|
Nutrition nutritionFromControllers(MacroControllers macros, String source) =>
|
|
nutritionForPortion(
|
|
kcal: parseMacroField(macros.kcal),
|
|
proteinG: parseMacroField(macros.protein),
|
|
carbsG: parseMacroField(macros.carbs),
|
|
fatG: parseMacroField(macros.fat),
|
|
perGrams: parseMacroField(macros.perGrams),
|
|
ateGrams: parseMacroField(macros.grams),
|
|
source: source,
|
|
);
|
|
|
|
/// The five destination buttons in [LogMealScreen]'s app bar.
|
|
///
|
|
/// Split out of `log_meal_screen.dart` for the repo's 250-line cap. Returned
|
|
/// as a list to be spread into `AppBar.actions`, so the bar's structure and
|
|
/// the order of the buttons are unchanged.
|
|
List<Widget> logMealAppBarActions({
|
|
required VoidCallback onFoodBank,
|
|
required VoidCallback onHistory,
|
|
required VoidCallback onCalendar,
|
|
required VoidCallback onSettings,
|
|
required VoidCallback onBody,
|
|
}) => [
|
|
IconButton(
|
|
icon: const Icon(Icons.monitor_weight, semanticLabel: 'Body'),
|
|
onPressed: onBody,
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.restaurant_menu, semanticLabel: 'Food bank'),
|
|
onPressed: onFoodBank,
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.history, semanticLabel: 'History'),
|
|
onPressed: onHistory,
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.calendar_month, semanticLabel: 'Calendar'),
|
|
onPressed: onCalendar,
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.settings, semanticLabel: 'Sync settings'),
|
|
onPressed: onSettings,
|
|
),
|
|
];
|