Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 10 additions & 27 deletions lib/src/api/mixins.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import 'package:json_annotation/json_annotation.dart';
import 'models/models.dart';
import 'nodes/nodes.dart';

/// To avoid "node is Canvas || node is ExpansionTileNode || ..." we use this mixin.
mixin IsolatedMixin {}

/// A base class for nodes that can have blends and decoration.
abstract class DefaultShapeNode extends SceneNode
with BlendMixin, GeometryMixin {
Expand Down Expand Up @@ -966,6 +969,13 @@ enum ScrollViewKeyboardDismissBehaviorC {
/// Nodes like [ListViewNode], [RowColumnNode] and [CanvasNode] uses this to
/// provide options for its scroll behavior.
mixin ScrollableMixin on BaseNode {
/// Whether this widget enforces its scrollable behavior.
/// [CanvasNode]s do not need to be scrollable but can.
/// [ListViewNode]s, on the other hand, must be scrollable.
///
/// If this is set to true, [isScrollable] becomes meaningless.
bool get isScrollingEnforced => false;

/// Whether the scrolling is enabled.
late bool isScrollable;

Expand Down Expand Up @@ -1014,33 +1024,6 @@ mixin ScrollableMixin on BaseNode {
}
}

/// Will link this node to a provided [CanvasId] to render it as a scrollable
/// list view.
///
/// This is meant to be for defining a simple rectangle node into a "view" into
/// a canvas, where-in the output simply puts the entire canvas tree as a child
/// of rectangle.
@Deprecated(
'This feature has been de-scoped and might be removed in the future. We have '
'dedicated [ListViewNode]s and [PageViewNode]s now.',
)
mixin ScrollLinkableMixin on BaseNode {
/// Whether the scroll link is enabled.
late bool scrollLinkEnabled;

/// The ID of the canvas node to link to.
late String? scrollableCanvasId;

/// Sets the properties of this mixin.
void setScrollLinkableMixin({
required bool scrollLinkEnabled,
required String? scrollableCanvasId,
}) {
this.scrollLinkEnabled = scrollLinkEnabled;
this.scrollableCanvasId = scrollableCanvasId;
}
}

/// Type casts rotation value to integer.
int castRotation(dynamic v) => (v as num?)?.toInt() ?? 0;

Expand Down
12 changes: 6 additions & 6 deletions lib/src/api/models/webview_models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// license that can be found in the LICENSE.md file.

/// Type of source for a webview.
enum WebviewWebpageSourceType {
enum WebViewWebpageSourceType {
/// A URL address of some website.
url('URL link'),

Expand All @@ -17,11 +17,11 @@ enum WebviewWebpageSourceType {
final String label;

/// Default constructor for this enum.
const WebviewWebpageSourceType(this.label);
const WebViewWebpageSourceType(this.label);
}

/// Different types of supported webviews.
enum WebviewType {
enum WebViewType {
/// A webpage on the web.
webpage('Webpage'),

Expand All @@ -35,11 +35,11 @@ enum WebviewType {
final String label;

/// Default constructor for this enum.
const WebviewType(this.label);
const WebViewType(this.label);
}

/// Represents media playback policy for a webview.
enum WebviewMediaAutoPlaybackPolicy {
enum WebViewMediaAutoPlaybackPolicy {
/// Initiate media playback only on user interaction.
requireUserActionForAllMedia('Never autoplay any media'),

Expand All @@ -50,5 +50,5 @@ enum WebviewMediaAutoPlaybackPolicy {
final String label;

/// Default constructor for this enum.
const WebviewMediaAutoPlaybackPolicy(this.label);
const WebViewMediaAutoPlaybackPolicy(this.label);
}
3 changes: 2 additions & 1 deletion lib/src/api/node_json_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ class NodeJsonConverter implements JsonConverter<BaseNode?, Map> {
'embeddedVideo': EmbeddedVideoNode.fromJson,
'divider': DividerNode.fromJson,
'loadingIndicator': LoadingIndicatorNode.fromJson,
'webview': WebviewNode.fromJson,
'webView': WebViewNode.fromJson,
'dropdown': DropdownNode.fromJson,
'progressBar': ProgressBarNode.fromJson,
'variance': VarianceNode.fromJson,
'listView': ListViewNode.fromJson,
};
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/api/nodes/accordion_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/app_bar_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/auto_placeholder_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions lib/src/api/nodes/base_node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ abstract class BaseNode with SerializableMixin, EquatableMixin {
/// through the [codelessly_sdk] is wrapped in a [Visibility] widget.
bool visible;

/// Since a lot of components can't support padding, the default value is set
/// to false. Any node that supports padding must override this and and set
/// it to true. Otherwise, the padding control won't show up in the editor.
///
/// Nodes that can't support external padding modifications are like
/// [EmbeddedVideoNode], [WebviewNode], [IconNode], [TextNode], etc.
final bool supportsPadding = false;

/// Constraints apply to the [middleBoxLocal]
/// See [BoxConstraintsModel] for more info on how to define the
/// constraints.
Expand Down Expand Up @@ -377,6 +369,15 @@ abstract class BaseNode with SerializableMixin, EquatableMixin {
@JsonKey(includeFromJson: false, includeToJson: false)
String get debugLabel => '$name [$id]';

/// Since a lot of components can't support padding, the default value is set
/// to false. Any node that supports padding must override this and and set
/// it to true. Otherwise, the padding control won't show up in the editor.
///
/// Nodes that can't support external padding modifications are like
/// [EmbeddedVideoNode], [WebViewNode], [IconNode], [TextNode], etc.
@JsonKey(includeFromJson: false, includeToJson: false)
bool get supportsPadding => false;

/// Default constructor of this class.
BaseNode({
required this.id,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/api/nodes/button_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions lib/src/api/nodes/canvas_node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import 'nodes.dart';

part 'canvas_node.g.dart';

/// To avoid "node is Canvas || node is ExpansionTileNode || ..." we use this mixin.
mixin IsolatedMixin {}

/// Represents a canvas or a screen.
@JsonSerializable()
class CanvasNode extends ParentNode
Expand Down
2 changes: 1 addition & 1 deletion lib/src/api/nodes/canvas_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/checkbox_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/divider_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/dropdown_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/src/api/nodes/embedded_video_node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class EmbeddedVideoNode extends SceneNode
bool get hasUrl =>
properties.url != null && properties.url!.trim().isNotEmpty;

@override
bool get supportsPadding => false;

/// Creates a blank embedded video preview.
EmbeddedVideoNode.empty()
: properties = EmbeddedYoutubeVideoProperties(),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/api/nodes/embedded_video_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/expansion_tile_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/floating_action_button_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/frame_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/freeform_placeholder_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions lib/src/api/nodes/icon_node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ class IconNode extends SceneNode
@override
final String type = 'icon';

@override
bool get supportsPadding => false;

@override
double get aspectRatio => 1;

/// Creates an [IconNode] with the given data.
IconNode({
required this.icon,
Expand Down Expand Up @@ -84,7 +90,4 @@ class IconNode extends SceneNode

@override
Map toJson() => _$IconNodeToJson(this);

@override
double get aspectRatio => 1;
}
2 changes: 1 addition & 1 deletion lib/src/api/nodes/icon_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/list_tile_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading