Skip to content

Commit

Permalink
Merge pull request #1814 from EnsembleUI/closeApp-action
Browse files Browse the repository at this point in the history
added closeApp action
  • Loading branch information
mehsaandev authored Jan 7, 2025
2 parents d6a7f4c + 3349522 commit efa3fa9
Show file tree
Hide file tree
Showing 3 changed files with 30 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 @@ -41,6 +41,7 @@ abstract class ActionInvokable with Invokable {
ActionType.executeActionGroup,
ActionType.saveFile,
ActionType.controlDeviceBackNavigation,
ActionType.closeApp,
]);
}

Expand Down
24 changes: 24 additions & 0 deletions modules/ensemble/lib/action/close_app.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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,
);
}

@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 @@ -23,6 +23,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 @@ -1056,8 +1057,9 @@ enum ActionType {
bluetoothDisconnect,
bluetoothSubscribeCharacteristic,
bluetoothUnsubscribeCharacteristic,
controlDeviceBackNavigation,
closeApp
saveFile
controlDeviceBackNavigation
}

/// payload representing an Action to do (navigateToScreen, InvokeAPI, ..)
Expand Down Expand Up @@ -1185,6 +1187,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 efa3fa9

Please sign in to comment.