Skip to content

Commit 3386d4a

Browse files
committed
Make FAB of Scaffold an action item.
1 parent 1e45c56 commit 3386d4a

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

lib/src/api/nodes/canvas_node.dart

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ part 'canvas_node.g.dart';
1515
/// Represents a canvas or a screen.
1616
@JsonSerializable()
1717
class CanvasNode extends ParentNode
18-
with RowColumnMixin, IsolatedMixin, ScrollableMixin, CustomPropertiesMixin {
18+
with
19+
RowColumnMixin,
20+
IsolatedMixin,
21+
ScrollableMixin,
22+
CustomPropertiesMixin,
23+
ParentReactionMixin {
1924
@override
2025
final String type = 'canvas';
2126

@@ -35,6 +40,15 @@ class CanvasNode extends ParentNode
3540
/// Whether this canvas is a scaffold.
3641
bool get isAScaffold => properties.isAScaffold;
3742

43+
@override
44+
List<TriggerType> get triggerTypes => [TriggerType.click];
45+
46+
@override
47+
List<ReactionMixin> get reactiveChildren =>
48+
properties.floatingActionButton != null
49+
? [properties.floatingActionButton!]
50+
: [];
51+
3852
/// Creates a new [CanvasNode] with given data.
3953
CanvasNode({
4054
required super.id,
@@ -90,7 +104,7 @@ class CanvasNode extends ParentNode
90104
// Custom properties.
91105
required this.properties,
92106
Map<String, String>? variables,
93-
}): super(fills: fills ?? [PaintModel.whitePaint]) {
107+
}) : super(fills: fills ?? [PaintModel.whitePaint]) {
94108
setRowColumnMixin(
95109
rowColumnType: rowColumnType,
96110
mainAxisAlignment: mainAxisAlignment,

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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/nodes/floating_action_button_node.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class FloatingActionButtonNode extends SceneNode with CustomPropertiesMixin {
8585
/// Holds configurable properties for the [FloatingActionButtonNode].
8686
@JsonSerializable()
8787
class FloatingActionButtonProperties
88-
with ShapeBorderMixin, SerializableMixin, EquatableMixin {
88+
with ShapeBorderMixin, SerializableMixin, EquatableMixin, ReactionMixin {
8989
/// Background color of the FAB.
9090
ColorRGBA backgroundColor;
9191

@@ -153,13 +153,16 @@ class FloatingActionButtonProperties
153153
CornerRadius cornerRadius = CornerRadius.zero,
154154
ColorRGBA? borderColor,
155155
double? borderWidth,
156+
List<Reaction>? reactions,
156157
}) : labelStyle = labelStyle ?? TextProp.general(fontSize: 14) {
157158
setShapeBorderMixin(
158159
shape: shape,
159160
cornerRadius: cornerRadius,
160161
borderWidth: borderWidth,
161162
borderColor: borderColor,
162163
);
164+
165+
setReactionMixin(reactions ?? []);
163166
}
164167

165168
/// Duplicate the current [FloatingActionButtonProperties] with the given data

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

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

0 commit comments

Comments
 (0)