Skip to content

Commit 602be60

Browse files
committed
Layout Groups #1
1 parent e42e14c commit 602be60

File tree

4 files changed

+58
-23
lines changed

4 files changed

+58
-23
lines changed

lib/src/api/converters.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,37 @@ class NullableDateTimeConverter extends JsonConverter<DateTime?, int?> {
4949
}
5050
}
5151

52+
/// Top level converter for serializing Nodes map to and from JSON.
53+
class CanvasesMapConverter extends JsonConverter<
54+
Map<String, Map<String, BaseNode>>, Map<String, dynamic>> {
55+
/// Creates a new instance of [CanvasesMapConverter].
56+
const CanvasesMapConverter();
57+
58+
@override
59+
Map<String, Map<String, BaseNode>> fromJson(Map<String, dynamic> json) =>
60+
deserialize(json);
61+
62+
@override
63+
Map<String, dynamic> toJson(Map<String, Map<String, BaseNode>> object) =>
64+
serialize(object);
65+
66+
/// Top level function to deserialize a JSON Map into a map of node ID to node.
67+
static Map<String, Map<String, BaseNode>> deserialize(
68+
Map<String, dynamic> value) =>
69+
{
70+
for (final MapEntry(key: key, value: value) in value.entries)
71+
key: NodesMapConverter.deserialize(value),
72+
};
73+
74+
/// Top level function to serialize a map of node ID to node into a JSON map.
75+
static Map<String, dynamic> serialize(
76+
Map<String, Map<String, BaseNode>> canvases) =>
77+
{
78+
for (final MapEntry(key: key, value: value) in canvases.entries)
79+
key: NodesMapConverter.serialize(value),
80+
};
81+
}
82+
5283
/// Top level converter for serializing Nodes map to and from JSON.
5384
class NodesMapConverter
5485
extends JsonConverter<Map<String, BaseNode>, Map<String, dynamic>> {

lib/src/api/models/breakpoint.dart

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,33 +56,27 @@ class Breakpoint with EquatableMixin, SerializableMixin {
5656
/// Upper bound of this breakpoint. It is an integer, but supports infinity.
5757
final num upperBound;
5858

59-
/// Scale mode of this breakpoint.
60-
final ScaleMode scaleMode;
61-
6259
/// Creates new [Breakpoint] with given values.
6360
const Breakpoint({
6461
required this.nodeId,
65-
required this.lowerBound,
66-
required this.upperBound,
67-
required this.scaleMode,
62+
this.lowerBound = 0,
63+
this.upperBound = double.infinity,
6864
});
6965

7066
/// Duplicates this [Breakpoint] with given data overrides.
7167
Breakpoint copyWith({
7268
String? nodeId,
7369
num? lowerBound,
7470
num? upperBound,
75-
ScaleMode? scaleMode,
7671
}) =>
7772
Breakpoint(
7873
nodeId: nodeId ?? this.nodeId,
7974
lowerBound: lowerBound ?? this.lowerBound,
8075
upperBound: upperBound ?? this.upperBound,
81-
scaleMode: scaleMode ?? this.scaleMode,
8276
);
8377

8478
@override
85-
List<Object?> get props => [nodeId, lowerBound, upperBound, scaleMode];
79+
List<Object?> get props => [nodeId, lowerBound, upperBound];
8680

8781
/// Factory constructor for creating a new [Breakpoint] instance from
8882
/// JSON data.

lib/src/api/models/breakpoint.g.dart

Lines changed: 21 additions & 14 deletions
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ class FloatingActionButtonProperties
132132
/// Space between the icon and label for [FloatingActionButtonType.extended].
133133
double extendedIconLabelSpacing;
134134

135+
@override
136+
List<TriggerType> get triggerTypes => [TriggerType.click];
137+
135138
/// Creates a [FloatingActionButtonProperties] with the given data.
136139
FloatingActionButtonProperties({
137140
this.backgroundColor = ColorRGBA.black,

0 commit comments

Comments
 (0)