88 lines
2.7 KiB
Dart
88 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/widgets.dart' as widgets;
|
|
import 'overlay_scrollbar.dart';
|
|
|
|
class SummaryTable extends StatelessWidget {
|
|
final List<String> keys;
|
|
final List<int> seasonCols;
|
|
final Map<int, double> seasonWidths;
|
|
final Widget Function(List<int> seasons, Map<int, double> widths) buildHeader;
|
|
final Widget Function(String key) buildRow;
|
|
|
|
const SummaryTable({
|
|
required this.keys,
|
|
required this.seasonCols,
|
|
required this.seasonWidths,
|
|
required this.buildHeader,
|
|
required this.buildRow,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
const headerHeight = 32.0;
|
|
final tableWidth = _calcTableWidth();
|
|
final summaryHController = ScrollController();
|
|
final summaryVController = ScrollController();
|
|
|
|
return LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
return Stack(
|
|
children: [
|
|
Scrollbar(
|
|
controller: summaryHController,
|
|
child: SingleChildScrollView(
|
|
controller: summaryHController,
|
|
scrollDirection: Axis.horizontal,
|
|
child: widgets.SizedBox(
|
|
width: tableWidth,
|
|
height: constraints.maxHeight,
|
|
child: Column(
|
|
children: [
|
|
widgets.SizedBox(height: headerHeight, child: buildHeader(seasonCols, seasonWidths)),
|
|
Expanded(
|
|
child: Scrollbar(
|
|
controller: summaryVController,
|
|
child: ListView.separated(
|
|
controller: summaryVController,
|
|
itemCount: keys.length,
|
|
separatorBuilder: (_, __) => const Divider(height: 1),
|
|
itemBuilder: (_, i) => widgets.SizedBox(
|
|
height: 88,
|
|
child: buildRow(keys[i]),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
right: 0,
|
|
top: 0,
|
|
bottom: 0,
|
|
child: SizedBox(
|
|
width: 10,
|
|
child: AlwaysOnScrollbar(
|
|
controller: summaryVController,
|
|
axis: Axis.vertical,
|
|
thickness: 10,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
double _calcTableWidth() {
|
|
double tableWidth = 360;
|
|
for (final s in seasonCols) {
|
|
tableWidth += 16 + (seasonWidths[s] ?? 74);
|
|
}
|
|
return tableWidth;
|
|
}
|
|
}
|