Settings
This commit is contained in:
parent
2315085696
commit
037715e5d3
|
|
@ -7,7 +7,7 @@ class SaveCancelButtons extends StatelessWidget {
|
|||
this.onSavePressed,
|
||||
this.onCancelPressed,
|
||||
this.saveLabel,
|
||||
this.isWorking,
|
||||
this.isWorking = false,
|
||||
});
|
||||
|
||||
final bool isWorking;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
import 'dart:async';
|
||||
import 'package:invoiceninja_flutter/data/models/company_gateway_model.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/group_model.dart';
|
||||
import 'package:invoiceninja_flutter/redux/group/group_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
@ -51,7 +49,6 @@ class CompanyGatewayListVM {
|
|||
@required this.onClearEntityFilterPressed,
|
||||
@required this.onViewEntityFilterPressed,
|
||||
@required this.onSortChanged,
|
||||
@required this.onSavePressed,
|
||||
});
|
||||
|
||||
static CompanyGatewayListVM fromStore(Store<AppState> store) {
|
||||
|
|
@ -101,30 +98,6 @@ class CompanyGatewayListVM {
|
|||
);
|
||||
store.dispatch(UpdateSettings(settings: settings));
|
||||
},
|
||||
onSavePressed: (context) {
|
||||
final settingsUIState = state.uiState.settingsUIState;
|
||||
switch (settingsUIState.entityType) {
|
||||
case EntityType.company:
|
||||
final completer = snackBarCompleter<Null>(
|
||||
context, AppLocalization.of(context).savedSettings);
|
||||
store.dispatch(SaveCompanyRequest(
|
||||
completer: completer,
|
||||
company: settingsUIState.userCompany.company));
|
||||
break;
|
||||
case EntityType.group:
|
||||
final completer = snackBarCompleter<GroupEntity>(
|
||||
context, AppLocalization.of(context).savedSettings);
|
||||
store.dispatch(SaveGroupRequest(
|
||||
completer: completer, group: settingsUIState.group));
|
||||
break;
|
||||
case EntityType.client:
|
||||
final completer = snackBarCompleter<ClientEntity>(
|
||||
context, AppLocalization.of(context).savedSettings);
|
||||
store.dispatch(SaveClientRequest(
|
||||
completer: completer, client: settingsUIState.client));
|
||||
break;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -142,5 +115,4 @@ class CompanyGatewayListVM {
|
|||
final Function onClearEntityFilterPressed;
|
||||
final Function(BuildContext) onViewEntityFilterPressed;
|
||||
final Function(int, int) onSortChanged;
|
||||
final Function(BuildContext) onSavePressed;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import 'package:invoiceninja_flutter/data/models/models.dart';
|
|||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/company_gateway/company_gateway_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/company_gateway/company_gateway_list_vm.dart';
|
||||
|
|
@ -53,27 +54,11 @@ class CompanyGatewayScreen extends StatelessWidget {
|
|||
appBarTitle: Text(localization.companyGateways),
|
||||
appBarActions: [
|
||||
if (viewModel.isInMultiselect)
|
||||
FlatButton(
|
||||
key: key,
|
||||
child: Text(
|
||||
localization.cancel,
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
onPressed: () {
|
||||
store.dispatch(ClearCompanyGatewayMultiselect(context: context));
|
||||
},
|
||||
),
|
||||
if (viewModel.isInMultiselect)
|
||||
FlatButton(
|
||||
key: key,
|
||||
textColor: Colors.white,
|
||||
disabledTextColor: Colors.white54,
|
||||
child: Text(
|
||||
localization.done,
|
||||
),
|
||||
onPressed: state.companyGatewayListState.selectedIds.isEmpty
|
||||
SaveCancelButtons(
|
||||
saveLabel: localization.done,
|
||||
onSavePressed: state.companyGatewayListState.selectedIds.isEmpty
|
||||
? null
|
||||
: () async {
|
||||
: (context) async {
|
||||
final companyGateways = viewModel.companyGatewayList
|
||||
.map<CompanyGatewayEntity>((companyGatewayId) =>
|
||||
viewModel.companyGatewayMap[companyGatewayId])
|
||||
|
|
@ -85,10 +70,17 @@ class CompanyGatewayScreen extends StatelessWidget {
|
|||
context: context,
|
||||
onEntityAction: viewModel.onEntityAction,
|
||||
multiselect: true);
|
||||
|
||||
store.dispatch(
|
||||
ClearCompanyGatewayMultiselect(context: context));
|
||||
},
|
||||
),
|
||||
onCancelPressed: (context) => store
|
||||
.dispatch(ClearCompanyGatewayMultiselect(context: context)),
|
||||
)
|
||||
else
|
||||
SaveCancelButtons(
|
||||
//onSavePressed: viewModel.on,
|
||||
),
|
||||
],
|
||||
body: CompanyGatewayListBuilder(),
|
||||
bottomNavigationBar: AppBottomBar(
|
||||
|
|
|
|||
|
|
@ -4,10 +4,16 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/company_gateway_model.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/group_model.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/client/client_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/company_gateway/company_gateway_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/company_gateway/company_gateway_selectors.dart';
|
||||
import 'package:invoiceninja_flutter/redux/group/group_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart';
|
||||
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
import 'company_gateway_screen.dart';
|
||||
|
|
@ -36,6 +42,7 @@ class CompanyGatewayScreenVM {
|
|||
@required this.userCompany,
|
||||
@required this.onEntityAction,
|
||||
@required this.companyGatewayMap,
|
||||
@required this.onSavePressed,
|
||||
});
|
||||
|
||||
final bool isInMultiselect;
|
||||
|
|
@ -43,6 +50,7 @@ class CompanyGatewayScreenVM {
|
|||
final List<String> companyGatewayList;
|
||||
final Function(BuildContext, List<BaseEntity>, EntityAction) onEntityAction;
|
||||
final BuiltMap<String, CompanyGatewayEntity> companyGatewayMap;
|
||||
final Function(BuildContext) onSavePressed;
|
||||
|
||||
static CompanyGatewayScreenVM fromStore(Store<AppState> store) {
|
||||
final state = store.state;
|
||||
|
|
@ -58,6 +66,30 @@ class CompanyGatewayScreenVM {
|
|||
onEntityAction: (BuildContext context, List<BaseEntity> companyGateways,
|
||||
EntityAction action) =>
|
||||
handleCompanyGatewayAction(context, companyGateways, action),
|
||||
onSavePressed: (context) {
|
||||
final settingsUIState = state.uiState.settingsUIState;
|
||||
switch (settingsUIState.entityType) {
|
||||
case EntityType.company:
|
||||
final completer = snackBarCompleter<Null>(
|
||||
context, AppLocalization.of(context).savedSettings);
|
||||
store.dispatch(SaveCompanyRequest(
|
||||
completer: completer,
|
||||
company: settingsUIState.userCompany.company));
|
||||
break;
|
||||
case EntityType.group:
|
||||
final completer = snackBarCompleter<GroupEntity>(
|
||||
context, AppLocalization.of(context).savedSettings);
|
||||
store.dispatch(SaveGroupRequest(
|
||||
completer: completer, group: settingsUIState.group));
|
||||
break;
|
||||
case EntityType.client:
|
||||
final completer = snackBarCompleter<ClientEntity>(
|
||||
context, AppLocalization.of(context).savedSettings);
|
||||
store.dispatch(SaveClientRequest(
|
||||
completer: completer, client: settingsUIState.client));
|
||||
break;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import 'package:flutter_redux/flutter_redux.dart';
|
|||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/save_cancel_buttons.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
import 'package:invoiceninja_flutter/utils/platforms.dart';
|
||||
|
||||
class SettingsScaffold extends StatelessWidget {
|
||||
|
|
|
|||
Loading…
Reference in New Issue