Settings
This commit is contained in:
parent
e0a1d69bf6
commit
b214daccd8
|
|
@ -4,20 +4,27 @@ import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
|||
|
||||
class AppForm extends StatelessWidget {
|
||||
const AppForm({
|
||||
@required this.children,
|
||||
this.children,
|
||||
this.child,
|
||||
@required this.formKey,
|
||||
@required this.focusNode,
|
||||
});
|
||||
|
||||
final GlobalKey<FormState> formKey;
|
||||
final List<Widget> children;
|
||||
final Widget child;
|
||||
final FocusScopeNode focusNode;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Form(
|
||||
key: formKey,
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
children: children,
|
||||
return FocusScope(
|
||||
node: focusNode,
|
||||
child: Form(
|
||||
key: formKey,
|
||||
child: child ?? ListView(
|
||||
shrinkWrap: true,
|
||||
children: children,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'package:invoiceninja_flutter/constants.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/form_card.dart';
|
||||
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/client_picker.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/custom_field.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/custom_surcharges.dart';
|
||||
|
|
@ -38,6 +39,10 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
with SingleTickerProviderStateMixin {
|
||||
TabController _tabController;
|
||||
|
||||
FocusNode _focusNode;
|
||||
static final GlobalKey<FormState> _formKey =
|
||||
GlobalKey<FormState>(debugLabel: '_invoicesEdit');
|
||||
|
||||
final _invoiceNumberController = TextEditingController();
|
||||
final _poNumberController = TextEditingController();
|
||||
final _discountController = TextEditingController();
|
||||
|
|
@ -63,6 +68,7 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_focusNode = FocusScopeNode();
|
||||
_tabController = TabController(vsync: this, length: 4);
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +117,7 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
_surcharge4Controller.text = formatNumber(invoice.customSurcharge4, context,
|
||||
formatNumberType: FormatNumberType.input);
|
||||
_designController.text =
|
||||
invoice.designId != null ? kInvoiceDesigns[invoice.designId] : '';
|
||||
invoice.designId != null ? kInvoiceDesigns[invoice.designId] : '';
|
||||
_publicNotesController.text = invoice.publicNotes;
|
||||
_privateNotesController.text = invoice.privateNotes;
|
||||
_termsController.text = invoice.terms;
|
||||
|
|
@ -125,6 +131,7 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
|
||||
@override
|
||||
void dispose() {
|
||||
_focusNode.dispose();
|
||||
_tabController.dispose();
|
||||
_controllers.forEach((controller) {
|
||||
controller.removeListener(_onChanged);
|
||||
|
|
@ -136,7 +143,8 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
|
||||
void _onChanged() {
|
||||
_debouncer.run(() {
|
||||
final invoice = widget.viewModel.invoice.rebuild((b) => b
|
||||
final invoice = widget.viewModel.invoice.rebuild((b) =>
|
||||
b
|
||||
..number = widget.viewModel.invoice.isNew
|
||||
? ''
|
||||
: _invoiceNumberController.text.trim()
|
||||
|
|
@ -168,273 +176,299 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
|
|||
final invoice = viewModel.invoice;
|
||||
final company = viewModel.company;
|
||||
|
||||
return ListView(
|
||||
children: <Widget>[
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: FormCard(
|
||||
padding: const EdgeInsets.only(
|
||||
top: kMobileDialogPadding,
|
||||
right: kMobileDialogPadding / 2,
|
||||
bottom: kMobileDialogPadding,
|
||||
left: kMobileDialogPadding),
|
||||
children: <Widget>[
|
||||
if (invoice.isNew)
|
||||
ClientPicker(
|
||||
clientId: invoice.clientId,
|
||||
clientState: viewModel.state.clientState,
|
||||
onSelected: (client) =>
|
||||
viewModel.onClientChanged(invoice, client),
|
||||
onAddPressed: (completer) =>
|
||||
viewModel.onAddClientPressed(context, completer),
|
||||
return AppForm(
|
||||
formKey: _formKey,
|
||||
focusNode: _focusNode,
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: FormCard(
|
||||
padding: const EdgeInsets.only(
|
||||
top: kMobileDialogPadding,
|
||||
right: kMobileDialogPadding / 2,
|
||||
bottom: kMobileDialogPadding,
|
||||
left: kMobileDialogPadding),
|
||||
children: <Widget>[
|
||||
if (invoice.isNew)
|
||||
ClientPicker(
|
||||
clientId: invoice.clientId,
|
||||
clientState: viewModel.state.clientState,
|
||||
onSelected: (client) =>
|
||||
viewModel.onClientChanged(invoice, client),
|
||||
onAddPressed: (completer) =>
|
||||
viewModel.onAddClientPressed(context, completer),
|
||||
),
|
||||
UserPicker(
|
||||
userId: invoice.assignedUserId,
|
||||
onChanged: (userId) =>
|
||||
viewModel.onChanged(
|
||||
invoice.rebuild((
|
||||
b) => b..assignedUserId = userId)),
|
||||
),
|
||||
UserPicker(
|
||||
userId: invoice.assignedUserId,
|
||||
onChanged: (userId) => viewModel.onChanged(
|
||||
invoice.rebuild((b) => b..assignedUserId = userId)),
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
child: InvoiceEditContactsScreen(),
|
||||
),
|
||||
],
|
||||
SizedBox(
|
||||
height: 100,
|
||||
child: InvoiceEditContactsScreen(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: FormCard(
|
||||
padding: const EdgeInsets.only(
|
||||
top: kMobileDialogPadding,
|
||||
right: kMobileDialogPadding / 2,
|
||||
bottom: kMobileDialogPadding,
|
||||
left: kMobileDialogPadding / 2),
|
||||
children: <Widget>[
|
||||
DatePicker(
|
||||
validator: (String val) => val.trim().isEmpty
|
||||
? AppLocalization.of(context).pleaseSelectADate
|
||||
: null,
|
||||
labelText: widget.isQuote
|
||||
? localization.quoteDate
|
||||
: localization.invoiceDate,
|
||||
selectedDate: invoice.date,
|
||||
onSelected: (date) {
|
||||
viewModel
|
||||
.onChanged(invoice.rebuild((b) => b..date = date));
|
||||
},
|
||||
),
|
||||
DatePicker(
|
||||
labelText: widget.isQuote
|
||||
? localization.validUntil
|
||||
: localization.dueDate,
|
||||
selectedDate: invoice.dueDate,
|
||||
onSelected: (date) {
|
||||
viewModel
|
||||
.onChanged(invoice.rebuild((b) => b..dueDate = date));
|
||||
},
|
||||
),
|
||||
DecoratedFormField(
|
||||
label: localization.partialDeposit,
|
||||
controller: _partialController,
|
||||
keyboardType:
|
||||
TextInputType.numberWithOptions(decimal: true),
|
||||
),
|
||||
if (invoice.partial != null && invoice.partial > 0)
|
||||
Expanded(
|
||||
child: FormCard(
|
||||
padding: const EdgeInsets.only(
|
||||
top: kMobileDialogPadding,
|
||||
right: kMobileDialogPadding / 2,
|
||||
bottom: kMobileDialogPadding,
|
||||
left: kMobileDialogPadding / 2),
|
||||
children: <Widget>[
|
||||
DatePicker(
|
||||
labelText: localization.partialDueDate,
|
||||
selectedDate: invoice.partialDueDate,
|
||||
validator: (String val) =>
|
||||
val
|
||||
.trim()
|
||||
.isEmpty
|
||||
? AppLocalization
|
||||
.of(context)
|
||||
.pleaseSelectADate
|
||||
: null,
|
||||
labelText: widget.isQuote
|
||||
? localization.quoteDate
|
||||
: localization.invoiceDate,
|
||||
selectedDate: invoice.date,
|
||||
onSelected: (date) {
|
||||
viewModel.onChanged(
|
||||
invoice.rebuild((b) => b..partialDueDate = date));
|
||||
viewModel
|
||||
.onChanged(invoice.rebuild((b) => b..date = date));
|
||||
},
|
||||
),
|
||||
CustomField(
|
||||
controller: _custom1Controller,
|
||||
field: CustomFieldType.invoice1,
|
||||
value: invoice.customValue1,
|
||||
),
|
||||
CustomField(
|
||||
controller: _custom2Controller,
|
||||
field: CustomFieldType.invoice2,
|
||||
value: invoice.customValue2,
|
||||
),
|
||||
],
|
||||
DatePicker(
|
||||
labelText: widget.isQuote
|
||||
? localization.validUntil
|
||||
: localization.dueDate,
|
||||
selectedDate: invoice.dueDate,
|
||||
onSelected: (date) {
|
||||
viewModel
|
||||
.onChanged(
|
||||
invoice.rebuild((b) => b..dueDate = date));
|
||||
},
|
||||
),
|
||||
DecoratedFormField(
|
||||
label: localization.partialDeposit,
|
||||
controller: _partialController,
|
||||
keyboardType:
|
||||
TextInputType.numberWithOptions(decimal: true),
|
||||
),
|
||||
if (invoice.partial != null && invoice.partial > 0)
|
||||
DatePicker(
|
||||
labelText: localization.partialDueDate,
|
||||
selectedDate: invoice.partialDueDate,
|
||||
onSelected: (date) {
|
||||
viewModel.onChanged(
|
||||
invoice.rebuild((b) => b..partialDueDate = date));
|
||||
},
|
||||
),
|
||||
CustomField(
|
||||
controller: _custom1Controller,
|
||||
field: CustomFieldType.invoice1,
|
||||
value: invoice.customValue1,
|
||||
),
|
||||
CustomField(
|
||||
controller: _custom2Controller,
|
||||
field: CustomFieldType.invoice2,
|
||||
value: invoice.customValue2,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: FormCard(
|
||||
padding: const EdgeInsets.only(
|
||||
top: kMobileDialogPadding,
|
||||
right: kMobileDialogPadding,
|
||||
bottom: kMobileDialogPadding,
|
||||
left: kMobileDialogPadding / 2),
|
||||
children: <Widget>[
|
||||
DecoratedFormField(
|
||||
controller: _invoiceNumberController,
|
||||
label: widget.isQuote
|
||||
? localization.quoteNumber
|
||||
: localization.invoiceNumber,
|
||||
validator: (String val) => val.trim().isEmpty &&
|
||||
invoice.isOld
|
||||
? AppLocalization.of(context).pleaseEnterAnInvoiceNumber
|
||||
: null,
|
||||
),
|
||||
DecoratedFormField(
|
||||
label: localization.poNumber,
|
||||
controller: _poNumberController,
|
||||
),
|
||||
DiscountField(
|
||||
controller: _discountController,
|
||||
value: invoice.discount,
|
||||
isAmountDiscount: invoice.isAmountDiscount,
|
||||
onTypeChanged: (value) => viewModel.onChanged(
|
||||
invoice.rebuild((b) => b..isAmountDiscount = value)),
|
||||
),
|
||||
CustomField(
|
||||
controller: _custom2Controller,
|
||||
field: CustomFieldType.invoice2,
|
||||
value: invoice.customValue2,
|
||||
),
|
||||
CustomField(
|
||||
controller: _custom4Controller,
|
||||
field: CustomFieldType.invoice4,
|
||||
value: invoice.customValue4,
|
||||
),
|
||||
],
|
||||
Expanded(
|
||||
child: FormCard(
|
||||
padding: const EdgeInsets.only(
|
||||
top: kMobileDialogPadding,
|
||||
right: kMobileDialogPadding,
|
||||
bottom: kMobileDialogPadding,
|
||||
left: kMobileDialogPadding / 2),
|
||||
children: <Widget>[
|
||||
DecoratedFormField(
|
||||
controller: _invoiceNumberController,
|
||||
label: widget.isQuote
|
||||
? localization.quoteNumber
|
||||
: localization.invoiceNumber,
|
||||
validator: (String val) =>
|
||||
val
|
||||
.trim()
|
||||
.isEmpty &&
|
||||
invoice.isOld
|
||||
? AppLocalization
|
||||
.of(context)
|
||||
.pleaseEnterAnInvoiceNumber
|
||||
: null,
|
||||
),
|
||||
DecoratedFormField(
|
||||
label: localization.poNumber,
|
||||
controller: _poNumberController,
|
||||
),
|
||||
DiscountField(
|
||||
controller: _discountController,
|
||||
value: invoice.discount,
|
||||
isAmountDiscount: invoice.isAmountDiscount,
|
||||
onTypeChanged: (value) =>
|
||||
viewModel.onChanged(
|
||||
invoice.rebuild((
|
||||
b) => b..isAmountDiscount = value)),
|
||||
),
|
||||
CustomField(
|
||||
controller: _custom2Controller,
|
||||
field: CustomFieldType.invoice2,
|
||||
value: invoice.customValue2,
|
||||
),
|
||||
CustomField(
|
||||
controller: _custom4Controller,
|
||||
field: CustomFieldType.invoice4,
|
||||
value: invoice.customValue4,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
widget.isQuote ? QuoteEditItemsScreen() : InvoiceEditItemsScreen(),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: FormCard(
|
||||
padding: const EdgeInsets.only(
|
||||
top: kMobileDialogPadding,
|
||||
right: kMobileDialogPadding / 2,
|
||||
bottom: kMobileDialogPadding,
|
||||
left: kMobileDialogPadding),
|
||||
children: <Widget>[
|
||||
TabBar(
|
||||
controller: _tabController,
|
||||
tabs: [
|
||||
Tab(text: localization.publicNotes),
|
||||
Tab(text: localization.privateNotes),
|
||||
Tab(text: localization.terms),
|
||||
Tab(text: localization.footer),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
child: TabBarView(
|
||||
],
|
||||
),
|
||||
widget.isQuote ? QuoteEditItemsScreen() : InvoiceEditItemsScreen(),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: FormCard(
|
||||
padding: const EdgeInsets.only(
|
||||
top: kMobileDialogPadding,
|
||||
right: kMobileDialogPadding / 2,
|
||||
bottom: kMobileDialogPadding,
|
||||
left: kMobileDialogPadding),
|
||||
children: <Widget>[
|
||||
TabBar(
|
||||
controller: _tabController,
|
||||
children: <Widget>[
|
||||
DecoratedFormField(
|
||||
maxLines: 4,
|
||||
controller: _publicNotesController,
|
||||
keyboardType: TextInputType.multiline,
|
||||
label: '',
|
||||
),
|
||||
DecoratedFormField(
|
||||
maxLines: 4,
|
||||
controller: _privateNotesController,
|
||||
keyboardType: TextInputType.multiline,
|
||||
label: '',
|
||||
),
|
||||
DecoratedFormField(
|
||||
maxLines: 4,
|
||||
controller: _termsController,
|
||||
keyboardType: TextInputType.multiline,
|
||||
label: '',
|
||||
),
|
||||
DecoratedFormField(
|
||||
maxLines: 4,
|
||||
controller: _footerController,
|
||||
keyboardType: TextInputType.multiline,
|
||||
label: '',
|
||||
),
|
||||
tabs: [
|
||||
Tab(text: localization.publicNotes),
|
||||
Tab(text: localization.privateNotes),
|
||||
Tab(text: localization.terms),
|
||||
Tab(text: localization.footer),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
SizedBox(
|
||||
height: 100,
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: <Widget>[
|
||||
DecoratedFormField(
|
||||
maxLines: 4,
|
||||
controller: _publicNotesController,
|
||||
keyboardType: TextInputType.multiline,
|
||||
label: '',
|
||||
),
|
||||
DecoratedFormField(
|
||||
maxLines: 4,
|
||||
controller: _privateNotesController,
|
||||
keyboardType: TextInputType.multiline,
|
||||
label: '',
|
||||
),
|
||||
DecoratedFormField(
|
||||
maxLines: 4,
|
||||
controller: _termsController,
|
||||
keyboardType: TextInputType.multiline,
|
||||
label: '',
|
||||
),
|
||||
DecoratedFormField(
|
||||
maxLines: 4,
|
||||
controller: _footerController,
|
||||
keyboardType: TextInputType.multiline,
|
||||
label: '',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: FormCard(
|
||||
padding: const EdgeInsets.only(
|
||||
top: kMobileDialogPadding,
|
||||
right: kMobileDialogPadding,
|
||||
bottom: kMobileDialogPadding,
|
||||
left: kMobileDialogPadding / 2),
|
||||
children: <Widget>[
|
||||
/*
|
||||
DecoratedFormField(
|
||||
controller: null,
|
||||
enabled: false,
|
||||
initialValue: '10',
|
||||
label: localization.subtotal,
|
||||
),
|
||||
*/
|
||||
CustomSurcharges(
|
||||
surcharge1Controller: _surcharge1Controller,
|
||||
surcharge2Controller: _surcharge2Controller,
|
||||
surcharge3Controller: _surcharge3Controller,
|
||||
surcharge4Controller: _surcharge4Controller,
|
||||
),
|
||||
if (company.settings.enableFirstInvoiceTaxRate)
|
||||
TaxRateDropdown(
|
||||
onSelected: (taxRate) =>
|
||||
viewModel.onChanged(invoice.applyTax(taxRate)),
|
||||
labelText: localization.tax,
|
||||
initialTaxName: invoice.taxName1,
|
||||
initialTaxRate: invoice.taxRate1,
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: FormCard(
|
||||
padding: const EdgeInsets.only(
|
||||
top: kMobileDialogPadding,
|
||||
right: kMobileDialogPadding,
|
||||
bottom: kMobileDialogPadding,
|
||||
left: kMobileDialogPadding / 2),
|
||||
children: <Widget>[
|
||||
/*
|
||||
DecoratedFormField(
|
||||
controller: null,
|
||||
enabled: false,
|
||||
initialValue: '10',
|
||||
label: localization.subtotal,
|
||||
),
|
||||
if (company.settings.enableSecondInvoiceTaxRate)
|
||||
TaxRateDropdown(
|
||||
onSelected: (taxRate) => viewModel
|
||||
.onChanged(invoice.applyTax(taxRate, isSecond: true)),
|
||||
labelText: localization.tax,
|
||||
initialTaxName: invoice.taxName2,
|
||||
initialTaxRate: invoice.taxRate2,
|
||||
*/
|
||||
CustomSurcharges(
|
||||
surcharge1Controller: _surcharge1Controller,
|
||||
surcharge2Controller: _surcharge2Controller,
|
||||
surcharge3Controller: _surcharge3Controller,
|
||||
surcharge4Controller: _surcharge4Controller,
|
||||
),
|
||||
if (company.settings.enableThirdInvoiceTaxRate)
|
||||
TaxRateDropdown(
|
||||
onSelected: (taxRate) => viewModel
|
||||
.onChanged(invoice.applyTax(taxRate, isThird: true)),
|
||||
labelText: localization.tax,
|
||||
initialTaxName: invoice.taxName3,
|
||||
initialTaxRate: invoice.taxRate3,
|
||||
if (company.settings.enableFirstInvoiceTaxRate)
|
||||
TaxRateDropdown(
|
||||
onSelected: (taxRate) =>
|
||||
viewModel.onChanged(invoice.applyTax(taxRate)),
|
||||
labelText: localization.tax,
|
||||
initialTaxName: invoice.taxName1,
|
||||
initialTaxRate: invoice.taxRate1,
|
||||
),
|
||||
if (company.settings.enableSecondInvoiceTaxRate)
|
||||
TaxRateDropdown(
|
||||
onSelected: (taxRate) =>
|
||||
viewModel
|
||||
.onChanged(
|
||||
invoice.applyTax(taxRate, isSecond: true)),
|
||||
labelText: localization.tax,
|
||||
initialTaxName: invoice.taxName2,
|
||||
initialTaxRate: invoice.taxRate2,
|
||||
),
|
||||
if (company.settings.enableThirdInvoiceTaxRate)
|
||||
TaxRateDropdown(
|
||||
onSelected: (taxRate) =>
|
||||
viewModel
|
||||
.onChanged(
|
||||
invoice.applyTax(taxRate, isThird: true)),
|
||||
labelText: localization.tax,
|
||||
initialTaxName: invoice.taxName3,
|
||||
initialTaxRate: invoice.taxRate3,
|
||||
),
|
||||
CustomSurcharges(
|
||||
surcharge1Controller: _surcharge1Controller,
|
||||
surcharge2Controller: _surcharge2Controller,
|
||||
surcharge3Controller: _surcharge3Controller,
|
||||
surcharge4Controller: _surcharge4Controller,
|
||||
isAfterTaxes: true,
|
||||
),
|
||||
CustomSurcharges(
|
||||
surcharge1Controller: _surcharge1Controller,
|
||||
surcharge2Controller: _surcharge2Controller,
|
||||
surcharge3Controller: _surcharge3Controller,
|
||||
surcharge4Controller: _surcharge4Controller,
|
||||
isAfterTaxes: true,
|
||||
),
|
||||
AppDropdownButton(
|
||||
labelText: localization.design,
|
||||
value: invoice.designId,
|
||||
onChanged: (dynamic value) => viewModel
|
||||
.onChanged(invoice.rebuild((b) => b..designId = value)),
|
||||
items: company.invoiceDesignIds
|
||||
.map((designId) => DropdownMenuItem<String>(
|
||||
value: designId,
|
||||
child: Text(kInvoiceDesigns[designId]),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
],
|
||||
AppDropdownButton(
|
||||
labelText: localization.design,
|
||||
value: invoice.designId,
|
||||
onChanged: (dynamic value) =>
|
||||
viewModel
|
||||
.onChanged(
|
||||
invoice.rebuild((b) => b..designId = value)),
|
||||
items: company.invoiceDesignIds
|
||||
.map((designId) =>
|
||||
DropdownMenuItem<String>(
|
||||
value: designId,
|
||||
child: Text(kInvoiceDesigns[designId]),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ import 'package:invoiceninja_flutter/utils/localization.dart';
|
|||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
|
||||
class InvoiceEditItemsDesktop extends StatefulWidget {
|
||||
const InvoiceEditItemsDesktop({this.viewModel});
|
||||
const InvoiceEditItemsDesktop({
|
||||
this.viewModel,
|
||||
});
|
||||
|
||||
final EntityEditItemsVM viewModel;
|
||||
|
||||
|
|
@ -20,6 +22,32 @@ class InvoiceEditItemsDesktop extends StatefulWidget {
|
|||
class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
||||
int _updatedAt;
|
||||
|
||||
/*
|
||||
final Map<int, FocusNode> _focusNodes = {};
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
_focusNodes.values.forEach((node) => node.dispose());
|
||||
|
||||
final lineItems = widget.viewModel.invoice.lineItems;
|
||||
for (var index = 0; index < lineItems.length; index++) {
|
||||
_focusNodes[index] = FocusNode()
|
||||
..addListener(() => _onFocusChange(index));
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_focusNodes.values.forEach((node) => node.dispose());
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onFocusChange(int index) {
|
||||
setState(() {});
|
||||
}
|
||||
*/
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final localization = AppLocalization.of(context);
|
||||
|
|
@ -96,6 +124,8 @@ class _InvoiceEditItemsDesktopState extends State<InvoiceEditItemsDesktop> {
|
|||
lineItems[index].rebuild((b) => b..notes = value), index),
|
||||
minLines: 1,
|
||||
maxLines: 6,
|
||||
//maxLines: _focusNodes[index].hasFocus ? 6 : 1,
|
||||
//focusNode: _focusNodes[index],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ import 'package:invoiceninja_flutter/data/models/models.dart';
|
|||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
|
||||
class InvoiceEditItemsScreen extends StatelessWidget {
|
||||
const InvoiceEditItemsScreen({Key key}) : super(key: key);
|
||||
const InvoiceEditItemsScreen({
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ import 'package:invoiceninja_flutter/data/models/models.dart';
|
|||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
|
||||
class QuoteEditItemsScreen extends StatelessWidget {
|
||||
const QuoteEditItemsScreen({Key key}) : super(key: key);
|
||||
const QuoteEditItemsScreen({
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
|||
|
|
@ -33,11 +33,19 @@ class _LocalizationSettingsState extends State<LocalizationSettings> {
|
|||
bool autoValidate = false;
|
||||
|
||||
final _firstNameController = TextEditingController();
|
||||
FocusScopeNode _focusNode;
|
||||
|
||||
List<TextEditingController> _controllers = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_focusNode = FocusScopeNode();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_focusNode.dispose();
|
||||
_controllers.forEach((dynamic controller) {
|
||||
controller.removeListener(_onChanged);
|
||||
controller.dispose();
|
||||
|
|
@ -78,6 +86,7 @@ class _LocalizationSettingsState extends State<LocalizationSettings> {
|
|||
onSavePressed: viewModel.onSavePressed,
|
||||
body: AppForm(
|
||||
formKey: _formKey,
|
||||
focusNode: _focusNode,
|
||||
children: <Widget>[
|
||||
FormCard(
|
||||
children: <Widget>[
|
||||
|
|
|
|||
|
|
@ -21,6 +21,19 @@ class ProductSettings extends StatefulWidget {
|
|||
class _ProductSettingsState extends State<ProductSettings> {
|
||||
static final GlobalKey<FormState> _formKey =
|
||||
GlobalKey<FormState>(debugLabel: '_productSettings');
|
||||
FocusScopeNode _focusNode;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_focusNode = FocusScopeNode();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_focusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
@ -33,6 +46,7 @@ class _ProductSettingsState extends State<ProductSettings> {
|
|||
onSavePressed: viewModel.onSavePressed,
|
||||
body: AppForm(
|
||||
formKey: _formKey,
|
||||
focusNode: _focusNode,
|
||||
children: <Widget>[
|
||||
FormCard(
|
||||
children: <Widget>[
|
||||
|
|
|
|||
|
|
@ -26,6 +26,19 @@ class TaxSettings extends StatefulWidget {
|
|||
class _TaxSettingsState extends State<TaxSettings> {
|
||||
static final GlobalKey<FormState> _formKey =
|
||||
GlobalKey<FormState>(debugLabel: '_taxSettings');
|
||||
FocusScopeNode _focusNode;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_focusNode = FocusScopeNode();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_focusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
@ -39,6 +52,7 @@ class _TaxSettingsState extends State<TaxSettings> {
|
|||
onSavePressed: viewModel.onSavePressed,
|
||||
body: AppForm(
|
||||
formKey: _formKey,
|
||||
focusNode: _focusNode,
|
||||
children: <Widget>[
|
||||
FormCard(
|
||||
children: <Widget>[
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class UserDetails extends StatefulWidget {
|
|||
class _UserDetailsState extends State<UserDetails> {
|
||||
static final GlobalKey<FormState> _formKey =
|
||||
GlobalKey<FormState>(debugLabel: '_userDetails');
|
||||
|
||||
FocusScopeNode _focusNode;
|
||||
bool autoValidate = false;
|
||||
|
||||
final _firstNameController = TextEditingController();
|
||||
|
|
@ -34,8 +34,15 @@ class _UserDetailsState extends State<UserDetails> {
|
|||
List<TextEditingController> _controllers = [];
|
||||
final _debouncer = Debouncer();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_focusNode = FocusScopeNode();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_focusNode.dispose();
|
||||
_controllers.forEach((dynamic controller) {
|
||||
controller.removeListener(_onChanged);
|
||||
controller.dispose();
|
||||
|
|
@ -89,6 +96,7 @@ class _UserDetailsState extends State<UserDetails> {
|
|||
title: localization.userDetails,
|
||||
onSavePressed: viewModel.onSavePressed,
|
||||
body: AppForm(
|
||||
focusNode: _focusNode,
|
||||
formKey: _formKey,
|
||||
children: <Widget>[
|
||||
FormCard(
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ class _TaxRateEditState extends State<TaxRateEdit> {
|
|||
static final GlobalKey<FormState> _formKey =
|
||||
GlobalKey<FormState>(debugLabel: '_taxRateEdit');
|
||||
|
||||
FocusScopeNode _focusNode;
|
||||
bool autoValidate = false;
|
||||
|
||||
final _nameController = TextEditingController();
|
||||
|
|
@ -85,6 +86,7 @@ class _TaxRateEditState extends State<TaxRateEdit> {
|
|||
onSavePressed: viewModel.onSavePressed,
|
||||
onCancelPressed: viewModel.onCancelPressed,
|
||||
body: AppForm(
|
||||
focusNode: _focusNode,
|
||||
formKey: _formKey,
|
||||
children: <Widget>[
|
||||
FormCard(
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class _UserEditState extends State<UserEdit> {
|
|||
static final GlobalKey<FormState> _formKey =
|
||||
GlobalKey<FormState>(debugLabel: '_userEdit');
|
||||
final _debouncer = Debouncer();
|
||||
|
||||
FocusScopeNode _focusNode;
|
||||
bool autoValidate = false;
|
||||
|
||||
final _firstNameController = TextEditingController();
|
||||
|
|
@ -143,6 +143,7 @@ class _UserEditState extends State<UserEdit> {
|
|||
],
|
||||
),
|
||||
body: AppForm(
|
||||
focusNode: _focusNode,
|
||||
formKey: _formKey,
|
||||
children: <Widget>[
|
||||
FormCard(
|
||||
|
|
|
|||
Loading…
Reference in New Issue