mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-10 20:47:12 +01:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWYndZhdUrRGFEjBazQ
34 lines
973 B
Dart
34 lines
973 B
Dart
/// Glyph for where a log entry came from, replacing the stored source word
|
|
/// (`manual`, `food bank`, `catering`) that used to be printed on screen.
|
|
library;
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
/// Icon for a stored entry `source` value; unknown values get a neutral dot.
|
|
IconData sourceIcon(String source) => switch (source) {
|
|
'manual' => Icons.edit,
|
|
'food bank' => Icons.restaurant_menu,
|
|
'catering' => Icons.local_shipping,
|
|
_ => Icons.circle_outlined,
|
|
};
|
|
|
|
/// A small painted [sourceIcon] that still speaks the stored source value.
|
|
class SourceMark extends StatelessWidget {
|
|
/// Creates a mark for [source].
|
|
const SourceMark(this.source, {this.size = 14, super.key});
|
|
|
|
/// Stored source value.
|
|
final String source;
|
|
|
|
/// Glyph size.
|
|
final double size;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Icon(
|
|
sourceIcon(source),
|
|
size: size,
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
semanticLabel: source,
|
|
);
|
|
}
|