mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-22 22:42:18 +01:00
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
file-length / file length <= 250 lines (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint) (push) Waiting to run
Tests / test (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWWy9HCAx2bNSRPvmTW
70 lines
2.4 KiB
Dart
70 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.
|
|
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 destination buttons in [LogMealScreen]'s app bar, after [leading]
|
|
/// (the date picker).
|
|
///
|
|
/// 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,
|
|
List<Widget> leading = const [],
|
|
}) => [
|
|
...leading,
|
|
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,
|
|
),
|
|
];
|