mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-19 06:14:33 +01:00
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
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>
68 lines
2.1 KiB
Dart
68 lines
2.1 KiB
Dart
/// Icon-only replacements for `showDatePicker`, `showDateRangePicker` and
|
|
/// `showTimePicker`, which paint "Select date", "Cancel", "OK" and tooltips.
|
|
///
|
|
/// Same arguments as the framework calls, so a call site changes by one
|
|
/// function name. Dropped on purpose: the weekday header, month names and
|
|
/// both text-entry modes (see the textgate rework report).
|
|
library;
|
|
|
|
import 'package:diet_guard_app/widgets/pickers/date_dialog.dart';
|
|
import 'package:diet_guard_app/widgets/pickers/date_selection.dart';
|
|
import 'package:diet_guard_app/widgets/pickers/time_dialog.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
/// Picks one day in [firstDate]..[lastDate]; null when cancelled.
|
|
///
|
|
/// [initialDatePickerMode] `year` focuses the year wheel first.
|
|
Future<DateTime?> pickDate({
|
|
required BuildContext context,
|
|
required DateTime firstDate,
|
|
required DateTime lastDate,
|
|
DateTime? initialDate,
|
|
DatePickerMode initialDatePickerMode = DatePickerMode.day,
|
|
}) => showDialog<DateTime>(
|
|
context: context,
|
|
builder: (_) => DateDialog(
|
|
selection: DateSelection.single(
|
|
first: firstDate,
|
|
last: lastDate,
|
|
initial: initialDate,
|
|
),
|
|
startOnYear: initialDatePickerMode == DatePickerMode.year,
|
|
),
|
|
);
|
|
|
|
/// Picks a range of days in [firstDate]..[lastDate] by two taps; null when
|
|
/// cancelled.
|
|
Future<DateTimeRange?> pickDateRange({
|
|
required BuildContext context,
|
|
required DateTime firstDate,
|
|
required DateTime lastDate,
|
|
DateTimeRange? initialDateRange,
|
|
}) => showDialog<DateTimeRange>(
|
|
context: context,
|
|
builder: (_) => DateDialog(
|
|
selection: DateSelection.range(
|
|
first: firstDate,
|
|
last: lastDate,
|
|
initial: initialDateRange,
|
|
),
|
|
),
|
|
);
|
|
|
|
/// Picks a 24 h time whose minute of day lies in [minMinute]..[maxMinute];
|
|
/// null when cancelled.
|
|
Future<TimeOfDay?> pickTime({
|
|
required BuildContext context,
|
|
required TimeOfDay initialTime,
|
|
int minMinute = 0,
|
|
int maxMinute = 24 * 60 - 1,
|
|
}) => showDialog<TimeOfDay>(
|
|
context: context,
|
|
builder: (_) => TimeDialog(
|
|
initialMinute: initialTime.hour * 60 + initialTime.minute,
|
|
minMinute: minMinute,
|
|
maxMinute: maxMinute,
|
|
),
|
|
);
|