-
Notifications
You must be signed in to change notification settings - Fork 17
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 feat/calendar
- Loading branch information
Showing
14 changed files
with
392 additions
and
84 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
View: | ||
title: Conditional | ||
|
||
body: | ||
Column: | ||
styles: { gap: 16, padding: 24 } | ||
children: | ||
- TextInput: | ||
id: textInputId | ||
onDelayedKeyPress: | | ||
//@code | ||
textInputId.value = textInputId.value; | ||
- Conditional: | ||
conditions: | ||
- if: ${textInputId.value == 'If'} | ||
Text: | ||
text: If Statement | ||
- elseif: ${textInputId.value == 'ElseIf1'} | ||
Text: | ||
text: Else If Statement - 1 | ||
- elseif: ${textInputId.value == 'ElseIf2'} | ||
Text: | ||
text: Else If Statement - 2 | ||
- elseif: ${textInputId.value == 'ElseIf3'} | ||
Text: | ||
text: Else If Statement - 3 | ||
- else: | ||
Text: | ||
text: Else Statement |
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
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,80 @@ | ||
import 'package:ensemble/ensemble.dart'; | ||
import 'package:ensemble/framework/extensions.dart'; | ||
import 'package:flutter/services.dart'; | ||
|
||
/// managing communication between Ensemble and the host platform (iOS/Android) | ||
class HostPlatformManager extends IsHostPlatformManager | ||
with _InboundManager, _OutboundManager { | ||
HostPlatformManager._internal(); | ||
|
||
static final HostPlatformManager _instance = HostPlatformManager._internal(); | ||
|
||
factory HostPlatformManager() => _instance; | ||
|
||
static const MethodChannel _channel = | ||
MethodChannel('com.ensembleui.host.platform'); | ||
|
||
@override | ||
MethodChannel getChannel() => _channel; | ||
|
||
void init() { | ||
_channel.setMethodCallHandler(_receiveData); | ||
} | ||
} | ||
|
||
abstract class IsHostPlatformManager { | ||
MethodChannel getChannel(); | ||
} | ||
|
||
/// Handle Inbound methods | ||
mixin _InboundManager on IsHostPlatformManager { | ||
Future<void> _receiveData(MethodCall call) async { | ||
Method? method = Method.values.from(call.method); | ||
switch (method) { | ||
case Method.updateEnvOverrides: | ||
_updateEnvOverrides(call.arguments); | ||
break; | ||
case Method.fromHostToEnsemble: | ||
print("Data From HOST: ${call.arguments}"); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
/// data coming from hosting platform's envVariable channel | ||
/// will be added to the environment overrides | ||
void _updateEnvOverrides(dynamic payload) { | ||
if (payload is Map && payload.isNotEmpty) { | ||
Map<String, dynamic> variables = {}; | ||
payload.forEach((key, value) { | ||
variables[key.toString()] = value; | ||
}); | ||
Ensemble().getConfig()?.updateEnvOverrides(variables); | ||
} | ||
} | ||
} | ||
|
||
/// Handle Outbound methods | ||
mixin _OutboundManager on IsHostPlatformManager { | ||
Future<void> navigateExternalScreen(dynamic payload) async { | ||
return await getChannel() | ||
.invokeMethod(Method.navigateExternalScreen.name, payload); | ||
} | ||
|
||
void sendData(dynamic payload) { | ||
getChannel().invokeMethod(Method.fromEnsembleToHost.name, payload); | ||
} | ||
} | ||
|
||
enum Method { | ||
// for sending environment variables from host to Ensemble | ||
updateEnvOverrides, | ||
|
||
// navigate to a host platform's screen | ||
navigateExternalScreen, | ||
|
||
// twp-way communication between host and Ensemble | ||
fromHostToEnsemble, | ||
fromEnsembleToHost | ||
} |
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
Oops, something went wrong.