Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Adding an Objective-C compatible API to LayoutKit #180

Merged
merged 26 commits into from Feb 15, 2018
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0913e65
Starting Objective-C sample app.
Jan 27, 2018
41386cb
Starting Layout/Measurement/Arrangement wrappers
Jan 28, 2018
4ea1c02
LabelLayout and InsetLayout
Jan 29, 2018
6872aa3
Fleshing out label and inset layouts a bit.
Jan 29, 2018
43bf916
Sample code illustrating usage of custom view classes.
Jan 29, 2018
e3a9769
Fixing nested wrap/unwrap classes.
Jan 29, 2018
8626593
Demonstrating ObjC custom layout.
Jan 29, 2018
ca11db5
Adding LOKSizeLayout
Jan 30, 2018
e5c2d5a
Starting LOKStackLayout
Feb 4, 2018
d58bb7f
Fleshing out LOKStackLayout
Feb 4, 2018
b54c3d6
LOKAxis becomes an enum
Feb 4, 2018
7a89619
LOKStackLayoutDistribution becomes an enum
Feb 4, 2018
8d5ad9e
Adding LOKReloadableViewLayoutAdapter and moving the sample RotationL…
Feb 8, 2018
482493c
Making some parameters optional, since ObjC doesn’t have strong nil c…
Feb 9, 2018
0a1fb6e
Adding LOKButtonLayout
Feb 9, 2018
3567629
Adding LOKOverlayLayout
Feb 12, 2018
124f221
Making OverlayLayout helper initializer internal
Feb 12, 2018
40a64dc
Adding LOKTextViewLayout
Feb 12, 2018
a0cd150
Removing @objc visibility for one of the enums.
Feb 13, 2018
ff5383d
Styling fixes as per review comments.
Feb 13, 2018
bd95914
Adding LayoutKitObjC.podspec
Feb 13, 2018
3b37f5e
Moving two files to Internal folder.
Feb 14, 2018
a107226
Merge branch 'master' into objc-api
Feb 15, 2018
f95d17a
Adding support for new lineHeight parameter
Feb 15, 2018
a82cbab
Making the LOKLayout.configureView protocol method optional.
Feb 15, 2018
c08e051
Updating the podspec after the creation of a nested directory.
Feb 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions LayoutKit.podspec
Expand Up @@ -11,7 +11,10 @@ Pod::Spec.new do |spec|

spec.ios.deployment_target = '8.0'
spec.ios.frameworks = 'Foundation', 'CoreGraphics', 'UIKit'
spec.ios.exclude_files = 'Sources/AppKitSupport.swift'
spec.ios.exclude_files = [
'Sources/AppKitSupport.swift',
'Sources/ObjCSupport/**'
]

spec.osx.deployment_target = '10.9'
spec.osx.frameworks = 'Foundation', 'CoreGraphics', 'AppKit'
Expand All @@ -22,14 +25,18 @@ Pod::Spec.new do |spec|
'Sources/Layouts/ButtonLayout.swift',
'Sources/Layouts/LabelLayout.swift',
'Sources/Layouts/TextViewLayout.swift',
'Sources/ObjCSupport/**',
'Sources/Text.swift',
'Sources/UIKitSupport.swift',
'Sources/Views/**'
]

spec.tvos.deployment_target = '9.0'
spec.tvos.frameworks = 'Foundation', 'CoreGraphics', 'UIKit'
spec.tvos.exclude_files = 'Sources/AppKitSupport.swift'
spec.tvos.exclude_files = [
'Sources/AppKitSupport.swift',
'Sources/ObjCSupport/**'
]

end

268 changes: 268 additions & 0 deletions LayoutKit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions LayoutKitObjC.podspec
@@ -0,0 +1,47 @@
Pod::Spec.new do |spec|
spec.name = 'LayoutKitObjC'
spec.version = '6.0.1'
spec.license = { :type => 'Apache License, Version 2.0' }
spec.homepage = 'http://layoutkit.org'
spec.authors = 'LinkedIn'
spec.summary = 'LayoutKit is a fast view layout library for iOS, macOS, and tvOS. Now with Objective-C support.'
spec.source = { :git => 'https://github.com/linkedin/LayoutKit.git', :tag => spec.version }
spec.source_files = 'Sources/**/*.swift'
spec.documentation_url = 'http://layoutkit.org'

spec.ios.deployment_target = '8.0'
spec.ios.frameworks = 'Foundation', 'CoreGraphics', 'UIKit'
spec.ios.exclude_files = 'Sources/AppKitSupport.swift'

spec.osx.deployment_target = '10.9'
spec.osx.frameworks = 'Foundation', 'CoreGraphics', 'AppKit'
spec.osx.exclude_files = [
'Sources/Internal/CGFloatExtension.swift',
'Sources/Internal/TextViewDefaultFont.swift',
'Sources/Internal/NSAttributedStringExtension.swift',
'Sources/Layouts/ButtonLayout.swift',
'Sources/Layouts/LabelLayout.swift',
'Sources/Layouts/TextViewLayout.swift',
'Sources/ObjCSupport/LOKButtonLayout.swift',
'Sources/ObjCSupport/LOKButtonLayoutType.swift',
'Sources/ObjCSupport/LOKLabelLayout.swift',
'Sources/ObjCSupport/LOKLayoutArrangementSection.swift',
'Sources/ObjCSupport/LOKLayoutSection.swift',
'Sources/ObjCSupport/LOKReloadableViewLayoutAdapter.swift',
'Sources/ObjCSupport/LOKTextViewLayout.swift',
'Sources/Text.swift',
'Sources/UIKitSupport.swift',
'Sources/Views/**'
]

spec.tvos.deployment_target = '9.0'
spec.tvos.frameworks = 'Foundation', 'CoreGraphics', 'UIKit'
spec.tvos.exclude_files = [
'Sources/AppKitSupport.swift',

# Excluded due to "'systemFontSize' is unavailable"
'Sources/ObjCSupport/LOKLabelLayout.swift'
]

end

17 changes: 17 additions & 0 deletions LayoutKitObjCSampleApp/AppDelegate.h
@@ -0,0 +1,17 @@
// Copyright 2018 LinkedIn Corp.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (nonatomic, strong) UIWindow *window;


@end

58 changes: 58 additions & 0 deletions LayoutKitObjCSampleApp/AppDelegate.m
@@ -0,0 +1,58 @@
// Copyright 2018 LinkedIn Corp.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.


#import "AppDelegate.h"
#import "ViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
ViewController *viewController = [[ViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}


- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


@end
@@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
43 changes: 43 additions & 0 deletions LayoutKitObjCSampleApp/Info.plist
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>Launch Screen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
29 changes: 29 additions & 0 deletions LayoutKitObjCSampleApp/Launch Screen.storyboard
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
23 changes: 23 additions & 0 deletions LayoutKitObjCSampleApp/RotationLayout.h
@@ -0,0 +1,23 @@
// Copyright 2018 LinkedIn Corp.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

#import <UIKit/UIKit.h>
#import <LayoutKit/LayoutKit-Swift.h>

@interface RotationLayout: NSObject <LOKLayout>

@property (nonatomic, nonnull, readonly) id<LOKLayout> sublayout;
@property (nonatomic, nonnull, readonly) LOKAlignment *alignment;
@property (nonatomic, nonnull, readonly) LOKFlexibility *flexibility;
@property (nonatomic, copy, nullable, readonly) NSString *viewReuseId;
@property (nonatomic, readonly) BOOL needsView;

- (nonnull instancetype)initWithSublayout:(nonnull id<LOKLayout>)sublayout alignment:(nullable LOKAlignment *)alignment viewReuseId:(nullable NSString *)viewReuseId;

@end