Skip to content

Commit

Permalink
added closeApp action
Browse files Browse the repository at this point in the history
  • Loading branch information
mehsaandev committed Jan 3, 2025
1 parent 1b4b85d commit 98ca461
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/ensemble/lib/action/action_invokable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ abstract class ActionInvokable with Invokable {
ActionType.closeAllDialogs,
ActionType.executeActionGroup,
ActionType.controlDeviceBackNavigation,
ActionType.closeApp,
]);
}

Expand Down
27 changes: 27 additions & 0 deletions modules/ensemble/lib/action/close_app.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:ensemble/framework/action.dart';
import 'package:ensemble/framework/scope.dart';
import 'package:ensemble/util/utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:ensemble_ts_interpreter/invokables/invokable.dart';

class CloseAppAction extends EnsembleAction {
CloseAppAction({
super.initiator,
});

factory CloseAppAction.from({Invokable? initiator, Map? payload}) {
return CloseAppAction(
initiator: initiator,
);
}

factory CloseAppAction.fromMap(dynamic inputs, {Map? payload}) =>
CloseAppAction.from(payload: Utils.getYamlMap(inputs));

@override
Future execute(BuildContext context, ScopeManager scopeManager) {
SystemNavigator.pop();
return Future.value(null);
}
}
6 changes: 5 additions & 1 deletion modules/ensemble/lib/framework/action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import 'package:ensemble/action/phone_contact_action.dart';
import 'package:ensemble/action/sign_in_out_action.dart';
import 'package:ensemble/action/toast_actions.dart';
import 'package:ensemble/action/disable_hardware_navigation.dart';
import 'package:ensemble/action/close_app.dart';
import 'package:ensemble/ensemble.dart';
import 'package:ensemble/framework/data_context.dart';
import 'package:ensemble/framework/error_handling.dart';
Expand Down Expand Up @@ -1055,7 +1056,8 @@ enum ActionType {
bluetoothDisconnect,
bluetoothSubscribeCharacteristic,
bluetoothUnsubscribeCharacteristic,
controlDeviceBackNavigation
controlDeviceBackNavigation,
closeApp
}

/// payload representing an Action to do (navigateToScreen, InvokeAPI, ..)
Expand Down Expand Up @@ -1181,6 +1183,8 @@ abstract class EnsembleAction {
return RateAppAction.from(payload: payload);
} else if (actionType == ActionType.getDeviceToken) {
return GetDeviceTokenAction.fromMap(payload: payload);
} else if (actionType == ActionType.closeApp) {
return CloseAppAction();
} else if (actionType == ActionType.openPlaidLink) {
return PlaidLinkAction.fromYaml(initiator: initiator, payload: payload);
} else if (actionType == ActionType.openAppSettings) {
Expand Down

0 comments on commit 98ca461

Please sign in to comment.