feat(app): previous/next for visits, artifacts and diffs are chevrons in one row at the bottom right

This commit is contained in:
2026-10-23 17:14:44 +01:00
parent 73d59f4d85
commit 3fc7a28e76
9 changed files with 204 additions and 225 deletions
@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../../ui/navigation/chevron_pager.dart';
import '../domain/change_kind.dart';
import '../domain/change_wording.dart';
import '../domain/file_change.dart';
@@ -276,9 +277,12 @@ class _FileDiffPageState extends State<FileDiffPage> {
);
final pager = count < 2
? null
: FileDiffPager(
: ChevronPager(
key: const ValueKey('file-diff-pager'),
index: _index,
count: count,
previousLabel: 'Previous file',
nextLabel: 'Next file',
onPrevious: _index > 0 ? () => _step(-1) : null,
onNext: _index < count - 1 ? () => _step(1) : null,
);
@@ -303,64 +307,3 @@ class _FileDiffPageState extends State<FileDiffPage> {
);
}
}
/// Previous and next as chevrons in one row at the bottom right, with the
/// position between them read as `2 of 5`.
class FileDiffPager extends StatelessWidget {
const FileDiffPager({
super.key,
required this.index,
required this.count,
this.onPrevious,
this.onNext,
});
final int index;
final int count;
final VoidCallback? onPrevious;
final VoidCallback? onNext;
@override
Widget build(BuildContext context) {
final cupertino = usesCupertino(context);
Widget button(
IconData material,
IconData ios,
String tip,
VoidCallback? on,
) => cupertino
? Semantics(
button: true,
label: tip,
child: CupertinoButton(
padding: const EdgeInsets.all(8),
onPressed: on,
child: Icon(ios),
),
)
: IconButton(onPressed: on, tooltip: tip, icon: Icon(material));
return Padding(
key: const ValueKey('file-diff-pager'),
padding: const EdgeInsets.fromLTRB(16, 4, 8, 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text('${index + 1} of $count'),
const SizedBox(width: 4),
button(
Icons.chevron_left,
CupertinoIcons.chevron_left,
'Previous file',
onPrevious,
),
button(
Icons.chevron_right,
CupertinoIcons.chevron_right,
'Next file',
onNext,
),
],
),
);
}
}