rename properties and methods in Swift to remove the yk_ prefix

This commit is contained in:
David Hart
2016-12-18 22:06:07 +01:00
parent 4be38891d8
commit ec31ea0bc9
5 changed files with 75 additions and 25 deletions

View File

@@ -15,25 +15,25 @@
/** /**
The property that decides if we should include this view when calculating layout. Defaults to YES. The property that decides if we should include this view when calculating layout. Defaults to YES.
*/ */
@property (nonatomic, setter=yk_setIncludeInLayout:) BOOL yk_includeInLayout; @property (nonatomic, setter=yk_setIncludeInLayout:) BOOL yk_includeInLayout NS_SWIFT_NAME(includeInLayout);
/** /**
The property that decides during layout/sizing whether or not yk_* properties should be applied. Defaults to NO. The property that decides during layout/sizing whether or not yk_* properties should be applied. Defaults to NO.
*/ */
@property (nonatomic, setter=yk_setUsesYoga:) BOOL yk_usesYoga; @property (nonatomic, setter=yk_setUsesYoga:) BOOL yk_usesYoga NS_SWIFT_NAME(usesYoga);
@property (nonatomic, setter=yk_setDirection:) YKDirection yk_direction; @property (nonatomic, setter=yk_setDirection:) YKDirection yk_direction NS_SWIFT_NAME(layoutDirection);
@property (nonatomic, setter=yk_setFlexDirection:) YKFlexDirection yk_flexDirection; @property (nonatomic, setter=yk_setFlexDirection:) YKFlexDirection yk_flexDirection NS_SWIFT_NAME(layoutFlexDirection);
@property (nonatomic, setter=yk_setJustifyContent:) YKJustify yk_justifyContent; @property (nonatomic, setter=yk_setJustifyContent:) YKJustify yk_justifyContent NS_SWIFT_NAME(layoutJustifyContent);
@property (nonatomic, setter=yk_setAlignContent:) YKAlign yk_alignContent; @property (nonatomic, setter=yk_setAlignContent:) YKAlign yk_alignContent NS_SWIFT_NAME(layoutAlignContent);
@property (nonatomic, setter=yk_setAlignItems:) YKAlign yk_alignItems; @property (nonatomic, setter=yk_setAlignItems:) YKAlign yk_alignItems NS_SWIFT_NAME(layoutAlignItems);
@property (nonatomic, setter=yk_setAlignSelf:) YKAlign yk_alignSelf; @property (nonatomic, setter=yk_setAlignSelf:) YKAlign yk_alignSelf NS_SWIFT_NAME(layoutAlignSelf);
@property (nonatomic, setter=yk_setPositionType:) YKPositionType yk_positionType; @property (nonatomic, setter=yk_setPositionType:) YKPositionType yk_positionType NS_SWIFT_NAME(layoutPositionType);
@property (nonatomic, setter=yk_setFlexWrap:) YKWrap yk_flexWrap; @property (nonatomic, setter=yk_setFlexWrap:) YKWrap yk_flexWrap NS_SWIFT_NAME(layoutFlexWrap);
@property (nonatomic, setter=yk_setFlexGrow:) CGFloat yk_flexGrow; @property (nonatomic, setter=yk_setFlexGrow:) CGFloat yk_flexGrow NS_SWIFT_NAME(layoutFlexGrow);
@property (nonatomic, setter=yk_setFlexShrink:) CGFloat yk_flexShrink; @property (nonatomic, setter=yk_setFlexShrink:) CGFloat yk_flexShrink NS_SWIFT_NAME(layoutFlexShrink);
@property (nonatomic, setter=yk_setFlexBasis:) CGFloat yk_flexBasis; @property (nonatomic, setter=yk_setFlexBasis:) CGFloat yk_flexBasis NS_SWIFT_NAME(layoutFlexBasis);
- (void)yk_positionForEdge:(YKEdge)edge; - (void)yk_positionForEdge:(YKEdge)edge;
- (void)yk_setPosition:(CGFloat)position forEdge:(YKEdge)edge; - (void)yk_setPosition:(CGFloat)position forEdge:(YKEdge)edge;
@@ -42,34 +42,34 @@
- (void)yk_paddingForEdge:(YKEdge)edge; - (void)yk_paddingForEdge:(YKEdge)edge;
- (void)yk_setPadding:(CGFloat)padding forEdge:(YKEdge)edge; - (void)yk_setPadding:(CGFloat)padding forEdge:(YKEdge)edge;
@property (nonatomic, setter=yk_setWidth:) CGFloat yk_width; @property (nonatomic, setter=yk_setWidth:) CGFloat yk_width NS_SWIFT_NAME(layoutWidth);
@property (nonatomic, setter=yk_setHeight:) CGFloat yk_height; @property (nonatomic, setter=yk_setHeight:) CGFloat yk_height NS_SWIFT_NAME(layoutHeight);
@property (nonatomic, setter=yk_setMinWidth:) CGFloat yk_minWidth; @property (nonatomic, setter=yk_setMinWidth:) CGFloat yk_minWidth NS_SWIFT_NAME(layoutMinWidth);
@property (nonatomic, setter=yk_setMinHeight:) CGFloat yk_minHeight; @property (nonatomic, setter=yk_setMinHeight:) CGFloat yk_minHeight NS_SWIFT_NAME(layoutMinHeight);
@property (nonatomic, setter=yk_setMaxWidth:) CGFloat yk_maxWidth; @property (nonatomic, setter=yk_setMaxWidth:) CGFloat yk_maxWidth NS_SWIFT_NAME(layoutMaxWidth);
@property (nonatomic, setter=yk_setMaxHeight:) CGFloat yk_maxHeight; @property (nonatomic, setter=yk_setMaxHeight:) CGFloat yk_maxHeight NS_SWIFT_NAME(layoutMaxHeight);
// Yoga specific properties, not compatible with flexbox specification // Yoga specific properties, not compatible with flexbox specification
@property (nonatomic, setter=yk_setAspectRatio:) CGFloat yk_aspectRatio; @property (nonatomic, setter=yk_setAspectRatio:) CGFloat yk_aspectRatio NS_SWIFT_NAME(layoutAspectRatio);
/** /**
Get the resolved direction of this node. This won't be YGDirectionInherit Get the resolved direction of this node. This won't be YGDirectionInherit
*/ */
@property (nonatomic, readonly) CGFloat yk_resolvedDirection; @property (nonatomic, readonly) CGFloat yk_resolvedDirection NS_SWIFT_NAME(layoutResolvedDirection);
/** /**
Perform a layout calculation and update the frames of the views in the hierarchy with the results Perform a layout calculation and update the frames of the views in the hierarchy with the results
*/ */
- (void)yk_applyLayout; - (void)yk_applyLayout NS_SWIFT_NAME(applyLayout());
/** /**
Returns the size of the view if no constraints were given. This could equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)]; Returns the size of the view if no constraints were given. This could equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
*/ */
@property (nonatomic, readonly) CGSize yk_intrinsicSize; @property (nonatomic, readonly) CGSize yk_intrinsicSize NS_SWIFT_NAME(layoutIntrinsicSize);
/** /**
Returns the number of children that are using Flexbox. Returns the number of children that are using Flexbox.
*/ */
@property (nonatomic, readonly) NSUInteger yk_numberOfChildren; @property (nonatomic, readonly) NSUInteger yk_numberOfChildren NS_SWIFT_NAME(layoutNumberOfChildren);
@end @end

View File

@@ -24,6 +24,7 @@
63EE08501E06EECB00EE5F9A /* Yoga.h in Headers */ = {isa = PBXBuildFile; fileRef = 13687D631DF8778F00E7C260 /* Yoga.h */; }; 63EE08501E06EECB00EE5F9A /* Yoga.h in Headers */ = {isa = PBXBuildFile; fileRef = 13687D631DF8778F00E7C260 /* Yoga.h */; };
63EE08511E06EECB00EE5F9A /* UIView+YogaKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 13687D691DF8778F00E7C260 /* UIView+YogaKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; 63EE08511E06EECB00EE5F9A /* UIView+YogaKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 13687D691DF8778F00E7C260 /* UIView+YogaKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
63EE08531E06F3D100EE5F9A /* YKEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 63EE08521E06F3D100EE5F9A /* YKEnums.h */; settings = {ATTRIBUTES = (Public, ); }; }; 63EE08531E06F3D100EE5F9A /* YKEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 63EE08521E06F3D100EE5F9A /* YKEnums.h */; settings = {ATTRIBUTES = (Public, ); }; };
63EE08551E072EF800EE5F9A /* SwiftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63EE08541E072EF800EE5F9A /* SwiftViewController.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
@@ -72,6 +73,7 @@
63EE083F1E06ED3D00EE5F9A /* YogaKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YogaKit.h; sourceTree = "<group>"; }; 63EE083F1E06ED3D00EE5F9A /* YogaKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YogaKit.h; sourceTree = "<group>"; };
63EE08401E06ED3D00EE5F9A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 63EE08401E06ED3D00EE5F9A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
63EE08521E06F3D100EE5F9A /* YKEnums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YKEnums.h; path = ../../YKEnums.h; sourceTree = "<group>"; }; 63EE08521E06F3D100EE5F9A /* YKEnums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YKEnums.h; path = ../../YKEnums.h; sourceTree = "<group>"; };
63EE08541E072EF800EE5F9A /* SwiftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@@ -121,6 +123,7 @@
13687D4A1DF8748400E7C260 /* AppDelegate.m */, 13687D4A1DF8748400E7C260 /* AppDelegate.m */,
13687D4C1DF8748400E7C260 /* ViewController.h */, 13687D4C1DF8748400E7C260 /* ViewController.h */,
13687D4D1DF8748400E7C260 /* ViewController.m */, 13687D4D1DF8748400E7C260 /* ViewController.m */,
63EE08541E072EF800EE5F9A /* SwiftViewController.swift */,
13687D521DF8748400E7C260 /* Assets.xcassets */, 13687D521DF8748400E7C260 /* Assets.xcassets */,
13687D571DF8748400E7C260 /* Info.plist */, 13687D571DF8748400E7C260 /* Info.plist */,
13687D461DF8748400E7C260 /* Supporting Files */, 13687D461DF8748400E7C260 /* Supporting Files */,
@@ -238,6 +241,7 @@
TargetAttributes = { TargetAttributes = {
13687D421DF8748300E7C260 = { 13687D421DF8748300E7C260 = {
CreatedOnToolsVersion = 8.1; CreatedOnToolsVersion = 8.1;
LastSwiftMigration = 0820;
ProvisioningStyle = Automatic; ProvisioningStyle = Automatic;
}; };
63EE083C1E06ED3D00EE5F9A = { 63EE083C1E06ED3D00EE5F9A = {
@@ -288,6 +292,7 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
63EE08551E072EF800EE5F9A /* SwiftViewController.swift in Sources */,
13687D4E1DF8748400E7C260 /* ViewController.m in Sources */, 13687D4E1DF8748400E7C260 /* ViewController.m in Sources */,
13687D4B1DF8748400E7C260 /* AppDelegate.m in Sources */, 13687D4B1DF8748400E7C260 /* AppDelegate.m in Sources */,
13687D481DF8748400E7C260 /* main.m in Sources */, 13687D481DF8748400E7C260 /* main.m in Sources */,
@@ -409,10 +414,13 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
INFOPLIST_FILE = YogaKitSample/Info.plist; INFOPLIST_FILE = YogaKitSample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSample; PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSample;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
}; };
name = Debug; name = Debug;
}; };
@@ -420,10 +428,12 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
INFOPLIST_FILE = YogaKitSample/Info.plist; INFOPLIST_FILE = YogaKitSample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSample; PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSample;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
}; };
name = Release; name = Release;
}; };

View File

@@ -0,0 +1,41 @@
//
// SwiftViewController.swift
// YogaKit
//
// Created by David Hart on 18.12.16.
// Copyright © 2016 facebook. All rights reserved.
//
import UIKit
import YogaKit
class SwiftViewController : UIViewController {
override func viewDidLoad() {
let root = view!
root.backgroundColor = .red
root.usesYoga = true
root.layoutWidth = view.bounds.size.width
root.layoutHeight = view.bounds.size.height
root.layoutAlignItems = .center
root.layoutJustifyContent = .center
let child1 = UIView()
child1.backgroundColor = .blue
child1.usesYoga = true
child1.layoutWidth = 100
child1.layoutHeight = 100
let child2 = UIView()
child2.backgroundColor = .green
child2.frame = CGRect(origin: .zero, size: CGSize(width: 200, height: 100))
let child3 = UIView()
child3.backgroundColor = .yellow
child3.frame = CGRect(origin: .zero, size: CGSize(width: 100, height: 100))
child2.addSubview(child3)
root.addSubview(child1)
root.addSubview(child2)
root.applyLayout()
}
}

View File

@@ -10,6 +10,5 @@
@interface ViewController : UIViewController @interface ViewController : UIViewController
@end @end