mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Show a page-level progress bar while paginating lists
Changing pages in the notifications or devices list gave no cue that the next page was loading. Render an indeterminate progress bar at the shell level, pinned flush against the bottom of the page body (above the nav bar on phones, the screen bottom on wide layouts), driven by a shared paginationLoading notifier the lists set while fetching. The pagination bar keeps disabling its buttons during the fetch. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
52533f447c
commit
c949deedb6
@@ -0,0 +1,50 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:frontend/theme/gruvbox_theme.dart';
|
||||
import 'package:frontend/widgets/pagination_bar.dart';
|
||||
|
||||
void main() {
|
||||
Widget wrap(Widget child) => MaterialApp(
|
||||
theme: gruvboxDarkTheme,
|
||||
home: Scaffold(body: child),
|
||||
);
|
||||
|
||||
testWidgets('disables every navigation button while loading', (tester) async {
|
||||
var changedTo = -1;
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
PaginationBar(
|
||||
currentPage: 1,
|
||||
hasNextPage: true,
|
||||
isLoading: true,
|
||||
onPageChanged: (page) => changedTo = page,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byTooltip('Next page'));
|
||||
await tester.tap(find.byTooltip('Previous page'));
|
||||
await tester.tap(find.byTooltip('First page'));
|
||||
expect(changedTo, -1);
|
||||
});
|
||||
|
||||
testWidgets('enables navigation when idle', (tester) async {
|
||||
var changedTo = -1;
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
PaginationBar(
|
||||
currentPage: 1,
|
||||
hasNextPage: true,
|
||||
isLoading: false,
|
||||
onPageChanged: (page) => changedTo = page,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byTooltip('Next page'));
|
||||
expect(changedTo, 2);
|
||||
|
||||
await tester.tap(find.byTooltip('Previous page'));
|
||||
expect(changedTo, 0);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user