Refactor
This commit is contained in:
parent
da873ed28e
commit
a0b72a27bd
|
|
@ -6,10 +6,11 @@ part 'date_format_model.g.dart';
|
||||||
|
|
||||||
abstract class DateFormatListResponse implements Built<DateFormatListResponse, DateFormatListResponseBuilder> {
|
abstract class DateFormatListResponse implements Built<DateFormatListResponse, DateFormatListResponseBuilder> {
|
||||||
|
|
||||||
|
factory DateFormatListResponse([void updates(DateFormatListResponseBuilder b)]) = _$DateFormatListResponse;
|
||||||
|
DateFormatListResponse._();
|
||||||
|
|
||||||
BuiltList<DateFormatEntity> get data;
|
BuiltList<DateFormatEntity> get data;
|
||||||
|
|
||||||
DateFormatListResponse._();
|
|
||||||
factory DateFormatListResponse([void updates(DateFormatListResponseBuilder b)]) = _$DateFormatListResponse;
|
|
||||||
static Serializer<DateFormatListResponse> get serializer => _$dateFormatListResponseSerializer;
|
static Serializer<DateFormatListResponse> get serializer => _$dateFormatListResponseSerializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class ClientRepository {
|
||||||
|
|
||||||
Future saveData(CompanyEntity company, AuthState auth, ClientEntity client, [EntityAction action]) async {
|
Future saveData(CompanyEntity company, AuthState auth, ClientEntity client, [EntityAction action]) async {
|
||||||
|
|
||||||
var data = serializers.serializeWith(ClientEntity.serializer, client);
|
final data = serializers.serializeWith(ClientEntity.serializer, client);
|
||||||
Future<dynamic> response;
|
Future<dynamic> response;
|
||||||
|
|
||||||
if (client.isNew) {
|
if (client.isNew) {
|
||||||
|
|
@ -42,7 +42,7 @@ class ClientRepository {
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response = await webClient.put(url, company.token, json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientItemResponse clientResponse = serializers.deserializeWith(
|
final ClientItemResponse clientResponse = serializers.deserializeWith(
|
||||||
ClientItemResponse.serializer, response);
|
ClientItemResponse.serializer, response);
|
||||||
|
|
||||||
return clientResponse.data;
|
return clientResponse.data;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class CreditsRepository {
|
||||||
final Future<dynamic> response = await webClient.get(
|
final Future<dynamic> response = await webClient.get(
|
||||||
auth.url + '/credits?per_page=500', company.token);
|
auth.url + '/credits?per_page=500', company.token);
|
||||||
|
|
||||||
CreditListResponse creditResponse = serializers.deserializeWith(
|
final CreditListResponse creditResponse = serializers.deserializeWith(
|
||||||
CreditListResponse.serializer, response);
|
CreditListResponse.serializer, response);
|
||||||
|
|
||||||
return creditResponse.data;
|
return creditResponse.data;
|
||||||
|
|
@ -28,7 +28,7 @@ class CreditsRepository {
|
||||||
|
|
||||||
Future saveData(CompanyEntity company, AuthState auth, CreditEntity credit, [EntityAction action]) async {
|
Future saveData(CompanyEntity company, AuthState auth, CreditEntity credit, [EntityAction action]) async {
|
||||||
|
|
||||||
var data = serializers.serializeWith(CreditEntity.serializer, credit);
|
final data = serializers.serializeWith(CreditEntity.serializer, credit);
|
||||||
Future<dynamic> response;
|
Future<dynamic> response;
|
||||||
|
|
||||||
if (credit.isNew) {
|
if (credit.isNew) {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class ExpenseRepository {
|
||||||
final Future<dynamic> response = await webClient.get(
|
final Future<dynamic> response = await webClient.get(
|
||||||
auth.url + '/expenses?per_page=500', company.token);
|
auth.url + '/expenses?per_page=500', company.token);
|
||||||
|
|
||||||
ExpenseListResponse expenseResponse = serializers.deserializeWith(
|
final ExpenseListResponse expenseResponse = serializers.deserializeWith(
|
||||||
ExpenseListResponse.serializer, response);
|
ExpenseListResponse.serializer, response);
|
||||||
|
|
||||||
return expenseResponse.data;
|
return expenseResponse.data;
|
||||||
|
|
@ -42,7 +42,7 @@ class ExpenseRepository {
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response = await webClient.put(url, company.token, json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpenseItemResponse expenseResponse = serializers.deserializeWith(
|
final ExpenseItemResponse expenseResponse = serializers.deserializeWith(
|
||||||
ExpenseItemResponse.serializer, response);
|
ExpenseItemResponse.serializer, response);
|
||||||
|
|
||||||
return expenseResponse.data;
|
return expenseResponse.data;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class InvoiceRepository {
|
||||||
final Future<dynamic> response = await webClient.get(
|
final Future<dynamic> response = await webClient.get(
|
||||||
auth.url + '/invoices?include=invitations', company.token);
|
auth.url + '/invoices?include=invitations', company.token);
|
||||||
|
|
||||||
InvoiceListResponse invoiceResponse = serializers.deserializeWith(
|
final InvoiceListResponse invoiceResponse = serializers.deserializeWith(
|
||||||
InvoiceListResponse.serializer, response);
|
InvoiceListResponse.serializer, response);
|
||||||
|
|
||||||
return invoiceResponse.data;
|
return invoiceResponse.data;
|
||||||
|
|
@ -28,7 +28,7 @@ class InvoiceRepository {
|
||||||
|
|
||||||
Future saveData(CompanyEntity company, AuthState auth, InvoiceEntity invoice, [EntityAction action]) async {
|
Future saveData(CompanyEntity company, AuthState auth, InvoiceEntity invoice, [EntityAction action]) async {
|
||||||
|
|
||||||
var data = serializers.serializeWith(InvoiceEntity.serializer, invoice);
|
final data = serializers.serializeWith(InvoiceEntity.serializer, invoice);
|
||||||
Future<dynamic> response;
|
Future<dynamic> response;
|
||||||
|
|
||||||
if (invoice.isNew) {
|
if (invoice.isNew) {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class PaymentsRepository {
|
||||||
final Future<dynamic> response = await webClient.get(
|
final Future<dynamic> response = await webClient.get(
|
||||||
auth.url + '/payments?per_page=500', company.token);
|
auth.url + '/payments?per_page=500', company.token);
|
||||||
|
|
||||||
PaymentListResponse paymentResponse = serializers.deserializeWith(
|
final PaymentListResponse paymentResponse = serializers.deserializeWith(
|
||||||
PaymentListResponse.serializer, response);
|
PaymentListResponse.serializer, response);
|
||||||
|
|
||||||
return paymentResponse.data;
|
return paymentResponse.data;
|
||||||
|
|
@ -42,7 +42,7 @@ class PaymentsRepository {
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response = await webClient.put(url, company.token, json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
PaymentItemResponse paymentResponse = serializers.deserializeWith(
|
final PaymentItemResponse paymentResponse = serializers.deserializeWith(
|
||||||
PaymentItemResponse.serializer, response);
|
PaymentItemResponse.serializer, response);
|
||||||
|
|
||||||
return paymentResponse.data;
|
return paymentResponse.data;
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class PersistenceRepository {
|
||||||
|
|
||||||
|
|
||||||
Future<File> saveAuthState(AuthState state) async {
|
Future<File> saveAuthState(AuthState state) async {
|
||||||
var data = serializers.serializeWith(AuthState.serializer, state);
|
final data = serializers.serializeWith(AuthState.serializer, state);
|
||||||
return await fileStorage.save(json.encode(data));
|
return await fileStorage.save(json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,7 +54,7 @@ class PersistenceRepository {
|
||||||
|
|
||||||
|
|
||||||
Future<File> saveUIState(UIState state) async {
|
Future<File> saveUIState(UIState state) async {
|
||||||
var data = serializers.serializeWith(UIState.serializer, state);
|
final data = serializers.serializeWith(UIState.serializer, state);
|
||||||
return await fileStorage.save(json.encode(data));
|
return await fileStorage.save(json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class ProductRepository {
|
||||||
|
|
||||||
Future saveData(CompanyEntity company, AuthState auth, ProductEntity product, [EntityAction action]) async {
|
Future saveData(CompanyEntity company, AuthState auth, ProductEntity product, [EntityAction action]) async {
|
||||||
|
|
||||||
var data = serializers.serializeWith(ProductEntity.serializer, product);
|
final data = serializers.serializeWith(ProductEntity.serializer, product);
|
||||||
Future<dynamic> response;
|
Future<dynamic> response;
|
||||||
|
|
||||||
if (product.isNew) {
|
if (product.isNew) {
|
||||||
|
|
@ -42,7 +42,7 @@ class ProductRepository {
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response = await webClient.put(url, company.token, json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
ProductItemResponse productResponse = serializers.deserializeWith(
|
final ProductItemResponse productResponse = serializers.deserializeWith(
|
||||||
ProductItemResponse.serializer, response);
|
ProductItemResponse.serializer, response);
|
||||||
|
|
||||||
return productResponse.data;
|
return productResponse.data;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class ProjectsRepository {
|
||||||
final Future<dynamic> response = await webClient.get(
|
final Future<dynamic> response = await webClient.get(
|
||||||
auth.url + '/projects?per_page=500', company.token);
|
auth.url + '/projects?per_page=500', company.token);
|
||||||
|
|
||||||
ProjectListResponse projectResponse = serializers.deserializeWith(
|
final ProjectListResponse projectResponse = serializers.deserializeWith(
|
||||||
ProjectListResponse.serializer, response);
|
ProjectListResponse.serializer, response);
|
||||||
|
|
||||||
return projectResponse.data;
|
return projectResponse.data;
|
||||||
|
|
@ -42,7 +42,7 @@ class ProjectsRepository {
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response = await webClient.put(url, company.token, json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectItemResponse projectResponse = serializers.deserializeWith(
|
final ProjectItemResponse projectResponse = serializers.deserializeWith(
|
||||||
ProjectItemResponse.serializer, response);
|
ProjectItemResponse.serializer, response);
|
||||||
|
|
||||||
return projectResponse.data;
|
return projectResponse.data;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class TasksRepository {
|
||||||
final Future<dynamic> response = await webClient.get(
|
final Future<dynamic> response = await webClient.get(
|
||||||
auth.url + '/tasks?per_page=500', company.token);
|
auth.url + '/tasks?per_page=500', company.token);
|
||||||
|
|
||||||
TaskListResponse taskResponse = serializers.deserializeWith(
|
final TaskListResponse taskResponse = serializers.deserializeWith(
|
||||||
TaskListResponse.serializer, response);
|
TaskListResponse.serializer, response);
|
||||||
|
|
||||||
return taskResponse.data;
|
return taskResponse.data;
|
||||||
|
|
@ -28,7 +28,7 @@ class TasksRepository {
|
||||||
|
|
||||||
Future saveData(CompanyEntity company, AuthState auth, TaskEntity task, [EntityAction action]) async {
|
Future saveData(CompanyEntity company, AuthState auth, TaskEntity task, [EntityAction action]) async {
|
||||||
|
|
||||||
var data = serializers.serializeWith(TaskEntity.serializer, task);
|
final data = serializers.serializeWith(TaskEntity.serializer, task);
|
||||||
Future<dynamic> response;
|
Future<dynamic> response;
|
||||||
|
|
||||||
if (task.isNew) {
|
if (task.isNew) {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class VendorRepository {
|
||||||
final Future<dynamic> response = await webClient.get(
|
final Future<dynamic> response = await webClient.get(
|
||||||
auth.url + '/vendors?per_page=500', company.token);
|
auth.url + '/vendors?per_page=500', company.token);
|
||||||
|
|
||||||
VendorListResponse vendorResponse = serializers.deserializeWith(
|
final VendorListResponse vendorResponse = serializers.deserializeWith(
|
||||||
VendorListResponse.serializer, response);
|
VendorListResponse.serializer, response);
|
||||||
|
|
||||||
return vendorResponse.data;
|
return vendorResponse.data;
|
||||||
|
|
@ -28,7 +28,7 @@ class VendorRepository {
|
||||||
|
|
||||||
Future saveData(CompanyEntity company, AuthState auth, VendorEntity vendor, [EntityAction action]) async {
|
Future saveData(CompanyEntity company, AuthState auth, VendorEntity vendor, [EntityAction action]) async {
|
||||||
|
|
||||||
var data = serializers.serializeWith(VendorEntity.serializer, vendor);
|
final data = serializers.serializeWith(VendorEntity.serializer, vendor);
|
||||||
Future<dynamic> response;
|
Future<dynamic> response;
|
||||||
|
|
||||||
if (vendor.isNew) {
|
if (vendor.isNew) {
|
||||||
|
|
|
||||||
|
|
@ -236,7 +236,7 @@ Middleware<AppState> _createUserLoggedIn(
|
||||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||||
next(action);
|
next(action);
|
||||||
|
|
||||||
var state = store.state;
|
final state = store.state;
|
||||||
|
|
||||||
authRepository.saveAuthState(state.authState);
|
authRepository.saveAuthState(state.authState);
|
||||||
uiRepository.saveUIState(state.uiState);
|
uiRepository.saveUIState(state.uiState);
|
||||||
|
|
@ -268,7 +268,7 @@ Middleware<AppState> _createDataLoaded(
|
||||||
// first process the action so the data is in the state
|
// first process the action so the data is in the state
|
||||||
next(action);
|
next(action);
|
||||||
|
|
||||||
AppState state = store.state;
|
final AppState state = store.state;
|
||||||
|
|
||||||
switch (state.uiState.selectedCompanyIndex) {
|
switch (state.uiState.selectedCompanyIndex) {
|
||||||
case 1:
|
case 1:
|
||||||
|
|
|
||||||
|
|
@ -88,8 +88,8 @@ Middleware<AppState> _createLoginRequest(AuthRepository repository) {
|
||||||
bool _isVersionSupported(String version) {
|
bool _isVersionSupported(String version) {
|
||||||
var parts = version.split('.');
|
var parts = version.split('.');
|
||||||
|
|
||||||
int major = int.parse(parts[0]);
|
final int major = int.parse(parts[0]);
|
||||||
int minor = int.parse(parts[1]);
|
final int minor = int.parse(parts[1]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ Middleware<AppState> _archiveClient(ClientRepository repository) {
|
||||||
|
|
||||||
Middleware<AppState> _deleteClient(ClientRepository repository) {
|
Middleware<AppState> _deleteClient(ClientRepository repository) {
|
||||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||||
var origClient = store.state.clientState.map[action.clientId];
|
final origClient = store.state.clientState.map[action.clientId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.selectedCompany, store.state.authState,
|
||||||
origClient, EntityAction.delete)
|
origClient, EntityAction.delete)
|
||||||
|
|
@ -155,7 +155,7 @@ Middleware<AppState> _saveClient(ClientRepository repository) {
|
||||||
Middleware<AppState> _loadClients(ClientRepository repository) {
|
Middleware<AppState> _loadClients(ClientRepository repository) {
|
||||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||||
|
|
||||||
AppState state = store.state;
|
final AppState state = store.state;
|
||||||
|
|
||||||
if (!state.clientState.isStale && !action.force) {
|
if (!state.clientState.isStale && !action.force) {
|
||||||
next(action);
|
next(action);
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ final clientsReducer = combineReducers<ClientState>([
|
||||||
]);
|
]);
|
||||||
|
|
||||||
ClientState _archiveClientRequest(ClientState clientState, ArchiveClientRequest action) {
|
ClientState _archiveClientRequest(ClientState clientState, ArchiveClientRequest action) {
|
||||||
var client = clientState.map[action.clientId].rebuild((b) => b
|
final client = clientState.map[action.clientId].rebuild((b) => b
|
||||||
..archivedAt = DateTime.now().millisecondsSinceEpoch
|
..archivedAt = DateTime.now().millisecondsSinceEpoch
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ List<int> dropdownClientsSelector(
|
||||||
BuiltList<int> clientList,
|
BuiltList<int> clientList,
|
||||||
String filter) {
|
String filter) {
|
||||||
|
|
||||||
var list = clientList.where((clientId) {
|
final list = clientList.where((clientId) {
|
||||||
var client = clientMap[clientId];
|
final client = clientMap[clientId];
|
||||||
if (! client.isActive) {
|
if (! client.isActive) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -52,8 +52,8 @@ List<int> visibleClientsSelector(
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
list.sort((clientAId, clientBId) {
|
list.sort((clientAId, clientBId) {
|
||||||
var clientA = clientMap[clientAId];
|
final clientA = clientMap[clientAId];
|
||||||
var clientB = clientMap[clientBId];
|
final clientB = clientMap[clientBId];
|
||||||
return clientA.compareTo(clientB, clientListState.sortField, clientListState.sortAscending);
|
return clientA.compareTo(clientB, clientListState.sortField, clientListState.sortAscending);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ Middleware<AppState> _editInvoice() {
|
||||||
|
|
||||||
Middleware<AppState> _archiveInvoice(InvoiceRepository repository) {
|
Middleware<AppState> _archiveInvoice(InvoiceRepository repository) {
|
||||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||||
var origInvoice = store.state.invoiceState.map[action.invoiceId];
|
final origInvoice = store.state.invoiceState.map[action.invoiceId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.selectedCompany, store.state.authState,
|
||||||
origInvoice, EntityAction.archive)
|
origInvoice, EntityAction.archive)
|
||||||
|
|
@ -180,7 +180,7 @@ Middleware<AppState> _saveInvoice(InvoiceRepository repository) {
|
||||||
Middleware<AppState> _loadInvoices(InvoiceRepository repository) {
|
Middleware<AppState> _loadInvoices(InvoiceRepository repository) {
|
||||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||||
|
|
||||||
AppState state = store.state;
|
final AppState state = store.state;
|
||||||
|
|
||||||
if (!state.invoiceState.isStale && !action.force) {
|
if (!state.invoiceState.isStale && !action.force) {
|
||||||
next(action);
|
next(action);
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ final invoicesReducer = combineReducers<InvoiceState>([
|
||||||
]);
|
]);
|
||||||
|
|
||||||
InvoiceState _archiveInvoiceRequest(InvoiceState invoiceState, ArchiveInvoiceRequest action) {
|
InvoiceState _archiveInvoiceRequest(InvoiceState invoiceState, ArchiveInvoiceRequest action) {
|
||||||
var invoice = invoiceState.map[action.invoiceId].rebuild((b) => b
|
final invoice = invoiceState.map[action.invoiceId].rebuild((b) => b
|
||||||
..archivedAt = DateTime.now().millisecondsSinceEpoch
|
..archivedAt = DateTime.now().millisecondsSinceEpoch
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -151,7 +151,7 @@ InvoiceState _archiveInvoiceFailure(InvoiceState invoiceState, ArchiveInvoiceFai
|
||||||
}
|
}
|
||||||
|
|
||||||
InvoiceState _deleteInvoiceRequest(InvoiceState invoiceState, DeleteInvoiceRequest action) {
|
InvoiceState _deleteInvoiceRequest(InvoiceState invoiceState, DeleteInvoiceRequest action) {
|
||||||
var invoice = invoiceState.map[action.invoiceId].rebuild((b) => b
|
final invoice = invoiceState.map[action.invoiceId].rebuild((b) => b
|
||||||
..archivedAt = DateTime.now().millisecondsSinceEpoch
|
..archivedAt = DateTime.now().millisecondsSinceEpoch
|
||||||
..isDeleted = true
|
..isDeleted = true
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ Middleware<AppState> _saveProduct(ProductRepository repository) {
|
||||||
|
|
||||||
Middleware<AppState> _loadProducts(ProductRepository repository) {
|
Middleware<AppState> _loadProducts(ProductRepository repository) {
|
||||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||||
AppState state = store.state;
|
final AppState state = store.state;
|
||||||
|
|
||||||
if (!state.productState.isStale && !action.force) {
|
if (!state.productState.isStale && !action.force) {
|
||||||
next(action);
|
next(action);
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ final productsReducer = combineReducers<ProductState>([
|
||||||
]);
|
]);
|
||||||
|
|
||||||
ProductState _archiveProductRequest(ProductState productState, ArchiveProductRequest action) {
|
ProductState _archiveProductRequest(ProductState productState, ArchiveProductRequest action) {
|
||||||
var product = productState.map[action.productId].rebuild((b) => b
|
final product = productState.map[action.productId].rebuild((b) => b
|
||||||
..archivedAt = DateTime.now().millisecondsSinceEpoch
|
..archivedAt = DateTime.now().millisecondsSinceEpoch
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ List<int> visibleProductsSelector(
|
||||||
BuiltList<int> productList,
|
BuiltList<int> productList,
|
||||||
ListUIState productListState) {
|
ListUIState productListState) {
|
||||||
|
|
||||||
var list = productList.where((productId) {
|
final list = productList.where((productId) {
|
||||||
var product = productMap[productId];
|
final product = productMap[productId];
|
||||||
if (! product.matchesStates(productListState.stateFilters)) {
|
if (! product.matchesStates(productListState.stateFilters)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ class ClientScreen extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var store = StoreProvider.of<AppState>(context);
|
final store = StoreProvider.of<AppState>(context);
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class ClientEditBillingAddressState extends State<ClientEditBillingAddress> {
|
||||||
|
|
||||||
_controllers.forEach((dynamic controller) => controller.removeListener(_onChanged));
|
_controllers.forEach((dynamic controller) => controller.removeListener(_onChanged));
|
||||||
|
|
||||||
var client = widget.viewModel.client;
|
final client = widget.viewModel.client;
|
||||||
_address1Controller.text = client.address1;
|
_address1Controller.text = client.address1;
|
||||||
_address2Controller.text = client.address2;
|
_address2Controller.text = client.address2;
|
||||||
_cityController.text = client.city;
|
_cityController.text = client.city;
|
||||||
|
|
@ -63,7 +63,7 @@ class ClientEditBillingAddressState extends State<ClientEditBillingAddress> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onChanged() {
|
void _onChanged() {
|
||||||
var client = widget.viewModel.client.rebuild((b) => b
|
final client = widget.viewModel.client.rebuild((b) => b
|
||||||
..address1 = _address1Controller.text.trim()
|
..address1 = _address1Controller.text.trim()
|
||||||
..address2 = _address2Controller.text.trim()
|
..address2 = _address2Controller.text.trim()
|
||||||
..city = _cityController.text.trim()
|
..city = _cityController.text.trim()
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@ class ClientEditContacts extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
var client = viewModel.client;
|
final client = viewModel.client;
|
||||||
var contacts = client.contacts.map((contact) => ContactEditDetails(
|
final contacts = client.contacts.map((contact) => ContactEditDetails(
|
||||||
viewModel: viewModel,
|
viewModel: viewModel,
|
||||||
key: Key('__${EntityType.contact}_${contact.id}__'),
|
key: Key('__${EntityType.contact}_${contact.id}__'),
|
||||||
isRemoveVisible: client.contacts.length > 1,
|
isRemoveVisible: client.contacts.length > 1,
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class ClientEditDetailsState extends State<ClientEditDetails> {
|
||||||
|
|
||||||
_controllers.forEach((dynamic controller) => controller.removeListener(_onChanged));
|
_controllers.forEach((dynamic controller) => controller.removeListener(_onChanged));
|
||||||
|
|
||||||
var client = widget.viewModel.client;
|
final client = widget.viewModel.client;
|
||||||
_nameController.text = client.name;
|
_nameController.text = client.name;
|
||||||
_idNumberController.text = client.idNumber;
|
_idNumberController.text = client.idNumber;
|
||||||
_vatNumberController.text = client.vatNumber;
|
_vatNumberController.text = client.vatNumber;
|
||||||
|
|
@ -76,7 +76,7 @@ class ClientEditDetailsState extends State<ClientEditDetails> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
|
|
||||||
return ListView(
|
return ListView(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ class ClientEditShippingAddressState extends State<ClientEditShippingAddress> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onChanged() {
|
void _onChanged() {
|
||||||
var client = widget.viewModel.client.rebuild((b) => b
|
final client = widget.viewModel.client.rebuild((b) => b
|
||||||
..shippingAddress1 = _shippingAddress1Controller.text.trim()
|
..shippingAddress1 = _shippingAddress1Controller.text.trim()
|
||||||
..shippingAddress2 = _shippingAddress2Controller.text.trim()
|
..shippingAddress2 = _shippingAddress2Controller.text.trim()
|
||||||
..shippingCity = _shippingCityController.text.trim()
|
..shippingCity = _shippingCityController.text.trim()
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class _ClientViewDetailsState extends State<ClientViewDetails> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _launchStatus(BuildContext context, AsyncSnapshot<Null> snapshot) {
|
Widget _launchStatus(BuildContext context, AsyncSnapshot<Null> snapshot) {
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
if (snapshot.hasError) {
|
if (snapshot.hasError) {
|
||||||
return new Text('${localization.error}: ${snapshot.error}');
|
return new Text('${localization.error}: ${snapshot.error}');
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -49,7 +49,7 @@ class _ClientViewDetailsState extends State<ClientViewDetails> {
|
||||||
listTiles
|
listTiles
|
||||||
.add(FutureBuilder<Null>(future: _launched, builder: _launchStatus));
|
.add(FutureBuilder<Null>(future: _launched, builder: _launchStatus));
|
||||||
|
|
||||||
var contacts = client.contacts;
|
final contacts = client.contacts;
|
||||||
contacts.forEach((contact) {
|
contacts.forEach((contact) {
|
||||||
if ((contact.email ?? '').isNotEmpty) {
|
if ((contact.email ?? '').isNotEmpty) {
|
||||||
listTiles.add(AppListTile(
|
listTiles.add(AppListTile(
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ class ItemEditDetailsState extends State<ItemEditDetails> with AutomaticKeepAliv
|
||||||
|
|
||||||
_controllers.forEach((dynamic controller) => controller.removeListener(_onChanged));
|
_controllers.forEach((dynamic controller) => controller.removeListener(_onChanged));
|
||||||
|
|
||||||
var invoiceItem = widget.invoiceItem;
|
final invoiceItem = widget.invoiceItem;
|
||||||
_productKeyController.text = invoiceItem.productKey;
|
_productKeyController.text = invoiceItem.productKey;
|
||||||
_notesController.text = invoiceItem.notes;
|
_notesController.text = invoiceItem.notes;
|
||||||
_costController.text = formatNumber(
|
_costController.text = formatNumber(
|
||||||
|
|
@ -105,7 +105,7 @@ class ItemEditDetailsState extends State<ItemEditDetails> with AutomaticKeepAliv
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onChanged() {
|
void _onChanged() {
|
||||||
var invoiceItem = widget.invoiceItem.rebuild((b) => b
|
final invoiceItem = widget.invoiceItem.rebuild((b) => b
|
||||||
..productKey = _productKeyController.text.trim()
|
..productKey = _productKeyController.text.trim()
|
||||||
..notes = _notesController.text.trim()
|
..notes = _notesController.text.trim()
|
||||||
..cost = double.tryParse(_costController.text) ?? 0.0
|
..cost = double.tryParse(_costController.text) ?? 0.0
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class InvoiceEditVM {
|
||||||
});
|
});
|
||||||
|
|
||||||
factory InvoiceEditVM.fromStore(Store<AppState> store) {
|
factory InvoiceEditVM.fromStore(Store<AppState> store) {
|
||||||
AppState state = store.state;
|
final AppState state = store.state;
|
||||||
final invoice = state.invoiceUIState.editing;
|
final invoice = state.invoiceUIState.editing;
|
||||||
|
|
||||||
return InvoiceEditVM(
|
return InvoiceEditVM(
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
|
|
||||||
Widget _headerRow() {
|
Widget _headerRow() {
|
||||||
return Row(
|
return Row(
|
||||||
|
|
@ -132,8 +132,8 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _entityList() {
|
Widget _entityList() {
|
||||||
var state = widget.state.selectedCompanyState.productState;
|
final state = widget.state.selectedCompanyState.productState;
|
||||||
var matches = state.list
|
final matches = state.list
|
||||||
.where((entityId) => state.map[entityId].matchesSearch(_filter))
|
.where((entityId) => state.map[entityId].matchesSearch(_filter))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ class InvoiceScreen extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var store = StoreProvider.of<AppState>(context);
|
final store = StoreProvider.of<AppState>(context);
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class _InvoiceViewState extends State<InvoiceView> {
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
Map<String, String> fields = {
|
final Map<String, String> fields = {
|
||||||
InvoiceFields.invoiceStatusId:
|
InvoiceFields.invoiceStatusId:
|
||||||
invoiceStatusSelector(invoice, store.state.staticState),
|
invoiceStatusSelector(invoice, store.state.staticState),
|
||||||
InvoiceFields.invoiceDate: invoice.invoiceDate,
|
InvoiceFields.invoiceDate: invoice.invoiceDate,
|
||||||
|
|
@ -67,7 +67,7 @@ class _InvoiceViewState extends State<InvoiceView> {
|
||||||
: FormatNumberType.percent),
|
: FormatNumberType.percent),
|
||||||
};
|
};
|
||||||
|
|
||||||
List<Widget> fieldWidgets = [];
|
final List<Widget> fieldWidgets = [];
|
||||||
fields.forEach((field, value) {
|
fields.forEach((field, value) {
|
||||||
if (value != null && value.isNotEmpty) {
|
if (value != null && value.isNotEmpty) {
|
||||||
fieldWidgets.add(Column(
|
fieldWidgets.add(Column(
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ class InvoiceViewVM {
|
||||||
final client = store.state.clientState.map[invoice.clientId];
|
final client = store.state.clientState.map[invoice.clientId];
|
||||||
|
|
||||||
Future<Null> _viewPdf(BuildContext context) async {
|
Future<Null> _viewPdf(BuildContext context) async {
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
String url;
|
String url;
|
||||||
bool useWebView;
|
bool useWebView;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ class _ProductEditState extends State<ProductEdit> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onChanged() {
|
void _onChanged() {
|
||||||
var product = widget.viewModel.product.rebuild((b) => b
|
final product = widget.viewModel.product.rebuild((b) => b
|
||||||
..productKey = _productKeyController.text.trim()
|
..productKey = _productKeyController.text.trim()
|
||||||
..notes = _notesController.text.trim()
|
..notes = _notesController.text.trim()
|
||||||
..cost = double.tryParse(_costController.text) ?? 0.0
|
..cost = double.tryParse(_costController.text) ?? 0.0
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ class ProductScreen extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var store = StoreProvider.of<AppState>(context);
|
final store = StoreProvider.of<AppState>(context);
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ String formatNumber(
|
||||||
currencyId = kCurrencyUSDollar;
|
currencyId = kCurrencyUSDollar;
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrencyEntity currency = state.staticState.currencyMap[currencyId];
|
final CurrencyEntity currency = state.staticState.currencyMap[currencyId];
|
||||||
CountryEntity country = state.staticState.countryMap[countryId];
|
final CountryEntity country = state.staticState.countryMap[countryId];
|
||||||
|
|
||||||
String thousandSeparator = currency.thousandSeparator;
|
String thousandSeparator = currency.thousandSeparator;
|
||||||
String decimalSeparator = currency.decimalSeparator;
|
String decimalSeparator = currency.decimalSeparator;
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ class ContactsPageState extends State<ContactsPage>
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ContactEntity> getContacts() {
|
List<ContactEntity> getContacts() {
|
||||||
List<ContactEntity> contacts = [];
|
final List<ContactEntity> contacts = [];
|
||||||
_contactKeys.forEach((contactKey) {
|
_contactKeys.forEach((contactKey) {
|
||||||
contacts.add(contactKey.currentState.getContact());
|
contacts.add(contactKey.currentState.getContact());
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -233,8 +233,8 @@ class ContactsPage extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return StoreBuilder(builder: (BuildContext context, Store<AppState> store) {
|
return StoreBuilder(builder: (BuildContext context, Store<AppState> store) {
|
||||||
var client = store.state.client;
|
final client = store.state.client;
|
||||||
var contacts = client.contacts.map((contact) => ContactForm(
|
final contacts = client.contacts.map((contact) => ContactForm(
|
||||||
contact: contact,
|
contact: contact,
|
||||||
//key: Key('__contact_${contact.id}__'),
|
//key: Key('__contact_${contact.id}__'),
|
||||||
index: store.state.client.contacts.indexOf(contact)));
|
index: store.state.client.contacts.indexOf(contact)));
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ void main() {
|
||||||
|
|
||||||
test('measure', () async {
|
test('measure', () async {
|
||||||
// Record the performance timeline of things that happen inside the closure
|
// Record the performance timeline of things that happen inside the closure
|
||||||
Timeline timeline = await driver.traceAction(() async {
|
final Timeline timeline = await driver.traceAction(() async {
|
||||||
|
|
||||||
//SerializableFinder email = find.byValueKey('email');
|
//SerializableFinder email = find.byValueKey('email');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue