Refactor
This commit is contained in:
parent
82bcd78e9f
commit
4bff8e1de8
|
|
@ -22,7 +22,7 @@ class AuthRepository {
|
|||
'password': password,
|
||||
};
|
||||
|
||||
final response = await webClient.post(url + '/login?include_static=true', '', json.encode(credentials));
|
||||
final Future<dynamic> response = await webClient.post(url + '/login?include_static=true', '', json.encode(credentials));
|
||||
print(response);
|
||||
LoginResponse loginResponse = serializers.deserializeWith(
|
||||
LoginResponse.serializer, response);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class ClientRepository {
|
|||
|
||||
Future<BuiltList<ClientEntity>> loadList(CompanyEntity company, AuthState auth) async {
|
||||
|
||||
final response = await webClient.get(
|
||||
final Future<dynamic> response = await webClient.get(
|
||||
auth.url + '/clients', company.token);
|
||||
|
||||
ClientListResponse clientResponse = serializers.deserializeWith(
|
||||
|
|
@ -29,7 +29,7 @@ class ClientRepository {
|
|||
Future saveData(CompanyEntity company, AuthState auth, ClientEntity client, [EntityAction action]) async {
|
||||
|
||||
var data = serializers.serializeWith(ClientEntity.serializer, client);
|
||||
var response;
|
||||
Future<dynamic> response;
|
||||
|
||||
if (client.isNew) {
|
||||
response = await webClient.post(
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class CreditsRepository {
|
|||
|
||||
Future<BuiltList<CreditEntity>> loadList(CompanyEntity company, AuthState auth) async {
|
||||
|
||||
final response = await webClient.get(
|
||||
final Future<dynamic> response = await webClient.get(
|
||||
auth.url + '/credits?per_page=500', company.token);
|
||||
|
||||
CreditListResponse creditResponse = serializers.deserializeWith(
|
||||
|
|
@ -29,7 +29,7 @@ class CreditsRepository {
|
|||
Future saveData(CompanyEntity company, AuthState auth, CreditEntity credit, [EntityAction action]) async {
|
||||
|
||||
var data = serializers.serializeWith(CreditEntity.serializer, credit);
|
||||
var response;
|
||||
Future<dynamic> response;
|
||||
|
||||
if (credit.isNew) {
|
||||
response = await webClient.post(
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class DashboardRepository {
|
|||
|
||||
Future<DashboardEntity> loadItem(CompanyEntity company, AuthState auth) async {
|
||||
|
||||
final response = await webClient.get(
|
||||
final Future<dynamic> response = await webClient.get(
|
||||
auth.url + '/dashboard', company.token);
|
||||
|
||||
DashboardResponse dashboardResponse = serializers.deserializeWith(
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class ExpenseRepository {
|
|||
|
||||
Future<BuiltList<ExpenseEntity>> loadList(CompanyEntity company, AuthState auth) async {
|
||||
|
||||
final response = await webClient.get(
|
||||
final Future<dynamic> response = await webClient.get(
|
||||
auth.url + '/expenses?per_page=500', company.token);
|
||||
|
||||
ExpenseListResponse expenseResponse = serializers.deserializeWith(
|
||||
|
|
@ -29,7 +29,7 @@ class ExpenseRepository {
|
|||
Future saveData(CompanyEntity company, AuthState auth, ExpenseEntity expense, [EntityAction action]) async {
|
||||
|
||||
var data = serializers.serializeWith(ExpenseEntity.serializer, expense);
|
||||
var response;
|
||||
Future<dynamic> response;
|
||||
|
||||
if (expense.isNew) {
|
||||
response = await webClient.post(
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class InvoiceRepository {
|
|||
|
||||
Future<BuiltList<InvoiceEntity>> loadList(CompanyEntity company, AuthState auth) async {
|
||||
|
||||
final response = await webClient.get(
|
||||
final Future<dynamic> response = await webClient.get(
|
||||
auth.url + '/invoices?include=invitations', company.token);
|
||||
|
||||
InvoiceListResponse invoiceResponse = serializers.deserializeWith(
|
||||
|
|
@ -29,7 +29,7 @@ class InvoiceRepository {
|
|||
Future saveData(CompanyEntity company, AuthState auth, InvoiceEntity invoice, [EntityAction action]) async {
|
||||
|
||||
var data = serializers.serializeWith(InvoiceEntity.serializer, invoice);
|
||||
var response;
|
||||
Future<dynamic> response;
|
||||
|
||||
if (invoice.isNew) {
|
||||
response = await webClient.post(
|
||||
|
|
@ -50,7 +50,7 @@ class InvoiceRepository {
|
|||
|
||||
Future emailInvoice(CompanyEntity company, AuthState auth, InvoiceEntity invoice) async {
|
||||
|
||||
var response = await webClient.post(
|
||||
final Future<dynamic> response = await webClient.post(
|
||||
auth.url + '/email_invoice?invoice_id=${invoice.id}', company.token, null);
|
||||
|
||||
InvoiceItemResponse invoiceResponse = serializers.deserializeWith(
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class PaymentsRepository {
|
|||
|
||||
Future<BuiltList<PaymentEntity>> loadList(CompanyEntity company, AuthState auth) async {
|
||||
|
||||
final response = await webClient.get(
|
||||
final Future<dynamic> response = await webClient.get(
|
||||
auth.url + '/payments?per_page=500', company.token);
|
||||
|
||||
PaymentListResponse paymentResponse = serializers.deserializeWith(
|
||||
|
|
@ -29,7 +29,7 @@ class PaymentsRepository {
|
|||
Future saveData(CompanyEntity company, AuthState auth, PaymentEntity payment, [EntityAction action]) async {
|
||||
|
||||
var data = serializers.serializeWith(PaymentEntity.serializer, payment);
|
||||
var response;
|
||||
Future<dynamic> response;
|
||||
|
||||
if (payment.isNew) {
|
||||
response = await webClient.post(
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class ProductRepository {
|
|||
|
||||
Future<BuiltList<ProductEntity>> loadList(CompanyEntity company, AuthState auth) async {
|
||||
|
||||
final response = await webClient.get(
|
||||
final Future<dynamic> response = await webClient.get(
|
||||
auth.url + '/products', company.token);
|
||||
|
||||
ProductListResponse productResponse = serializers.deserializeWith(
|
||||
|
|
@ -29,7 +29,7 @@ class ProductRepository {
|
|||
Future saveData(CompanyEntity company, AuthState auth, ProductEntity product, [EntityAction action]) async {
|
||||
|
||||
var data = serializers.serializeWith(ProductEntity.serializer, product);
|
||||
var response;
|
||||
Future<dynamic> response;
|
||||
|
||||
if (product.isNew) {
|
||||
response = await webClient.post(
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class ProjectsRepository {
|
|||
|
||||
Future<BuiltList<ProjectEntity>> loadList(CompanyEntity company, AuthState auth) async {
|
||||
|
||||
final response = await webClient.get(
|
||||
final Future<dynamic> response = await webClient.get(
|
||||
auth.url + '/projects?per_page=500', company.token);
|
||||
|
||||
ProjectListResponse projectResponse = serializers.deserializeWith(
|
||||
|
|
@ -29,7 +29,7 @@ class ProjectsRepository {
|
|||
Future saveData(CompanyEntity company, AuthState auth, ProjectEntity project, [EntityAction action]) async {
|
||||
|
||||
var data = serializers.serializeWith(ProjectEntity.serializer, project);
|
||||
var response;
|
||||
Future<dynamic> response;
|
||||
|
||||
if (project.isNew) {
|
||||
response = await webClient.post(
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class StaticRepository {
|
|||
|
||||
Future<StaticDataEntity> loadList(CompanyEntity company, AuthState auth) async {
|
||||
|
||||
final response = await webClient.get(
|
||||
final Future<dynamic> response = await webClient.get(
|
||||
auth.url + '/static', company.token);
|
||||
|
||||
StaticDataItemResponse staticDataResponse = serializers.deserializeWith(
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class TasksRepository {
|
|||
|
||||
Future<BuiltList<TaskEntity>> loadList(CompanyEntity company, AuthState auth) async {
|
||||
|
||||
final response = await webClient.get(
|
||||
final Future<dynamic> response = await webClient.get(
|
||||
auth.url + '/tasks?per_page=500', company.token);
|
||||
|
||||
TaskListResponse taskResponse = serializers.deserializeWith(
|
||||
|
|
@ -29,7 +29,7 @@ class TasksRepository {
|
|||
Future saveData(CompanyEntity company, AuthState auth, TaskEntity task, [EntityAction action]) async {
|
||||
|
||||
var data = serializers.serializeWith(TaskEntity.serializer, task);
|
||||
var response;
|
||||
Future<dynamic> response;
|
||||
|
||||
if (task.isNew) {
|
||||
response = await webClient.post(
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class VendorRepository {
|
|||
|
||||
Future<BuiltList<VendorEntity>> loadList(CompanyEntity company, AuthState auth) async {
|
||||
|
||||
final response = await webClient.get(
|
||||
final Future<dynamic> response = await webClient.get(
|
||||
auth.url + '/vendors?per_page=500', company.token);
|
||||
|
||||
VendorListResponse vendorResponse = serializers.deserializeWith(
|
||||
|
|
@ -29,7 +29,7 @@ class VendorRepository {
|
|||
Future saveData(CompanyEntity company, AuthState auth, VendorEntity vendor, [EntityAction action]) async {
|
||||
|
||||
var data = serializers.serializeWith(VendorEntity.serializer, vendor);
|
||||
var response;
|
||||
Future<dynamic> response;
|
||||
|
||||
if (vendor.isNew) {
|
||||
response = await webClient.post(
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class WebClient {
|
|||
throw _parseError(response.body);
|
||||
}
|
||||
|
||||
final jsonResponse = json.decode(response.body);
|
||||
final dynamic jsonResponse = json.decode(response.body);
|
||||
|
||||
//print(jsonResponse);
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ class WebClient {
|
|||
}
|
||||
|
||||
try {
|
||||
final jsonResponse = json.decode(response.body);
|
||||
final dynamic jsonResponse = json.decode(response.body);
|
||||
return jsonResponse;
|
||||
} catch (exception) {
|
||||
print(response.body);
|
||||
|
|
@ -82,7 +82,7 @@ class WebClient {
|
|||
}
|
||||
|
||||
try {
|
||||
final jsonResponse = json.decode(response.body);
|
||||
final dynamic jsonResponse = json.decode(response.body);
|
||||
return jsonResponse;
|
||||
} catch (exception) {
|
||||
print(response.body);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ void main() {
|
|||
..addAll(createStoreInvoicesMiddleware())
|
||||
..addAll(createStorePersistenceMiddleware())
|
||||
..addAll([
|
||||
LoggingMiddleware.printer(),
|
||||
LoggingMiddleware<dynamic>.printer(),
|
||||
]));
|
||||
|
||||
runApp(InvoiceNinjaApp(store: store));
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class _AppBottomBarState extends State<AppBottomBar> {
|
|||
return;
|
||||
}
|
||||
|
||||
_filterController = Scaffold.of(context).showBottomSheet((context) {
|
||||
_filterController = Scaffold.of(context).showBottomSheet<StoreConnector>((context) {
|
||||
return StoreConnector<AppState, BuiltList<EntityState>>(
|
||||
//distinct: true,
|
||||
converter: (Store<AppState> store) => store.state.getListState(widget.entityType).stateFilters,
|
||||
|
|
@ -95,7 +95,7 @@ class _AppBottomBarState extends State<AppBottomBar> {
|
|||
return;
|
||||
}
|
||||
|
||||
_sortController = Scaffold.of(context).showBottomSheet((context) {
|
||||
_sortController = Scaffold.of(context).showBottomSheet<StoreConnector>((context) {
|
||||
return StoreConnector<AppState, ListUIState>(
|
||||
//distinct: true,
|
||||
converter: (Store<AppState> store) => store.state.getListState(widget.entityType),
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ class _EntityDropdownState extends State<EntityDropdown> {
|
|||
}).toList());
|
||||
}
|
||||
|
||||
showDialog(
|
||||
showDialog<Padding>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return Padding(
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class DatePicker extends StatefulWidget {
|
|||
@required this.labelText,
|
||||
@required this.onSelected,
|
||||
@required this.selectedDate,
|
||||
@required this.validator,
|
||||
this.validator,
|
||||
});
|
||||
|
||||
final String labelText;
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
|
|||
var localization = AppLocalization.of(context);
|
||||
|
||||
_confirmDelete() {
|
||||
showDialog(
|
||||
showDialog<AlertDialog>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
semanticLabel: localization.areYouSure,
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class ClientEditVM {
|
|||
Navigator.of(context).pop();
|
||||
Navigator
|
||||
.of(context)
|
||||
.push(MaterialPageRoute(builder: (_) => ClientViewScreen()));
|
||||
.push<ClientViewScreen>(MaterialPageRoute(builder: (_) => ClientViewScreen()));
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class _ClientViewState extends State<ClientView>
|
|||
floatingActionButton: FloatingActionButton(
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
showDialog<SimpleDialog>(
|
||||
context: context,
|
||||
builder: (BuildContext context) =>
|
||||
SimpleDialog(children: <Widget>[
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ class ItemEditDetailsState extends State<ItemEditDetails> with AutomaticKeepAliv
|
|||
var localization = AppLocalization.of(context);
|
||||
|
||||
_confirmDelete() {
|
||||
showDialog(
|
||||
showDialog<AlertDialog>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
semanticLabel: localization.areYouSure,
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class InvoiceEditVM {
|
|||
Navigator.of(context).pop();
|
||||
Navigator
|
||||
.of(context)
|
||||
.push(MaterialPageRoute(builder: (_) => InvoiceViewScreen()));
|
||||
.push<InvoiceViewScreen>(MaterialPageRoute(builder: (_) => InvoiceViewScreen()));
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ class InvoiceViewVM {
|
|||
|
||||
Future<Null> _viewPdf(BuildContext context) async {
|
||||
var localization = AppLocalization.of(context);
|
||||
var url;
|
||||
var useWebView;
|
||||
String url;
|
||||
bool useWebView;
|
||||
|
||||
if (Theme.of(context).platform == TargetPlatform.iOS) {
|
||||
url = invoice.invitationSilentLink;
|
||||
|
|
@ -96,7 +96,7 @@ class InvoiceViewVM {
|
|||
},
|
||||
onActionSelected: (BuildContext context, EntityAction action) {
|
||||
final Completer<Null> completer = new Completer<Null>();
|
||||
var message;
|
||||
String message;
|
||||
switch (action) {
|
||||
case EntityAction.pdf:
|
||||
_viewPdf(context);
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ String formatNumber(
|
|||
ClientEntity client = state.selectedCompanyState.clientState.map[clientId];
|
||||
|
||||
//var countryId = client?.countryId ?? company.countryId;
|
||||
var currencyId;
|
||||
var countryId = client?.countryId ?? 1;
|
||||
int currencyId;
|
||||
int countryId = client?.countryId ?? 1;
|
||||
|
||||
if (client != null && client.currencyId > 0) {
|
||||
currencyId = client.currencyId;
|
||||
|
|
@ -73,7 +73,7 @@ String formatNumber(
|
|||
MINUS_SIGN: '-',
|
||||
);
|
||||
|
||||
var formatter;
|
||||
NumberFormat formatter;
|
||||
String formatted;
|
||||
|
||||
if (formatNumberType == FormatNumberType.int) {
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ AppState reducer(AppState state, dynamic action) {
|
|||
void main() {
|
||||
final store =
|
||||
Store<AppState>(reducer, initialState: AppState.init(), middleware: [
|
||||
LoggingMiddleware.printer(),
|
||||
LoggingMiddleware<dynamic>.printer(),
|
||||
]);
|
||||
|
||||
runApp(MyApp(store: store));
|
||||
|
|
|
|||
Loading…
Reference in New Issue