Fixed horizontal scroll
This commit is contained in:
parent
ee1bf5e113
commit
0b900d3480
|
|
@ -230,7 +230,18 @@ class TasQAdaptiveList<T> extends StatelessWidget {
|
|||
onRowTap: onRowTap,
|
||||
);
|
||||
|
||||
final contentWidth = constraints.maxWidth * 0.8;
|
||||
// Use progressively smaller fractions of the viewport on larger screens
|
||||
// so that content doesn't stretch too widely, but also consume as much
|
||||
// width as possible when the display is more modest.
|
||||
double contentFactor;
|
||||
if (constraints.maxWidth < 1200) {
|
||||
contentFactor = 0.95; // not-so-wide monitors
|
||||
} else if (constraints.maxWidth < 1800) {
|
||||
contentFactor = 0.85; // wide monitors
|
||||
} else {
|
||||
contentFactor = 0.75; // ultra-wide monitors
|
||||
}
|
||||
final contentWidth = constraints.maxWidth * contentFactor;
|
||||
final tableWidth = math.max(
|
||||
contentWidth,
|
||||
(columns.length + (rowActions == null ? 0 : 1)) * 140.0,
|
||||
|
|
@ -240,25 +251,34 @@ class TasQAdaptiveList<T> extends StatelessWidget {
|
|||
math.max(1, items.length),
|
||||
);
|
||||
|
||||
final tableWidget = SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: tableWidth,
|
||||
child: PaginatedDataTable(
|
||||
header: tableHeader,
|
||||
rowsPerPage: effectiveRowsPerPage,
|
||||
columnSpacing: 20,
|
||||
horizontalMargin: 16,
|
||||
showCheckboxColumn: false,
|
||||
headingRowColor: WidgetStateProperty.resolveWith(
|
||||
(states) => Theme.of(context).colorScheme.surfaceContainer,
|
||||
// wrap horizontal scroll with a visible scrollbar on desktop. the
|
||||
// ScrollController is shared so the scrollbar has something to observe.
|
||||
final horizontalController = ScrollController();
|
||||
final tableWidget = Scrollbar(
|
||||
controller: horizontalController,
|
||||
thumbVisibility: true,
|
||||
trackVisibility: true,
|
||||
child: SingleChildScrollView(
|
||||
controller: horizontalController,
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: tableWidth,
|
||||
child: PaginatedDataTable(
|
||||
header: tableHeader,
|
||||
rowsPerPage: effectiveRowsPerPage,
|
||||
columnSpacing: 20,
|
||||
horizontalMargin: 16,
|
||||
showCheckboxColumn: false,
|
||||
headingRowColor: WidgetStateProperty.resolveWith(
|
||||
(states) => Theme.of(context).colorScheme.surfaceContainer,
|
||||
),
|
||||
columns: [
|
||||
for (final column in columns)
|
||||
DataColumn(label: Text(column.header)),
|
||||
if (rowActions != null) const DataColumn(label: Text('Actions')),
|
||||
],
|
||||
source: dataSource,
|
||||
),
|
||||
columns: [
|
||||
for (final column in columns)
|
||||
DataColumn(label: Text(column.header)),
|
||||
if (rowActions != null) const DataColumn(label: Text('Actions')),
|
||||
],
|
||||
source: dataSource,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
@ -277,6 +297,7 @@ class TasQAdaptiveList<T> extends StatelessWidget {
|
|||
primary: true,
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
key: const Key('adaptive_list_content'),
|
||||
width: contentWidth,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user