File tree Expand file tree Collapse file tree 2 files changed +31
-8
lines changed
Development/Demo/Components
Sources/LayoutSpecBuilders Expand file tree Collapse file tree 2 files changed +31
-8
lines changed Original file line number Diff line number Diff line change @@ -65,8 +65,7 @@ enum Mocks {
65
65
AnyDisplayNode { _, _ in
66
66
LayoutSpec {
67
67
shape
68
- . height ( 16 )
69
- . width ( 120 )
68
+ . frame ( width: 120 , height: 16 )
70
69
. padding ( 2 )
71
70
}
72
71
}
@@ -85,8 +84,7 @@ enum Mocks {
85
84
AnyDisplayNode { _, _ in
86
85
LayoutSpec {
87
86
shape
88
- . height ( 6 )
89
- . width ( 20 )
87
+ . frame ( width: 20 , height: 6 )
90
88
. padding ( 2 )
91
89
}
92
90
}
@@ -107,8 +105,7 @@ enum Mocks {
107
105
AnyDisplayNode { _, _ in
108
106
LayoutSpec {
109
107
shape
110
- . width ( 28 )
111
- . height ( 28 )
108
+ . frame ( width: 28 , height: 28 )
112
109
. padding ( 2 )
113
110
}
114
111
}
@@ -132,8 +129,7 @@ enum Mocks {
132
129
LayoutSpec {
133
130
VStackLayout ( spacing: 2 ) {
134
131
shapes
135
- . width ( 120 )
136
- . height ( 16 )
132
+ . frame ( width: 120 , height: 16 )
137
133
}
138
134
}
139
135
}
Original file line number Diff line number Diff line change @@ -426,6 +426,33 @@ extension _ASLayoutElementType {
426
426
public func spacingBefore( _ spacing: CGFloat ) -> ModifiedContent < Self , SpacingModifier > {
427
427
modifier ( SpacingModifier ( after: nil , before: spacing) )
428
428
}
429
+
430
+ public func frame( width: CGFloat ? = nil , height: CGFloat ? = nil ) -> ModifiedContent < Self , SizeModifier > {
431
+ let width : ASDimension ? = if let width { . init( unit: . points, value: width) } else { nil }
432
+ let height : ASDimension ? = if let height { . init( unit: . points, value: height) } else { nil }
433
+ return modifier ( SizeModifier (
434
+ width: width,
435
+ height: height
436
+ ) )
437
+ }
438
+
439
+ public func frame( minWidth: CGFloat ? = nil , minHeight: CGFloat ? = nil ) -> ModifiedContent < Self , MinSizeModifier > {
440
+ let minWidth : ASDimension ? = if let minWidth { . init( unit: . points, value: minWidth) } else { nil }
441
+ let minHeight : ASDimension ? = if let minHeight { . init( unit: . points, value: minHeight) } else { nil }
442
+ return modifier ( MinSizeModifier (
443
+ minWidth: minWidth,
444
+ minHeight: minHeight
445
+ ) )
446
+ }
447
+
448
+ public func frame( maxWidth: CGFloat ? = nil , maxHeight: CGFloat ? = nil ) -> ModifiedContent < Self , MaxSizeModifier > {
449
+ let maxWidth : ASDimension ? = if let maxWidth { . init( unit: . points, value: maxWidth) } else { nil }
450
+ let maxHeight : ASDimension ? = if let maxHeight { . init( unit: . points, value: maxHeight) } else { nil }
451
+ return modifier ( MaxSizeModifier (
452
+ maxWidth: maxWidth,
453
+ maxHeight: maxHeight
454
+ ) )
455
+ }
429
456
430
457
}
431
458
You can’t perform that action at this time.
0 commit comments