Skip to content

Commit 48f0644

Browse files
committed
Add gap function in Flex class
1 parent bfd1374 commit 48f0644

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Sources/Swift/FlexLayout.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,26 @@ public final class Flex {
12131213
return self
12141214
}
12151215

1216+
//
1217+
// MARK: Gap
1218+
//
1219+
1220+
/**
1221+
Set paddings between views.
1222+
*/
1223+
@discardableResult
1224+
public func setGap(_ gutter: Gutter, _ value: CGFloat) -> Flex {
1225+
switch gutter {
1226+
case .column:
1227+
yoga.columnGap = value
1228+
case .row:
1229+
yoga.rowGap = value
1230+
case .all:
1231+
yoga.gap = value
1232+
}
1233+
return self
1234+
}
1235+
12161236
//
12171237
// MARK: UIView Visual properties
12181238
//
@@ -1416,6 +1436,12 @@ public final class Flex {
14161436
case none
14171437
}
14181438

1439+
public enum Gutter {
1440+
case column
1441+
case row
1442+
case all
1443+
}
1444+
14191445
/*public enum Overflow {
14201446
/// Items that overflow
14211447
case visible

Sources/YogaKit/include/YogaKit/YGLayout.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) {
115115
// Yoga specific properties, not compatible with flexbox specification
116116
@property(nonatomic, readwrite, assign) CGFloat aspectRatio;
117117

118+
@property(nonatomic, readwrite, assign) CGFloat columnGap;
119+
@property(nonatomic, readwrite, assign) CGFloat rowGap;
120+
@property(nonatomic, readwrite, assign) CGFloat gap;
121+
118122
/**
119123
Get the resolved direction of this node. This won't be YGDirectionInherit
120124
*/

0 commit comments

Comments
 (0)