Refactor
This commit is contained in:
parent
9b9902cdb6
commit
d16fc4f65c
|
|
@ -250,7 +250,7 @@ abstract class InvoiceEntity extends Object with BaseEntity, CalculateInvoiceTot
|
||||||
//String get custom_messages;
|
//String get custom_messages;
|
||||||
|
|
||||||
int compareTo(InvoiceEntity invoice, String sortField, bool sortAscending) {
|
int compareTo(InvoiceEntity invoice, String sortField, bool sortAscending) {
|
||||||
int response = 0;
|
final response = 0;
|
||||||
final InvoiceEntity invoiceA = sortAscending ? this : invoice;
|
final InvoiceEntity invoiceA = sortAscending ? this : invoice;
|
||||||
final InvoiceEntity invoiceB = sortAscending ? invoice: this;
|
final InvoiceEntity invoiceB = sortAscending ? invoice: this;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class InvoiceRepository {
|
||||||
final Future<dynamic> response = await webClient.post(
|
final Future<dynamic> response = await webClient.post(
|
||||||
auth.url + '/email_invoice?invoice_id=${invoice.id}', company.token, null);
|
auth.url + '/email_invoice?invoice_id=${invoice.id}', company.token, null);
|
||||||
|
|
||||||
InvoiceItemResponse invoiceResponse = serializers.deserializeWith(
|
final InvoiceItemResponse invoiceResponse = serializers.deserializeWith(
|
||||||
InvoiceItemResponse.serializer, response);
|
InvoiceItemResponse.serializer, response);
|
||||||
|
|
||||||
return invoiceResponse.data;
|
return invoiceResponse.data;
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@ class PersistenceRepository {
|
||||||
|
|
||||||
|
|
||||||
Future<File> saveCompanyState(CompanyState state) async {
|
Future<File> saveCompanyState(CompanyState state) async {
|
||||||
var data = serializers.serializeWith(CompanyState.serializer, state);
|
final data = serializers.serializeWith(CompanyState.serializer, state);
|
||||||
return await fileStorage.save(json.encode(data));
|
return await fileStorage.save(json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<CompanyState> loadCompanyState() async {
|
Future<CompanyState> loadCompanyState() async {
|
||||||
String data = await fileStorage.load();
|
final String data = await fileStorage.load();
|
||||||
return serializers.deserializeWith(CompanyState.serializer, json.decode(data));
|
return serializers.deserializeWith(CompanyState.serializer, json.decode(data));
|
||||||
//return compute(_deserialize, data);
|
//return compute(_deserialize, data);
|
||||||
}
|
}
|
||||||
|
|
@ -37,18 +37,18 @@ class PersistenceRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<AuthState> loadAuthState() async {
|
Future<AuthState> loadAuthState() async {
|
||||||
String data = await fileStorage.load();
|
final String data = await fileStorage.load();
|
||||||
return serializers.deserializeWith(AuthState.serializer, json.decode(data));
|
return serializers.deserializeWith(AuthState.serializer, json.decode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<File> saveStaticState(StaticState state) async {
|
Future<File> saveStaticState(StaticState state) async {
|
||||||
var data = serializers.serializeWith(StaticState.serializer, state);
|
final data = serializers.serializeWith(StaticState.serializer, state);
|
||||||
return await fileStorage.save(json.encode(data));
|
return await fileStorage.save(json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<StaticState> loadStaticState() async {
|
Future<StaticState> loadStaticState() async {
|
||||||
String data = await fileStorage.load();
|
final String data = await fileStorage.load();
|
||||||
return serializers.deserializeWith(StaticState.serializer, json.decode(data));
|
return serializers.deserializeWith(StaticState.serializer, json.decode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ List<Middleware<AppState>> createStoreAuthMiddleware([
|
||||||
}
|
}
|
||||||
|
|
||||||
void _saveAuthLocal(dynamic action) async {
|
void _saveAuthLocal(dynamic action) async {
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
prefs.setString('email', action.email);
|
prefs.setString('email', action.email);
|
||||||
prefs.setString('url', action.url);
|
prefs.setString('url', action.url);
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ void _saveAuthLocal(dynamic action) async {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _loadAuthLocal(Store<AppState> store, dynamic action) async {
|
void _loadAuthLocal(Store<AppState> store, dynamic action) async {
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
|
||||||
final String email = prefs.getString('email') ?? Config.LOGIN_EMAIL;
|
final String email = prefs.getString('email') ?? Config.LOGIN_EMAIL;
|
||||||
final String password = prefs.getString('password') ?? Config.LOGIN_PASSWORD;
|
final String password = prefs.getString('password') ?? Config.LOGIN_PASSWORD;
|
||||||
|
|
@ -86,7 +86,7 @@ Middleware<AppState> _createLoginRequest(AuthRepository repository) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _isVersionSupported(String version) {
|
bool _isVersionSupported(String version) {
|
||||||
var parts = version.split('.');
|
final parts = version.split('.');
|
||||||
|
|
||||||
final int major = int.parse(parts[0]);
|
final int major = int.parse(parts[0]);
|
||||||
final int minor = int.parse(parts[1]);
|
final int minor = int.parse(parts[1]);
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ Middleware<AppState> _viewClientList() {
|
||||||
|
|
||||||
Middleware<AppState> _archiveClient(ClientRepository repository) {
|
Middleware<AppState> _archiveClient(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.archive)
|
origClient, EntityAction.archive)
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ ClientState _archiveClientFailure(ClientState clientState, ArchiveClientFailure
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientState _deleteClientRequest(ClientState clientState, DeleteClientRequest action) {
|
ClientState _deleteClientRequest(ClientState clientState, DeleteClientRequest 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
|
||||||
..isDeleted = true
|
..isDeleted = true
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ List<int> dropdownClientsSelector(
|
||||||
}).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, ClientFields.name, true);
|
return clientA.compareTo(clientB, ClientFields.name, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -43,7 +43,7 @@ List<int> visibleClientsSelector(
|
||||||
BuiltList<int> clientList,
|
BuiltList<int> clientList,
|
||||||
ListUIState clientListState) {
|
ListUIState clientListState) {
|
||||||
|
|
||||||
var list = clientList.where((clientId) {
|
final list = clientList.where((clientId) {
|
||||||
final client = clientMap[clientId];
|
final client = clientMap[clientId];
|
||||||
if (! client.matchesStates(clientListState.stateFilters)) {
|
if (! client.matchesStates(clientListState.stateFilters)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ Middleware<AppState> _createViewDashboard() {
|
||||||
|
|
||||||
Middleware<AppState> _createLoadDashboard(DashboardRepository repository) {
|
Middleware<AppState> _createLoadDashboard(DashboardRepository repository) {
|
||||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||||
AppState state = store.state;
|
final state = store.state;
|
||||||
|
|
||||||
if (!state.dashboardState.isStale && !action.force) {
|
if (!state.dashboardState.isStale && !action.force) {
|
||||||
next(action);
|
next(action);
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ Middleware<AppState> _deleteInvoice(InvoiceRepository repository) {
|
||||||
|
|
||||||
Middleware<AppState> _restoreInvoice(InvoiceRepository repository) {
|
Middleware<AppState> _restoreInvoice(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.restore)
|
origInvoice, EntityAction.restore)
|
||||||
|
|
@ -134,7 +134,7 @@ Middleware<AppState> _restoreInvoice(InvoiceRepository repository) {
|
||||||
|
|
||||||
Middleware<AppState> _emailInvoice(InvoiceRepository repository) {
|
Middleware<AppState> _emailInvoice(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
|
||||||
.emailInvoice(store.state.selectedCompany, store.state.authState,
|
.emailInvoice(store.state.selectedCompany, store.state.authState,
|
||||||
origInvoice)
|
origInvoice)
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ Middleware<AppState> _viewProductList() {
|
||||||
|
|
||||||
Middleware<AppState> _archiveProduct(ProductRepository repository) {
|
Middleware<AppState> _archiveProduct(ProductRepository repository) {
|
||||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||||
var origProduct = store.state.productState.map[action.productId];
|
final origProduct = store.state.productState.map[action.productId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.selectedCompany, store.state.authState,
|
||||||
origProduct, EntityAction.archive)
|
origProduct, EntityAction.archive)
|
||||||
|
|
@ -96,7 +96,7 @@ Middleware<AppState> _deleteProduct(ProductRepository repository) {
|
||||||
|
|
||||||
Middleware<AppState> _restoreProduct(ProductRepository repository) {
|
Middleware<AppState> _restoreProduct(ProductRepository repository) {
|
||||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||||
var origProduct = store.state.productState.map[action.productId];
|
final origProduct = store.state.productState.map[action.productId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.selectedCompany, store.state.authState,
|
||||||
origProduct, EntityAction.restore)
|
origProduct, EntityAction.restore)
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ ProductState _archiveProductFailure(ProductState productState, ArchiveProductFai
|
||||||
}
|
}
|
||||||
|
|
||||||
ProductState _deleteProductRequest(ProductState productState, DeleteProductRequest action) {
|
ProductState _deleteProductRequest(ProductState productState, DeleteProductRequest 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
|
||||||
..isDeleted = true
|
..isDeleted = true
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,8 @@ class AppDrawer extends StatelessWidget {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
Store<AppState> store = StoreProvider.of<AppState>(context);
|
final Store<AppState> store = StoreProvider.of<AppState>(context);
|
||||||
NavigatorState navigator = Navigator.of(context);
|
final NavigatorState navigator = Navigator.of(context);
|
||||||
|
|
||||||
return Drawer(
|
return Drawer(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class AppSearchButton extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
//var store = StoreProvider.of<AppState>(context);
|
//var store = StoreProvider.of<AppState>(context);
|
||||||
|
|
||||||
return StoreConnector<AppState, ListUIState>(
|
return StoreConnector<AppState, ListUIState>(
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class EditIconButton extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
|
|
||||||
if (!isVisible) {
|
if (!isVisible) {
|
||||||
return Container();
|
return Container();
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class SaveIconButton extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
|
|
||||||
if (!isVisible) {
|
if (!isVisible) {
|
||||||
return Container();
|
return Container();
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class _EntityDropdownState extends State<EntityDropdown> {
|
||||||
|
|
||||||
void _showOptions() {
|
void _showOptions() {
|
||||||
widget.onFilterChanged('');
|
widget.onFilterChanged('');
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
|
|
||||||
Widget _headerRow() {
|
Widget _headerRow() {
|
||||||
return Row(
|
return Row(
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class EntityStateLabel extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
|
|
||||||
return entity.isDeleted
|
return entity.isDeleted
|
||||||
? Text(localization.deleted,
|
? Text(localization.deleted,
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ class InvoiceItemListTile extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
String cost = formatNumber(invoiceItem.cost, state, clientId: invoice.clientId);
|
final String cost = formatNumber(invoiceItem.cost, state, clientId: invoice.clientId);
|
||||||
String qty = formatNumber(invoiceItem.qty, state, clientId: invoice.clientId, formatNumberType: FormatNumberType.double);
|
final String qty = formatNumber(invoiceItem.qty, state, clientId: invoice.clientId, formatNumberType: FormatNumberType.double);
|
||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(invoiceItem.productKey),
|
title: Text(invoiceItem.productKey),
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ class ClientList extends StatelessWidget {
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: viewModel.clientList.length,
|
itemCount: viewModel.clientList.length,
|
||||||
itemBuilder: (BuildContext context, index) {
|
itemBuilder: (BuildContext context, index) {
|
||||||
var clientId = viewModel.clientList[index];
|
final clientId = viewModel.clientList[index];
|
||||||
var client = viewModel.clientMap[clientId];
|
final client = viewModel.clientMap[clientId];
|
||||||
return Column(children: <Widget>[
|
return Column(children: <Widget>[
|
||||||
ClientItem(
|
ClientItem(
|
||||||
filter: viewModel.filter,
|
filter: viewModel.filter,
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
|
||||||
|
|
||||||
_controllers.forEach((dynamic controller) => controller.removeListener(_onChanged));
|
_controllers.forEach((dynamic controller) => controller.removeListener(_onChanged));
|
||||||
|
|
||||||
var contact = widget.contact;
|
final contact = widget.contact;
|
||||||
_firstNameController.text = contact.firstName;
|
_firstNameController.text = contact.firstName;
|
||||||
_lastNameController.text = contact.lastName;
|
_lastNameController.text = contact.lastName;
|
||||||
_emailController.text = contact.email;
|
_emailController.text = contact.email;
|
||||||
|
|
@ -113,7 +113,7 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
|
|
||||||
void _confirmDelete() {
|
void _confirmDelete() {
|
||||||
showDialog<AlertDialog>(
|
showDialog<AlertDialog>(
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class ClientEditDetailsState extends State<ClientEditDetails> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
List<TextEditingController> _controllers = [
|
final List<TextEditingController> _controllers = [
|
||||||
_nameController,
|
_nameController,
|
||||||
_idNumberController,
|
_idNumberController,
|
||||||
_vatNumberController,
|
_vatNumberController,
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class ClientEditShippingAddressState extends State<ClientEditShippingAddress> {
|
||||||
|
|
||||||
_controllers.forEach((dynamic controller) => controller.removeListener(_onChanged));
|
_controllers.forEach((dynamic controller) => controller.removeListener(_onChanged));
|
||||||
|
|
||||||
var client = widget.viewModel.client;
|
final client = widget.viewModel.client;
|
||||||
_shippingAddress1Controller.text = client.shippingAddress1;
|
_shippingAddress1Controller.text = client.shippingAddress1;
|
||||||
_shippingAddress2Controller.text = client.shippingAddress2;
|
_shippingAddress2Controller.text = client.shippingAddress2;
|
||||||
_shippingCityController.text = client.shippingCity;
|
_shippingCityController.text = client.shippingCity;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class _ClientViewDetailsState extends State<ClientViewDetails> {
|
||||||
Future<Null> _launched;
|
Future<Null> _launched;
|
||||||
|
|
||||||
Future<Null> _launchURL(BuildContext context, String url) async {
|
Future<Null> _launchURL(BuildContext context, String url) async {
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
if (await canLaunch(url)) {
|
if (await canLaunch(url)) {
|
||||||
await launch(url, forceSafariVC: false, forceWebView: false);
|
await launch(url, forceSafariVC: false, forceWebView: false);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -40,11 +40,11 @@ class _ClientViewDetailsState extends State<ClientViewDetails> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
var client = widget.client;
|
final client = widget.client;
|
||||||
|
|
||||||
List<Widget> _buildDetailsList() {
|
List<Widget> _buildDetailsList() {
|
||||||
var listTiles = <Widget>[];
|
final listTiles = <Widget>[];
|
||||||
|
|
||||||
listTiles
|
listTiles
|
||||||
.add(FutureBuilder<Null>(future: _launched, builder: _launchStatus));
|
.add(FutureBuilder<Null>(future: _launched, builder: _launchStatus));
|
||||||
|
|
@ -122,8 +122,8 @@ class _ClientViewDetailsState extends State<ClientViewDetails> {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
var billingAddress = formatAddress(object: client);
|
final billingAddress = formatAddress(object: client);
|
||||||
var shippingAddress = formatAddress(object: client, isShipping: true);
|
final shippingAddress = formatAddress(object: client, isShipping: true);
|
||||||
|
|
||||||
if (billingAddress.isNotEmpty) {
|
if (billingAddress.isNotEmpty) {
|
||||||
listTiles.add(AppListTile(
|
listTiles.add(AppListTile(
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class ClientOverview extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
|
|
||||||
return ListView(
|
return ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class InvoiceEditItems extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var invoiceItems = invoice.invoiceItems.map((invoiceItem) =>
|
final invoiceItems = invoice.invoiceItems.map((invoiceItem) =>
|
||||||
ItemEditDetails(
|
ItemEditDetails(
|
||||||
viewModel: viewModel,
|
viewModel: viewModel,
|
||||||
key: Key('__${EntityType.invoiceItem}_${invoiceItem.id}__'),
|
key: Key('__${EntityType.invoiceItem}_${invoiceItem.id}__'),
|
||||||
|
|
@ -117,7 +117,7 @@ class ItemEditDetailsState extends State<ItemEditDetails> with AutomaticKeepAliv
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
|
|
||||||
void _confirmDelete() {
|
void _confirmDelete() {
|
||||||
showDialog<AlertDialog>(
|
showDialog<AlertDialog>(
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,10 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onItemsSelected() {
|
void _onItemsSelected() {
|
||||||
List<InvoiceItemEntity> items = [];
|
final List<InvoiceItemEntity> items = [];
|
||||||
|
|
||||||
_selectedIds.forEach((entityId) {
|
_selectedIds.forEach((entityId) {
|
||||||
var product = widget.state.productState.map[entityId];
|
final product = widget.state.productState.map[entityId];
|
||||||
items.add(product.asInvoiceItem);
|
items.add(product.asInvoiceItem);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -143,8 +143,8 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector> {
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
itemCount: matches.length,
|
itemCount: matches.length,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
int entityId = matches[index];
|
final int entityId = matches[index];
|
||||||
var entity = state.map[entityId];
|
final entity = state.map[entityId];
|
||||||
final String subtitle = entity.matchesSearchValue(_filter);
|
final String subtitle = entity.matchesSearchValue(_filter);
|
||||||
return ListTile(
|
return ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class _ProductEditState extends State<ProductEdit> {
|
||||||
|
|
||||||
_controllers.forEach((dynamic controller) => controller.removeListener(_onChanged));
|
_controllers.forEach((dynamic controller) => controller.removeListener(_onChanged));
|
||||||
|
|
||||||
var product = widget.viewModel.product;
|
final product = widget.viewModel.product;
|
||||||
_productKeyController.text = product.productKey;
|
_productKeyController.text = product.productKey;
|
||||||
_notesController.text = product.notes;
|
_notesController.text = product.notes;
|
||||||
_costController.text = formatNumber(product.cost, widget.viewModel.state, formatNumberType: FormatNumberType.input);
|
_costController.text = formatNumber(product.cost, widget.viewModel.state, formatNumberType: FormatNumberType.input);
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ String formatNumber(
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CompanyEntity company = state.selectedCompany;
|
final CompanyEntity company = state.selectedCompany;
|
||||||
ClientEntity client = state.selectedCompanyState.clientState.map[clientId];
|
final ClientEntity client = state.selectedCompanyState.clientState.map[clientId];
|
||||||
|
|
||||||
//var countryId = client?.countryId ?? company.countryId;
|
//var countryId = client?.countryId ?? company.countryId;
|
||||||
int currencyId;
|
int currencyId;
|
||||||
|
|
@ -114,13 +114,13 @@ String formatAddress(
|
||||||
{dynamic object, bool isShipping = false, String delimiter = '\n'}) {
|
{dynamic object, bool isShipping = false, String delimiter = '\n'}) {
|
||||||
var str = '';
|
var str = '';
|
||||||
|
|
||||||
String address1 =
|
final String address1 =
|
||||||
(isShipping ? object.shippingAddress1 : object.address1) ?? '';
|
(isShipping ? object.shippingAddress1 : object.address1) ?? '';
|
||||||
String address2 =
|
final String address2 =
|
||||||
(isShipping ? object.shippingAddress2 : object.address2) ?? '';
|
(isShipping ? object.shippingAddress2 : object.address2) ?? '';
|
||||||
String city = (isShipping ? object.city : object.city) ?? '';
|
final String city = (isShipping ? object.city : object.city) ?? '';
|
||||||
String state = (isShipping ? object.state : object.state) ?? '';
|
final String state = (isShipping ? object.state : object.state) ?? '';
|
||||||
String postalCode =
|
final String postalCode =
|
||||||
(isShipping ? object.postalCode : object.postalCode) ?? '';
|
(isShipping ? object.postalCode : object.postalCode) ?? '';
|
||||||
|
|
||||||
if (address1.isNotEmpty) {
|
if (address1.isNotEmpty) {
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class _MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// Create a test client to show initially
|
// Create a test client to show initially
|
||||||
ClientEntity _client = ClientEntity(
|
final ClientEntity _client = ClientEntity(
|
||||||
name: 'Acme Client',
|
name: 'Acme Client',
|
||||||
contacts: [ContactEntity(email: 'test@example.com')]);
|
contacts: [ContactEntity(email: 'test@example.com')]);
|
||||||
|
|
||||||
|
|
@ -63,12 +63,12 @@ class _MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
|
||||||
|
|
||||||
_formKey.currentState.save();
|
_formKey.currentState.save();
|
||||||
|
|
||||||
var clientState = _clientKey.currentState;
|
final clientState = _clientKey.currentState;
|
||||||
var contactsState = _contactsKey.currentState;
|
final contactsState = _contactsKey.currentState;
|
||||||
|
|
||||||
// If the user never views a tab the state can be null
|
// If the user never views a tab the state can be null
|
||||||
// in which case we'll use the current value
|
// in which case we'll use the current value
|
||||||
ClientEntity client = ClientEntity(
|
final ClientEntity client = ClientEntity(
|
||||||
name: clientState?.name ?? _client.name,
|
name: clientState?.name ?? _client.name,
|
||||||
contacts: contactsState?.getContacts() ?? _client.contacts,
|
contacts: contactsState?.getContacts() ?? _client.contacts,
|
||||||
);
|
);
|
||||||
|
|
@ -168,7 +168,7 @@ class ContactsPageState extends State<ContactsPage>
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
var client = widget.client;
|
final client = widget.client;
|
||||||
_contacts = client.contacts.toList();
|
_contacts = client.contacts.toList();
|
||||||
_contactKeys = client.contacts
|
_contactKeys = client.contacts
|
||||||
.map((contact) => GlobalKey<ContactFormState>())
|
.map((contact) => GlobalKey<ContactFormState>())
|
||||||
|
|
@ -192,7 +192,7 @@ class ContactsPageState extends State<ContactsPage>
|
||||||
|
|
||||||
void _onRemovePressed(GlobalKey<ContactFormState> key) {
|
void _onRemovePressed(GlobalKey<ContactFormState> key) {
|
||||||
setState(() {
|
setState(() {
|
||||||
var index = _contactKeys.indexOf(key);
|
final index = _contactKeys.indexOf(key);
|
||||||
_contactKeys.removeAt(index);
|
_contactKeys.removeAt(index);
|
||||||
_contacts.removeAt(index);
|
_contacts.removeAt(index);
|
||||||
});
|
});
|
||||||
|
|
@ -200,7 +200,7 @@ class ContactsPageState extends State<ContactsPage>
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
List<Widget> items = [];
|
final List<Widget> items = [];
|
||||||
|
|
||||||
for (var i = 0; i < _contacts.length; i++) {
|
for (var i = 0; i < _contacts.length; i++) {
|
||||||
final contact = _contacts[i];
|
final contact = _contacts[i];
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ class _ClientPageState extends State<ClientPage> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
var store = StoreProvider.of<AppState>(context);
|
final store = StoreProvider.of<AppState>(context);
|
||||||
_nameController.removeListener(_onChanged);
|
_nameController.removeListener(_onChanged);
|
||||||
_nameController.text = store.state.client.name;
|
_nameController.text = store.state.client.name;
|
||||||
_nameController.addListener(_onChanged);
|
_nameController.addListener(_onChanged);
|
||||||
|
|
@ -289,8 +289,8 @@ class _ContactFormState extends State<ContactForm> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onChanged() {
|
void _onChanged() {
|
||||||
var store = StoreProvider.of<AppState>(context);
|
final store = StoreProvider.of<AppState>(context);
|
||||||
var email = _emailController.text.trim();
|
final email = _emailController.text.trim();
|
||||||
if (email != widget.contact.email) {
|
if (email != widget.contact.email) {
|
||||||
store.dispatch(UpdateContact(email: email, index: widget.index));
|
store.dispatch(UpdateContact(email: email, index: widget.index));
|
||||||
}
|
}
|
||||||
|
|
@ -298,7 +298,7 @@ class _ContactFormState extends State<ContactForm> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var store = StoreProvider.of<AppState>(context);
|
final store = StoreProvider.of<AppState>(context);
|
||||||
|
|
||||||
return FormCard(
|
return FormCard(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue