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