This commit is contained in:
Hillel Coren 2019-10-27 21:47:06 +02:00
parent 008a146ace
commit 6e11b48307
3 changed files with 84 additions and 48 deletions

View File

@ -127,17 +127,17 @@ class _CustomFieldsState extends State<CustomFields>
ListView(children: <Widget>[
CustomFieldsSettings(
viewModel: viewModel,
fieldLabel: localization.customClientField,
fieldLabel: localization.clientField,
),
CustomFieldsSettings(
viewModel: viewModel,
fieldLabel: localization.customContactField,
fieldLabel: localization.contactField,
),
]),
ListView(children: <Widget>[
CustomFieldsSettings(
viewModel: viewModel,
fieldLabel: localization.customInvoiceField,
fieldLabel: localization.invoiceField,
),
CustomFieldsSettings(
viewModel: viewModel,
@ -148,13 +148,13 @@ class _CustomFieldsState extends State<CustomFields>
ListView(children: <Widget>[
CustomFieldsSettings(
viewModel: viewModel,
fieldLabel: localization.customCreditField,
fieldLabel: localization.creditField,
),
]),
ListView(children: <Widget>[
CustomFieldsSettings(
viewModel: viewModel,
fieldLabel: localization.customPaymentField,
fieldLabel: localization.paymentField,
),
]),
],

View File

@ -7,6 +7,7 @@ import 'package:invoiceninja_flutter/ui/app/forms/date_picker.dart';
import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart';
import 'package:invoiceninja_flutter/ui/settings/generated_numbers_vm.dart';
import 'package:invoiceninja_flutter/ui/settings/settings_scaffold.dart';
import 'package:invoiceninja_flutter/utils/formatting.dart';
import 'package:invoiceninja_flutter/utils/localization.dart';
class GeneratedNumbers extends StatefulWidget {
@ -179,16 +180,44 @@ class _GeneratedNumbersState extends State<GeneratedNumbers>
],
),
ListView(children: <Widget>[
EntityNumberSettings(),
EntityNumberSettings(
counterValue: settings.clientNumberCounter,
patternValue: settings.clientNumberPattern,
onChanged: (counter, pattern) =>
viewModel.onSettingsChanged(settings.rebuild((b) => b
..clientNumberCounter = counter
..clientNumberPattern = pattern)),
),
]),
ListView(children: <Widget>[
EntityNumberSettings(),
EntityNumberSettings(
counterValue: settings.invoiceNumberCounter,
patternValue: settings.invoiceNumberPattern,
onChanged: (counter, pattern) =>
viewModel.onSettingsChanged(settings.rebuild((b) => b
..invoiceNumberCounter = counter
..invoiceNumberPattern = pattern)),
),
]),
ListView(children: <Widget>[
EntityNumberSettings(),
EntityNumberSettings(
counterValue: settings.quoteNumberCounter,
patternValue: settings.quoteNumberPattern,
onChanged: (counter, pattern) =>
viewModel.onSettingsChanged(settings.rebuild((b) => b
..quoteNumberCounter = counter
..quoteNumberPattern = pattern)),
),
]),
ListView(children: <Widget>[
EntityNumberSettings(),
EntityNumberSettings(
counterValue: settings.paymentNumberCounter,
patternValue: settings.paymentNumberPattern,
onChanged: (counter, pattern) =>
viewModel.onSettingsChanged(settings.rebuild((b) => b
..paymentNumberCounter = counter
..paymentNumberPattern = pattern)),
),
]),
],
),
@ -197,6 +226,16 @@ class _GeneratedNumbersState extends State<GeneratedNumbers>
}
class EntityNumberSettings extends StatefulWidget {
const EntityNumberSettings({
@required this.counterValue,
@required this.patternValue,
@required this.onChanged,
});
final int counterValue;
final String patternValue;
final Function(int, String) onChanged;
@override
_EntityNumberSettingsState createState() => _EntityNumberSettingsState();
}
@ -226,10 +265,8 @@ class _EntityNumberSettingsState extends State<EntityNumberSettings> {
_controllers
.forEach((dynamic controller) => controller.removeListener(_onChanged));
/*
final product = widget.viewModel.product;
_productKeyController.text = product.productKey;
*/
_counterController.text = '${widget.counterValue}';
_patternController.text = widget.patternValue;
_controllers
.forEach((dynamic controller) => controller.addListener(_onChanged));
@ -238,13 +275,13 @@ class _EntityNumberSettingsState extends State<EntityNumberSettings> {
}
void _onChanged() {
/*
final product = widget.viewModel.product.rebuild((b) => b
..customValue2 = _custom2Controller.text.trim());
if (product != widget.viewModel.product) {
widget.viewModel.onChanged(product);
final int counter = parseDouble(_counterController.text.trim()).toInt();
final String pattern = _patternController.text.trim();
if (counter != widget.counterValue || pattern != widget.patternValue) {
widget.onChanged(counter, pattern);
}
*/
}
@override
@ -265,4 +302,3 @@ class _EntityNumberSettingsState extends State<EntityNumberSettings> {
);
}
}

View File

@ -24,20 +24,20 @@ mixin LocalizationsProvider on LocaleCodeAware {
'recurring_prefix': 'Recurring Prefix',
'number_padding': 'Number Padding',
'general': 'General',
'custom_company_field': 'Custom Company Field',
'custom_company_value': 'Custom Company Value',
'custom_credit_field': 'Custom Credit Field',
'custom_invoice_field': 'Custom Invoice Field',
'custom_invoice_surcharge': 'Custom Invoice Surcharge',
'custom_client_field': 'Custom Client Field',
'custom_product_field': 'Custom Product Field',
'custom_payment_field': 'Custom Payment Field',
'custom_contact_field': 'Custom Contact Field',
'custom_vendor_field': 'Custom Vendor Field',
'custom_expense_field': 'Custom Expense Field',
'custom_project_field': 'Custom Project Field',
'custom_task_field': 'Custom Task Field',
'custom_group_field': 'Custom Group Field',
'company_field': 'Company Field',
'company_value': 'Company Value',
'credit_field': 'Credit Field',
'invoice_field': 'Invoice Field',
'invoice_surcharge': 'Invoice Surcharge',
'client_field': 'Client Field',
'product_field': 'Product Field',
'payment_field': 'Payment Field',
'contact_field': 'Contact Field',
'vendor_field': 'Vendor Field',
'expense_field': 'Expense Field',
'project_field': 'Project Field',
'task_field': 'Task Field',
'group_field': 'Group Field',
'number_counter': 'Number Counter',
'prefix': 'Prefix',
'number_pattern': 'Number Pattern',
@ -15162,27 +15162,27 @@ mixin LocalizationsProvider on LocaleCodeAware {
String get numberCounter => _localizedValues[localeCode]['number_counter'];
String get customCreditField => _localizedValues[localeCode]['custom_credit_field'];
String get creditField => _localizedValues[localeCode]['credit_field'];
String get customInvoiceField => _localizedValues[localeCode]['custom_invoice_field'];
String get invoiceField => _localizedValues[localeCode]['invoice_field'];
String get customClientField => _localizedValues[localeCode]['custom_client_field'];
String get clientField => _localizedValues[localeCode]['client_field'];
String get customProductField => _localizedValues[localeCode]['custom_product_field'];
String get productField => _localizedValues[localeCode]['product_field'];
String get customPaymentField => _localizedValues[localeCode]['custom_payment_field'];
String get paymentField => _localizedValues[localeCode]['payment_field'];
String get customContactField => _localizedValues[localeCode]['custom_contact_field'];
String get contactField => _localizedValues[localeCode]['contact_field'];
String get customVendorField => _localizedValues[localeCode]['custom_vendor_field'];
String get vendorField => _localizedValues[localeCode]['vendor_field'];
String get customExpenseField => _localizedValues[localeCode]['custom_expense_field'];
String get expenseField => _localizedValues[localeCode]['expense_field'];
String get customProjectField => _localizedValues[localeCode]['custom_project_field'];
String get projectField => _localizedValues[localeCode]['project_field'];
String get customTaskField => _localizedValues[localeCode]['custom_task_field'];
String get taskField => _localizedValues[localeCode]['task_field'];
String get customGroupField => _localizedValues[localeCode]['custom_group_field'];
String get groupField => _localizedValues[localeCode]['group_field'];
String get general => _localizedValues[localeCode]['general'];
@ -15198,13 +15198,13 @@ mixin LocalizationsProvider on LocaleCodeAware {
String get credits => _localizedValues[localeCode]['credits'];
String get customInvoiceSurcharge => _localizedValues[localeCode]['custom_invoice_surcharge'];
String get customInvoiceSurcharge => _localizedValues[localeCode]['invoice_surcharge'];
String get chargeTaxes => _localizedValues[localeCode]['charge_taxes'];
String get customCompanyField => _localizedValues[localeCode]['custom_company_field'];
String get customCompanyField => _localizedValues[localeCode]['company_field'];
String get customCompanyValue => _localizedValues[localeCode]['custom_company_value'];
String get customCompanyValue => _localizedValues[localeCode]['company_value'];
String get generatedNumbers => _localizedValues[localeCode]['generated_numbers'];