wake-alarm/phone_app/lib/screens/energy_picker.dart
Krzysztof kuhy Rudnicki 8e6fa90c80
Some checks are pending
dependency freshness / dependencies on newest stable (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,free-days-interop) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / free-days-interop (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Bump Flutter to 3.50.0 via material_ui
Flutter 3.50 deprecates package:flutter/material.dart, so the app
moves to material_ui 1.11.0 together with sync_settings_ui 0.8.0
and github_device_auth 0.5.0 (crdt_sync 0.13.1 rides along).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 09:06:16 +01:00

55 lines
1.7 KiB
Dart

import 'package:material_ui/material_ui.dart';
import 'package:wake_alarm_sync/services/weight_entry.dart';
/// Five chips, 1 to 5: the morning's energy, tapped next to the weigh-in.
///
/// Chips rather than a field because a rating is a tap, not a number to
/// type. The selected colour is the theme's chip container (a raised ink),
/// deliberately not the gold `primaryContainer`: `scripts/emu_morning.py`
/// finds the submit button by its gold pixels, and a gold chip sat above it
/// was found first -- and the label vanished into it.
class EnergyPicker extends StatelessWidget {
/// Creates the picker; [selected] is null until a chip is tapped.
const EnergyPicker({
required this.selected,
required this.onSelect,
super.key,
});
/// The chosen level, or null.
final int? selected;
/// Called with the tapped level.
final ValueChanged<int> onSelect;
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
const Row(
children: <Widget>[
Icon(Icons.bolt, semanticLabel: 'Energy'),
SizedBox(width: 8),
],
),
const SizedBox(height: 4),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
for (var level = minEnergy; level <= maxEnergy; level++)
ChoiceChip(
label: Text('$level'),
selected: selected == level,
selectedColor: scheme.secondaryContainer,
showCheckmark: false,
onSelected: (_) => onSelect(level),
),
],
),
],
);
}
}