Refactor
This commit is contained in:
parent
f125db74ce
commit
837fa64c4e
|
|
@ -40,6 +40,13 @@ class CreditFields {
|
|||
|
||||
abstract class CreditEntity extends Object with BaseEntity implements Built<CreditEntity, CreditEntityBuilder> {
|
||||
|
||||
static int counter = 0;
|
||||
factory CreditEntity() {
|
||||
return _$CreditEntity._(
|
||||
id: --CreditEntity.counter,
|
||||
);
|
||||
}
|
||||
|
||||
@nullable
|
||||
double get amount;
|
||||
|
||||
|
|
@ -89,6 +96,5 @@ abstract class CreditEntity extends Object with BaseEntity implements Built<Cred
|
|||
}
|
||||
|
||||
CreditEntity._();
|
||||
factory CreditEntity([updates(CreditEntityBuilder b)]) = _$CreditEntity;
|
||||
static Serializer<CreditEntity> get serializer => _$creditEntitySerializer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class EntityType extends EnumClass {
|
|||
static const EntityType quote = _$quote;
|
||||
static const EntityType product = _$product;
|
||||
static const EntityType client = _$client;
|
||||
static const EntityType contact = _$contact;
|
||||
static const EntityType task = _$task;
|
||||
static const EntityType project = _$project;
|
||||
static const EntityType expense = _$expense;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ const EntityType _$invoice = const EntityType._('invoice');
|
|||
const EntityType _$quote = const EntityType._('quote');
|
||||
const EntityType _$product = const EntityType._('product');
|
||||
const EntityType _$client = const EntityType._('client');
|
||||
const EntityType _$contact = const EntityType._('contact');
|
||||
const EntityType _$task = const EntityType._('task');
|
||||
const EntityType _$project = const EntityType._('project');
|
||||
const EntityType _$expense = const EntityType._('expense');
|
||||
|
|
@ -35,6 +36,8 @@ EntityType _$typeValueOf(String name) {
|
|||
return _$product;
|
||||
case 'client':
|
||||
return _$client;
|
||||
case 'contact':
|
||||
return _$contact;
|
||||
case 'task':
|
||||
return _$task;
|
||||
case 'project':
|
||||
|
|
@ -58,6 +61,7 @@ final BuiltSet<EntityType> _$typeValues =
|
|||
_$quote,
|
||||
_$product,
|
||||
_$client,
|
||||
_$contact,
|
||||
_$task,
|
||||
_$project,
|
||||
_$expense,
|
||||
|
|
|
|||
|
|
@ -54,6 +54,13 @@ class ExpenseFields {
|
|||
|
||||
abstract class ExpenseEntity extends Object with BaseEntity implements Built<ExpenseEntity, ExpenseEntityBuilder> {
|
||||
|
||||
static int counter = 0;
|
||||
factory ExpenseEntity() {
|
||||
return _$ExpenseEntity._(
|
||||
id: --ExpenseEntity.counter,
|
||||
);
|
||||
}
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'private_notes')
|
||||
String get privateNotes;
|
||||
|
|
@ -160,7 +167,6 @@ abstract class ExpenseEntity extends Object with BaseEntity implements Built<Exp
|
|||
}
|
||||
|
||||
ExpenseEntity._();
|
||||
factory ExpenseEntity([updates(ExpenseEntityBuilder b)]) = _$ExpenseEntity;
|
||||
static Serializer<ExpenseEntity> get serializer => _$expenseEntitySerializer;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,14 @@ class InvoiceFields {
|
|||
abstract class InvoiceEntity extends Object with BaseEntity
|
||||
implements Built<InvoiceEntity, InvoiceEntityBuilder> {
|
||||
|
||||
static int counter = 0;
|
||||
factory InvoiceEntity() {
|
||||
return _$InvoiceEntity._(
|
||||
id: --InvoiceEntity.counter,
|
||||
invoiceItems: BuiltList<InvoiceItemEntity>(),
|
||||
);
|
||||
}
|
||||
|
||||
@nullable
|
||||
double get amount;
|
||||
|
||||
|
|
@ -242,20 +250,20 @@ abstract class InvoiceEntity extends Object with BaseEntity
|
|||
return invoiceNumber.contains(search);
|
||||
}
|
||||
|
||||
factory InvoiceEntity() {
|
||||
return _$InvoiceEntity._(
|
||||
invoiceItems: BuiltList<InvoiceItemEntity>(),
|
||||
);
|
||||
}
|
||||
|
||||
InvoiceEntity._();
|
||||
//factory InvoiceEntity([updates(InvoiceEntityBuilder b)]) = _$InvoiceEntity;
|
||||
static Serializer<InvoiceEntity> get serializer => _$invoiceEntitySerializer;
|
||||
}
|
||||
|
||||
|
||||
abstract class InvoiceItemEntity extends Object with BaseEntity implements Built<InvoiceItemEntity, InvoiceItemEntityBuilder> {
|
||||
|
||||
static int counter = 0;
|
||||
factory InvoiceItemEntity() {
|
||||
return _$InvoiceItemEntity._(
|
||||
id: --InvoiceItemEntity.counter
|
||||
);
|
||||
}
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'product_key')
|
||||
String get productKey;
|
||||
|
|
@ -301,7 +309,6 @@ abstract class InvoiceItemEntity extends Object with BaseEntity implements Built
|
|||
double get discount;
|
||||
|
||||
InvoiceItemEntity._();
|
||||
factory InvoiceItemEntity([updates(InvoiceItemEntityBuilder b)]) = _$InvoiceItemEntity;
|
||||
static Serializer<InvoiceItemEntity> get serializer => _$invoiceItemEntitySerializer;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,13 @@ class PaymentFields {
|
|||
|
||||
abstract class PaymentEntity extends Object with BaseEntity implements Built<PaymentEntity, PaymentEntityBuilder> {
|
||||
|
||||
static int counter = 0;
|
||||
factory PaymentEntity() {
|
||||
return _$PaymentEntity._(
|
||||
id: --PaymentEntity.counter,
|
||||
);
|
||||
}
|
||||
|
||||
@nullable
|
||||
double get amount;
|
||||
|
||||
|
|
@ -99,6 +106,5 @@ abstract class PaymentEntity extends Object with BaseEntity implements Built<Pay
|
|||
}
|
||||
|
||||
PaymentEntity._();
|
||||
factory PaymentEntity([updates(PaymentEntityBuilder b)]) = _$PaymentEntity;
|
||||
static Serializer<PaymentEntity> get serializer => _$paymentEntitySerializer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,13 @@ class ProductFields {
|
|||
|
||||
abstract class ProductEntity extends Object with BaseEntity implements Built<ProductEntity, ProductEntityBuilder> {
|
||||
|
||||
static int counter = 0;
|
||||
factory ProductEntity() {
|
||||
return _$ProductEntity._(
|
||||
id: --ProductEntity.counter
|
||||
);
|
||||
}
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'product_key')
|
||||
String get productKey;
|
||||
|
|
@ -96,6 +103,5 @@ abstract class ProductEntity extends Object with BaseEntity implements Built<Pro
|
|||
}
|
||||
|
||||
ProductEntity._();
|
||||
factory ProductEntity([updates(ProductEntityBuilder b)]) = _$ProductEntity;
|
||||
static Serializer<ProductEntity> get serializer => _$productEntitySerializer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,13 @@ class ProjectFields {
|
|||
|
||||
abstract class ProjectEntity extends Object with BaseEntity implements Built<ProjectEntity, ProjectEntityBuilder> {
|
||||
|
||||
static int counter = 0;
|
||||
factory ProjectEntity() {
|
||||
return _$ProjectEntity._(
|
||||
id: --ProjectEntity.counter
|
||||
);
|
||||
}
|
||||
|
||||
@nullable
|
||||
String get name;
|
||||
|
||||
|
|
@ -97,6 +104,5 @@ abstract class ProjectEntity extends Object with BaseEntity implements Built<Pro
|
|||
}
|
||||
|
||||
ProjectEntity._();
|
||||
factory ProjectEntity([updates(ProjectEntityBuilder b)]) = _$ProjectEntity;
|
||||
static Serializer<ProjectEntity> get serializer => _$projectEntitySerializer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,13 @@ class TaskFields {
|
|||
|
||||
abstract class TaskEntity extends Object with BaseEntity implements Built<TaskEntity, TaskEntityBuilder> {
|
||||
|
||||
static int counter = 0;
|
||||
factory TaskEntity() {
|
||||
return _$TaskEntity._(
|
||||
id: --TaskEntity.counter
|
||||
);
|
||||
}
|
||||
|
||||
@nullable
|
||||
String get description;
|
||||
|
||||
|
|
@ -101,6 +108,5 @@ abstract class TaskEntity extends Object with BaseEntity implements Built<TaskEn
|
|||
}
|
||||
|
||||
TaskEntity._();
|
||||
factory TaskEntity([updates(TaskEntityBuilder b)]) = _$TaskEntity;
|
||||
static Serializer<TaskEntity> get serializer => _$taskEntitySerializer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,13 @@ class VendorFields {
|
|||
|
||||
abstract class VendorEntity extends Object with BaseEntity implements Built<VendorEntity, VendorEntityBuilder> {
|
||||
|
||||
static int counter = 0;
|
||||
factory VendorEntity() {
|
||||
return _$VendorEntity._(
|
||||
id: --VendorEntity.counter
|
||||
);
|
||||
}
|
||||
|
||||
@nullable
|
||||
String get name;
|
||||
|
||||
|
|
@ -143,12 +150,18 @@ abstract class VendorEntity extends Object with BaseEntity implements Built<Vend
|
|||
}
|
||||
|
||||
VendorEntity._();
|
||||
factory VendorEntity([updates(VendorEntityBuilder b)]) = _$VendorEntity;
|
||||
static Serializer<VendorEntity> get serializer => _$vendorEntitySerializer;
|
||||
}
|
||||
|
||||
abstract class VendorContactEntity extends Object with BaseEntity implements Built<VendorContactEntity, VendorContactEntityBuilder> {
|
||||
|
||||
static int counter = 0;
|
||||
factory VendorContactEntity() {
|
||||
return _$VendorContactEntity._(
|
||||
id: --VendorContactEntity.counter
|
||||
);
|
||||
}
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'first_name')
|
||||
String get firstName;
|
||||
|
|
@ -168,6 +181,5 @@ abstract class VendorContactEntity extends Object with BaseEntity implements Bui
|
|||
String get phone;
|
||||
|
||||
VendorContactEntity._();
|
||||
factory VendorContactEntity([updates(VendorContactEntityBuilder b)]) = _$VendorContactEntity;
|
||||
static Serializer<VendorContactEntity> get serializer => _$vendorContactEntitySerializer;
|
||||
}
|
||||
|
|
@ -97,7 +97,8 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return '';
|
||||
//return '';
|
||||
return this.clientUIState.selected.toString();
|
||||
//return this.invoiceUIState.selected.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,12 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class FormCard extends StatelessWidget {
|
||||
FormCard({this.children});
|
||||
|
||||
FormCard({
|
||||
Key key,
|
||||
@required this.children,
|
||||
}) : super(key: key);
|
||||
|
||||
final List<Widget> children;
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -19,13 +19,13 @@ class ClientEditContacts extends StatelessWidget {
|
|||
var client = viewModel.client;
|
||||
var contacts = client.contacts.map((contact) => ContactEditDetails(
|
||||
viewModel: viewModel,
|
||||
key: Key('__${EntityType.contact}_${contact.id}__'),
|
||||
isRemoveVisible: client.contacts.length > 1,
|
||||
contact: contact,
|
||||
index: client.contacts.indexOf(contact)));
|
||||
|
||||
return ListView(
|
||||
children: []
|
||||
..addAll(client.contacts.map((contact) => Container()))
|
||||
..addAll(contacts)
|
||||
..add(Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ class InvoiceEditItems extends StatelessWidget {
|
|||
var invoiceItems = invoice.invoiceItems.map((invoiceItem) =>
|
||||
ItemEditDetails(
|
||||
viewModel: viewModel,
|
||||
key: Key('__${EntityType.contact}_${invoiceItem.id}__'),
|
||||
invoiceItem: invoiceItem,
|
||||
index: invoice.invoiceItems.indexOf(invoiceItem)));
|
||||
|
||||
return ListView(
|
||||
children: []
|
||||
..addAll(invoice.invoiceItems.map((contact) => Container()))
|
||||
..addAll(invoiceItems)
|
||||
..add(Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
|
|
|
|||
|
|
@ -234,15 +234,13 @@ class ContactsPage extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return StoreBuilder(builder: (BuildContext context, Store<AppState> store) {
|
||||
var client = store.state.client;
|
||||
var contacts = client.contacts
|
||||
.map((contact) => ContactForm(
|
||||
var contacts = client.contacts.map((contact) => ContactForm(
|
||||
contact: contact,
|
||||
//key: Key('__contact_${contact.id}__'),
|
||||
index: store.state.client.contacts.indexOf(contact)));
|
||||
|
||||
return ListView(
|
||||
children: []
|
||||
..addAll(client.contacts.map((contact) => Container()))
|
||||
..addAll(contacts)
|
||||
..add(Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: RaisedButton(
|
||||
|
|
@ -261,7 +259,8 @@ class ContactsPage extends StatelessWidget {
|
|||
}
|
||||
|
||||
class ContactForm extends StatefulWidget {
|
||||
ContactForm({this.contact, this.index});
|
||||
ContactForm({Key key, @required this.contact, @required this.index})
|
||||
: super(key: key);
|
||||
|
||||
final int index;
|
||||
final ContactEntity contact;
|
||||
|
|
@ -333,7 +332,11 @@ class _ContactFormState extends State<ContactForm> {
|
|||
|
||||
// Helper widget to make the form look a bit nicer
|
||||
class FormCard extends StatelessWidget {
|
||||
FormCard({this.children});
|
||||
FormCard({
|
||||
Key key,
|
||||
@required this.children,
|
||||
}) : super(key: key);
|
||||
|
||||
final List<Widget> children;
|
||||
|
||||
@override
|
||||
|
|
|
|||
Loading…
Reference in New Issue