Code refactor
This commit is contained in:
parent
1480cd5b44
commit
02f43005ff
|
|
@ -416,7 +416,7 @@ const String kSettingsPaymentTermView = 'payment_term/view';
|
||||||
const String kSettingsPaymentTermEdit = 'payment_term/edit';
|
const String kSettingsPaymentTermEdit = 'payment_term/edit';
|
||||||
const String kSettingsUserDetails = 'user_details';
|
const String kSettingsUserDetails = 'user_details';
|
||||||
const String kSettingsLocalization = 'localization';
|
const String kSettingsLocalization = 'localization';
|
||||||
const String kSettingsOnlinePayments = 'online_payments';
|
const String kSettingsPaymentSettings = 'payment_settings';
|
||||||
const String kSettingsCompanyGateways = 'company_gateways';
|
const String kSettingsCompanyGateways = 'company_gateways';
|
||||||
const String kSettingsCompanyGatewaysView = 'company_gateways/view';
|
const String kSettingsCompanyGatewaysView = 'company_gateways/view';
|
||||||
const String kSettingsCompanyGatewaysEdit = 'company_gateways/edit';
|
const String kSettingsCompanyGatewaysEdit = 'company_gateways/edit';
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/settings/payment_settings_vm.dart';
|
||||||
import 'package:local_auth/local_auth.dart';
|
import 'package:local_auth/local_auth.dart';
|
||||||
import 'package:redux/redux.dart';
|
import 'package:redux/redux.dart';
|
||||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||||
|
|
@ -68,7 +69,6 @@ import 'package:invoiceninja_flutter/ui/reports/reports_screen_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/account_management_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/account_management_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/device_settings_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/device_settings_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/expense_settings_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/expense_settings_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/online_payments_vm.dart';
|
|
||||||
import 'package:invoiceninja_flutter/ui/settings/settings_screen_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/settings_screen_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/task_settings_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/task_settings_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/tax_settings_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/tax_settings_vm.dart';
|
||||||
|
|
@ -565,8 +565,8 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
||||||
UserDetailsScreen(),
|
UserDetailsScreen(),
|
||||||
LocalizationScreen.route: (context) =>
|
LocalizationScreen.route: (context) =>
|
||||||
LocalizationScreen(),
|
LocalizationScreen(),
|
||||||
OnlinePaymentsScreen.route: (context) =>
|
PaymentsSettingsScreen.route: (context) =>
|
||||||
OnlinePaymentsScreen(),
|
PaymentsSettingsScreen(),
|
||||||
CompanyGatewayScreen.route: (context) =>
|
CompanyGatewayScreen.route: (context) =>
|
||||||
CompanyGatewayScreenBuilder(),
|
CompanyGatewayScreenBuilder(),
|
||||||
CompanyGatewayViewScreen.route: (context) =>
|
CompanyGatewayViewScreen.route: (context) =>
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||||
// Package imports:
|
// Package imports:
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/app_title_bar.dart';
|
import 'package:invoiceninja_flutter/ui/app/app_title_bar.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/settings/payment_settings_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/platforms.dart';
|
import 'package:invoiceninja_flutter/utils/platforms.dart';
|
||||||
import 'package:redux/redux.dart';
|
import 'package:redux/redux.dart';
|
||||||
|
|
||||||
|
|
@ -59,7 +60,6 @@ import 'package:invoiceninja_flutter/ui/reports/reports_screen_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/account_management_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/account_management_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/device_settings_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/device_settings_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/expense_settings_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/expense_settings_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/online_payments_vm.dart';
|
|
||||||
import 'package:invoiceninja_flutter/ui/settings/settings_screen_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/settings_screen_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/task_settings_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/task_settings_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/tax_settings_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/tax_settings_vm.dart';
|
||||||
|
|
@ -758,8 +758,8 @@ class SettingsScreens extends StatelessWidget {
|
||||||
case kSettingsLocalization:
|
case kSettingsLocalization:
|
||||||
screen = LocalizationScreen();
|
screen = LocalizationScreen();
|
||||||
break;
|
break;
|
||||||
case kSettingsOnlinePayments:
|
case kSettingsPaymentSettings:
|
||||||
screen = OnlinePaymentsScreen();
|
screen = PaymentsSettingsScreen();
|
||||||
break;
|
break;
|
||||||
case kSettingsCompanyGateways:
|
case kSettingsCompanyGateways:
|
||||||
screen = CompanyGatewayScreenBuilder();
|
screen = CompanyGatewayScreenBuilder();
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ class CompanyGatewayScreen extends StatelessWidget {
|
||||||
store.dispatch(ResetSettings());
|
store.dispatch(ResetSettings());
|
||||||
} else {
|
} else {
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
ViewSettings(section: kSettingsOnlinePayments));
|
ViewSettings(section: kSettingsPaymentSettings));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -11,25 +11,25 @@ import 'package:invoiceninja_flutter/ui/app/forms/app_dropdown_button.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/forms/app_form.dart';
|
import 'package:invoiceninja_flutter/ui/app/forms/app_form.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/forms/bool_dropdown_button.dart';
|
import 'package:invoiceninja_flutter/ui/app/forms/bool_dropdown_button.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart';
|
import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/online_payments_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/payment_settings_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||||
|
|
||||||
class OnlinePayments extends StatefulWidget {
|
class PaymentSettings extends StatefulWidget {
|
||||||
const OnlinePayments({
|
const PaymentSettings({
|
||||||
Key key,
|
Key key,
|
||||||
@required this.viewModel,
|
@required this.viewModel,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final OnlinePaymentsVM viewModel;
|
final PaymentSettingsVM viewModel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_OnlinePaymentsState createState() => _OnlinePaymentsState();
|
_PaymentSettingsState createState() => _PaymentSettingsState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _OnlinePaymentsState extends State<OnlinePayments> {
|
class _PaymentSettingsState extends State<PaymentSettings> {
|
||||||
static final GlobalKey<FormState> _formKey =
|
static final GlobalKey<FormState> _formKey =
|
||||||
GlobalKey<FormState>(debugLabel: '_onlinePayments');
|
GlobalKey<FormState>(debugLabel: '_paymentSettings');
|
||||||
FocusScopeNode _focusNode;
|
FocusScopeNode _focusNode;
|
||||||
final _minimumAmountController = TextEditingController();
|
final _minimumAmountController = TextEditingController();
|
||||||
List<TextEditingController> _controllers = [];
|
List<TextEditingController> _controllers = [];
|
||||||
|
|
@ -82,7 +82,7 @@ class _OnlinePaymentsState extends State<OnlinePayments> {
|
||||||
final settings = viewModel.settings;
|
final settings = viewModel.settings;
|
||||||
|
|
||||||
return EditScaffold(
|
return EditScaffold(
|
||||||
title: localization.onlinePayments,
|
title: localization.paymentSettings,
|
||||||
onSavePressed: viewModel.onSavePressed,
|
onSavePressed: viewModel.onSavePressed,
|
||||||
body: AppForm(
|
body: AppForm(
|
||||||
formKey: _formKey,
|
formKey: _formKey,
|
||||||
|
|
@ -4,6 +4,7 @@ import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
// Package imports:
|
// Package imports:
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/settings/payment_settings.dart';
|
||||||
import 'package:redux/redux.dart';
|
import 'package:redux/redux.dart';
|
||||||
|
|
||||||
// Project imports:
|
// Project imports:
|
||||||
|
|
@ -18,20 +19,19 @@ import 'package:invoiceninja_flutter/redux/client/client_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/company/company_actions.dart';
|
import 'package:invoiceninja_flutter/redux/company/company_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/group/group_actions.dart';
|
import 'package:invoiceninja_flutter/redux/group/group_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart';
|
import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/online_payments.dart';
|
|
||||||
import 'package:invoiceninja_flutter/utils/completers.dart';
|
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||||
|
|
||||||
class OnlinePaymentsScreen extends StatelessWidget {
|
class PaymentsSettingsScreen extends StatelessWidget {
|
||||||
const OnlinePaymentsScreen({Key key}) : super(key: key);
|
const PaymentsSettingsScreen({Key key}) : super(key: key);
|
||||||
static const String route = '/$kSettings/$kSettingsOnlinePayments';
|
static const String route = '/$kSettings/$kSettingsPaymentSettings';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return StoreConnector<AppState, OnlinePaymentsVM>(
|
return StoreConnector<AppState, PaymentSettingsVM>(
|
||||||
converter: OnlinePaymentsVM.fromStore,
|
converter: PaymentSettingsVM.fromStore,
|
||||||
builder: (context, viewModel) {
|
builder: (context, viewModel) {
|
||||||
return OnlinePayments(
|
return PaymentSettings(
|
||||||
viewModel: viewModel,
|
viewModel: viewModel,
|
||||||
key: ValueKey(viewModel.state.settingsUIState.updatedAt),
|
key: ValueKey(viewModel.state.settingsUIState.updatedAt),
|
||||||
);
|
);
|
||||||
|
|
@ -40,8 +40,8 @@ class OnlinePaymentsScreen extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OnlinePaymentsVM {
|
class PaymentSettingsVM {
|
||||||
OnlinePaymentsVM({
|
PaymentSettingsVM({
|
||||||
@required this.state,
|
@required this.state,
|
||||||
@required this.company,
|
@required this.company,
|
||||||
@required this.onCompanyChanged,
|
@required this.onCompanyChanged,
|
||||||
|
|
@ -51,10 +51,10 @@ class OnlinePaymentsVM {
|
||||||
@required this.onConfigureGatewaysPressed,
|
@required this.onConfigureGatewaysPressed,
|
||||||
});
|
});
|
||||||
|
|
||||||
static OnlinePaymentsVM fromStore(Store<AppState> store) {
|
static PaymentSettingsVM fromStore(Store<AppState> store) {
|
||||||
final state = store.state;
|
final state = store.state;
|
||||||
|
|
||||||
return OnlinePaymentsVM(
|
return PaymentSettingsVM(
|
||||||
state: state,
|
state: state,
|
||||||
company: state.uiState.settingsUIState.company,
|
company: state.uiState.settingsUIState.company,
|
||||||
settings: state.uiState.settingsUIState.settings,
|
settings: state.uiState.settingsUIState.settings,
|
||||||
|
|
@ -121,7 +121,7 @@ class _SettingsListState extends State<SettingsList> {
|
||||||
viewModel: widget.viewModel,
|
viewModel: widget.viewModel,
|
||||||
),
|
),
|
||||||
SettingsListTile(
|
SettingsListTile(
|
||||||
section: kSettingsOnlinePayments,
|
section: kSettingsPaymentSettings,
|
||||||
viewModel: widget.viewModel,
|
viewModel: widget.viewModel,
|
||||||
),
|
),
|
||||||
SettingsListTile(
|
SettingsListTile(
|
||||||
|
|
@ -375,7 +375,7 @@ class SettingsSearch extends StatelessWidget {
|
||||||
'custom_labels',
|
'custom_labels',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
kSettingsOnlinePayments: [
|
kSettingsPaymentSettings: [
|
||||||
[
|
[
|
||||||
'company_gateways',
|
'company_gateways',
|
||||||
'auto_bill_on',
|
'auto_bill_on',
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
||||||
static final Map<String, Map<String, String>> _localizedValues = {
|
static final Map<String, Map<String, String>> _localizedValues = {
|
||||||
'en': {
|
'en': {
|
||||||
// STARTER: lang key - do not remove comment
|
// STARTER: lang key - do not remove comment
|
||||||
|
'payment_settings': 'Payment Settings',
|
||||||
'default': 'Default',
|
'default': 'Default',
|
||||||
'stock_quantity': 'Stock Quantity',
|
'stock_quantity': 'Stock Quantity',
|
||||||
'notification_threshold': 'Notification Threshold',
|
'notification_threshold': 'Notification Threshold',
|
||||||
|
|
@ -70583,6 +70584,10 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
||||||
_localizedValues[localeCode]['default'] ??
|
_localizedValues[localeCode]['default'] ??
|
||||||
_localizedValues['en']['default'];
|
_localizedValues['en']['default'];
|
||||||
|
|
||||||
|
String get paymentSettings =>
|
||||||
|
_localizedValues[localeCode]['payment_settings'] ??
|
||||||
|
_localizedValues['en']['payment_settings'];
|
||||||
|
|
||||||
// STARTER: lang field - do not remove comment
|
// STARTER: lang field - do not remove comment
|
||||||
|
|
||||||
String lookup(String key) {
|
String lookup(String key) {
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ IconData getSettingIcon(String section) {
|
||||||
return Icons.person;
|
return Icons.person;
|
||||||
case kSettingsLocalization:
|
case kSettingsLocalization:
|
||||||
return Icons.language;
|
return Icons.language;
|
||||||
case kSettingsOnlinePayments:
|
case kSettingsPaymentSettings:
|
||||||
case kSettingsCompanyGateways:
|
case kSettingsCompanyGateways:
|
||||||
return MdiIcons.creditCard;
|
return MdiIcons.creditCard;
|
||||||
case kSettingsTaxSettings:
|
case kSettingsTaxSettings:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue