app settings: "Custom…" first in the meal-time dropdowns

At the end of the list it sat ~95 grid items down; now it is the first
item, above 00:00. Test pins the order.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015npsYVB2PdtWkG7MPAi4tn
This commit is contained in:
Krzysztof Rudnicki 2026-10-10 20:04:19 +02:00
parent a9aa379a13
commit b2176f8b69
3 changed files with 20 additions and 3 deletions

View File

@ -106,10 +106,11 @@ class MealTimeDropdown extends StatelessWidget {
value: value,
isDense: true,
isExpanded: true,
// "Custom…" first: at the end it sat ~95 grid items down.
items: [
const DropdownMenuItem(value: _customValue, child: Text('Custom…')),
for (final minute in options)
DropdownMenuItem(value: minute, child: Text(slotLabel(minute))),
const DropdownMenuItem(value: _customValue, child: Text('Custom…')),
],
onChanged: (minute) {
if (minute == null) return;

View File

@ -2,7 +2,7 @@ name: diet_guard_app
description: "Companion phone app for diet_guard: log meals on the go."
publish_to: 'none'
version: 1.0.108+1
version: 1.0.109+1
environment:
sdk: ^3.12.2

View File

@ -58,9 +58,11 @@ void main() {
/// Picks "Custom…" from the open menu, typing [hhmm] in the time picker's
/// keyboard mode.
Future<void> pickCustom(WidgetTester tester, String hh, String mm) async {
// The menu opens centred on the current value; "Custom…" is the first
// item, so it is reached by scrolling up.
await tester.scrollUntilVisible(
find.text('Custom…'),
300,
-300,
scrollable: find.byType(Scrollable).last,
);
await tester.tap(find.text('Custom…').last);
@ -118,6 +120,20 @@ void main() {
expect(find.text('07:23'), findsWidgets);
});
testWidgets('Custom… is the first item, above 00:00', (tester) async {
await pump(tester, _fiveMeals);
await openDropdown(tester, 'First meal');
await tester.scrollUntilVisible(
find.text('00:00'),
-300,
scrollable: find.byType(Scrollable).last,
);
final custom = tester.getTopLeft(find.text('Custom…').last).dy;
expect(custom, lessThan(tester.getTopLeft(find.text('00:00').last).dy));
});
testWidgets('a custom last meal before the first is clamped', (tester) async {
await pump(tester, _fiveMeals);