Starter...
This commit is contained in:
parent
5b0984ef18
commit
5aaf30f1f9
|
|
@ -2,17 +2,20 @@ import 'dart:async';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/credit_model.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/list_filter.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/list_filter_button.dart';
|
||||
import 'package:invoiceninja_flutter/ui/credit/credit_screen_vm.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/ui/credit/credit_list_vm.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/credit/credit_actions.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/app_bottom_bar.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/save_cancel_buttons.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/list_scaffold.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/entities/entity_actions_dialog.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/list_filter.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/list_filter_button.dart';
|
||||
import 'package:invoiceninja_flutter/ui/credit/credit_list_vm.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
|
||||
import 'credit_screen_vm.dart';
|
||||
|
||||
class CreditScreen extends StatelessWidget {
|
||||
const CreditScreen({
|
||||
|
|
@ -28,28 +31,29 @@ class CreditScreen extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
final userCompany = state.userCompany;
|
||||
final localization = AppLocalization.of(context);
|
||||
final listUIState = state.uiState.creditUIState.listUIState;
|
||||
final isInMultiselect = listUIState.isInMultiselect();
|
||||
|
||||
return AppScaffold(
|
||||
return ListScaffold(
|
||||
isChecked: isInMultiselect &&
|
||||
listUIState.selectedIds.length == viewModel.creditList.length,
|
||||
showCheckbox: isInMultiselect,
|
||||
onHamburgerLongPress: () => store.dispatch(StartCreditMultiselect()),
|
||||
onCheckboxChanged: (value) {
|
||||
final credits = viewModel.creditList
|
||||
.map<InvoiceEntity>((creditId) => viewModel.creditMap[creditId])
|
||||
.where((credit) => value != listUIState.isSelected(credit))
|
||||
.where((credit) => value != listUIState.isSelected(credit.id))
|
||||
.toList();
|
||||
|
||||
viewModel.onEntityAction(
|
||||
context, credits, EntityAction.toggleMultiselect);
|
||||
handleCreditAction(context, credits, EntityAction.toggleMultiselect);
|
||||
},
|
||||
appBarTitle: ListFilter(
|
||||
title: localization.credits
|
||||
title: localization.credits,
|
||||
key: ValueKey(state.creditListState.filterClearedAt),
|
||||
entityType: EntityType.credit,
|
||||
filter: state.creditListState.filter,
|
||||
onFilterChanged: (value) {
|
||||
store.dispatch(FilterCredits(value));
|
||||
},
|
||||
|
|
@ -57,7 +61,7 @@ class CreditScreen extends StatelessWidget {
|
|||
appBarActions: [
|
||||
if (!viewModel.isInMultiselect)
|
||||
ListFilterButton(
|
||||
entityType: EntityType.credit,
|
||||
filter: state.creditListState.filter,
|
||||
onFilterPressed: (String value) {
|
||||
store.dispatch(FilterCredits(value));
|
||||
},
|
||||
|
|
@ -74,10 +78,12 @@ class CreditScreen extends StatelessWidget {
|
|||
.toList();
|
||||
|
||||
await showEntityActionsDialog(
|
||||
entities: credits, context: context, multiselect: true,
|
||||
entities: credits,
|
||||
context: context,
|
||||
multiselect: true,
|
||||
completer: Completer<Null>()
|
||||
..future.then((_) =>
|
||||
store.dispatch(ClearCreditMultiselect())),
|
||||
..future.then<dynamic>(
|
||||
(_) => store.dispatch(ClearCreditMultiselect())),
|
||||
);
|
||||
},
|
||||
onCancelPressed: (context) =>
|
||||
|
|
@ -87,16 +93,12 @@ class CreditScreen extends StatelessWidget {
|
|||
body: CreditListBuilder(),
|
||||
bottomNavigationBar: AppBottomBar(
|
||||
entityType: EntityType.credit,
|
||||
onSelectedSortField: (value) => store.dispatch(SortCredits(value)),
|
||||
customValues1: company.getCustomFieldValues(CustomFieldType.credit1,
|
||||
excludeBlank: true),
|
||||
customValues2: company.getCustomFieldValues(CustomFieldType.credit2,
|
||||
excludeBlank: true),
|
||||
onSelectedCustom1: (value) =>
|
||||
store.dispatch(FilterCreditsByCustom1(value)),
|
||||
onSelectedCustom2: (value) =>
|
||||
store.dispatch(FilterCreditsByCustom2(value)),
|
||||
onSelectedSortField: (value) {
|
||||
store.dispatch(SortCredits(value));
|
||||
},
|
||||
sortFields: [
|
||||
CreditFields.number,
|
||||
CreditFields.amount,
|
||||
CreditFields.updatedAt,
|
||||
],
|
||||
onSelectedState: (EntityState state, value) {
|
||||
|
|
@ -109,14 +111,30 @@ class CreditScreen extends StatelessWidget {
|
|||
store.dispatch(StartCreditMultiselect());
|
||||
}
|
||||
},
|
||||
customValues1: company.getCustomFieldValues(CustomFieldType.invoice1,
|
||||
excludeBlank: true),
|
||||
customValues2: company.getCustomFieldValues(CustomFieldType.invoice2,
|
||||
excludeBlank: true),
|
||||
customValues3: company.getCustomFieldValues(CustomFieldType.invoice3,
|
||||
excludeBlank: true),
|
||||
customValues4: company.getCustomFieldValues(CustomFieldType.invoice4,
|
||||
excludeBlank: true),
|
||||
onSelectedCustom1: (value) =>
|
||||
store.dispatch(FilterCreditsByCustom1(value)),
|
||||
onSelectedCustom2: (value) =>
|
||||
store.dispatch(FilterCreditsByCustom2(value)),
|
||||
onSelectedCustom3: (value) =>
|
||||
store.dispatch(FilterCreditsByCustom3(value)),
|
||||
onSelectedCustom4: (value) =>
|
||||
store.dispatch(FilterCreditsByCustom4(value)),
|
||||
),
|
||||
floatingActionButton: user.canCreate(EntityType.credit)
|
||||
floatingActionButton: userCompany.canCreate(EntityType.credit)
|
||||
? FloatingActionButton(
|
||||
heroTag: 'credit_fab',
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
onPressed: () {
|
||||
store.dispatch(
|
||||
EditCredit(credit: InvoiceEntity(), context: context));
|
||||
createEntityByType(
|
||||
context: context, entityType: EntityType.credit);
|
||||
},
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
|
|
|
|||
|
|
@ -2,17 +2,20 @@ import 'dart:async';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/stub_model.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/list_filter.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/list_filter_button.dart';
|
||||
import 'package:invoiceninja_flutter/ui/stub/stub_screen_vm.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/ui/stub/stub_list_vm.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/stub/stub_actions.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/app_bottom_bar.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/save_cancel_buttons.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/list_scaffold.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/entities/entity_actions_dialog.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/list_filter.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/list_filter_button.dart';
|
||||
import 'package:invoiceninja_flutter/ui/stub/stub_list_vm.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
|
||||
import 'stub_screen_vm.dart';
|
||||
|
||||
class StubScreen extends StatelessWidget {
|
||||
const StubScreen({
|
||||
|
|
@ -28,28 +31,29 @@ class StubScreen extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
final userCompany = state.userCompany;
|
||||
final localization = AppLocalization.of(context);
|
||||
final listUIState = state.uiState.stubUIState.listUIState;
|
||||
final isInMultiselect = listUIState.isInMultiselect();
|
||||
|
||||
return AppScaffold(
|
||||
return ListScaffold(
|
||||
isChecked: isInMultiselect &&
|
||||
listUIState.selectedIds.length == viewModel.stubList.length,
|
||||
showCheckbox: isInMultiselect,
|
||||
onHamburgerLongPress: () => store.dispatch(StartStubMultiselect()),
|
||||
onCheckboxChanged: (value) {
|
||||
final stubs = viewModel.stubList
|
||||
.map<StubEntity>((stubId) => viewModel.stubMap[stubId])
|
||||
.where((stub) => value != listUIState.isSelected(stub))
|
||||
.where((stub) => value != listUIState.isSelected(stub.id))
|
||||
.toList();
|
||||
|
||||
viewModel.onEntityAction(
|
||||
context, stubs, EntityAction.toggleMultiselect);
|
||||
handleStubAction(context, stubs, EntityAction.toggleMultiselect);
|
||||
},
|
||||
appBarTitle: ListFilter(
|
||||
title: localization.stubs
|
||||
title: localization.stubs,
|
||||
key: ValueKey(state.stubListState.filterClearedAt),
|
||||
entityType: EntityType.stub,
|
||||
filter: state.stubListState.filter,
|
||||
onFilterChanged: (value) {
|
||||
store.dispatch(FilterStubs(value));
|
||||
},
|
||||
|
|
@ -57,7 +61,7 @@ class StubScreen extends StatelessWidget {
|
|||
appBarActions: [
|
||||
if (!viewModel.isInMultiselect)
|
||||
ListFilterButton(
|
||||
entityType: EntityType.stub,
|
||||
filter: state.stubListState.filter,
|
||||
onFilterPressed: (String value) {
|
||||
store.dispatch(FilterStubs(value));
|
||||
},
|
||||
|
|
@ -74,10 +78,12 @@ class StubScreen extends StatelessWidget {
|
|||
.toList();
|
||||
|
||||
await showEntityActionsDialog(
|
||||
entities: stubs, context: context, multiselect: true,
|
||||
entities: stubs,
|
||||
context: context,
|
||||
multiselect: true,
|
||||
completer: Completer<Null>()
|
||||
..future.then((_) =>
|
||||
store.dispatch(ClearStubMultiselect())),
|
||||
..future.then<dynamic>(
|
||||
(_) => store.dispatch(ClearStubMultiselect())),
|
||||
);
|
||||
},
|
||||
onCancelPressed: (context) =>
|
||||
|
|
@ -87,16 +93,12 @@ class StubScreen extends StatelessWidget {
|
|||
body: StubListBuilder(),
|
||||
bottomNavigationBar: AppBottomBar(
|
||||
entityType: EntityType.stub,
|
||||
onSelectedSortField: (value) => store.dispatch(SortStubs(value)),
|
||||
customValues1: company.getCustomFieldValues(CustomFieldType.stub1,
|
||||
excludeBlank: true),
|
||||
customValues2: company.getCustomFieldValues(CustomFieldType.stub2,
|
||||
excludeBlank: true),
|
||||
onSelectedCustom1: (value) =>
|
||||
store.dispatch(FilterStubsByCustom1(value)),
|
||||
onSelectedCustom2: (value) =>
|
||||
store.dispatch(FilterStubsByCustom2(value)),
|
||||
onSelectedSortField: (value) {
|
||||
store.dispatch(SortStubs(value));
|
||||
},
|
||||
sortFields: [
|
||||
StubFields.name,
|
||||
StubFields.balance,
|
||||
StubFields.updatedAt,
|
||||
],
|
||||
onSelectedState: (EntityState state, value) {
|
||||
|
|
@ -109,14 +111,30 @@ class StubScreen extends StatelessWidget {
|
|||
store.dispatch(StartStubMultiselect());
|
||||
}
|
||||
},
|
||||
customValues1: company.getCustomFieldValues(CustomFieldType.stub1,
|
||||
excludeBlank: true),
|
||||
customValues2: company.getCustomFieldValues(CustomFieldType.stub2,
|
||||
excludeBlank: true),
|
||||
customValues3: company.getCustomFieldValues(CustomFieldType.stub3,
|
||||
excludeBlank: true),
|
||||
customValues4: company.getCustomFieldValues(CustomFieldType.stub4,
|
||||
excludeBlank: true),
|
||||
onSelectedCustom1: (value) =>
|
||||
store.dispatch(FilterStubsByCustom1(value)),
|
||||
onSelectedCustom2: (value) =>
|
||||
store.dispatch(FilterStubsByCustom2(value)),
|
||||
onSelectedCustom3: (value) =>
|
||||
store.dispatch(FilterStubsByCustom3(value)),
|
||||
onSelectedCustom4: (value) =>
|
||||
store.dispatch(FilterStubsByCustom4(value)),
|
||||
),
|
||||
floatingActionButton: user.canCreate(EntityType.stub)
|
||||
floatingActionButton: userCompany.canCreate(EntityType.stub)
|
||||
? FloatingActionButton(
|
||||
heroTag: 'stub_fab',
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
onPressed: () {
|
||||
store.dispatch(
|
||||
EditStub(stub: StubEntity(), context: context));
|
||||
createEntityByType(
|
||||
context: context, entityType: EntityType.stub);
|
||||
},
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
|
|
|
|||
Loading…
Reference in New Issue