Optimizations
This commit is contained in:
parent
e481bbf671
commit
23877bb83c
|
|
@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/custom_field.dart';
|
||||
import 'package:invoiceninja_flutter/ui/client/edit/client_edit_vm.dart';
|
||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/form_card.dart';
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class ClientViewScreen extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StoreConnector<AppState, ClientViewVM>(
|
||||
distinct: true,
|
||||
converter: (Store<AppState> store) {
|
||||
return ClientViewVM.fromStore(store);
|
||||
},
|
||||
|
|
@ -85,10 +86,9 @@ class ClientViewVM {
|
|||
client: client, context: context, completer: completer));
|
||||
completer.future.then((client) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: SnackBarRow(
|
||||
message:
|
||||
AppLocalization.of(context).updatedClient,
|
||||
)));
|
||||
content: SnackBarRow(
|
||||
message: AppLocalization.of(context).updatedClient,
|
||||
)));
|
||||
});
|
||||
},
|
||||
onInvoicesPressed: (BuildContext context) {
|
||||
|
|
@ -104,8 +104,7 @@ class ClientViewVM {
|
|||
switch (action) {
|
||||
case EntityAction.archive:
|
||||
store.dispatch(ArchiveClientRequest(
|
||||
popCompleter(
|
||||
context, localization.archivedClient),
|
||||
popCompleter(context, localization.archivedClient),
|
||||
client.id));
|
||||
break;
|
||||
case EntityAction.delete:
|
||||
|
|
@ -115,11 +114,17 @@ class ClientViewVM {
|
|||
break;
|
||||
case EntityAction.restore:
|
||||
store.dispatch(RestoreClientRequest(
|
||||
snackBarCompleter(
|
||||
context, localization.restoredClient),
|
||||
snackBarCompleter(context, localization.restoredClient),
|
||||
client.id));
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
client == other.client && company == other.company;
|
||||
|
||||
@override
|
||||
int get hashCode => client.hashCode ^ company.hashCode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@ class DashboardBuilder extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StoreConnector<AppState, DashboardVM>(
|
||||
distinct: true,
|
||||
converter: DashboardVM.fromStore,
|
||||
builder: (context, vm) {
|
||||
return DashboardView(viewModel: vm);
|
||||
builder: (context, viewModel) {
|
||||
return DashboardView(viewModel: viewModel);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
@ -30,17 +31,17 @@ class DashboardBuilder extends StatelessWidget {
|
|||
|
||||
class DashboardVM {
|
||||
final DashboardState dashboardState;
|
||||
final bool isLoading;
|
||||
final Function(BuildContext) onRefreshed;
|
||||
final String filter;
|
||||
final List<BaseEntity> filteredList;
|
||||
final bool isLoading;
|
||||
final Function(BuildContext) onRefreshed;
|
||||
|
||||
DashboardVM({
|
||||
@required this.dashboardState,
|
||||
@required this.isLoading,
|
||||
@required this.onRefreshed,
|
||||
@required this.filter,
|
||||
@required this.filteredList,
|
||||
@required this.onRefreshed,
|
||||
});
|
||||
|
||||
static DashboardVM fromStore(Store<AppState> store) {
|
||||
|
|
@ -66,4 +67,18 @@ class DashboardVM {
|
|||
memoizedFilteredSelector(filter, state.selectedCompanyState),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
dashboardState == other.dashboardState &&
|
||||
isLoading == other.isLoading &&
|
||||
filter == other.filter &&
|
||||
filteredList == other.filteredList;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
dashboardState.hashCode ^
|
||||
isLoading.hashCode ^
|
||||
filter.hashCode ^
|
||||
filteredList.hashCode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,12 +23,13 @@ class InvoiceViewScreen extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StoreConnector<AppState, InvoiceViewVM>(
|
||||
distinct: true,
|
||||
converter: (Store<AppState> store) {
|
||||
return InvoiceViewVM.fromStore(store);
|
||||
},
|
||||
builder: (context, vm) {
|
||||
builder: (context, viewModel) {
|
||||
return InvoiceView(
|
||||
viewModel: vm,
|
||||
viewModel: viewModel,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
@ -39,24 +40,24 @@ class InvoiceViewVM {
|
|||
final CompanyEntity company;
|
||||
final InvoiceEntity invoice;
|
||||
final ClientEntity client;
|
||||
final bool isSaving;
|
||||
final bool isDirty;
|
||||
final Function(BuildContext, EntityAction) onActionSelected;
|
||||
final Function(BuildContext, [InvoiceItemEntity]) onEditPressed;
|
||||
final Function(BuildContext) onClientPressed;
|
||||
final Function(BuildContext) onRefreshed;
|
||||
final Function onBackPressed;
|
||||
final bool isSaving;
|
||||
final bool isDirty;
|
||||
|
||||
InvoiceViewVM({
|
||||
@required this.company,
|
||||
@required this.invoice,
|
||||
@required this.client,
|
||||
@required this.isSaving,
|
||||
@required this.isDirty,
|
||||
@required this.onActionSelected,
|
||||
@required this.onEditPressed,
|
||||
@required this.onBackPressed,
|
||||
@required this.onClientPressed,
|
||||
@required this.isSaving,
|
||||
@required this.isDirty,
|
||||
@required this.onRefreshed,
|
||||
});
|
||||
|
||||
|
|
@ -107,33 +108,29 @@ class InvoiceViewVM {
|
|||
break;
|
||||
case EntityAction.markSent:
|
||||
store.dispatch(MarkSentInvoiceRequest(
|
||||
snackBarCompleter(
|
||||
context, localization.markedInvoiceAsSent),
|
||||
snackBarCompleter(context, localization.markedInvoiceAsSent),
|
||||
invoice.id));
|
||||
break;
|
||||
case EntityAction.emailInvoice:
|
||||
store.dispatch(ShowEmailInvoice(
|
||||
completer: snackBarCompleter(
|
||||
context, localization.emailedInvoice),
|
||||
completer:
|
||||
snackBarCompleter(context, localization.emailedInvoice),
|
||||
invoice: invoice,
|
||||
context: context));
|
||||
break;
|
||||
case EntityAction.archive:
|
||||
store.dispatch(ArchiveInvoiceRequest(
|
||||
popCompleter(
|
||||
context, localization.archivedInvoice),
|
||||
popCompleter(context, localization.archivedInvoice),
|
||||
invoice.id));
|
||||
break;
|
||||
case EntityAction.delete:
|
||||
store.dispatch(DeleteInvoiceRequest(
|
||||
popCompleter(
|
||||
context, localization.deletedInvoice),
|
||||
popCompleter(context, localization.deletedInvoice),
|
||||
invoice.id));
|
||||
break;
|
||||
case EntityAction.restore:
|
||||
store.dispatch(RestoreInvoiceRequest(
|
||||
snackBarCompleter(
|
||||
context, localization.restoredInvoice),
|
||||
snackBarCompleter(context, localization.restoredInvoice),
|
||||
invoice.id));
|
||||
break;
|
||||
case EntityAction.clone:
|
||||
|
|
@ -144,4 +141,20 @@ class InvoiceViewVM {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
client == other.client &&
|
||||
company == other.company &&
|
||||
invoice == other.invoice &&
|
||||
isSaving == other.isSaving &&
|
||||
isDirty == other.isDirty;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
client.hashCode ^
|
||||
company.hashCode ^
|
||||
invoice.hashCode ^
|
||||
isSaving.hashCode ^
|
||||
isDirty.hashCode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class ProductListBuilder extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StoreConnector<AppState, ProductListVM>(
|
||||
//distinct: true,
|
||||
converter: ProductListVM.fromStore,
|
||||
builder: (context, vm) {
|
||||
return ProductList(
|
||||
|
|
@ -132,4 +133,13 @@ class ProductListVM {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
client == other.client && company == other.company;
|
||||
|
||||
@override
|
||||
int get hashCode => client.hashCode ^ company.hashCode;
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue