-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into input-field-update
- Loading branch information
Showing
9 changed files
with
209 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import 'package:ensemble/framework/data_context.dart'; | ||
import 'package:ensemble_ts_interpreter/invokables/invokable.dart'; | ||
|
||
class DevMode { | ||
static bool debug = false; | ||
static String? screenId; | ||
static String? screenName; | ||
static DataContext? _pageDataContext; | ||
|
||
static DataContext? get pageDataContext => _pageDataContext; | ||
|
||
static set pageDataContext(DataContext? dataContext) { | ||
if (!debug) return; | ||
_pageDataContext = dataContext; | ||
} | ||
|
||
// Recursive function to process Invokable objects at any depth | ||
static Map<String, dynamic> processInvokable(Invokable invokable) { | ||
Map<String, dynamic> propMap = {}; | ||
List<String> getters = Invokable.getGettableProperties(invokable); | ||
for (String getter in getters) { | ||
dynamic propValue = invokable.getProperty(getter); | ||
|
||
// Check if the property value is also an Invokable and process it recursively | ||
if (propValue is Invokable) { | ||
propValue = processInvokable(propValue); | ||
} | ||
|
||
propMap[getter] = propValue; | ||
} | ||
Map<String, Function> methods = Invokable.getMethods(invokable); | ||
for (String method in methods.keys) { | ||
Function f = methods[method]!; | ||
propMap[method] = 'function() {}'; | ||
} | ||
|
||
return propMap; | ||
} | ||
|
||
static Map<String, dynamic> getContextAsJs(Map<String, dynamic> contextMap) { | ||
Map<String, dynamic> context = {}; | ||
|
||
contextMap.forEach((key, value) { | ||
if (value is Invokable) { | ||
// Use the recursive function to process Invokable objects deeply | ||
Map<String, dynamic> propMap = processInvokable(value); | ||
|
||
// Add propMap to context only if the value is Invokable | ||
context[key] = propMap; | ||
} | ||
// If the value does not extend Invokable, it's not added to the context | ||
}); | ||
|
||
return context; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters