- Add Control Room page with stacks sidebar and containers list - Implement container actions (start/stop/restart) with snackbars - Add container logs viewer dialog - Add search/filter for both stacks and containers lists - Add external links for Portainer and Netdata (url_launcher) - Add VS Code launch configuration for Flutter web debugging 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
112 lines
3.3 KiB
Dart
112 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../data_grid_config.dart';
|
|
|
|
/// Footer for DataGrid with item count and pagination controls.
|
|
class DataGridFooter extends StatelessWidget {
|
|
const DataGridFooter({
|
|
super.key,
|
|
required this.totalCount,
|
|
required this.displayedCount,
|
|
required this.dataMode,
|
|
this.currentPage = 0,
|
|
this.onPageChange,
|
|
this.isLoading = false,
|
|
});
|
|
|
|
final int totalCount;
|
|
final int displayedCount;
|
|
final DataGridDataMode dataMode;
|
|
final int currentPage;
|
|
final void Function(int page)? onPageChange;
|
|
final bool isLoading;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
decoration: BoxDecoration(
|
|
color: colorScheme.surfaceContainerHighest,
|
|
border: Border(
|
|
top: BorderSide(color: colorScheme.outlineVariant),
|
|
),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Text(
|
|
_getCountText(),
|
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
color: colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
const Spacer(),
|
|
if (dataMode is PaginatedDataMode) _buildPaginationControls(context),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
String _getCountText() {
|
|
return switch (dataMode) {
|
|
AllDataMode() => '$totalCount items',
|
|
PaginatedDataMode(:final pageSize) => _getPaginatedCountText(pageSize),
|
|
InfiniteDataMode() => '$displayedCount of $totalCount items',
|
|
};
|
|
}
|
|
|
|
String _getPaginatedCountText(int pageSize) {
|
|
final start = currentPage * pageSize + 1;
|
|
final end = (start + displayedCount - 1).clamp(start, totalCount);
|
|
return '$start-$end of $totalCount items';
|
|
}
|
|
|
|
Widget _buildPaginationControls(BuildContext context) {
|
|
final mode = dataMode as PaginatedDataMode;
|
|
final totalPages = (totalCount / mode.pageSize).ceil();
|
|
final canGoPrevious = currentPage > 0;
|
|
final canGoNext = currentPage < totalPages - 1;
|
|
|
|
return Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
IconButton(
|
|
icon: const Icon(Icons.first_page),
|
|
onPressed: canGoPrevious ? () => onPageChange?.call(0) : null,
|
|
tooltip: 'First page',
|
|
iconSize: 20,
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.chevron_left),
|
|
onPressed:
|
|
canGoPrevious ? () => onPageChange?.call(currentPage - 1) : null,
|
|
tooltip: 'Previous page',
|
|
iconSize: 20,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
child: Text(
|
|
'Page ${currentPage + 1} of $totalPages',
|
|
style: Theme.of(context).textTheme.bodySmall,
|
|
),
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.chevron_right),
|
|
onPressed:
|
|
canGoNext ? () => onPageChange?.call(currentPage + 1) : null,
|
|
tooltip: 'Next page',
|
|
iconSize: 20,
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.last_page),
|
|
onPressed:
|
|
canGoNext ? () => onPageChange?.call(totalPages - 1) : null,
|
|
tooltip: 'Last page',
|
|
iconSize: 20,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|