Add horizontal scrolling to reports
This commit is contained in:
parent
f37970f69a
commit
0f4ff64e6a
|
|
@ -1,5 +1,6 @@
|
||||||
// Flutter imports:
|
// Flutter imports:
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart' hide DataRow, DataCell, DataColumn;
|
||||||
|
import 'package:flutter/material.dart' as mt;
|
||||||
|
|
||||||
// Package imports:
|
// Package imports:
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
|
|
@ -30,6 +31,9 @@ import 'package:invoiceninja_flutter/ui/app/history_drawer_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/menu_drawer_vm.dart';
|
import 'package:invoiceninja_flutter/ui/app/menu_drawer_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/presenters/entity_presenter.dart';
|
import 'package:invoiceninja_flutter/ui/app/presenters/entity_presenter.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/scrollable_listview.dart';
|
import 'package:invoiceninja_flutter/ui/app/scrollable_listview.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_paginated_data_table.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/upgrade_dialog.dart';
|
import 'package:invoiceninja_flutter/ui/app/upgrade_dialog.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/reports/report_charts.dart';
|
import 'package:invoiceninja_flutter/ui/reports/report_charts.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/reports/reports_screen_vm.dart';
|
import 'package:invoiceninja_flutter/ui/reports/reports_screen_vm.dart';
|
||||||
|
|
@ -671,8 +675,8 @@ class _ReportDataTableState extends State<ReportDataTable> {
|
||||||
),
|
),
|
||||||
SingleChildScrollView(
|
SingleChildScrollView(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
child: PaginatedDataTable(
|
child: AppPaginatedDataTable(
|
||||||
showFirstLastButtons: true,
|
//showFirstLastButtons: true,
|
||||||
header: SizedBox(),
|
header: SizedBox(),
|
||||||
sortColumnIndex: sortedColumns.contains(reportSettings.sortColumn)
|
sortColumnIndex: sortedColumns.contains(reportSettings.sortColumn)
|
||||||
? sortedColumns.indexOf(reportSettings.sortColumn)
|
? sortedColumns.indexOf(reportSettings.sortColumn)
|
||||||
|
|
@ -700,7 +704,7 @@ class TotalsDataTable extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return DataTable(
|
return mt.DataTable(
|
||||||
sortColumnIndex: reportSettings.sortTotalsIndex != null &&
|
sortColumnIndex: reportSettings.sortTotalsIndex != null &&
|
||||||
reportResult.columns.length > reportSettings.sortTotalsIndex
|
reportResult.columns.length > reportSettings.sortTotalsIndex
|
||||||
? reportSettings.sortTotalsIndex
|
? reportSettings.sortTotalsIndex
|
||||||
|
|
@ -776,7 +780,7 @@ ReportColumnType getReportColumnType(String column, BuildContext context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ReportDataTableSource extends DataTableSource {
|
class ReportDataTableSource extends AppDataTableSource {
|
||||||
ReportDataTableSource({
|
ReportDataTableSource({
|
||||||
@required this.context,
|
@required this.context,
|
||||||
@required this.textEditingControllers,
|
@required this.textEditingControllers,
|
||||||
|
|
@ -1415,7 +1419,7 @@ class ReportResult {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DataColumn> totalColumns(
|
List<mt.DataColumn> totalColumns(
|
||||||
BuildContext context, Function(int, bool) onSortCallback) {
|
BuildContext context, Function(int, bool) onSortCallback) {
|
||||||
final store = StoreProvider.of<AppState>(context);
|
final store = StoreProvider.of<AppState>(context);
|
||||||
final company = store.state.company;
|
final company = store.state.company;
|
||||||
|
|
@ -1429,11 +1433,11 @@ class ReportResult {
|
||||||
// print('## $column => ${getReportColumnType(column, context)}');
|
// print('## $column => ${getReportColumnType(column, context)}');
|
||||||
|
|
||||||
final totalColumns = [
|
final totalColumns = [
|
||||||
DataColumn(
|
mt.DataColumn(
|
||||||
label: Text(localization.currency),
|
label: Text(localization.currency),
|
||||||
onSort: onSortCallback,
|
onSort: onSortCallback,
|
||||||
),
|
),
|
||||||
DataColumn(
|
mt.DataColumn(
|
||||||
label: Text(localization.count),
|
label: Text(localization.count),
|
||||||
onSort: onSortCallback,
|
onSort: onSortCallback,
|
||||||
),
|
),
|
||||||
|
|
@ -1443,7 +1447,7 @@ class ReportResult {
|
||||||
ReportColumnType.age,
|
ReportColumnType.age,
|
||||||
ReportColumnType.duration,
|
ReportColumnType.duration,
|
||||||
].contains(getReportColumnType(column, context)))
|
].contains(getReportColumnType(column, context)))
|
||||||
DataColumn(
|
mt.DataColumn(
|
||||||
label: Text(
|
label: Text(
|
||||||
company.getCustomFieldLabel(column).isEmpty
|
company.getCustomFieldLabel(column).isEmpty
|
||||||
? localization.lookup(column)
|
? localization.lookup(column)
|
||||||
|
|
@ -1460,8 +1464,8 @@ class ReportResult {
|
||||||
return totalColumns;
|
return totalColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DataRow> totalRows(BuildContext context) {
|
List<mt.DataRow> totalRows(BuildContext context) {
|
||||||
final rows = <DataRow>[];
|
final rows = <mt.DataRow>[];
|
||||||
final store = StoreProvider.of<AppState>(context);
|
final store = StoreProvider.of<AppState>(context);
|
||||||
final state = store.state;
|
final state = store.state;
|
||||||
final reportState = state.uiState.reportsUIState;
|
final reportState = state.uiState.reportsUIState;
|
||||||
|
|
@ -1580,11 +1584,11 @@ class ReportResult {
|
||||||
|
|
||||||
keys.forEach((currencyId) {
|
keys.forEach((currencyId) {
|
||||||
final values = totals[currencyId];
|
final values = totals[currencyId];
|
||||||
final cells = <DataCell>[
|
final cells = <mt.DataCell>[
|
||||||
DataCell(Text(
|
mt.DataCell(Text(
|
||||||
store.state.staticState.currencyMap[currencyId]?.listDisplayName ??
|
store.state.staticState.currencyMap[currencyId]?.listDisplayName ??
|
||||||
'')),
|
'')),
|
||||||
DataCell(Text(values['count'].toInt().toString())),
|
mt.DataCell(Text(values['count'].toInt().toString())),
|
||||||
];
|
];
|
||||||
|
|
||||||
allFields.forEach((field) {
|
allFields.forEach((field) {
|
||||||
|
|
@ -1603,12 +1607,12 @@ class ReportResult {
|
||||||
? FormatNumberType.double
|
? FormatNumberType.double
|
||||||
: FormatNumberType.money);
|
: FormatNumberType.money);
|
||||||
}
|
}
|
||||||
cells.add(DataCell(Text(value)));
|
cells.add(mt.DataCell(Text(value)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//print('## Total Rows: ${cells.length}');
|
//print('## Total Rows: ${cells.length}');
|
||||||
rows.add(DataRow(cells: cells));
|
rows.add(mt.DataRow(cells: cells));
|
||||||
});
|
});
|
||||||
|
|
||||||
return rows;
|
return rows;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue