This commit is contained in:
Hillel Coren 2020-02-11 18:32:12 +02:00
parent d9461c7205
commit 649157478b
3 changed files with 16 additions and 16 deletions

View File

@ -11,6 +11,7 @@ void multiselectDialog(
List<String> selected, List<String> selected,
Function(List<String>) onSelected}) { Function(List<String>) onSelected}) {
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
List<String> selected;
showDialog<AlertDialog>( showDialog<AlertDialog>(
context: context, context: context,
@ -21,6 +22,7 @@ void multiselectDialog(
options: options, options: options,
selected: selected, selected: selected,
addTitle: addTitle, addTitle: addTitle,
onSelected: (values) => selected = values,
), ),
actions: <Widget>[ actions: <Widget>[
FlatButton( FlatButton(
@ -32,7 +34,7 @@ void multiselectDialog(
child: Text(localization.save.toUpperCase()), child: Text(localization.save.toUpperCase()),
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
onSelected(['']); onSelected(selected);
}) })
], ],
), ),
@ -40,11 +42,13 @@ void multiselectDialog(
} }
class _MultiSelectList extends StatefulWidget { class _MultiSelectList extends StatefulWidget {
const _MultiSelectList({this.options, this.selected, this.addTitle}); const _MultiSelectList(
{this.options, this.selected, this.addTitle, this.onSelected});
final List<String> options; final List<String> options;
final List<String> selected; final List<String> selected;
final String addTitle; final String addTitle;
final Function(List<String>) onSelected;
@override @override
_MultiSelectListState createState() => _MultiSelectListState(); _MultiSelectListState createState() => _MultiSelectListState();
@ -56,7 +60,7 @@ class _MultiSelectListState extends State<_MultiSelectList> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
selected = widget.selected; selected = widget.selected ?? [];
} }
@override @override
@ -84,6 +88,7 @@ class _MultiSelectListState extends State<_MultiSelectList> {
} }
setState(() { setState(() {
selected.add(value); selected.add(value);
widget.onSelected(selected);
}); });
}, },
), ),
@ -129,6 +134,7 @@ class _MultiSelectListState extends State<_MultiSelectList> {
final field = selected[oldIndex]; final field = selected[oldIndex];
selected.remove(field); selected.remove(field);
selected.insert(newIndex, field); selected.insert(newIndex, field);
widget.onSelected(selected);
}); });
}, },
), ),

View File

@ -14,8 +14,10 @@ ReportResult clientReport({
final List<List<ReportElement>> data = []; final List<List<ReportElement>> data = [];
BuiltList<String> columns; BuiltList<String> columns;
if (userCompany.settings.reportColumns.containsKey(kReportClient)) { final reportColumns = userCompany.settings.reportColumns;
columns = userCompany.settings.reportColumns[kReportClient];
if (reportColumns != null && reportColumns.containsKey(kReportClient)) {
columns = reportColumns[kReportClient];
} else { } else {
columns = BuiltList(<String>[ columns = BuiltList(<String>[
ClientFields.name, ClientFields.name,

View File

@ -34,6 +34,7 @@ class ReportsScreen extends StatelessWidget {
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = viewModel.state; final state = viewModel.state;
final reportsUIState = state.uiState.reportsUIState; final reportsUIState = state.uiState.reportsUIState;
final reportResult = viewModel.reportResult;
return WillPopScope( return WillPopScope(
onWillPop: () async { onWillPop: () async {
@ -130,17 +131,8 @@ class ReportsScreen extends StatelessWidget {
onSelected: (selected) { onSelected: (selected) {
print('## ON SELECTED: $selected'); print('## ON SELECTED: $selected');
}, },
options: [ options: reportResult.allColumns,
'one', selected: reportResult.columns,
'two',
'three',
'four',
],
selected: [
'one',
'two',
'three',
],
title: localization.editColumns, title: localization.editColumns,
addTitle: localization.addColumn, addTitle: localization.addColumn,
); );