57 lines
1.8 KiB
Dart
57 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../theme/theme_x.dart';
|
|
|
|
/// The bordered, horizontally-scrollable card wrapper used by every dense
|
|
/// table in the app (Services, Fleet, Updates, Backup history). A thin
|
|
/// shell around [DataTable] — column/row content stays screen-specific,
|
|
/// this just guarantees the same card chrome, spacing, and empty-state
|
|
/// fallback everywhere.
|
|
class DataTableScaffold extends StatelessWidget {
|
|
const DataTableScaffold({
|
|
super.key,
|
|
required this.columns,
|
|
required this.rows,
|
|
this.empty,
|
|
this.columnSpacing = 28,
|
|
this.horizontalMargin = 16,
|
|
});
|
|
|
|
final List<DataColumn> columns;
|
|
final List<DataRow> rows;
|
|
final Widget? empty;
|
|
final double columnSpacing;
|
|
final double horizontalMargin;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: context.colors.surface,
|
|
borderRadius: BorderRadius.circular(10),
|
|
border: Border.all(color: context.colors.outlineVariant),
|
|
),
|
|
clipBehavior: Clip.antiAlias,
|
|
child: rows.isEmpty && empty != null
|
|
? empty
|
|
: SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
child: ConstrainedBox(
|
|
constraints: BoxConstraints(minWidth: MediaQuery.sizeOf(context).width),
|
|
child: DataTable(
|
|
showCheckboxColumn: false,
|
|
columns: columns,
|
|
rows: rows,
|
|
columnSpacing: columnSpacing,
|
|
horizontalMargin: horizontalMargin,
|
|
headingRowHeight: 38,
|
|
dataRowMinHeight: 46,
|
|
dataRowMaxHeight: 58,
|
|
dividerThickness: 1,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|