Add scrollbars to tables
This commit is contained in:
parent
7c54561161
commit
ae1b5bb63a
|
|
@ -8,6 +8,7 @@ import 'package:flutter/material.dart' hide DataRow, DataCell, DataColumn;
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/gestures.dart' show DragStartBehavior;
|
||||
import 'package:invoiceninja_flutter/ui/app/app_scrollbar.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/tables/app_data_table.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/tables/app_data_table_source.dart';
|
||||
|
||||
|
|
@ -223,11 +224,13 @@ class AppPaginatedDataTableState extends State<AppPaginatedDataTable> {
|
|||
int _firstRowIndex;
|
||||
int _rowCount;
|
||||
bool _rowCountApproximate;
|
||||
ScrollController _controller;
|
||||
final Map<int, DataRow> _rows = <int, DataRow>{};
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = ScrollController();
|
||||
_firstRowIndex = PageStorage.of(context)?.readState(context) as int ??
|
||||
widget.initialFirstRowIndex ??
|
||||
0;
|
||||
|
|
@ -247,6 +250,7 @@ class AppPaginatedDataTableState extends State<AppPaginatedDataTable> {
|
|||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
widget.source.removeListener(_handleDataSourceChanged);
|
||||
super.dispose();
|
||||
}
|
||||
|
|
@ -470,7 +474,10 @@ class AppPaginatedDataTableState extends State<AppPaginatedDataTable> {
|
|||
),
|
||||
),
|
||||
*/
|
||||
SingleChildScrollView(
|
||||
Scrollbar(
|
||||
controller: _controller,
|
||||
child: SingleChildScrollView(
|
||||
controller: _controller,
|
||||
scrollDirection: Axis.horizontal,
|
||||
dragStartBehavior: widget.dragStartBehavior,
|
||||
child: ConstrainedBox(
|
||||
|
|
@ -490,6 +497,7 @@ class AppPaginatedDataTableState extends State<AppPaginatedDataTable> {
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
DefaultTextStyle(
|
||||
style: footerTextStyle,
|
||||
child: IconTheme.merge(
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
|||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/ui/pref_state.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/app_border.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/app_scrollbar.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/entities/entity_actions_dialog.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/save_cancel_buttons.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/help_text.dart';
|
||||
|
|
@ -60,11 +61,14 @@ class _EntityListState extends State<EntityList> {
|
|||
EntityDataTableSource dataTableSource;
|
||||
|
||||
int _firstRowIndex = 0;
|
||||
ScrollController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_controller = ScrollController();
|
||||
|
||||
final entityType = widget.entityType;
|
||||
final state = widget.state;
|
||||
final entityList = widget.entityList;
|
||||
|
|
@ -107,6 +111,12 @@ class _EntityListState extends State<EntityList> {
|
|||
dataTableSource.notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
|
|
@ -229,15 +239,18 @@ class _EntityListState extends State<EntityList> {
|
|||
},
|
||||
),
|
||||
Expanded(
|
||||
child: AppScrollbar(
|
||||
controller: _controller,
|
||||
child: SingleChildScrollView(
|
||||
controller: _controller,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: AppPaginatedDataTable(
|
||||
onSelectAll: (value) {
|
||||
final startIndex =
|
||||
min(_firstRowIndex, entityList.length - 1);
|
||||
final endIndex =
|
||||
min(_firstRowIndex + rowsPerPage, entityList.length);
|
||||
final endIndex = min(
|
||||
_firstRowIndex + rowsPerPage, entityList.length);
|
||||
final entities = entityList
|
||||
.sublist(startIndex, endIndex)
|
||||
.map<BaseEntity>(
|
||||
|
|
@ -281,8 +294,8 @@ class _EntityListState extends State<EntityList> {
|
|||
}),
|
||||
],
|
||||
source: dataTableSource,
|
||||
sortColumnIndex:
|
||||
widget.tableColumns.contains(listUIState.sortField)
|
||||
sortColumnIndex: widget.tableColumns
|
||||
.contains(listUIState.sortField)
|
||||
? widget.tableColumns.indexOf(listUIState.sortField)
|
||||
: 0,
|
||||
sortAscending: listUIState.sortAscending,
|
||||
|
|
@ -295,12 +308,14 @@ class _EntityListState extends State<EntityList> {
|
|||
50,
|
||||
],
|
||||
onRowsPerPageChanged: (value) {
|
||||
store.dispatch(UpdateUserPreferences(rowsPerPage: value));
|
||||
store.dispatch(
|
||||
UpdateUserPreferences(rowsPerPage: value));
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue