Food: the header's arrows go by week; days switch in place
- Dashboard: the arrows (and the left / right keys) move a week, the week strip picks the day. Switching fetches the page and swaps in its header and diary instead of loading everything again (back / forward work); a day is fetched ahead while the pointer rests on it. - App: the arrows move a week, swiping sideways moves a day (1.1.6). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
eeca189b7f
commit
98b110dd56
7 changed files with 62 additions and 9 deletions
|
|
@ -92,7 +92,18 @@ class _FoodPageState extends State<FoodPage> {
|
|||
label: Text(es.isEmpty ? 'Make a meal' : 'Make a meal (from this day’s entries)'),
|
||||
),
|
||||
];
|
||||
return ListView(padding: const EdgeInsets.fromLTRB(12, 10, 12, 24), children: [
|
||||
// the arrows go by week; a swipe sideways goes by day
|
||||
return GestureDetector(
|
||||
onHorizontalDragEnd: (e) {
|
||||
final v = e.primaryVelocity ?? 0;
|
||||
if (v.abs() < 300) return;
|
||||
if (v > 0) {
|
||||
setState(() => d = plus(d, -1));
|
||||
} else if (daysBetween(today(), d) < ahead) {
|
||||
setState(() => d = plus(d, 1));
|
||||
}
|
||||
},
|
||||
child: ListView(padding: const EdgeInsets.fromLTRB(12, 10, 12, 24), children: [
|
||||
if (wide)
|
||||
Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Expanded(child: Column(children: head)),
|
||||
|
|
@ -100,13 +111,14 @@ class _FoodPageState extends State<FoodPage> {
|
|||
Expanded(child: Column(children: meals)),
|
||||
])
|
||||
else ...[...head, const SizedBox(height: 10), ...meals],
|
||||
]);
|
||||
]),
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
Widget _nav() => Row(children: [
|
||||
IconButton(onPressed: () => setState(() => d = plus(d, -1)), icon: const Icon(Icons.chevron_left)),
|
||||
IconButton(tooltip: 'Week before', onPressed: () => setState(() => d = plus(d, -7)), icon: const Icon(Icons.chevron_left)),
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => setState(() => d = today()),
|
||||
|
|
@ -115,7 +127,8 @@ class _FoodPageState extends State<FoodPage> {
|
|||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: daysBetween(today(), d) < ahead ? () => setState(() => d = plus(d, 1)) : null,
|
||||
tooltip: 'Week after',
|
||||
onPressed: daysBetween(today(), d) + 7 <= ahead ? () => setState(() => d = plus(d, 7)) : null,
|
||||
icon: const Icon(Icons.chevron_right)),
|
||||
]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue