diet-guard/app/lib/widgets/pickers/month_chips.dart
Krzysztof kuhy Rudnicki 4eca59bac9
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
Icon-only date and time pickers
Replace showDatePicker, showDateRangePicker and showTimePicker with
numeral grid/wheel dialogs confirmed by check and close icons. Adds a
no-words picker guard and a repo invariant banning the framework pickers.

Todo: e09dac36

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

47 lines
1.2 KiB
Dart

/// The month row of the date picker: numerals 1-12 instead of month names.
library;
import 'package:diet_guard_app/widgets/pickers/numeral_cell.dart';
import 'package:flutter/material.dart';
/// Twelve numeral chips in two rows of six; months wholly outside the bounds
/// are dimmed and inert.
class MonthChips extends StatelessWidget {
/// Creates a [MonthChips].
const MonthChips({
required this.year,
required this.selected,
required this.allowed,
required this.onTap,
super.key,
});
/// The shown year (for the spoken month names).
final int year;
/// The shown month, 1-12.
final int selected;
/// Whether month 1-12 has any day within the bounds.
final bool Function(int month) allowed;
/// Called with a tapped allowed month.
final ValueChanged<int> onTap;
@override
Widget build(BuildContext context) {
final l10n = MaterialLocalizations.of(context);
return numeralRows(6, aspectRatio: 1.6, [
for (var m = 1; m <= 12; m++)
NumeralCell(
key: ValueKey('month-$m'),
label: '$m',
semanticLabel: l10n.formatMonthYear(DateTime(year, m)),
onTap: () => onTap(m),
enabled: allowed(m),
selected: m == selected,
),
]);
}
}