feat(app): previous/next for visits, artifacts and diffs are chevrons in one row at the bottom right
This commit is contained in:
@@ -161,12 +161,6 @@ class _ChangesViewerState extends State<ChangesViewer> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
ChangesVisitPager(
|
||||
index: _visitIndex,
|
||||
count: captures.length,
|
||||
onPrevious: () => _stepVisit(-1),
|
||||
onNext: () => _stepVisit(1),
|
||||
),
|
||||
StageCaptureSection(
|
||||
stage: visit,
|
||||
query: _query,
|
||||
@@ -184,6 +178,14 @@ class _ChangesViewerState extends State<ChangesViewer> {
|
||||
),
|
||||
),
|
||||
),
|
||||
// Previous/next visit sit at the bottom right, under the visit.
|
||||
if (visit != null)
|
||||
ChangesVisitPager(
|
||||
index: _visitIndex,
|
||||
count: captures.length,
|
||||
onPrevious: () => _stepVisit(-1),
|
||||
onNext: () => _stepVisit(1),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../domain/change_wording.dart';
|
||||
import 'change_style.dart';
|
||||
import '../../../ui/navigation/chevron_pager.dart';
|
||||
|
||||
/// The Changes page's Previous/Next pager over the run's recorded stage visits.
|
||||
///
|
||||
@@ -31,81 +30,16 @@ class ChangesVisitPager extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (count <= 1) return const SizedBox.shrink();
|
||||
final hasPrevious = index > 0;
|
||||
final hasNext = index < count - 1;
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(
|
||||
'${changePositionLabel(index, count)} recorded visits',
|
||||
key: const ValueKey<String>('changes-visit-position'),
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
// A `Wrap` keeps both controls whole and lets them take separate
|
||||
// lines at large text sizes or on a narrow page.
|
||||
Wrap(
|
||||
alignment: WrapAlignment.spaceBetween,
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
_button(
|
||||
context,
|
||||
key: previousKey,
|
||||
label: 'Previous visit',
|
||||
enabled: hasPrevious,
|
||||
onPressed: onPrevious,
|
||||
previous: true,
|
||||
),
|
||||
_button(
|
||||
context,
|
||||
key: nextKey,
|
||||
label: 'Next visit',
|
||||
enabled: hasNext,
|
||||
onPressed: onNext,
|
||||
previous: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _button(
|
||||
BuildContext context, {
|
||||
required Key key,
|
||||
required String label,
|
||||
required bool enabled,
|
||||
required VoidCallback onPressed,
|
||||
required bool previous,
|
||||
}) {
|
||||
if (usesCupertino(context)) {
|
||||
return CupertinoButton(
|
||||
key: key,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: enabled ? onPressed : null,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
previous ? CupertinoIcons.back : CupertinoIcons.forward,
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(label),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return TextButton.icon(
|
||||
key: key,
|
||||
onPressed: enabled ? onPressed : null,
|
||||
icon: Icon(previous ? Icons.arrow_back : Icons.arrow_forward),
|
||||
label: Text(label),
|
||||
return ChevronPager(
|
||||
index: index,
|
||||
count: count,
|
||||
previousLabel: 'Previous visit',
|
||||
nextLabel: 'Next visit',
|
||||
previousKey: previousKey,
|
||||
nextKey: nextKey,
|
||||
positionKey: const ValueKey<String>('changes-visit-position'),
|
||||
onPrevious: index > 0 ? onPrevious : null,
|
||||
onNext: index < count - 1 ? onNext : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user