Archiving/deleting on mobile should pop the screen
This commit is contained in:
parent
5c3fd1f716
commit
09aa054c63
|
|
@ -971,16 +971,23 @@ void editEntity(
|
|||
completer: completer);
|
||||
|
||||
void handleEntityAction(
|
||||
BuildContext context, BaseEntity entity, dynamic action) {
|
||||
handleEntitiesActions(context, [entity], action);
|
||||
BuildContext context, BaseEntity entity, EntityAction action, {bool autoPop = false}) {
|
||||
handleEntitiesActions(context, [entity], action, autoPop: autoPop);
|
||||
}
|
||||
|
||||
void handleEntitiesActions(
|
||||
BuildContext context, List<BaseEntity> entities, dynamic action) {
|
||||
BuildContext context, List<BaseEntity> entities, EntityAction action,
|
||||
{bool autoPop = false}) {
|
||||
if (entities.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ([EntityAction.archive, EntityAction.delete].contains(action) &&
|
||||
autoPop &&
|
||||
isMobile(context)) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
switch (entities.first.entityType) {
|
||||
case EntityType.client:
|
||||
handleClientAction(context, entities, action);
|
||||
|
|
|
|||
|
|
@ -96,8 +96,9 @@ class ViewScaffold extends StatelessWidget {
|
|||
ViewActionMenuButton(
|
||||
isSaving: state.isSaving,
|
||||
entity: entity,
|
||||
onSelected: (context, action) =>
|
||||
handleEntityAction(context, entity, action),
|
||||
onSelected: (context, action) => handleEntityAction(
|
||||
context, entity, action,
|
||||
autoPop: true),
|
||||
entityActions: entity.getActions(
|
||||
userCompany: userCompany,
|
||||
client: entity is BelongsToClient
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ class ClientViewVM {
|
|||
}
|
||||
},
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handleClientAction(context, [client], action),
|
||||
handleEntitiesActions(context, [client], action, autoPop: true),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
|||
import 'package:invoiceninja_flutter/constants.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
||||
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||
import 'package:invoiceninja_flutter/ui/company_gateway/company_gateway_screen.dart';
|
||||
|
|
@ -78,7 +79,7 @@ class CompanyGatewayViewVM {
|
|||
store.dispatch(UpdateCurrentRoute(CompanyGatewayScreen.route));
|
||||
},
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handleCompanyGatewayAction(context, [companyGateway], action),
|
||||
handleEntitiesActions(context, [companyGateway], action, autoPop: true),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ class CreditViewVM extends EntityViewVM {
|
|||
},
|
||||
onRefreshed: (context) => _handleRefresh(context),
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handleCreditAction(context, [credit], action),
|
||||
handleEntitiesActions(context, [credit], action, autoPop: true),
|
||||
onUploadDocument: (BuildContext context, String filePath) {
|
||||
final Completer<DocumentEntity> completer = Completer<DocumentEntity>();
|
||||
store.dispatch(SaveCreditDocumentRequest(
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
|||
import 'package:invoiceninja_flutter/constants.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
||||
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||
import 'package:invoiceninja_flutter/ui/design/design_screen.dart';
|
||||
|
|
@ -76,7 +77,7 @@ class DesignViewVM {
|
|||
},
|
||||
onRefreshed: (context) => _handleRefresh(context),
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handleDesignAction(context, [design], action),
|
||||
handleEntitiesActions(context, [design], action, autoPop: true),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/document_model.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/document/document_actions.dart';
|
||||
import 'package:invoiceninja_flutter/ui/document/view/document_view.dart';
|
||||
|
|
@ -72,7 +73,7 @@ class DocumentViewVM {
|
|||
document: document,
|
||||
onRefreshed: (context) => _handleRefresh(context),
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handleDocumentAction(context, [document], action),
|
||||
handleEntitiesActions(context, [document], action, autoPop: true),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ class ExpenseViewVM {
|
|||
}
|
||||
},
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handleExpenseAction(context, [expense], action),
|
||||
handleEntitiesActions(context, [expense], action, autoPop: true),
|
||||
onUploadDocument: (BuildContext context, String filePath) {
|
||||
final Completer<DocumentEntity> completer =
|
||||
Completer<DocumentEntity>();
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class GroupViewVM {
|
|||
store.dispatch(UpdateCurrentRoute(GroupSettingsScreen.route));
|
||||
},
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handleGroupAction(context, [group], action),
|
||||
handleEntitiesActions(context, [group], action, autoPop: true),
|
||||
onClientsPressed: (context, [longPress = false]) {
|
||||
if (longPress) {
|
||||
handleGroupAction(context, [group], EntityAction.newClient);
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ class InvoiceViewVM extends EntityViewVM {
|
|||
filterEntity: invoice);
|
||||
},
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handleInvoiceAction(context, [invoice], action),
|
||||
handleEntitiesActions(context, [invoice], action, autoPop: true),
|
||||
onUploadDocument: (BuildContext context, String filePath) {
|
||||
final Completer<DocumentEntity> completer = Completer<DocumentEntity>();
|
||||
store.dispatch(SaveInvoiceDocumentRequest(
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/payment_model.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/payment/payment_actions.dart';
|
||||
import 'package:invoiceninja_flutter/ui/payment/view/payment_view.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ class PaymentViewVM {
|
|||
isLoading: state.isLoading,
|
||||
payment: payment,
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handlePaymentAction(context, [payment], action),
|
||||
handleEntitiesActions(context, [payment], action, autoPop: true),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'package:invoiceninja_flutter/constants.dart';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/payment_term_model.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/payment_term/payment_term_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
||||
import 'package:invoiceninja_flutter/ui/payment_term/payment_term_screen.dart';
|
||||
|
|
@ -76,7 +77,7 @@ class PaymentTermViewVM {
|
|||
store.dispatch(UpdateCurrentRoute(PaymentTermScreen.route));
|
||||
},
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handlePaymentTermAction(context, [paymentTerm], action),
|
||||
handleEntitiesActions(context, [paymentTerm], action, autoPop: true),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/product/product_actions.dart';
|
||||
import 'package:invoiceninja_flutter/ui/product/view/product_view.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ class ProductViewVM {
|
|||
_handleRefresh(context),
|
||||
*/
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handleProductAction(context, [product], action),
|
||||
handleEntitiesActions(context, [product], action, autoPop: true),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class ProjectViewVM {
|
|||
force: true);
|
||||
},
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handleProjectAction(context, [project], action),
|
||||
handleEntitiesActions(context, [project], action, autoPop: true),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ class QuoteViewVM extends EntityViewVM {
|
|||
},
|
||||
onRefreshed: (context) => _handleRefresh(context),
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handleQuoteAction(context, [quote], action),
|
||||
handleEntitiesActions(context, [quote], action, autoPop: true),
|
||||
onUploadDocument: (BuildContext context, String filePath) {
|
||||
final Completer<DocumentEntity> completer = Completer<DocumentEntity>();
|
||||
store.dispatch(SaveQuoteDocumentRequest(
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ class TaskViewVM {
|
|||
},
|
||||
onRefreshed: (context) => _handleRefresh(context),
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handleTaskAction(context, [task], action),
|
||||
handleEntitiesActions(context, [task], action, autoPop: true),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
|||
import 'package:invoiceninja_flutter/constants.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
||||
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||
import 'package:invoiceninja_flutter/ui/tax_rate/tax_rate_screen.dart';
|
||||
|
|
@ -75,7 +76,7 @@ class TaxRateViewVM {
|
|||
store.dispatch(UpdateCurrentRoute(TaxRateSettingsScreen.route));
|
||||
},
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handleTaxRateAction(context, [taxRate], action),
|
||||
handleEntitiesActions(context, [taxRate], action, autoPop: true),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class UserViewVM {
|
|||
store.dispatch(UpdateCurrentRoute(UserScreen.route));
|
||||
},
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handleUserAction(context, [user], action),
|
||||
handleEntitiesActions(context, [user], action, autoPop: true),
|
||||
onEntityPressed: (BuildContext context, EntityType entityType,
|
||||
[longPress = false]) {
|
||||
switch (entityType) {
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class VendorViewVM {
|
|||
entity: ExpenseEntity(state: state, vendor: vendor));
|
||||
},
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handleVendorAction(context, [vendor], action),
|
||||
handleEntitiesActions(context, [vendor], action, autoPop: true),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class StubViewVM {
|
|||
stub: stub,
|
||||
onRefreshed: (context) => _handleRefresh(context),
|
||||
onEntityAction: (BuildContext context, EntityAction action) =>
|
||||
handleStubAction(context, [stub], action),
|
||||
handleEntitiesActions(context, [stub], action, autoPop: true),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue