Refactor
This commit is contained in:
parent
1d1f173d8b
commit
fde7f54b2c
|
|
@ -0,0 +1,23 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class FormCard extends StatelessWidget {
|
||||||
|
FormCard({this.children});
|
||||||
|
final List<Widget> children;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(12.0),
|
||||||
|
child: Card(
|
||||||
|
elevation: 2.0,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 16.0, right: 16.0, top: 16.0, bottom: 20.0),
|
||||||
|
child: Column(
|
||||||
|
children: children,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -23,7 +23,7 @@ class ProgressButton extends StatelessWidget {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(top: 20.0),
|
padding: EdgeInsets.only(left: 14.0, right: 14.0, top: 2.0),
|
||||||
child: this.isLoading
|
child: this.isLoading
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
width: 100.0,
|
width: 100.0,
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ import 'package:invoiceninja/redux/auth/auth_state.dart';
|
||||||
import 'package:invoiceninja/ui/app/progress_button.dart';
|
import 'package:invoiceninja/ui/app/progress_button.dart';
|
||||||
import 'package:invoiceninja/utils/localization.dart';
|
import 'package:invoiceninja/utils/localization.dart';
|
||||||
|
|
||||||
|
import '../app/form_card.dart';
|
||||||
|
|
||||||
class Login extends StatelessWidget {
|
class Login extends StatelessWidget {
|
||||||
final bool isLoading;
|
final bool isLoading;
|
||||||
final bool isDirty;
|
final bool isDirty;
|
||||||
|
|
@ -36,27 +38,22 @@ class Login extends StatelessWidget {
|
||||||
|
|
||||||
return ListView(
|
return ListView(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
padding: EdgeInsets.only(left: 12.0, right: 12.0, top: 20.0),
|
children: <Widget>[
|
||||||
children: [
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(top: 20.0, bottom: 20.0),
|
padding: EdgeInsets.only(top: 20.0, bottom: 20.0),
|
||||||
child: new Image.asset('assets/images/logo.png',
|
child: new Image.asset('assets/images/logo.png',
|
||||||
width: 100.0, height: 100.0),
|
width: 100.0, height: 100.0),
|
||||||
),
|
),
|
||||||
Card(
|
Form(
|
||||||
elevation: 2.0,
|
|
||||||
margin: EdgeInsets.all(0.0),
|
|
||||||
child: Form(
|
|
||||||
key: _formKey,
|
key: _formKey,
|
||||||
child: Container(
|
child: FormCard(
|
||||||
padding: EdgeInsets.all(16.0),
|
|
||||||
child: Column(
|
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
TextFormField(
|
TextFormField(
|
||||||
key: _emailKey,
|
key: _emailKey,
|
||||||
initialValue: authState.email,
|
initialValue: authState.email,
|
||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
decoration: InputDecoration(labelText: AppLocalization.of(context).email),
|
decoration: InputDecoration(
|
||||||
|
labelText: AppLocalization.of(context).email),
|
||||||
keyboardType: TextInputType.emailAddress,
|
keyboardType: TextInputType.emailAddress,
|
||||||
validator: (val) => val.isEmpty || val.trim().length == 0
|
validator: (val) => val.isEmpty || val.trim().length == 0
|
||||||
? AppLocalization.of(context).pleaseEnterYourEmail
|
? AppLocalization.of(context).pleaseEnterYourEmail
|
||||||
|
|
@ -66,7 +63,8 @@ class Login extends StatelessWidget {
|
||||||
key: _passwordKey,
|
key: _passwordKey,
|
||||||
initialValue: authState.password,
|
initialValue: authState.password,
|
||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
decoration: InputDecoration(labelText: AppLocalization.of(context).password),
|
decoration: InputDecoration(
|
||||||
|
labelText: AppLocalization.of(context).password),
|
||||||
validator: (val) => val.isEmpty || val.trim().length == 0
|
validator: (val) => val.isEmpty || val.trim().length == 0
|
||||||
? AppLocalization.of(context).pleaseEnterYourPassword
|
? AppLocalization.of(context).pleaseEnterYourPassword
|
||||||
: null,
|
: null,
|
||||||
|
|
@ -76,7 +74,8 @@ class Login extends StatelessWidget {
|
||||||
key: _urlKey,
|
key: _urlKey,
|
||||||
initialValue: authState.url,
|
initialValue: authState.url,
|
||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
decoration: InputDecoration(labelText: AppLocalization.of(context).url),
|
decoration:
|
||||||
|
InputDecoration(labelText: AppLocalization.of(context).url),
|
||||||
validator: (val) => val.isEmpty || val.trim().length == 0
|
validator: (val) => val.isEmpty || val.trim().length == 0
|
||||||
? AppLocalization.of(context).pleaseEnterYourUrl
|
? AppLocalization.of(context).pleaseEnterYourUrl
|
||||||
: null,
|
: null,
|
||||||
|
|
@ -86,7 +85,8 @@ class Login extends StatelessWidget {
|
||||||
key: _secretKey,
|
key: _secretKey,
|
||||||
initialValue: authState.secret,
|
initialValue: authState.secret,
|
||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
decoration: InputDecoration(labelText: AppLocalization.of(context).secret),
|
decoration: InputDecoration(
|
||||||
|
labelText: AppLocalization.of(context).secret),
|
||||||
/*
|
/*
|
||||||
validator: (val) => val.isEmpty || val.trim().length == 0
|
validator: (val) => val.isEmpty || val.trim().length == 0
|
||||||
? AppLocalization.of(context).pleaseEnterYourPassword
|
? AppLocalization.of(context).pleaseEnterYourPassword
|
||||||
|
|
@ -111,8 +111,6 @@ class Login extends StatelessWidget {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
ProgressButton(
|
ProgressButton(
|
||||||
label: 'LOGIN',
|
label: 'LOGIN',
|
||||||
isLoading: this.isLoading,
|
isLoading: this.isLoading,
|
||||||
|
|
@ -122,7 +120,8 @@ class Login extends StatelessWidget {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onLoginClicked(context,
|
this.onLoginClicked(
|
||||||
|
context,
|
||||||
_emailKey.currentState.value,
|
_emailKey.currentState.value,
|
||||||
_passwordKey.currentState.value,
|
_passwordKey.currentState.value,
|
||||||
_urlKey.currentState.value,
|
_urlKey.currentState.value,
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ class _ClientEditState extends State<ClientEdit>
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Form(
|
child: Form(
|
||||||
key: _formKey,
|
key: _formKey,
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,7 @@ class ClientEditBillingAddressState extends State<ClientEditBillingAddress>
|
||||||
Card(
|
Card(
|
||||||
elevation: 2.0,
|
elevation: 2.0,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.all(16.0),
|
||||||
left: 12.0, right: 12.0, top: 12.0, bottom: 18.0),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
TextFormField(
|
TextFormField(
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ class ClientEditContactsState extends State<ClientEditContacts>
|
||||||
}
|
}
|
||||||
|
|
||||||
items.add(Padding(
|
items.add(Padding(
|
||||||
padding: const EdgeInsets.all(12.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: RaisedButton(
|
child: RaisedButton(
|
||||||
elevation: 4.0,
|
elevation: 4.0,
|
||||||
color: Theme.of(context).primaryColor,
|
color: Theme.of(context).primaryColor,
|
||||||
|
|
@ -151,7 +151,7 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
|
||||||
child: Card(
|
child: Card(
|
||||||
elevation: 2.0,
|
elevation: 2.0,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(12.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
TextFormField(
|
TextFormField(
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,7 @@ class ClientEditDetailsState extends State<ClientEditDetails>
|
||||||
Card(
|
Card(
|
||||||
elevation: 2.0,
|
elevation: 2.0,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.all(16.0),
|
||||||
left: 12.0, right: 12.0, top: 12.0, bottom: 18.0),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
TextFormField(
|
TextFormField(
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,7 @@ class ClientEditShippingAddressState extends State<ClientEditShippingAddress>
|
||||||
Card(
|
Card(
|
||||||
elevation: 2.0,
|
elevation: 2.0,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.all(16.0),
|
||||||
left: 12.0, right: 12.0, top: 12.0, bottom: 18.0),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
TextFormField(
|
TextFormField(
|
||||||
|
|
|
||||||
|
|
@ -66,11 +66,11 @@ class ClientOverview extends StatelessWidget {
|
||||||
return Column(
|
return Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.all(12.0),
|
padding: EdgeInsets.all(16.0),
|
||||||
child: Card(
|
child: Card(
|
||||||
elevation: 2.0,
|
elevation: 2.0,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(12.0),
|
padding: EdgeInsets.all(16.0),
|
||||||
child: _headerRow(),
|
child: _headerRow(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ import 'package:invoiceninja/ui/app/progress_button.dart';
|
||||||
import 'package:invoiceninja/ui/product/product_edit_vm.dart';
|
import 'package:invoiceninja/ui/product/product_edit_vm.dart';
|
||||||
import 'package:invoiceninja/utils/localization.dart';
|
import 'package:invoiceninja/utils/localization.dart';
|
||||||
|
|
||||||
|
import '../app/form_card.dart';
|
||||||
|
|
||||||
class ProductEdit extends StatefulWidget {
|
class ProductEdit extends StatefulWidget {
|
||||||
|
|
||||||
final ProductEditVM viewModel;
|
final ProductEditVM viewModel;
|
||||||
static final GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
static final GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
|
@ -16,7 +16,6 @@ class ProductEdit extends StatefulWidget {
|
||||||
@required this.viewModel,
|
@required this.viewModel,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_ProductEditState createState() => _ProductEditState();
|
_ProductEditState createState() => _ProductEditState();
|
||||||
}
|
}
|
||||||
|
|
@ -36,24 +35,20 @@ class _ProductEditState extends State<ProductEdit> {
|
||||||
? AppLocalization.of(context).newProduct
|
? AppLocalization.of(context).newProduct
|
||||||
: viewModel
|
: viewModel
|
||||||
.product.productKey), // Text(localizations.productDetails),
|
.product.productKey), // Text(localizations.productDetails),
|
||||||
actions: viewModel.product.id == null ? [] : [
|
actions: viewModel.product.id == null
|
||||||
|
? []
|
||||||
|
: [
|
||||||
ActionMenuButton(
|
ActionMenuButton(
|
||||||
entity: viewModel.product,
|
entity: viewModel.product,
|
||||||
onSelected: viewModel.onActionSelected,
|
onSelected: viewModel.onActionSelected,
|
||||||
)],
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Form(
|
||||||
padding: EdgeInsets.all(16.0),
|
child: ListView(
|
||||||
child: ListView(children: [
|
children: <Widget>[
|
||||||
Card(
|
FormCard(
|
||||||
elevation: 2.0,
|
children: <Widget>[
|
||||||
margin: EdgeInsets.all(0.0),
|
|
||||||
child: Form(
|
|
||||||
key: ProductEdit.formKey,
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.all(16.0),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
TextFormField(
|
TextFormField(
|
||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
onSaved: (value) {
|
onSaved: (value) {
|
||||||
|
|
@ -95,9 +90,6 @@ class _ProductEditState extends State<ProductEdit> {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
new Builder(builder: (BuildContext context) {
|
new Builder(builder: (BuildContext context) {
|
||||||
return viewModel.product.isDeleted == true
|
return viewModel.product.isDeleted == true
|
||||||
? Container()
|
? Container()
|
||||||
|
|
@ -106,12 +98,13 @@ class _ProductEditState extends State<ProductEdit> {
|
||||||
isLoading: viewModel.isLoading,
|
isLoading: viewModel.isLoading,
|
||||||
isDirty: viewModel.isDirty,
|
isDirty: viewModel.isDirty,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (! ProductEdit.formKey.currentState.validate()) {
|
if (!ProductEdit.formKey.currentState.validate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ProductEdit.formKey.currentState.save();
|
ProductEdit.formKey.currentState.save();
|
||||||
|
|
||||||
viewModel.onSaveClicked(context,
|
viewModel.onSaveClicked(
|
||||||
|
context,
|
||||||
viewModel.product.rebuild((b) => b
|
viewModel.product.rebuild((b) => b
|
||||||
..productKey = _productKey
|
..productKey = _productKey
|
||||||
..notes = _notes
|
..notes = _notes
|
||||||
|
|
@ -119,7 +112,8 @@ class _ProductEditState extends State<ProductEdit> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
]),
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
/*
|
/*
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue