Files
tatlock-ui/lib/shared/components/data_grid/data_grid_state.dart
T
Jeroen SchweitzerandClaude Opus 4.5 3b89ed8c18 feat: add Control Room with containers and stacks management
- 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>
2025-12-31 02:01:01 +01:00

63 lines
1.8 KiB
Dart

import 'package:freezed_annotation/freezed_annotation.dart';
part 'data_grid_state.freezed.dart';
/// State for a DataGrid instance.
@freezed
class DataGridState<T> with _$DataGridState<T> {
const factory DataGridState({
/// Current items being displayed.
@Default([]) List<T> items,
/// Total count of items (may differ from items.length for pagination).
@Default(0) int totalCount,
/// Whether data is currently loading.
@Default(false) bool isLoading,
/// Whether initial load is in progress.
@Default(true) bool isInitialLoad,
/// Error that occurred during loading.
Object? error,
/// Current search query.
@Default('') String searchQuery,
/// Index of the column currently sorted by.
int? sortColumnIndex,
/// Whether sort is descending.
@Default(false) bool sortDescending,
/// Currently selected item IDs (if selectable).
@Default({}) Set<Object> selectedIds,
/// Current page (for paginated mode).
@Default(0) int currentPage,
/// Whether more items can be loaded (for infinite scroll).
@Default(false) bool hasMore,
}) = _DataGridState<T>;
}
/// Extension methods for DataGridState.
extension DataGridStateX<T> on DataGridState<T> {
/// Whether the grid has an error.
bool get hasError => error != null;
/// Whether the grid is empty (no items and not loading).
bool get isEmpty => items.isEmpty && !isLoading && !hasError;
/// Whether all visible items are selected.
bool get allSelected =>
items.isNotEmpty && selectedIds.length == items.length;
/// Whether some (but not all) items are selected.
bool get someSelected =>
selectedIds.isNotEmpty && selectedIds.length < items.length;
/// Number of selected items.
int get selectedCount => selectedIds.length;
}