diet-guard/app/lib/widgets/pickers/time_dialog.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

53 lines
1.4 KiB
Dart

/// The time dialog: hour and minute wheels between check and close icons.
library;
import 'package:diet_guard_app/widgets/pickers/picker_frame.dart';
import 'package:diet_guard_app/widgets/pickers/time_wheels.dart';
import 'package:flutter/material.dart';
/// Pops the chosen [TimeOfDay], always within [minMinute]..[maxMinute].
class TimeDialog extends StatefulWidget {
/// Creates a [TimeDialog]; [initialMinute] is clamped into range, since a
/// value written by another device may lie outside it.
const TimeDialog({
required this.initialMinute,
required this.minMinute,
required this.maxMinute,
super.key,
});
/// The starting minute of day.
final int initialMinute;
/// Earliest allowed minute of day.
final int minMinute;
/// Latest allowed minute of day.
final int maxMinute;
@override
State<TimeDialog> createState() => _TimeDialogState();
}
class _TimeDialogState extends State<TimeDialog> {
late int _minute = clampMinute(
widget.initialMinute,
widget.minMinute,
widget.maxMinute,
);
@override
Widget build(BuildContext context) => PickerFrame(
canConfirm: true,
onConfirm: () => Navigator.of(
context,
).pop(TimeOfDay(hour: _minute ~/ 60, minute: _minute % 60)),
child: TimeWheels(
minute: _minute,
minMinute: widget.minMinute,
maxMinute: widget.maxMinute,
onChanged: (m) => setState(() => _minute = m),
),
);
}