diet-guard/app/lib/widgets/body/formula_figure.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

66 lines
1.7 KiB
Dart

/// A kcal formula shown as a glyph + number; its proper name is only the
/// glyph's spoken label.
library;
import 'package:diet_guard_app/services/activity_kcal.dart';
import 'package:diet_guard_app/ui/theme.dart';
import 'package:material_ui/material_ui.dart';
/// One distinct glyph per entry of [activityFormulas].
const Map<String, IconData> formulaIcons = {
'MET': Icons.speed,
'ACSM': Icons.functions,
'Per-km': Icons.straighten,
};
/// The glyph for formula [name], spoken as the formula's proper name.
class FormulaGlyph extends StatelessWidget {
/// Creates a glyph for [name].
const FormulaGlyph(this.name, {this.size = 16, super.key});
/// The formula's proper name (a key of [formulaIcons]).
final String name;
/// Glyph size.
final double size;
// The proper name is spoken only: a tooltip paints on long-press.
@override
Widget build(BuildContext context) => Icon(
formulaIcons[name],
size: size,
color: Theme.of(context).colorScheme.onSurfaceVariant,
semanticLabel: name,
);
}
/// Glyph + number (a trailing `~` marks a figure that reuses the MET value).
class FormulaFigure extends StatelessWidget {
/// Creates a figure.
const FormulaFigure(
this.name,
this.value, {
this.fallback = false,
super.key,
});
/// The formula's proper name.
final String name;
/// The formatted kcal number.
final String value;
/// Whether the figure is a fallback to the MET value.
final bool fallback;
@override
Widget build(BuildContext context) => Row(
mainAxisSize: MainAxisSize.min,
children: [
FormulaGlyph(name),
const SizedBox(width: AppSpacing.xs),
Text(fallback ? '$value~' : value),
],
);
}