mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Collapse scanner-card and pagination duplication into shared widgets
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>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
9b521e0847
commit
17712c25f1
@@ -8,6 +8,7 @@ import '../model/device_type.dart';
|
||||
import '../navigation.dart';
|
||||
import '../utils/friendly_date_formatter.dart';
|
||||
import '../utils/oott_api.dart';
|
||||
import '../widgets/pagination_bar.dart';
|
||||
import 'device_list_filter.dart';
|
||||
import 'device_list_rows.dart';
|
||||
import 'device_list_sort.dart';
|
||||
@@ -300,51 +301,17 @@ class _DeviceListState extends State<DeviceList> with RouteAware {
|
||||
},
|
||||
separatorBuilder: (_, _) => const Divider(height: 1),
|
||||
),
|
||||
if (_currentPage > 0 || _hasNextPage) _buildPaginationControls(),
|
||||
if (_currentPage > 0 || _hasNextPage)
|
||||
SliverToBoxAdapter(
|
||||
child: PaginationBar(
|
||||
currentPage: _currentPage,
|
||||
hasNextPage: _hasNextPage,
|
||||
isLoading: _isLoading,
|
||||
onPageChanged: _fetchPage,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPaginationControls() {
|
||||
return SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton.outlined(
|
||||
onPressed: _currentPage > 0 && !_isLoading
|
||||
? () => _fetchPage(0)
|
||||
: null,
|
||||
icon: const Icon(Icons.first_page),
|
||||
tooltip: 'First page',
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
IconButton.outlined(
|
||||
onPressed: _currentPage > 0 && !_isLoading
|
||||
? () => _fetchPage(_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: _hasNextPage && !_isLoading
|
||||
? () => _fetchPage(_currentPage + 1)
|
||||
: null,
|
||||
icon: const Icon(Icons.chevron_right),
|
||||
tooltip: 'Next page',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user