diff --git a/Example/FlexLayoutSample/AppDelegate.swift b/Example/FlexLayoutSample/AppDelegate.swift index 31bb7ee0..81a30d25 100644 --- a/Example/FlexLayoutSample/AppDelegate.swift +++ b/Example/FlexLayoutSample/AppDelegate.swift @@ -14,7 +14,7 @@ import UIKit -@UIApplicationMain +@main class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? diff --git a/Example/FlexLayoutSample/UI/Examples/CollectionViewExample/CollectionViewExampleView.swift b/Example/FlexLayoutSample/UI/Examples/CollectionViewExample/CollectionViewExampleView.swift index 6589811a..ceac7790 100644 --- a/Example/FlexLayoutSample/UI/Examples/CollectionViewExample/CollectionViewExampleView.swift +++ b/Example/FlexLayoutSample/UI/Examples/CollectionViewExample/CollectionViewExampleView.swift @@ -29,10 +29,7 @@ class CollectionViewExampleView: UIView { flowLayout.minimumLineSpacing = 8 flowLayout.minimumInteritemSpacing = 0 - - if #available(iOS 11.0, *) { - flowLayout.sectionInsetReference = .fromSafeArea - } + flowLayout.sectionInsetReference = .fromSafeArea collectionView.backgroundColor = .white collectionView.dataSource = self diff --git a/Example/cocoapods/FlexLayoutSample.xcodeproj/project.pbxproj b/Example/cocoapods/FlexLayoutSample.xcodeproj/project.pbxproj index ca6c764f..39830539 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 */, @@ -589,7 +589,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -645,7 +645,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; @@ -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 = 14.0; 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 = 14.0; PRODUCT_BUNDLE_IDENTIFIER = com.lucdion.FlexLayoutSample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; diff --git a/FlexLayout.podspec b/FlexLayout.podspec index 5e1d53e4..ce7417dd 100644 --- a/FlexLayout.podspec +++ b/FlexLayout.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |spec| spec.name = "FlexLayout" - spec.version = "2.1.0" + spec.version = "2.2.0" spec.summary = "FlexLayout" spec.homepage = "https://github.com/lucdion/FlexLayout.git" spec.license = "MIT license" diff --git a/FlexLayout.xcodeproj/project.pbxproj b/FlexLayout.xcodeproj/project.pbxproj index ea500dfd..3370bcfa 100644 --- a/FlexLayout.xcodeproj/project.pbxproj +++ b/FlexLayout.xcodeproj/project.pbxproj @@ -501,7 +501,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -563,7 +563,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = XCODE_PROJECT_BUILD; diff --git a/Package.resolved b/Package.resolved index 4cc6489b..d357dcba 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": "f55265f5182ca433211f536b2f466587899bc443", + "version": "3.2.0" } } ] diff --git a/Package.swift b/Package.swift index ddcc190c..9a697985 100644 --- a/Package.swift +++ b/Package.swift @@ -6,13 +6,13 @@ import PackageDescription let package = Package( name: "FlexLayout", platforms: [ - .iOS(.v12), + .iOS(.v14), ], products: [ .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", from: "3.2.0"), ], targets: [ .target( diff --git a/Podfile b/Podfile index 5425a248..5cec9c4a 100644 --- a/Podfile +++ b/Podfile @@ -5,7 +5,7 @@ platform :ios, '14.0' workspace 'FlexLayout.xcworkspace' target 'FlexLayout' do - pod 'Yoga', git: 'https://github.com/facebook/yoga.git', tag: 'v3.1.0' + pod 'Yoga', git: 'https://github.com/facebook/yoga.git', tag: 'v3.2.0' end target 'FlexLayoutTests' do diff --git a/Podfile.lock b/Podfile.lock index 26472063..de33d8ea 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,15 +1,15 @@ PODS: - - FlexLayout (2.0.10): + - FlexLayout (2.2.0): - Yoga - PinLayout (1.10.5) - SwiftLint (0.55.1) - - Yoga (3.1.0) + - Yoga (3.2.0) DEPENDENCIES: - FlexLayout (from `./`) - PinLayout - SwiftLint - - Yoga (from `https://github.com/facebook/yoga.git`, tag `v3.1.0`) + - Yoga (from `https://github.com/facebook/yoga.git`, tag `v3.2.0`) SPEC REPOS: trunk: @@ -21,19 +21,19 @@ EXTERNAL SOURCES: :path: "./" Yoga: :git: https://github.com/facebook/yoga.git - :tag: v3.1.0 + :tag: v3.2.0 CHECKOUT OPTIONS: Yoga: :git: https://github.com/facebook/yoga.git - :tag: v3.1.0 + :tag: v3.2.0 SPEC CHECKSUMS: - FlexLayout: aaf305c1f3203be3d8694c3835773d1e7a912b72 + FlexLayout: 8780755eda402e29eddd4b45a72018c8811ed78d PinLayout: f6c2b63a5a5b24864064e1d15c67de41b4e74748 SwiftLint: 3fe909719babe5537c552ee8181c0031392be933 - Yoga: 955c6d6390d5b00fb54d02151e67d69b3ac6f2d8 + Yoga: 05f97d1ab7a72d84edff52f6699fe7bd58332c43 -PODFILE CHECKSUM: 616cb577f11ab8498737680dedeed47c6fae4b64 +PODFILE CHECKSUM: 83806357f78a79818dc54f3a63b5b2677be70533 -COCOAPODS: 1.16.2 +COCOAPODS: 1.15.2 diff --git a/Sources/Swift/FlexLayout.swift b/Sources/Swift/FlexLayout.swift index bf8cf93d..072911f4 100644 --- a/Sources/Swift/FlexLayout.swift +++ b/Sources/Swift/FlexLayout.swift @@ -891,7 +891,6 @@ public final class Flex { /** Set all margins using UIEdgeInsets. - This method is particularly useful to set all margins using iOS 11 `UIView.safeAreaInsets`. */ @discardableResult public func margin(_ insets: UIEdgeInsets) -> Flex { @@ -904,11 +903,7 @@ 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. */ - @available(tvOS 11.0, iOS 11.0, *) @discardableResult public func margin(_ directionalInsets: NSDirectionalEdgeInsets) -> Flex { yoga.marginTop = YGValue(directionalInsets.top) @@ -1138,10 +1133,7 @@ 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. */ - @available(tvOS 11.0, iOS 11.0, *) @discardableResult public func padding(_ directionalInsets: NSDirectionalEdgeInsets) -> Flex { yoga.paddingTop = YGValue(directionalInsets.top) @@ -1335,6 +1327,16 @@ public final class Flex { return self } + // + // MARK: BoxSizing + // + + @discardableResult + public func boxSizing(_ boxSizing: BoxSizing) -> Self { + yoga.boxSizing = boxSizing.yogaValue + return self + } + // MARK: Enums /** @@ -1472,6 +1474,16 @@ public final class Flex { case flex /// With this value, the item will be hidden and not be calculated case none + /// Yoga nodes may now be set to display: contents to remove them from the layout flow, while preserving and hoisting the node's children. This may be used by the higher level UI framework to allow more easily composing wrapper components (such as those which may need to handle events, without influencing child layout) + case contents + } + + /// Allowing sizing values to influence the content box instead of the border box. + public enum BoxSizing { + /// Default value: If you set an element's width to 100 pixels, that 100 pixels will include any border or padding you added, and the content box will shrink to absorb that extra width. This typically makes it much easier to size elements. + case borderBox + /// If you set an element's width to 100 pixels, then the element's content box will be 100 pixels wide, and the width of any border or padding will be added to the final rendered width, making the element wider than 100px. + case contentBox } /*public enum Overflow { diff --git a/Sources/Swift/Impl/FlexLayout+Enum.swift b/Sources/Swift/Impl/FlexLayout+Enum.swift index 2ba399dc..665fb7ee 100644 --- a/Sources/Swift/Impl/FlexLayout+Enum.swift +++ b/Sources/Swift/Impl/FlexLayout+Enum.swift @@ -19,10 +19,10 @@ import yoga extension Flex.Direction { var yogaValue: YGFlexDirection { switch self { - case .column: return YGFlexDirection.column - case .columnReverse: return YGFlexDirection.columnReverse - case .row: return YGFlexDirection.row - case .rowReverse: return YGFlexDirection.rowReverse + case .column: .column + case .columnReverse: .columnReverse + case .row: .row + case .rowReverse: .rowReverse } } } @@ -30,12 +30,12 @@ extension Flex.Direction { extension Flex.JustifyContent { var yogaValue: YGJustify { switch self { - case .start: return YGJustify.flexStart - case .center: return YGJustify.center - case .end: return YGJustify.flexEnd - case .spaceBetween: return YGJustify.spaceBetween - case .spaceAround: return YGJustify.spaceAround - case .spaceEvenly: return YGJustify.spaceEvenly + case .start: .flexStart + case .center: .center + case .end: .flexEnd + case .spaceBetween: .spaceBetween + case .spaceAround: .spaceAround + case .spaceEvenly: .spaceEvenly } } } @@ -43,13 +43,13 @@ extension Flex.JustifyContent { extension Flex.AlignContent { var yogaValue: YGAlign { switch self { - case .stretch: return YGAlign.stretch - case .start: return YGAlign.flexStart - case .center: return YGAlign.center - case .end: return YGAlign.flexEnd - case .spaceBetween: return YGAlign.spaceBetween - case .spaceAround: return YGAlign.spaceAround - case .spaceEvenly: return YGAlign.spaceEvenly + case .stretch: .stretch + case .start: .flexStart + case .center: .center + case .end: .flexEnd + case .spaceBetween: .spaceBetween + case .spaceAround: .spaceAround + case .spaceEvenly: .spaceEvenly } } } @@ -57,11 +57,11 @@ extension Flex.AlignContent { extension Flex.AlignItems { var yogaValue: YGAlign { switch self { - case .stretch: return YGAlign.stretch - case .start: return YGAlign.flexStart - case .center: return YGAlign.center - case .end: return YGAlign.flexEnd - case .baseline: return YGAlign.baseline + case .stretch: .stretch + case .start: .flexStart + case .center: .center + case .end: .flexEnd + case .baseline: .baseline } } } @@ -69,12 +69,12 @@ extension Flex.AlignItems { extension Flex.AlignSelf { var yogaValue: YGAlign { switch self { - case .auto: return YGAlign.auto - case .stretch: return YGAlign.stretch - case .start: return YGAlign.flexStart - case .center: return YGAlign.center - case .end: return YGAlign.flexEnd - case .baseline: return YGAlign.baseline + case .auto: .auto + case .stretch: .stretch + case .start: .flexStart + case .center: .center + case .end: .flexEnd + case .baseline: .baseline } } } @@ -82,9 +82,9 @@ extension Flex.AlignSelf { extension Flex.Wrap { var yogaValue: YGWrap { switch self { - case .noWrap: return YGWrap.noWrap - case .wrap: return YGWrap.wrap - case .wrapReverse: return YGWrap.wrapReverse + case .noWrap: .noWrap + case .wrap: .wrap + case .wrapReverse: .wrapReverse } } } @@ -92,9 +92,9 @@ extension Flex.Wrap { extension Flex.Position { var yogaValue: YGPositionType { switch self { - case .relative: return YGPositionType.relative - case .absolute: return YGPositionType.absolute - case .static: return YGPositionType.static + case .relative: .relative + case .absolute: .absolute + case .static: .static } } } @@ -102,9 +102,9 @@ extension Flex.Position { extension Flex.LayoutDirection { var yogaValue: YGDirection { switch self { - case .ltr: return YGDirection.LTR - case .rtl: return YGDirection.RTL - default: return YGDirection.inherit + case .ltr: .LTR + case .rtl: .RTL + default: .inherit } } } @@ -112,18 +112,28 @@ extension Flex.LayoutDirection { extension Flex.Display { var yogaValue: YGDisplay { switch self { - case .flex: return YGDisplay.flex - case .none: return YGDisplay.none + case .flex: .flex + case .none: .none + case .contents: .contents } } } -/*extension Flex.Overflow { - var yogaValue: YGOverflow { +extension Flex.BoxSizing { + var yogaValue: YGBoxSizing { switch self { - case .visible: return YGOverflow.visible - case .hidden: return YGOverflow.hidden - case .scroll: return YGOverflow.scroll + case .borderBox: .borderBox + case .contentBox: .contentBox } } -}*/ +} + +/* extension Flex.Overflow { + var yogaValue: YGOverflow { + switch self { + case .visible: YGOverflow.visible + case .hidden: YGOverflow.hidden + case .scroll: YGOverflow.scroll + } + } + } */ diff --git a/Sources/YogaKit/YGLayout.mm b/Sources/YogaKit/YGLayout.mm index c6420b0c..c849ced2 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 337b9737..fef5ad41 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;