From 12edb73b59326ceded9ace663bec4088f9be2901 Mon Sep 17 00:00:00 2001 From: Nehal Jaisalmeria Date: Mon, 4 Dec 2023 21:45:58 +0530 Subject: [PATCH 01/10] 971-actions-in-js --- lib/framework/action.dart | 12 ++++++++++++ lib/framework/data_context.dart | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/framework/action.dart b/lib/framework/action.dart index f51235012..10ac2f786 100644 --- a/lib/framework/action.dart +++ b/lib/framework/action.dart @@ -67,6 +67,18 @@ class ShowDialogAction extends EnsembleAction { final Map? options; final EnsembleAction? onDialogDismiss; + factory ShowDialogAction.from({Invokable? initiator, Map? payload}) { + if (payload == null || payload['widget'] == null) { + throw LanguageError( + "${ActionType.showDialog.name} requires the 'widget' for the Dialog's content."); + } + return ShowDialogAction( + initiator: initiator, + widget: payload['widget'], + options: Utils.getMap(payload['options']), + onDialogDismiss: EnsembleAction.fromYaml(payload['onDialogDismiss'])); + } + factory ShowDialogAction.fromYaml({Invokable? initiator, Map? payload}) { if (payload == null || payload['widget'] == null) { throw LanguageError( diff --git a/lib/framework/data_context.dart b/lib/framework/data_context.dart index 1a6eaf3c6..d43ae65c9 100644 --- a/lib/framework/data_context.dart +++ b/lib/framework/data_context.dart @@ -4,9 +4,11 @@ import 'dart:developer'; import 'dart:io' as io; import 'dart:ui'; import 'package:ensemble/action/action_invokable.dart'; +import 'package:ensemble/action/bottom_modal_action.dart'; import 'package:ensemble/action/call_external_method.dart'; import 'package:ensemble/action/haptic_action.dart'; import 'package:ensemble/action/invoke_api_action.dart'; +import 'package:ensemble/action/misc_action.dart'; import 'package:ensemble/action/navigation_action.dart'; import 'package:ensemble/ensemble.dart'; import 'package:ensemble/ensemble_app.dart'; @@ -365,6 +367,16 @@ class NativeInvokable extends ActionInvokable { final scope = ScreenController().getScopeManager(buildContext); callNativeMethod(buildContext, scope, inputs); }, + ActionType.showBottomModal.name: (inputs) => ScreenController() + .executeAction( + buildContext, ShowBottomModalAction.from(payload: inputs)), + ActionType.dismissBottomModal.name: (inputs) => ScreenController() + .executeAction( + buildContext, DismissBottomModalAction.from(payload: inputs)), + ActionType.showDialog.name: (inputs) => ScreenController().executeAction( + buildContext, ShowDialogAction.from(payload: inputs)), + ActionType.rateApp.name: (inputs) => ScreenController() + .executeAction(buildContext, RateAppAction.from(payload: inputs)), 'connectSocket': (String socketName, Map? inputs) { connectSocket(buildContext, socketName, inputs: inputs); }, From e58d81db3121880601a5a63a4eaed284e46e5109 Mon Sep 17 00:00:00 2001 From: Nehal Jaisalmeria Date: Mon, 4 Dec 2023 22:11:55 +0530 Subject: [PATCH 02/10] fixed formatting --- lib/framework/data_context.dart | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/framework/data_context.dart b/lib/framework/data_context.dart index d43ae65c9..8cb063f08 100644 --- a/lib/framework/data_context.dart +++ b/lib/framework/data_context.dart @@ -1,19 +1,14 @@ import 'dart:async'; -import 'dart:convert'; import 'dart:developer'; import 'dart:io' as io; import 'dart:ui'; import 'package:ensemble/action/action_invokable.dart'; import 'package:ensemble/action/bottom_modal_action.dart'; -import 'package:ensemble/action/call_external_method.dart'; import 'package:ensemble/action/haptic_action.dart'; import 'package:ensemble/action/invoke_api_action.dart'; import 'package:ensemble/action/misc_action.dart'; import 'package:ensemble/action/navigation_action.dart'; -import 'package:ensemble/ensemble.dart'; -import 'package:ensemble/ensemble_app.dart'; import 'package:ensemble/framework/all_countries.dart'; -import 'package:ensemble/framework/bindings.dart'; import 'package:ensemble/framework/config.dart'; import 'package:ensemble/framework/device.dart'; import 'package:ensemble/framework/error_handling.dart'; @@ -367,14 +362,18 @@ class NativeInvokable extends ActionInvokable { final scope = ScreenController().getScopeManager(buildContext); callNativeMethod(buildContext, scope, inputs); }, - ActionType.showBottomModal.name: (inputs) => ScreenController() - .executeAction( - buildContext, ShowBottomModalAction.from(payload: inputs)), - ActionType.dismissBottomModal.name: (inputs) => ScreenController() - .executeAction( - buildContext, DismissBottomModalAction.from(payload: inputs)), - ActionType.showDialog.name: (inputs) => ScreenController().executeAction( - buildContext, ShowDialogAction.from(payload: inputs)), + ActionType.showBottomModal.name: (inputs) => + ScreenController().executeAction( + buildContext, + ShowBottomModalAction.from(payload: inputs), + ), + ActionType.dismissBottomModal.name: (inputs) => + ScreenController().executeAction( + buildContext, + DismissBottomModalAction.from(payload: inputs), + ), + ActionType.showDialog.name: (inputs) => ScreenController() + .executeAction(buildContext, ShowDialogAction.from(payload: inputs)), ActionType.rateApp.name: (inputs) => ScreenController() .executeAction(buildContext, RateAppAction.from(payload: inputs)), 'connectSocket': (String socketName, Map? inputs) { From e9824bdb7bd790fc252084811e2fd4bec11c349d Mon Sep 17 00:00:00 2001 From: Nehal Jaisalmeria Date: Mon, 4 Dec 2023 22:47:06 +0530 Subject: [PATCH 03/10] dismissModalBottom fixed --- lib/action/bottom_modal_action.dart | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lib/action/bottom_modal_action.dart b/lib/action/bottom_modal_action.dart index 72063baa6..fe8fc7753 100644 --- a/lib/action/bottom_modal_action.dart +++ b/lib/action/bottom_modal_action.dart @@ -1,5 +1,3 @@ -import 'dart:ui'; - import 'package:ensemble/framework/action.dart'; import 'package:ensemble/framework/data_context.dart'; import 'package:ensemble/framework/error_handling.dart'; @@ -9,9 +7,7 @@ import 'package:ensemble/framework/view/context_scope_widget.dart'; import 'package:ensemble/screen_controller.dart'; import 'package:ensemble/util/utils.dart'; import 'package:ensemble_ts_interpreter/invokables/invokable.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:yaml/yaml.dart'; /// open a Modal Bottom Sheet class ShowBottomModalAction extends EnsembleAction { @@ -100,12 +96,6 @@ class DismissBottomModalAction extends EnsembleAction { @override Future execute(BuildContext context, ScopeManager scopeManager, {DataContext? dataContext}) { - BuildContext? bottomModalContext = - ContextScopeWidget.getRootContext(context); - if (bottomModalContext != null) { - return Navigator.maybePop( - bottomModalContext, scopeManager.dataContext.eval(payload)); - } - return Future.value(null); + return Navigator.maybePop(context, scopeManager.dataContext.eval(payload)); } } From 2521ba0ea5f7c11b44b9d95a39b694da7b3cd5c6 Mon Sep 17 00:00:00 2001 From: Nehal Jaisalmeria Date: Mon, 4 Dec 2023 23:18:48 +0530 Subject: [PATCH 04/10] renaming fromYaml in ShowDialogAction --- lib/framework/action.dart | 15 +-------------- lib/framework/data_context.dart | 2 +- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/lib/framework/action.dart b/lib/framework/action.dart index 10ac2f786..b4152c93a 100644 --- a/lib/framework/action.dart +++ b/lib/framework/action.dart @@ -15,7 +15,6 @@ import 'package:ensemble/framework/extensions.dart'; import 'package:ensemble/framework/keychain_manager.dart'; import 'package:ensemble/framework/permissions_manager.dart'; import 'package:ensemble/framework/scope.dart'; -import 'package:ensemble/framework/view/bottom_nav_page_group.dart'; import 'package:ensemble/framework/view/page_group.dart'; import 'package:ensemble/framework/widget/view_util.dart'; import 'package:ensemble/receive_intent_manager.dart'; @@ -68,18 +67,6 @@ class ShowDialogAction extends EnsembleAction { final EnsembleAction? onDialogDismiss; factory ShowDialogAction.from({Invokable? initiator, Map? payload}) { - if (payload == null || payload['widget'] == null) { - throw LanguageError( - "${ActionType.showDialog.name} requires the 'widget' for the Dialog's content."); - } - return ShowDialogAction( - initiator: initiator, - widget: payload['widget'], - options: Utils.getMap(payload['options']), - onDialogDismiss: EnsembleAction.fromYaml(payload['onDialogDismiss'])); - } - - factory ShowDialogAction.fromYaml({Invokable? initiator, Map? payload}) { if (payload == null || payload['widget'] == null) { throw LanguageError( "${ActionType.showDialog.name} requires the 'widget' for the Dialog's content."); @@ -1018,7 +1005,7 @@ abstract class EnsembleAction { } else if (actionType == ActionType.openCamera) { return ShowCameraAction.fromYaml(initiator: initiator, payload: payload); } else if (actionType == ActionType.showDialog) { - return ShowDialogAction.fromYaml(initiator: initiator, payload: payload); + return ShowDialogAction.from(initiator: initiator, payload: payload); } else if (actionType == ActionType.closeAllDialogs) { return CloseAllDialogsAction(); } else if (actionType == ActionType.startTimer) { diff --git a/lib/framework/data_context.dart b/lib/framework/data_context.dart index 8cb063f08..21d80cd69 100644 --- a/lib/framework/data_context.dart +++ b/lib/framework/data_context.dart @@ -370,7 +370,7 @@ class NativeInvokable extends ActionInvokable { ActionType.dismissBottomModal.name: (inputs) => ScreenController().executeAction( buildContext, - DismissBottomModalAction.from(payload: inputs), + DismissBottomModalAction.from(), ), ActionType.showDialog.name: (inputs) => ScreenController() .executeAction(buildContext, ShowDialogAction.from(payload: inputs)), From bdbf5f5e55c7c1c86621386ca7a7e83816324c4b Mon Sep 17 00:00:00 2001 From: Nehal Jaisalmeria Date: Mon, 4 Dec 2023 23:22:38 +0530 Subject: [PATCH 05/10] adding actions to ActionsInvokable --- lib/action/action_invokable.dart | 5 ++++- lib/framework/data_context.dart | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/action/action_invokable.dart b/lib/action/action_invokable.dart index 8b1f95367..173afc56a 100644 --- a/lib/action/action_invokable.dart +++ b/lib/action/action_invokable.dart @@ -1,4 +1,3 @@ -import 'package:ensemble/action/call_external_method.dart'; import 'package:ensemble/framework/action.dart'; import 'package:ensemble/framework/error_handling.dart'; import 'package:ensemble/framework/scope.dart'; @@ -22,6 +21,10 @@ abstract class ActionInvokable with Invokable { ActionType.copyToClipboard, ActionType.getDeviceToken, ActionType.getPhoneContacts, + ActionType.showBottomModal, + ActionType.dismissBottomModal, + ActionType.showDialog, + ActionType.rateApp ]); } diff --git a/lib/framework/data_context.dart b/lib/framework/data_context.dart index 21d80cd69..8cb063f08 100644 --- a/lib/framework/data_context.dart +++ b/lib/framework/data_context.dart @@ -370,7 +370,7 @@ class NativeInvokable extends ActionInvokable { ActionType.dismissBottomModal.name: (inputs) => ScreenController().executeAction( buildContext, - DismissBottomModalAction.from(), + DismissBottomModalAction.from(payload: inputs), ), ActionType.showDialog.name: (inputs) => ScreenController() .executeAction(buildContext, ShowDialogAction.from(payload: inputs)), From 9503dd0e4dbd0c39b4ad8ab6fd026bf2d0483296 Mon Sep 17 00:00:00 2001 From: Nehal Jaisalmeria Date: Wed, 6 Dec 2023 20:51:28 +0530 Subject: [PATCH 06/10] code review changes --- .android/gradle.properties | 2 +- .ios/Podfile | 2 -- .ios/Runner/AppDelegate.m | 2 -- lib/action/bottom_modal_action.dart | 8 +++++++- lib/framework/action.dart | 13 ++++++++----- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.android/gradle.properties b/.android/gradle.properties index 94adc3a3f..598d13fee 100644 --- a/.android/gradle.properties +++ b/.android/gradle.properties @@ -1,3 +1,3 @@ -org.gradle.jvmargs=-Xmx1536M +org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true diff --git a/.ios/Podfile b/.ios/Podfile index 55ea59749..08805d6c7 100644 --- a/.ios/Podfile +++ b/.ios/Podfile @@ -2,7 +2,6 @@ platform :ios, '11.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' -ENV['SWIFT_VERSION'] = '5' project 'Runner', { 'Debug' => :debug, @@ -32,7 +31,6 @@ target 'Runner' do flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) pod 'FlutterPluginRegistrant', :path => File.join('Flutter', 'FlutterPluginRegistrant'), :inhibit_warnings => true - pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '10.10.0' end post_install do |installer| diff --git a/.ios/Runner/AppDelegate.m b/.ios/Runner/AppDelegate.m index 3f7960023..7644d81dc 100644 --- a/.ios/Runner/AppDelegate.m +++ b/.ios/Runner/AppDelegate.m @@ -1,12 +1,10 @@ #import "AppDelegate.h" #import "FlutterPluginRegistrant/GeneratedPluginRegistrant.h" -#import "GoogleMaps/GoogleMaps.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - [GMSServices provideAPIKey:@"AIzaSyD8vwvoaEPEgYemp1EkIETetJMvyS4Ptqk"]; [GeneratedPluginRegistrant registerWithRegistry:self]; return [super application:application didFinishLaunchingWithOptions:launchOptions]; } diff --git a/lib/action/bottom_modal_action.dart b/lib/action/bottom_modal_action.dart index fe8fc7753..e460fd742 100644 --- a/lib/action/bottom_modal_action.dart +++ b/lib/action/bottom_modal_action.dart @@ -71,7 +71,7 @@ class ShowBottomModalAction extends EnsembleAction { enableDrag: _enableDrag(scopeManager), showDragHandle: _enableDragHandler(scopeManager), builder: (modalContext) => - ContextScopeWidget(rootContext: modalContext, child: widget!)) + ContextScopeWidget(rootContext: context, child: widget!)) .then((payload) { if (onDismiss != null) { return ScreenController().executeActionWithScope( @@ -96,6 +96,12 @@ class DismissBottomModalAction extends EnsembleAction { @override Future execute(BuildContext context, ScopeManager scopeManager, {DataContext? dataContext}) { + BuildContext? bottomModalContext = + ContextScopeWidget.getRootContext(context); + if (bottomModalContext != null) { + return Navigator.maybePop( + bottomModalContext, scopeManager.dataContext.eval(payload)); + } return Navigator.maybePop(context, scopeManager.dataContext.eval(payload)); } } diff --git a/lib/framework/action.dart b/lib/framework/action.dart index b4152c93a..e2a813c6d 100644 --- a/lib/framework/action.dart +++ b/lib/framework/action.dart @@ -72,11 +72,14 @@ class ShowDialogAction extends EnsembleAction { "${ActionType.showDialog.name} requires the 'widget' for the Dialog's content."); } return ShowDialogAction( - initiator: initiator, - widget: payload['widget'], - //inputs: Utils.getMap(payload["inputs"]), - options: Utils.getMap(payload['options']), - onDialogDismiss: EnsembleAction.fromYaml(payload['onDialogDismiss'])); + initiator: initiator, + widget: payload['widget'], + //inputs: Utils.getMap(payload["inputs"]), + options: Utils.getMap(payload['options']), + onDialogDismiss: payload['onDialogDismiss'] == null + ? null + : EnsembleAction.fromYaml(payload['onDialogDismiss']), + ); } } From d53cf0d3ef4d98e6be1109ece3e9d39422e58776 Mon Sep 17 00:00:00 2001 From: Nehal Jaisalmeria Date: Thu, 7 Dec 2023 00:45:24 +0530 Subject: [PATCH 07/10] undo-changes --- .android/gradle.properties | 2 +- .ios/Podfile | 2 ++ .ios/Runner/AppDelegate.m | 1 + lib/action/bottom_modal_action.dart | 4 ++-- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.android/gradle.properties b/.android/gradle.properties index 598d13fee..94adc3a3f 100644 --- a/.android/gradle.properties +++ b/.android/gradle.properties @@ -1,3 +1,3 @@ -org.gradle.jvmargs=-Xmx4G +org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true diff --git a/.ios/Podfile b/.ios/Podfile index 08805d6c7..55ea59749 100644 --- a/.ios/Podfile +++ b/.ios/Podfile @@ -2,6 +2,7 @@ platform :ios, '11.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' +ENV['SWIFT_VERSION'] = '5' project 'Runner', { 'Debug' => :debug, @@ -31,6 +32,7 @@ target 'Runner' do flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) pod 'FlutterPluginRegistrant', :path => File.join('Flutter', 'FlutterPluginRegistrant'), :inhibit_warnings => true + pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '10.10.0' end post_install do |installer| diff --git a/.ios/Runner/AppDelegate.m b/.ios/Runner/AppDelegate.m index 7644d81dc..c6cc0d83f 100644 --- a/.ios/Runner/AppDelegate.m +++ b/.ios/Runner/AppDelegate.m @@ -5,6 +5,7 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [GMSServices provideAPIKey:@"AIzaSyD8vwvoaEPEgYemp1EkIETetJMvyS4Ptqk"]; [GeneratedPluginRegistrant registerWithRegistry:self]; return [super application:application didFinishLaunchingWithOptions:launchOptions]; } diff --git a/lib/action/bottom_modal_action.dart b/lib/action/bottom_modal_action.dart index e460fd742..5e1eb375b 100644 --- a/lib/action/bottom_modal_action.dart +++ b/lib/action/bottom_modal_action.dart @@ -71,7 +71,7 @@ class ShowBottomModalAction extends EnsembleAction { enableDrag: _enableDrag(scopeManager), showDragHandle: _enableDragHandler(scopeManager), builder: (modalContext) => - ContextScopeWidget(rootContext: context, child: widget!)) + ContextScopeWidget(rootContext: modalContext, child: widget!)) .then((payload) { if (onDismiss != null) { return ScreenController().executeActionWithScope( @@ -102,6 +102,6 @@ class DismissBottomModalAction extends EnsembleAction { return Navigator.maybePop( bottomModalContext, scopeManager.dataContext.eval(payload)); } - return Navigator.maybePop(context, scopeManager.dataContext.eval(payload)); + return Future.value(null); } } From a1e3fb85df0f3c5172490a244e9c7586d9f0d4c5 Mon Sep 17 00:00:00 2001 From: Nehal Jaisalmeria Date: Thu, 7 Dec 2023 00:46:55 +0530 Subject: [PATCH 08/10] fixing changes --- .ios/Runner/AppDelegate.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.ios/Runner/AppDelegate.m b/.ios/Runner/AppDelegate.m index c6cc0d83f..3f7960023 100644 --- a/.ios/Runner/AppDelegate.m +++ b/.ios/Runner/AppDelegate.m @@ -1,11 +1,12 @@ #import "AppDelegate.h" #import "FlutterPluginRegistrant/GeneratedPluginRegistrant.h" +#import "GoogleMaps/GoogleMaps.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - [GMSServices provideAPIKey:@"AIzaSyD8vwvoaEPEgYemp1EkIETetJMvyS4Ptqk"]; + [GMSServices provideAPIKey:@"AIzaSyD8vwvoaEPEgYemp1EkIETetJMvyS4Ptqk"]; [GeneratedPluginRegistrant registerWithRegistry:self]; return [super application:application didFinishLaunchingWithOptions:launchOptions]; } From 34c3cf8faf4af65310d21c84d29e7e5519dabf73 Mon Sep 17 00:00:00 2001 From: Nehal Jaisalmeria Date: Thu, 7 Dec 2023 01:15:25 +0530 Subject: [PATCH 09/10] dismissBottomModal --- lib/action/bottom_modal_action.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/action/bottom_modal_action.dart b/lib/action/bottom_modal_action.dart index fa8498f59..0df9206fd 100644 --- a/lib/action/bottom_modal_action.dart +++ b/lib/action/bottom_modal_action.dart @@ -106,6 +106,6 @@ class DismissBottomModalAction extends EnsembleAction { return Navigator.maybePop( bottomModalContext, scopeManager.dataContext.eval(payload)); } - return Future.value(null); + return Navigator.maybePop(context, scopeManager.dataContext.eval(payload)); } } From 11988d0f00288c53f40d251cf020f342acaa9d4a Mon Sep 17 00:00:00 2001 From: Nehal Jaisalmeria Date: Thu, 7 Dec 2023 02:34:06 +0530 Subject: [PATCH 10/10] chore: removed duplicate action --- lib/action/action_invokable.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/action/action_invokable.dart b/lib/action/action_invokable.dart index 173afc56a..22e2ba5f3 100644 --- a/lib/action/action_invokable.dart +++ b/lib/action/action_invokable.dart @@ -24,7 +24,6 @@ abstract class ActionInvokable with Invokable { ActionType.showBottomModal, ActionType.dismissBottomModal, ActionType.showDialog, - ActionType.rateApp ]); }