diff --git a/modules/ensemble/lib/action/action_invokable.dart b/modules/ensemble/lib/action/action_invokable.dart index c35b99426..e1e47ea33 100644 --- a/modules/ensemble/lib/action/action_invokable.dart +++ b/modules/ensemble/lib/action/action_invokable.dart @@ -40,6 +40,7 @@ abstract class ActionInvokable with Invokable { ActionType.closeAllDialogs, ActionType.executeActionGroup, ActionType.controlDeviceBackNavigation, + ActionType.closeApp, ]); } diff --git a/modules/ensemble/lib/action/close_app.dart b/modules/ensemble/lib/action/close_app.dart new file mode 100644 index 000000000..02981ad22 --- /dev/null +++ b/modules/ensemble/lib/action/close_app.dart @@ -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); + } +} diff --git a/modules/ensemble/lib/framework/action.dart b/modules/ensemble/lib/framework/action.dart index b2ec78a88..bd2baf7d2 100644 --- a/modules/ensemble/lib/framework/action.dart +++ b/modules/ensemble/lib/framework/action.dart @@ -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'; @@ -1055,7 +1056,8 @@ enum ActionType { bluetoothDisconnect, bluetoothSubscribeCharacteristic, bluetoothUnsubscribeCharacteristic, - controlDeviceBackNavigation + controlDeviceBackNavigation, + closeApp } /// payload representing an Action to do (navigateToScreen, InvokeAPI, ..) @@ -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) {