import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../ui/navigation/chevron_pager.dart'; /// The Changes page's Previous/Next pager over the run's recorded stage visits. /// /// It only moves between the captures the viewer already holds and never wraps: /// the first recorded visit has no previous page and the last none after it. /// The shown visit's own heading (its stage and visit number) stays with the /// capture section below, so paging never loses which visit is on screen. class ChangesVisitPager extends StatelessWidget { const ChangesVisitPager({ super.key, required this.index, required this.count, required this.onPrevious, required this.onNext, }); static const previousKey = ValueKey('changes-previous-visit'); static const nextKey = ValueKey('changes-next-visit'); /// The shown visit's zero-based position in the run's recorded visits. final int index; final int count; final VoidCallback onPrevious; final VoidCallback onNext; @override Widget build(BuildContext context) { if (count <= 1) return const SizedBox.shrink(); return ChevronPager( index: index, count: count, previousLabel: 'Previous visit', nextLabel: 'Next visit', previousKey: previousKey, nextKey: nextKey, positionKey: const ValueKey('changes-visit-position'), onPrevious: index > 0 ? onPrevious : null, onNext: index < count - 1 ? onNext : null, ); } }