This commit is contained in:
Hillel Coren 2020-01-17 15:00:52 +02:00
parent ebfa67a817
commit eed7c920b0
5 changed files with 12 additions and 17 deletions

View File

@ -13,12 +13,10 @@ import 'package:invoiceninja_flutter/utils/localization.dart';
class InvoiceEdit extends StatefulWidget {
const InvoiceEdit({
Key key,
@required this.formKey,
@required this.viewModel,
}) : super(key: key);
final EntityEditVM viewModel;
final GlobalKey<FormState> formKey;
@override
_InvoiceEditState createState() => _InvoiceEditState();
@ -28,6 +26,9 @@ class _InvoiceEditState extends State<InvoiceEdit>
with SingleTickerProviderStateMixin {
TabController _controller;
static final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: '_invoiceEdit');
static const kDetailsScreen = 0;
static const kContactScreen = 1;
static const kItemScreen = 2;
@ -71,7 +72,7 @@ class _InvoiceEditState extends State<InvoiceEdit>
title: invoice.isNew ? localization.newInvoice : localization.editInvoice,
onCancelPressed: (context) => viewModel.onCancelPressed(context),
onSavePressed: (context) {
if (!widget.formKey.currentState.validate()) {
if (!_formKey.currentState.validate()) {
return;
}
@ -98,7 +99,7 @@ class _InvoiceEditState extends State<InvoiceEdit>
],
),
body: Form(
key: widget.formKey,
key: _formKey,
child: state.prefState.isDesktop
? InvoiceEditDetailsScreen()
: TabBarView(

View File

@ -41,7 +41,7 @@ class InvoiceEditDesktopState extends State<InvoiceEditDesktop>
FocusNode _focusNode;
static final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: '_invoicesEdit');
GlobalKey<FormState>(debugLabel: '_invoiceDesktopEdit');
final _invoiceNumberController = TextEditingController();
final _poNumberController = TextEditingController();

View File

@ -18,9 +18,6 @@ class InvoiceEditScreen extends StatelessWidget {
static const String route = '/invoice/edit';
static final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: '_invoiceEdit');
@override
Widget build(BuildContext context) {
return StoreConnector<AppState, InvoiceEditVM>(
@ -30,7 +27,6 @@ class InvoiceEditScreen extends StatelessWidget {
builder: (context, viewModel) {
return InvoiceEdit(
viewModel: viewModel,
formKey: _formKey,
);
},
);

View File

@ -19,9 +19,6 @@ class QuoteEditScreen extends StatelessWidget {
static const String route = '/quote/edit';
static final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: '_quoteEdit');
@override
Widget build(BuildContext context) {
return StoreConnector<AppState, QuoteEditVM>(
@ -31,7 +28,6 @@ class QuoteEditScreen extends StatelessWidget {
builder: (context, viewModel) {
return QuoteEdit(
viewModel: viewModel,
formKey: _formKey,
);
},
);

View File

@ -12,12 +12,10 @@ import 'package:invoiceninja_flutter/utils/localization.dart';
class QuoteEdit extends StatefulWidget {
const QuoteEdit({
Key key,
@required this.formKey,
@required this.viewModel,
}) : super(key: key);
final EntityEditVM viewModel;
final GlobalKey<FormState> formKey;
@override
_QuoteEditState createState() => _QuoteEditState();
@ -27,6 +25,10 @@ class _QuoteEditState extends State<QuoteEdit>
with SingleTickerProviderStateMixin {
TabController _controller;
static final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: '_quoteEdit');
static const kDetailsScreen = 0;
static const kItemScreen = 1;
static const kNotesScreen = 2;
@ -69,7 +71,7 @@ class _QuoteEditState extends State<QuoteEdit>
title: invoice.isNew ? localization.newQuote : localization.editQuote,
onCancelPressed: (context) => viewModel.onCancelPressed(context),
onSavePressed: (context) {
if (!widget.formKey.currentState.validate()) {
if (!_formKey.currentState.validate()) {
return;
}
@ -93,7 +95,7 @@ class _QuoteEditState extends State<QuoteEdit>
],
),
body: Form(
key: widget.formKey,
key: _formKey,
child: state.prefState.isDesktop
? QuoteEditDetailsScreen()
: TabBarView(