diff --git a/Example/cocoapods/FlexLayoutSample.xcodeproj/project.pbxproj b/Example/cocoapods/FlexLayoutSample.xcodeproj/project.pbxproj index ca6c764..6087957 100644 --- a/Example/cocoapods/FlexLayoutSample.xcodeproj/project.pbxproj +++ b/Example/cocoapods/FlexLayoutSample.xcodeproj/project.pbxproj @@ -199,7 +199,7 @@ 249EFE361E64FAFE00165E39 = { isa = PBXGroup; children = ( - 249EFE411E64FAFE00165E39 /* FlexLayoutSample */, + 249EFE411E64FAFE00165E39 /* ../FlexLayoutSample */, 461884C59B72ACEAFC912B8A /* Frameworks */, 85CAAE97812075333AF3E88F /* Pods */, 249EFE401E64FAFE00165E39 /* Products */, @@ -214,7 +214,7 @@ name = Products; sourceTree = ""; }; - 249EFE411E64FAFE00165E39 /* FlexLayoutSample */ = { + 249EFE411E64FAFE00165E39 /* ../FlexLayoutSample */ = { isa = PBXGroup; children = ( 2439CC671E66614D003326FB /* Supporting Files */, @@ -664,7 +664,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; GCC_INPUT_FILETYPE = automatic; INFOPLIST_FILE = "../FlexLayoutSample/Supporting Files/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; PRODUCT_BUNDLE_IDENTIFIER = com.lucdion.FlexLayoutSample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -678,7 +678,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; GCC_INPUT_FILETYPE = automatic; INFOPLIST_FILE = "../FlexLayoutSample/Supporting Files/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; PRODUCT_BUNDLE_IDENTIFIER = com.lucdion.FlexLayoutSample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; diff --git a/FlexLayout.podspec b/FlexLayout.podspec index 5e1d53e..9319046 100644 --- a/FlexLayout.podspec +++ b/FlexLayout.podspec @@ -7,7 +7,7 @@ Pod::Spec.new do |spec| spec.license = "MIT license" spec.author = { "Luc Dion" => "luc_dion@yahoo.com" } - spec.platform = :ios, "14.0" + spec.platform = :ios, "13.4" spec.source = { :git => "https://github.com/lucdion/FlexLayout.git", :tag => "#{spec.version}" } spec.source_files = "Sources/**/*.{swift,h,m,mm,cpp,c}" spec.public_header_files = "Sources/YogaKit/include/YogaKit/*.h" @@ -24,5 +24,5 @@ Pod::Spec.new do |spec| '-fPIC' ] - spec.dependency 'Yoga' + spec.dependency 'Yoga', '3.2.1' end diff --git a/FlexLayout.xcodeproj/project.pbxproj b/FlexLayout.xcodeproj/project.pbxproj index ea500df..94c80cd 100644 --- a/FlexLayout.xcodeproj/project.pbxproj +++ b/FlexLayout.xcodeproj/project.pbxproj @@ -594,6 +594,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; GENERATE_INFOPLIST_FILE = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.lucdion.FlexLayout; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -622,6 +623,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; GENERATE_INFOPLIST_FILE = YES; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.lucdion.FlexLayout; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -640,6 +642,7 @@ DEVELOPMENT_TEAM = F37Y9H9E46; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; OTHER_LDFLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = com.lucdion.FlexLayoutTests; @@ -656,6 +659,7 @@ DEVELOPMENT_TEAM = F37Y9H9E46; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; OTHER_LDFLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = com.lucdion.FlexLayoutTests; diff --git a/Package.resolved b/Package.resolved index 4cc6489..4e09ffa 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/facebook/yoga.git", "state": { "branch": null, - "revision": "69b8934429702bd3ab06e8d6f709112a761b474b", - "version": "3.1.0" + "revision": "042f5013152eb81c1552dec945b88f7b95ca350f", + "version": "3.2.1" } } ] diff --git a/Package.swift b/Package.swift index ddcc190..1c514ce 100644 --- a/Package.swift +++ b/Package.swift @@ -12,7 +12,7 @@ let package = Package( .library(name: "FlexLayout", targets: ["FlexLayout"]), ], dependencies: [ - .package(url: "https://github.com/facebook/yoga.git", from: "3.1.0"), + .package(url: "https://github.com/facebook/yoga.git", .upToNextMinor(from: "3.2.1")), ], targets: [ .target( diff --git a/Podfile b/Podfile index 5425a24..f5214fb 100644 --- a/Podfile +++ b/Podfile @@ -1,11 +1,11 @@ source 'https://cdn.cocoapods.org/' use_frameworks! -platform :ios, '14.0' +platform :ios, '13.4' workspace 'FlexLayout.xcworkspace' target 'FlexLayout' do - pod 'Yoga', git: 'https://github.com/facebook/yoga.git', tag: 'v3.1.0' + pod 'Yoga' end target 'FlexLayoutTests' do diff --git a/Podfile.lock b/Podfile.lock index 2647206..a559f77 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,39 +1,32 @@ PODS: - - FlexLayout (2.0.10): - - Yoga + - FlexLayout (2.1.0): + - Yoga (= 3.2.1) - PinLayout (1.10.5) - SwiftLint (0.55.1) - - Yoga (3.1.0) + - Yoga (3.2.1) DEPENDENCIES: - FlexLayout (from `./`) - PinLayout - SwiftLint - - Yoga (from `https://github.com/facebook/yoga.git`, tag `v3.1.0`) + - Yoga SPEC REPOS: trunk: - PinLayout - SwiftLint + - Yoga EXTERNAL SOURCES: FlexLayout: :path: "./" - Yoga: - :git: https://github.com/facebook/yoga.git - :tag: v3.1.0 - -CHECKOUT OPTIONS: - Yoga: - :git: https://github.com/facebook/yoga.git - :tag: v3.1.0 SPEC CHECKSUMS: - FlexLayout: aaf305c1f3203be3d8694c3835773d1e7a912b72 + FlexLayout: 4832b2e2069002e7d3f48dffbb20cc773a1813be PinLayout: f6c2b63a5a5b24864064e1d15c67de41b4e74748 SwiftLint: 3fe909719babe5537c552ee8181c0031392be933 - Yoga: 955c6d6390d5b00fb54d02151e67d69b3ac6f2d8 + Yoga: 636ce73bd247407928a7df089f3bc3675916b3ff -PODFILE CHECKSUM: 616cb577f11ab8498737680dedeed47c6fae4b64 +PODFILE CHECKSUM: de7bb13eccf1a1ff875980af83b7d4a0cba2ca59 -COCOAPODS: 1.16.2 +COCOAPODS: 1.15.2 diff --git a/README.md b/README.md index a7ff018..a907d50 100644 --- a/README.md +++ b/README.md @@ -722,6 +722,26 @@ FlexLayout automatically includes the UIView when: Set the item display or not, with `none` value, the item will be hidden and not included in the layout. +Values: +* **`flex`**: Default value. The item is displayed normally and included in the layout. +* **`none`**: The item will be hidden and not included in the layout. +* **`contents`**: The node is removed from the layout flow, while its children are preserved and hoisted. This allows higher-level UI frameworks to compose wrapper components (e.g., to handle events) without influencing the layout of child nodes. + +
+ +### boxSizing +- Applies to: `flex items` + +**Method:** + +* **`boxSizing(_: BoxSizing)`** + +Set the box sizing mode for the item. This determines how the width and height of an element are calculated. + +Values: +* **`borderBox`**: Default value. With `borderBox`, the specified dimensions (width, height) include the content, padding, and border. This means the overall size of the element is as defined, with padding and border accounted for inside. +* **`contentBox`**: With `contentBox`, the specified dimensions refer only to the content area. Padding and borders are added outside these dimensions, potentially increasing the total size of the element. +
### markDirty() diff --git a/Sources/Swift/FlexLayout.swift b/Sources/Swift/FlexLayout.swift index bf8cf93..7608429 100644 --- a/Sources/Swift/FlexLayout.swift +++ b/Sources/Swift/FlexLayout.swift @@ -891,7 +891,7 @@ public final class Flex { /** Set all margins using UIEdgeInsets. - This method is particularly useful to set all margins using iOS 11 `UIView.safeAreaInsets`. + This method is particularly useful to set all margins using `UIView.safeAreaInsets`. */ @discardableResult public func margin(_ insets: UIEdgeInsets) -> Flex { @@ -904,11 +904,8 @@ public final class Flex { /** Set margins using NSDirectionalEdgeInsets. - This method is particularly to set all margins using iOS 11 `UIView.directionalLayoutMargins`. - - Available only on iOS 11 and higher. + This method is particularly to set all margins using `UIView.directionalLayoutMargins`. */ - @available(tvOS 11.0, iOS 11.0, *) @discardableResult public func margin(_ directionalInsets: NSDirectionalEdgeInsets) -> Flex { yoga.marginTop = YGValue(directionalInsets.top) @@ -1124,7 +1121,7 @@ public final class Flex { /** Set paddings using UIEdgeInsets. - This method is particularly useful to set all paddings using iOS 11 `UIView.safeAreaInsets`. + This method is particularly useful to set all paddings using `UIView.safeAreaInsets`. */ @discardableResult public func padding(_ insets: UIEdgeInsets) -> Flex { @@ -1137,11 +1134,8 @@ public final class Flex { /** Set paddings using NSDirectionalEdgeInsets. - This method is particularly to set all paddings using iOS 11 `UIView.directionalLayoutMargins`. - - Available only on iOS 11 and higher. + This method is particularly to set all paddings using `UIView.directionalLayoutMargins`. */ - @available(tvOS 11.0, iOS 11.0, *) @discardableResult public func padding(_ directionalInsets: NSDirectionalEdgeInsets) -> Flex { yoga.paddingTop = YGValue(directionalInsets.top) @@ -1334,7 +1328,20 @@ public final class Flex { yoga.display = value.yogaValue return self } - + + // + // MARK: Box Sizing + // + + /** + Set the box sizing + */ + @discardableResult + public func boxSizing(_ value: BoxSizing) -> Flex { + yoga.boxSizing = value.yogaValue + return self + } + // MARK: Enums /** @@ -1472,8 +1479,22 @@ public final class Flex { case flex /// With this value, the item will be hidden and not be calculated case none + /// With this value, the node is removed from the layout flow, while its children are preserved and hoisted. + /// This allows higher-level UI frameworks to compose wrapper components (e.g., to handle events) + /// without influencing the layout of child nodes. + case contents } - + + public enum BoxSizing { + /// Default value. + /// With `borderBox`, the specified dimensions (e.g., width, height) include the content, padding, and border. + /// This means the overall size of the element is as defined, with padding and border accounted for inside. + case borderBox + /// With `contentBox`, the specified dimensions refer only to the content area. + /// Padding and borders are added outside these dimensions, potentially increasing the total size of the element. + case contentBox + } + /*public enum Overflow { /// Items that overflow case visible diff --git a/Sources/Swift/Impl/FlexLayout+Enum.swift b/Sources/Swift/Impl/FlexLayout+Enum.swift index 2ba399d..b7da68d 100644 --- a/Sources/Swift/Impl/FlexLayout+Enum.swift +++ b/Sources/Swift/Impl/FlexLayout+Enum.swift @@ -114,6 +114,16 @@ extension Flex.Display { switch self { case .flex: return YGDisplay.flex case .none: return YGDisplay.none + case .contents: return YGDisplay.contents + } + } +} + +extension Flex.BoxSizing { + var yogaValue: YGBoxSizing { + switch self { + case .borderBox: return YGBoxSizing.borderBox + case .contentBox: return YGBoxSizing.contentBox } } } diff --git a/Sources/YogaKit/YGLayout.mm b/Sources/YogaKit/YGLayout.mm index c6420b0..c849ced 100644 --- a/Sources/YogaKit/YGLayout.mm +++ b/Sources/YogaKit/YGLayout.mm @@ -273,6 +273,7 @@ - (void)setPosition:(YGPositionType)position { YG_PROPERTY(YGWrap, flexWrap, FlexWrap) YG_PROPERTY(YGOverflow, overflow, Overflow) YG_PROPERTY(YGDisplay, display, Display) +YG_PROPERTY(YGBoxSizing, boxSizing, BoxSizing) YG_PROPERTY(CGFloat, flex, Flex) YG_PROPERTY(CGFloat, flexGrow, FlexGrow) diff --git a/Sources/YogaKit/include/YogaKit/YGLayout.h b/Sources/YogaKit/include/YogaKit/YGLayout.h index 337b973..fef5ad4 100644 --- a/Sources/YogaKit/include/YogaKit/YGLayout.h +++ b/Sources/YogaKit/include/YogaKit/YGLayout.h @@ -64,6 +64,7 @@ typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) { @property(nonatomic, readwrite, assign) YGWrap flexWrap; @property(nonatomic, readwrite, assign) YGOverflow overflow; @property(nonatomic, readwrite, assign) YGDisplay display; +@property(nonatomic, readwrite, assign) YGBoxSizing boxSizing; @property(nonatomic, readwrite, assign) CGFloat flex; @property(nonatomic, readwrite, assign) CGFloat flexGrow;