diet-guard/app/lib/widgets/body/goal_icons.dart
Krzysztof kuhy Rudnicki 2dc502bbb6
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
Speak formula names, fit sheet value
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 18:11:23 +01:00

46 lines
1.6 KiB
Dart

/// Glyphs for the goal's enumerations (direction, time unit, activity), so
/// the goal reads as a row of icons and numbers instead of a sentence.
library;
import 'package:diet_guard_app/services/body_energy.dart';
import 'package:diet_guard_app/widgets/body/formula_figure.dart';
import 'package:flutter/material.dart';
/// Lose = down arrow, maintain = level bar, gain = up arrow.
IconData directionIcon(String direction) => switch (direction) {
'lose' => Icons.south,
'gain' => Icons.north,
_ => Icons.drag_handle,
};
/// Day / week / month / year as calendar views of growing span.
IconData timeUnitIcon(String unit) => switch (unit) {
'day' => Icons.calendar_view_day,
'week' => Icons.calendar_view_week,
'month' => Icons.calendar_view_month,
_ => Icons.event_repeat,
};
/// The five levels ramp from a chair to a barbell; a measured choice wears
/// its formula's glyph (the same one the Activity sheet shows next to kcal).
IconData activityIcon(String key) => switch (key) {
'sedentary' => Icons.chair,
'light' => Icons.directions_walk,
'moderate' => Icons.directions_bike,
'very' => Icons.directions_run,
'extra' => Icons.fitness_center,
_ when key.startsWith(measuredPrefix) =>
formulaIcons[key.substring(measuredPrefix.length)] ?? Icons.speed,
_ => Icons.speed,
};
/// Numeric caption under an activity icon: the TDEE multiplier of a level.
/// Null for a measured formula (its glyph names it; the proper name is only
/// spoken) and for an unknown key.
String? activityCaption(String key) {
for (final level in activityLevels) {
if (level.key == key) return formatG(level.factor);
}
return null;
}