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 kSettingsUserDetails = 'user_details';
|
||||
const String kSettingsLocalization = 'localization';
|
||||
const String kSettingsOnlinePayments = 'online_payments';
|
||||
const String kSettingsPaymentSettings = 'payment_settings';
|
||||
const String kSettingsCompanyGateways = 'company_gateways';
|
||||
const String kSettingsCompanyGatewaysView = 'company_gateways/view';
|
||||
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_styled_toast/flutter_styled_toast.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:redux/redux.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/device_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/task_settings_vm.dart';
|
||||
import 'package:invoiceninja_flutter/ui/settings/tax_settings_vm.dart';
|
||||
|
|
@ -565,8 +565,8 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
|||
UserDetailsScreen(),
|
||||
LocalizationScreen.route: (context) =>
|
||||
LocalizationScreen(),
|
||||
OnlinePaymentsScreen.route: (context) =>
|
||||
OnlinePaymentsScreen(),
|
||||
PaymentsSettingsScreen.route: (context) =>
|
||||
PaymentsSettingsScreen(),
|
||||
CompanyGatewayScreen.route: (context) =>
|
||||
CompanyGatewayScreenBuilder(),
|
||||
CompanyGatewayViewScreen.route: (context) =>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|||
// Package imports:
|
||||
import 'package:flutter_redux/flutter_redux.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: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/device_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/task_settings_vm.dart';
|
||||
import 'package:invoiceninja_flutter/ui/settings/tax_settings_vm.dart';
|
||||
|
|
@ -758,8 +758,8 @@ class SettingsScreens extends StatelessWidget {
|
|||
case kSettingsLocalization:
|
||||
screen = LocalizationScreen();
|
||||
break;
|
||||
case kSettingsOnlinePayments:
|
||||
screen = OnlinePaymentsScreen();
|
||||
case kSettingsPaymentSettings:
|
||||
screen = PaymentsSettingsScreen();
|
||||
break;
|
||||
case kSettingsCompanyGateways:
|
||||
screen = CompanyGatewayScreenBuilder();
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ class CompanyGatewayScreen extends StatelessWidget {
|
|||
store.dispatch(ResetSettings());
|
||||
} else {
|
||||
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/bool_dropdown_button.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/localization.dart';
|
||||
|
||||
class OnlinePayments extends StatefulWidget {
|
||||
const OnlinePayments({
|
||||
class PaymentSettings extends StatefulWidget {
|
||||
const PaymentSettings({
|
||||
Key key,
|
||||
@required this.viewModel,
|
||||
}) : super(key: key);
|
||||
|
||||
final OnlinePaymentsVM viewModel;
|
||||
final PaymentSettingsVM viewModel;
|
||||
|
||||
@override
|
||||
_OnlinePaymentsState createState() => _OnlinePaymentsState();
|
||||
_PaymentSettingsState createState() => _PaymentSettingsState();
|
||||
}
|
||||
|
||||
class _OnlinePaymentsState extends State<OnlinePayments> {
|
||||
class _PaymentSettingsState extends State<PaymentSettings> {
|
||||
static final GlobalKey<FormState> _formKey =
|
||||
GlobalKey<FormState>(debugLabel: '_onlinePayments');
|
||||
GlobalKey<FormState>(debugLabel: '_paymentSettings');
|
||||
FocusScopeNode _focusNode;
|
||||
final _minimumAmountController = TextEditingController();
|
||||
List<TextEditingController> _controllers = [];
|
||||
|
|
@ -82,7 +82,7 @@ class _OnlinePaymentsState extends State<OnlinePayments> {
|
|||
final settings = viewModel.settings;
|
||||
|
||||
return EditScaffold(
|
||||
title: localization.onlinePayments,
|
||||
title: localization.paymentSettings,
|
||||
onSavePressed: viewModel.onSavePressed,
|
||||
body: AppForm(
|
||||
formKey: _formKey,
|
||||
|
|
@ -4,6 +4,7 @@ import 'package:flutter/widgets.dart';
|
|||
|
||||
// Package imports:
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/ui/settings/payment_settings.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
// 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/group/group_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/localization.dart';
|
||||
|
||||
class OnlinePaymentsScreen extends StatelessWidget {
|
||||
const OnlinePaymentsScreen({Key key}) : super(key: key);
|
||||
static const String route = '/$kSettings/$kSettingsOnlinePayments';
|
||||
class PaymentsSettingsScreen extends StatelessWidget {
|
||||
const PaymentsSettingsScreen({Key key}) : super(key: key);
|
||||
static const String route = '/$kSettings/$kSettingsPaymentSettings';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StoreConnector<AppState, OnlinePaymentsVM>(
|
||||
converter: OnlinePaymentsVM.fromStore,
|
||||
return StoreConnector<AppState, PaymentSettingsVM>(
|
||||
converter: PaymentSettingsVM.fromStore,
|
||||
builder: (context, viewModel) {
|
||||
return OnlinePayments(
|
||||
return PaymentSettings(
|
||||
viewModel: viewModel,
|
||||
key: ValueKey(viewModel.state.settingsUIState.updatedAt),
|
||||
);
|
||||
|
|
@ -40,8 +40,8 @@ class OnlinePaymentsScreen extends StatelessWidget {
|
|||
}
|
||||
}
|
||||
|
||||
class OnlinePaymentsVM {
|
||||
OnlinePaymentsVM({
|
||||
class PaymentSettingsVM {
|
||||
PaymentSettingsVM({
|
||||
@required this.state,
|
||||
@required this.company,
|
||||
@required this.onCompanyChanged,
|
||||
|
|
@ -51,10 +51,10 @@ class OnlinePaymentsVM {
|
|||
@required this.onConfigureGatewaysPressed,
|
||||
});
|
||||
|
||||
static OnlinePaymentsVM fromStore(Store<AppState> store) {
|
||||
static PaymentSettingsVM fromStore(Store<AppState> store) {
|
||||
final state = store.state;
|
||||
|
||||
return OnlinePaymentsVM(
|
||||
return PaymentSettingsVM(
|
||||
state: state,
|
||||
company: state.uiState.settingsUIState.company,
|
||||
settings: state.uiState.settingsUIState.settings,
|
||||
|
|
@ -121,7 +121,7 @@ class _SettingsListState extends State<SettingsList> {
|
|||
viewModel: widget.viewModel,
|
||||
),
|
||||
SettingsListTile(
|
||||
section: kSettingsOnlinePayments,
|
||||
section: kSettingsPaymentSettings,
|
||||
viewModel: widget.viewModel,
|
||||
),
|
||||
SettingsListTile(
|
||||
|
|
@ -375,7 +375,7 @@ class SettingsSearch extends StatelessWidget {
|
|||
'custom_labels',
|
||||
],
|
||||
],
|
||||
kSettingsOnlinePayments: [
|
||||
kSettingsPaymentSettings: [
|
||||
[
|
||||
'company_gateways',
|
||||
'auto_bill_on',
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
static final Map<String, Map<String, String>> _localizedValues = {
|
||||
'en': {
|
||||
// STARTER: lang key - do not remove comment
|
||||
'payment_settings': 'Payment Settings',
|
||||
'default': 'Default',
|
||||
'stock_quantity': 'Stock Quantity',
|
||||
'notification_threshold': 'Notification Threshold',
|
||||
|
|
@ -70583,6 +70584,10 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
_localizedValues[localeCode]['default'] ??
|
||||
_localizedValues['en']['default'];
|
||||
|
||||
String get paymentSettings =>
|
||||
_localizedValues[localeCode]['payment_settings'] ??
|
||||
_localizedValues['en']['payment_settings'];
|
||||
|
||||
// STARTER: lang field - do not remove comment
|
||||
|
||||
String lookup(String key) {
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ IconData getSettingIcon(String section) {
|
|||
return Icons.person;
|
||||
case kSettingsLocalization:
|
||||
return Icons.language;
|
||||
case kSettingsOnlinePayments:
|
||||
case kSettingsPaymentSettings:
|
||||
case kSettingsCompanyGateways:
|
||||
return MdiIcons.creditCard;
|
||||
case kSettingsTaxSettings:
|
||||
|
|
|
|||
Loading…
Reference in New Issue