Skip to content

Commit 1119197

Browse files
committed
Miscellaneous improvements
- Allow external components to have reactions. - Introduce handlesDefaultReactionsInternally to better handle external reactivity for nodes with custom properties.
1 parent 689ab2f commit 1119197

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

lib/src/api/mixins.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,13 @@ mixin CornerMixin on BaseNode {
737737
}
738738

739739
/// Indicates that the node has some custom properties.
740-
mixin CustomPropertiesMixin on BaseNode {}
740+
mixin CustomPropertiesMixin on BaseNode {
741+
/// Whether the node with custom properties handles its default reactions
742+
/// like click, long press, etc. internally. If this is true then the
743+
/// node itself is responsible for handling its own reactions. Otherwise,
744+
/// the transformer will provide for the default reactions.
745+
bool get handlesDefaultReactionsInternally => true;
746+
}
741747

742748
/// Defines node that preserves its aspect ratio and cannot be resized by only
743749
/// its width or height.

lib/src/api/nodes/external_component_node.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ part 'external_component_node.g.dart';
99
/// An inert node that does nothing.
1010
/// This is populated dynamically through the Codelessly SDK.
1111
@JsonSerializable()
12-
class ExternalComponentNode extends BaseNode with CustomPropertiesMixin {
12+
class ExternalComponentNode extends SceneNode with CustomPropertiesMixin {
1313
@override
1414
final String type = 'external';
1515

@@ -20,6 +20,9 @@ class ExternalComponentNode extends BaseNode with CustomPropertiesMixin {
2020
/// nodes to the same widget builder.
2121
String? builderID;
2222

23+
@override
24+
bool get handlesDefaultReactionsInternally => false;
25+
2326
/// Creates an [ExternalComponentNode] with the given data.
2427
ExternalComponentNode({
2528
required super.id,
@@ -40,12 +43,20 @@ class ExternalComponentNode extends BaseNode with CustomPropertiesMixin {
4043
super.edgePins,
4144
super.aspectRatioLock,
4245
super.positioningMode,
46+
super.parentID,
47+
super.reactions,
48+
super.variables,
49+
super.multipleVariables,
4350
});
4451

4552
/// Creates a [ExternalComponentNode] from a JSON object.
4653
factory ExternalComponentNode.fromJson(Map json) =>
4754
_$ExternalComponentNodeFromJson(json);
4855

56+
@override
57+
List<TriggerType> get triggerTypes =>
58+
[TriggerType.click, TriggerType.longPress];
59+
4960
@override
5061
Map toJson() => _$ExternalComponentNodeToJson(this);
5162
}

lib/src/api/nodes/external_component_node.g.dart

Lines changed: 11 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)