mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Extract ScannerStatusCard<T> and PaginationBar so the ARP/mDNS cards and the two paginated lists share one implementation each. Also fold the four UISnackbars methods over a severity enum and fix Notification.toJson serializing a method tear-off instead of the enum name. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
56 lines
1.6 KiB
Dart
56 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class PaginationBar extends StatelessWidget {
|
|
const PaginationBar({
|
|
super.key,
|
|
required this.currentPage,
|
|
required this.hasNextPage,
|
|
required this.isLoading,
|
|
required this.onPageChanged,
|
|
});
|
|
|
|
final int currentPage;
|
|
final bool hasNextPage;
|
|
final bool isLoading;
|
|
final ValueChanged<int> onPageChanged;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final canGoBack = currentPage > 0 && !isLoading;
|
|
final canGoForward = hasNextPage && !isLoading;
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
IconButton.outlined(
|
|
onPressed: canGoBack ? () => onPageChanged(0) : null,
|
|
icon: const Icon(Icons.first_page),
|
|
tooltip: 'First page',
|
|
),
|
|
const SizedBox(width: 8),
|
|
IconButton.outlined(
|
|
onPressed: canGoBack ? () => onPageChanged(currentPage - 1) : null,
|
|
icon: const Icon(Icons.chevron_left),
|
|
tooltip: 'Previous page',
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: Text(
|
|
'Page ${currentPage + 1}',
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
),
|
|
),
|
|
IconButton.outlined(
|
|
onPressed: canGoForward
|
|
? () => onPageChanged(currentPage + 1)
|
|
: null,
|
|
icon: const Icon(Icons.chevron_right),
|
|
tooltip: 'Next page',
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|