diff --git a/examples/LayoutSpecExamples/Podfile b/examples/LayoutSpecExamples/Podfile new file mode 100644 index 0000000000..5c30ce798e --- /dev/null +++ b/examples/LayoutSpecExamples/Podfile @@ -0,0 +1,6 @@ +source 'https://github.com/CocoaPods/Specs.git' +platform :ios, '7.0' +target 'Sample' do + pod 'AsyncDisplayKit', :path => '../..' +end + diff --git a/examples/LayoutSpecExamples/Sample.xcodeproj/project.pbxproj b/examples/LayoutSpecExamples/Sample.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..076d8ed2d4 --- /dev/null +++ b/examples/LayoutSpecExamples/Sample.xcodeproj/project.pbxproj @@ -0,0 +1,391 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 694993D21C8B334F00491CA5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 694993D11C8B334F00491CA5 /* main.m */; }; + 694993D51C8B334F00491CA5 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 694993D41C8B334F00491CA5 /* AppDelegate.m */; }; + 694993D81C8B334F00491CA5 /* OverviewViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 694993D71C8B334F00491CA5 /* OverviewViewController.m */; }; + 694993E01C8B334F00491CA5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 694993DE1C8B334F00491CA5 /* LaunchScreen.storyboard */; }; + 77E904A7F1CA1E967CBECF1B /* libPods-Sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 19C07F7EA804F418514FC00F /* libPods-Sample.a */; }; + 8032A2FC1DCD07580083C469 /* Utilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 8032A2FB1DCD07580083C469 /* Utilities.m */; }; + 8032A2FF1DCD076E0083C469 /* LayoutExampleNodes.m in Sources */ = {isa = PBXBuildFile; fileRef = 8032A2FE1DCD076E0083C469 /* LayoutExampleNodes.m */; }; + 8092664B1DCD9CE1008373C2 /* OverviewCellNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8092664A1DCD9CE1008373C2 /* OverviewCellNode.m */; }; + 8092664E1DCDA64A008373C2 /* LayoutExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8092664D1DCDA64A008373C2 /* LayoutExampleViewController.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 19C07F7EA804F418514FC00F /* libPods-Sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 49ABEBD1ABCEC54CD6585C1B /* Pods-Sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.release.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig"; sourceTree = ""; }; + 694993CD1C8B334F00491CA5 /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 694993D11C8B334F00491CA5 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 694993D31C8B334F00491CA5 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 694993D41C8B334F00491CA5 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 694993D61C8B334F00491CA5 /* OverviewViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OverviewViewController.h; sourceTree = ""; }; + 694993D71C8B334F00491CA5 /* OverviewViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OverviewViewController.m; sourceTree = ""; }; + 694993DF1C8B334F00491CA5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 694993E11C8B334F00491CA5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 8032A2FA1DCD07580083C469 /* Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utilities.h; sourceTree = ""; }; + 8032A2FB1DCD07580083C469 /* Utilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Utilities.m; sourceTree = ""; }; + 8032A2FD1DCD076E0083C469 /* LayoutExampleNodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutExampleNodes.h; sourceTree = ""; }; + 8032A2FE1DCD076E0083C469 /* LayoutExampleNodes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LayoutExampleNodes.m; sourceTree = ""; }; + 809266491DCD9CE1008373C2 /* OverviewCellNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverviewCellNode.h; sourceTree = ""; }; + 8092664A1DCD9CE1008373C2 /* OverviewCellNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OverviewCellNode.m; sourceTree = ""; }; + 8092664C1DCDA64A008373C2 /* LayoutExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutExampleViewController.h; sourceTree = ""; }; + 8092664D1DCDA64A008373C2 /* LayoutExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LayoutExampleViewController.m; sourceTree = ""; }; + C2FE4C0B2EE2F08E2186823E /* Pods-Sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.debug.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 694993CA1C8B334F00491CA5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 77E904A7F1CA1E967CBECF1B /* libPods-Sample.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 694993C41C8B334F00491CA5 = { + isa = PBXGroup; + children = ( + 694993CF1C8B334F00491CA5 /* Sample */, + 694993CE1C8B334F00491CA5 /* Products */, + B4D85F4D35E1EEC1C00CAFE8 /* Pods */, + E5CE41038A61211B6B519735 /* Frameworks */, + ); + sourceTree = ""; + }; + 694993CE1C8B334F00491CA5 /* Products */ = { + isa = PBXGroup; + children = ( + 694993CD1C8B334F00491CA5 /* Sample.app */, + ); + name = Products; + sourceTree = ""; + }; + 694993CF1C8B334F00491CA5 /* Sample */ = { + isa = PBXGroup; + children = ( + 694993D31C8B334F00491CA5 /* AppDelegate.h */, + 694993D41C8B334F00491CA5 /* AppDelegate.m */, + 694993D61C8B334F00491CA5 /* OverviewViewController.h */, + 694993D71C8B334F00491CA5 /* OverviewViewController.m */, + 809266491DCD9CE1008373C2 /* OverviewCellNode.h */, + 8092664A1DCD9CE1008373C2 /* OverviewCellNode.m */, + 8092664C1DCDA64A008373C2 /* LayoutExampleViewController.h */, + 8092664D1DCDA64A008373C2 /* LayoutExampleViewController.m */, + 8032A2FD1DCD076E0083C469 /* LayoutExampleNodes.h */, + 8032A2FE1DCD076E0083C469 /* LayoutExampleNodes.m */, + 8032A2FA1DCD07580083C469 /* Utilities.h */, + 8032A2FB1DCD07580083C469 /* Utilities.m */, + 694993D01C8B334F00491CA5 /* Supporting Files */, + ); + path = Sample; + sourceTree = ""; + }; + 694993D01C8B334F00491CA5 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 694993E11C8B334F00491CA5 /* Info.plist */, + 694993DE1C8B334F00491CA5 /* LaunchScreen.storyboard */, + 694993D11C8B334F00491CA5 /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + B4D85F4D35E1EEC1C00CAFE8 /* Pods */ = { + isa = PBXGroup; + children = ( + C2FE4C0B2EE2F08E2186823E /* Pods-Sample.debug.xcconfig */, + 49ABEBD1ABCEC54CD6585C1B /* Pods-Sample.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + E5CE41038A61211B6B519735 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 19C07F7EA804F418514FC00F /* libPods-Sample.a */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 694993CC1C8B334F00491CA5 /* Sample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 694993E41C8B334F00491CA5 /* Build configuration list for PBXNativeTarget "Sample" */; + buildPhases = ( + 339DA21AF893915BAA46F6A1 /* [CP] Check Pods Manifest.lock */, + 694993C91C8B334F00491CA5 /* Sources */, + 694993CA1C8B334F00491CA5 /* Frameworks */, + 694993CB1C8B334F00491CA5 /* Resources */, + 06EE2E0ABEB6289D4775A867 /* [CP] Copy Pods Resources */, + 23FC03B282CBD9014D868DF6 /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Sample; + productName = Sample; + productReference = 694993CD1C8B334F00491CA5 /* Sample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 694993C51C8B334F00491CA5 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0720; + ORGANIZATIONNAME = AsyncDisplayKit; + TargetAttributes = { + 694993CC1C8B334F00491CA5 = { + CreatedOnToolsVersion = 7.2.1; + }; + }; + }; + buildConfigurationList = 694993C81C8B334F00491CA5 /* Build configuration list for PBXProject "Sample" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 694993C41C8B334F00491CA5; + productRefGroup = 694993CE1C8B334F00491CA5 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 694993CC1C8B334F00491CA5 /* Sample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 694993CB1C8B334F00491CA5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 694993E01C8B334F00491CA5 /* LaunchScreen.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 06EE2E0ABEB6289D4775A867 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 23FC03B282CBD9014D868DF6 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 339DA21AF893915BAA46F6A1 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 694993C91C8B334F00491CA5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8092664B1DCD9CE1008373C2 /* OverviewCellNode.m in Sources */, + 694993D81C8B334F00491CA5 /* OverviewViewController.m in Sources */, + 694993D51C8B334F00491CA5 /* AppDelegate.m in Sources */, + 694993D21C8B334F00491CA5 /* main.m in Sources */, + 8032A2FF1DCD076E0083C469 /* LayoutExampleNodes.m in Sources */, + 8032A2FC1DCD07580083C469 /* Utilities.m in Sources */, + 8092664E1DCDA64A008373C2 /* LayoutExampleViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 694993DE1C8B334F00491CA5 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 694993DF1C8B334F00491CA5 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 694993E21C8B334F00491CA5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 694993E31C8B334F00491CA5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 694993E51C8B334F00491CA5 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = C2FE4C0B2EE2F08E2186823E /* Pods-Sample.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = Sample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = org.AsyncDisplayKit.Sample; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 694993E61C8B334F00491CA5 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 49ABEBD1ABCEC54CD6585C1B /* Pods-Sample.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = Sample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = org.AsyncDisplayKit.Sample; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 694993C81C8B334F00491CA5 /* Build configuration list for PBXProject "Sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 694993E21C8B334F00491CA5 /* Debug */, + 694993E31C8B334F00491CA5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 694993E41C8B334F00491CA5 /* Build configuration list for PBXNativeTarget "Sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 694993E51C8B334F00491CA5 /* Debug */, + 694993E61C8B334F00491CA5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 694993C51C8B334F00491CA5 /* Project object */; +} diff --git a/examples/LayoutSpecExamples/Sample.xcodeproj/xcshareddata/xcschemes/Sample.xcscheme b/examples/LayoutSpecExamples/Sample.xcodeproj/xcshareddata/xcschemes/Sample.xcscheme new file mode 100644 index 0000000000..10e9c51e22 --- /dev/null +++ b/examples/LayoutSpecExamples/Sample.xcodeproj/xcshareddata/xcschemes/Sample.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/LayoutSpecExamples/Sample/AppDelegate.h b/examples/LayoutSpecExamples/Sample/AppDelegate.h new file mode 100644 index 0000000000..32777218dd --- /dev/null +++ b/examples/LayoutSpecExamples/Sample/AppDelegate.h @@ -0,0 +1,16 @@ +// +// AppDelegate.h +// Sample +// +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. +// + +#import + +@interface AppDelegate : UIResponder +@property (strong, nonatomic) UIWindow *window; +@end + diff --git a/examples/LayoutSpecExamples/Sample/AppDelegate.m b/examples/LayoutSpecExamples/Sample/AppDelegate.m new file mode 100644 index 0000000000..88772c00d2 --- /dev/null +++ b/examples/LayoutSpecExamples/Sample/AppDelegate.m @@ -0,0 +1,30 @@ +// +// AppDelegate.m +// Sample +// +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. +// + +#import "AppDelegate.h" +#import "OverviewViewController.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + self.window.backgroundColor = [UIColor whiteColor]; + self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[OverviewViewController new]]; + [self.window makeKeyAndVisible]; + + [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:47/255.0 green:184/255.0 blue:253/255.0 alpha:1.0]]; + [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; + [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];; + + return YES; +} + +@end diff --git a/examples/LayoutSpecExamples/Sample/Base.lproj/LaunchScreen.storyboard b/examples/LayoutSpecExamples/Sample/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000000..f4fc7f7736 --- /dev/null +++ b/examples/LayoutSpecExamples/Sample/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/LayoutSpecExamples/Sample/Info.plist b/examples/LayoutSpecExamples/Sample/Info.plist new file mode 100644 index 0000000000..6105445463 --- /dev/null +++ b/examples/LayoutSpecExamples/Sample/Info.plist @@ -0,0 +1,43 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/examples/LayoutSpecExamples/Sample/LayoutExampleNodes.h b/examples/LayoutSpecExamples/Sample/LayoutExampleNodes.h new file mode 100644 index 0000000000..65da5f5475 --- /dev/null +++ b/examples/LayoutSpecExamples/Sample/LayoutExampleNodes.h @@ -0,0 +1,28 @@ +// +// LayoutExampleNodes.h +// Sample +// +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. +// + +#import + +@interface LayoutExampleNode : ASDisplayNode ++ (NSString *)title; ++ (NSString *)descriptionTitle; +@end + +@interface HeaderWithRightAndLeftItems : LayoutExampleNode +@end + +@interface PhotoWithInsetTextOverlay : LayoutExampleNode +@end + +@interface PhotoWithOutsetIconOverlay : LayoutExampleNode +@end + +@interface FlexibleSeparatorSurroundingContent : LayoutExampleNode +@end diff --git a/examples/LayoutSpecExamples/Sample/LayoutExampleNodes.m b/examples/LayoutSpecExamples/Sample/LayoutExampleNodes.m new file mode 100644 index 0000000000..5880d3e80e --- /dev/null +++ b/examples/LayoutSpecExamples/Sample/LayoutExampleNodes.m @@ -0,0 +1,256 @@ +// +// LayoutExampleNodes.m +// Sample +// +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. +// + +#import "LayoutExampleNodes.h" +#import "Utilities.h" +#import "UIImage+ASConvenience.h" + +@interface HeaderWithRightAndLeftItems () +@property (nonatomic, strong) ASTextNode *usernameNode; +@property (nonatomic, strong) ASTextNode *postLocationNode; +@property (nonatomic, strong) ASTextNode *postTimeNode; +@end + +@interface PhotoWithInsetTextOverlay () +@property (nonatomic, strong) ASNetworkImageNode *photoNode; +@property (nonatomic, strong) ASTextNode *titleNode; +@end + +@interface PhotoWithOutsetIconOverlay () +@property (nonatomic, strong) ASNetworkImageNode *photoNode; +@property (nonatomic, strong) ASNetworkImageNode *iconNode; +@end + +@interface FlexibleSeparatorSurroundingContent () +@property (nonatomic, strong) ASImageNode *topSeparator; +@property (nonatomic, strong) ASImageNode *bottomSeparator; +@property (nonatomic, strong) ASTextNode *textNode; +@end + +@implementation HeaderWithRightAndLeftItems + ++ (NSString *)title +{ + return @"Header with left and right justified text"; +} + ++ (NSString *)descriptionTitle +{ + return @"try rotating me!"; +} + +- (instancetype)init +{ + self = [super init]; + + if (self) { + _usernameNode = [[ASTextNode alloc] init]; + _usernameNode.attributedText = [NSAttributedString attributedStringWithString:@"hannahmbanana" + fontSize:20 + color:[UIColor darkBlueColor]]; + _usernameNode.maximumNumberOfLines = 1; + _usernameNode.truncationMode = NSLineBreakByTruncatingTail; + + _postLocationNode = [[ASTextNode alloc] init]; + _postLocationNode.maximumNumberOfLines = 1; + _postLocationNode.attributedText = [NSAttributedString attributedStringWithString:@"Sunset Beach, San Fransisco, CA" + fontSize:20 + color:[UIColor lightBlueColor]]; + _postLocationNode.maximumNumberOfLines = 1; + _postLocationNode.truncationMode = NSLineBreakByTruncatingTail; + + _postTimeNode = [[ASTextNode alloc] init]; + _postTimeNode.attributedText = [NSAttributedString attributedStringWithString:@"30m" + fontSize:20 + color:[UIColor lightGrayColor]]; + _postLocationNode.maximumNumberOfLines = 1; + _postLocationNode.truncationMode = NSLineBreakByTruncatingTail; + } + + return self; +} + +@end + + +@implementation PhotoWithInsetTextOverlay + ++ (NSString *)title +{ + return @"Photo with inset text overlay"; +} + ++ (NSString *)descriptionTitle +{ + return @"try rotating me!"; +} + +- (instancetype)init +{ + self = [super init]; + + if (self) { + self.backgroundColor = [UIColor clearColor]; + + _photoNode = [[ASNetworkImageNode alloc] init]; + _photoNode.URL = [NSURL URLWithString:@"http://asyncdisplaykit.org/static/images/layout-examples-photo-with-inset-text-overlay-photo.png"]; + _photoNode.willDisplayNodeContentWithRenderingContext = ^(CGContextRef context) { + CGRect bounds = CGContextGetClipBoundingBox(context); + [[UIBezierPath bezierPathWithRoundedRect:bounds cornerRadius:10] addClip]; + }; + + _titleNode = [[ASTextNode alloc] init]; + _titleNode.maximumNumberOfLines = 2; + _titleNode.truncationMode = NSLineBreakByTruncatingTail; + _titleNode.truncationAttributedText = [NSAttributedString attributedStringWithString:@"..." fontSize:16 color:[UIColor whiteColor]]; + _titleNode.attributedText = [NSAttributedString attributedStringWithString:@"family fall hikes" fontSize:16 color:[UIColor whiteColor]]; + } + + return self; +} + +- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize +{ + CGFloat photoDimension = constrainedSize.max.width / 4.0; + _photoNode.style.preferredSize = CGSizeMake(photoDimension, photoDimension); + + // INFINITY is used to make the inset unbounded + UIEdgeInsets insets = UIEdgeInsetsMake(INFINITY, 12, 12, 12); + ASInsetLayoutSpec *textInsetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:_titleNode]; + + return [ASOverlayLayoutSpec overlayLayoutSpecWithChild:_photoNode overlay:textInsetSpec];; +} + +@end + + +@implementation PhotoWithOutsetIconOverlay + ++ (NSString *)title +{ + return @"Photo with outset icon overlay"; +} + +- (instancetype)init +{ + self = [super init]; + + if (self) { + _photoNode = [[ASNetworkImageNode alloc] init]; + _photoNode.URL = [NSURL URLWithString:@"http://asyncdisplaykit.org/static/images/layout-examples-photo-with-outset-icon-overlay-photo.png"]; + + _iconNode = [[ASNetworkImageNode alloc] init]; + _iconNode.URL = [NSURL URLWithString:@"http://asyncdisplaykit.org/static/images/layout-examples-photo-with-outset-icon-overlay-icon.png"]; + + [_iconNode setImageModificationBlock:^UIImage *(UIImage *image) { // FIXME: in framework autocomplete for setImageModificationBlock line seems broken + CGSize profileImageSize = CGSizeMake(60, 60); + return [image makeCircularImageWithSize:profileImageSize withBorderWidth:10]; + }]; + } + + return self; +} + +- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize +{ + _iconNode.style.preferredSize = CGSizeMake(40, 40); + _iconNode.style.layoutPosition = CGPointMake(150, 0); + + _photoNode.style.preferredSize = CGSizeMake(150, 150); + _photoNode.style.layoutPosition = CGPointMake(40 / 2.0, 40 / 2.0); + + ASAbsoluteLayoutSpec *absoluteSpec = [ASAbsoluteLayoutSpec absoluteLayoutSpecWithChildren:@[_photoNode, _iconNode]]; + + // ASAbsoluteLayoutSpec's .sizing property recreates the behavior of ASDK Layout API 1.0's "ASStaticLayoutSpec" + absoluteSpec.sizing = ASAbsoluteLayoutSpecSizingSizeToFit; + + return absoluteSpec; +} + + + +@end + + +@implementation FlexibleSeparatorSurroundingContent + ++ (NSString *)title +{ + return @"Top and bottom cell separator lines"; +} + ++ (NSString *)descriptionTitle +{ + return @"try rotating me!"; +} + +- (instancetype)init +{ + self = [super init]; + + if (self) { + self.backgroundColor = [UIColor whiteColor]; + + _topSeparator = [[ASImageNode alloc] init]; + _topSeparator.image = [UIImage as_resizableRoundedImageWithCornerRadius:1.0 cornerColor:[UIColor blackColor] fillColor:[UIColor blackColor]]; + + _textNode = [[ASTextNode alloc] init]; + _textNode.attributedText = [NSAttributedString attributedStringWithString:@"this is a long text node" + fontSize:16 + color:[UIColor blackColor]]; + + _bottomSeparator = [[ASImageNode alloc] init]; + _bottomSeparator.image = [UIImage as_resizableRoundedImageWithCornerRadius:1.0 cornerColor:[UIColor blackColor] fillColor:[UIColor blackColor]]; + } + + return self; +} + +- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize +{ + _topSeparator.style.flexGrow = 1.0; + _bottomSeparator.style.flexGrow = 1.0; + _textNode.style.alignSelf = ASStackLayoutAlignSelfCenter; + + ASStackLayoutSpec *verticalStackSpec = [ASStackLayoutSpec verticalStackLayoutSpec]; + verticalStackSpec.spacing = 20; + verticalStackSpec.justifyContent = ASStackLayoutJustifyContentCenter; + verticalStackSpec.children = @[_topSeparator, _textNode, _bottomSeparator]; + + return [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(60, 0, 60, 0) child:verticalStackSpec]; +} + +@end + +@implementation LayoutExampleNode + ++ (NSString *)title +{ + NSAssert(NO, @"All layout example nodes must provide a title!"); + return nil; +} + ++ (NSString *)descriptionTitle +{ + return nil; +} + +- (instancetype)init +{ + self = [super init]; + if (self) { + self.automaticallyManagesSubnodes = YES; + self.backgroundColor = [UIColor whiteColor]; + } + return self; +} + +@end + diff --git a/examples/LayoutSpecExamples/Sample/LayoutExampleViewController.h b/examples/LayoutSpecExamples/Sample/LayoutExampleViewController.h new file mode 100644 index 0000000000..6426a8d8a2 --- /dev/null +++ b/examples/LayoutSpecExamples/Sample/LayoutExampleViewController.h @@ -0,0 +1,16 @@ +// +// LayoutExampleViewController.h +// Sample +// +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. +// + +#import + +@interface LayoutExampleViewController : ASViewController +- (instancetype)initWithLayoutExampleClass:(Class)layoutExampleClass NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithNode:(ASDisplayNode *)node NS_UNAVAILABLE; +@end diff --git a/examples/LayoutSpecExamples/Sample/LayoutExampleViewController.m b/examples/LayoutSpecExamples/Sample/LayoutExampleViewController.m new file mode 100644 index 0000000000..cc3cddc3cb --- /dev/null +++ b/examples/LayoutSpecExamples/Sample/LayoutExampleViewController.m @@ -0,0 +1,48 @@ +// +// LayoutExampleViewController.m +// Sample +// +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. +// + +#import "LayoutExampleViewController.h" +#import "LayoutExampleNodes.h" + +@interface LayoutExampleViewController () +@property (nonatomic, strong) LayoutExampleNode *customNode; +@end + +@implementation LayoutExampleViewController + +- (instancetype)initWithLayoutExampleClass:(Class)layoutExampleClass +{ + NSAssert([layoutExampleClass isSubclassOfClass:[LayoutExampleNode class]], @"Must pass a subclass of LayoutExampleNode."); + + self = [super initWithNode:[ASDisplayNode new]]; + + if (self) { + self.title = @"Layout Example"; + + _customNode = [layoutExampleClass new]; + [self.node addSubnode:_customNode]; + + BOOL needsOnlyYCentering = [layoutExampleClass isEqual:[HeaderWithRightAndLeftItems class]] || + [layoutExampleClass isEqual:[FlexibleSeparatorSurroundingContent class]]; + + self.node.backgroundColor = needsOnlyYCentering ? [UIColor lightGrayColor] : [UIColor whiteColor]; + + __weak __typeof(self) weakself = self; + self.node.layoutSpecBlock = ^ASLayoutSpec*(__kindof ASDisplayNode * _Nonnull node, ASSizeRange constrainedSize) { + return [ASCenterLayoutSpec centerLayoutSpecWithCenteringOptions:needsOnlyYCentering ? ASCenterLayoutSpecCenteringY : ASCenterLayoutSpecCenteringXY + sizingOptions:ASCenterLayoutSpecSizingOptionMinimumXY + child:weakself.customNode]; + }; + } + + return self; +} + +@end diff --git a/examples/LayoutSpecExamples/Sample/OverviewCellNode.h b/examples/LayoutSpecExamples/Sample/OverviewCellNode.h new file mode 100644 index 0000000000..28926d294a --- /dev/null +++ b/examples/LayoutSpecExamples/Sample/OverviewCellNode.h @@ -0,0 +1,20 @@ +// +// OverviewCellNode.h +// Sample +// +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. +// + +#import + +@interface OverviewCellNode : ASCellNode + +@property (nonatomic, strong) Class layoutExampleClass; + +- (instancetype)initWithLayoutExampleClass:(Class)layoutExampleClass NS_DESIGNATED_INITIALIZER; +- (instancetype)init NS_UNAVAILABLE; + +@end diff --git a/examples/LayoutSpecExamples/Sample/OverviewCellNode.m b/examples/LayoutSpecExamples/Sample/OverviewCellNode.m new file mode 100644 index 0000000000..bab20e61d3 --- /dev/null +++ b/examples/LayoutSpecExamples/Sample/OverviewCellNode.m @@ -0,0 +1,53 @@ +// +// OverviewCellNode.m +// Sample +// +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. +// + +#import "OverviewCellNode.h" +#import "LayoutExampleNodes.h" +#import "Utilities.h" + +@interface OverviewCellNode () +@property (nonatomic, strong) ASTextNode *titleNode; +@property (nonatomic, strong) ASTextNode *descriptionNode; +@end + +@implementation OverviewCellNode + +- (instancetype)initWithLayoutExampleClass:(Class)layoutExampleClass +{ + self = [super init]; + if (self) { + self.automaticallyManagesSubnodes = YES; + + _layoutExampleClass = layoutExampleClass; + + _titleNode = [[ASTextNode alloc] init]; + _titleNode.attributedText = [NSAttributedString attributedStringWithString:[layoutExampleClass title] + fontSize:16 + color:[UIColor blackColor]]; + + _descriptionNode = [[ASTextNode alloc] init]; + _descriptionNode.attributedText = [NSAttributedString attributedStringWithString:[layoutExampleClass descriptionTitle] + fontSize:12 + color:[UIColor lightGrayColor]]; + } + return self; +} + +- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize +{ + ASStackLayoutSpec *verticalStackSpec = [ASStackLayoutSpec verticalStackLayoutSpec]; + verticalStackSpec.alignItems = ASStackLayoutAlignItemsStart; + verticalStackSpec.spacing = 5.0; + verticalStackSpec.children = @[self.titleNode, self.descriptionNode]; + + return [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(10, 16, 10, 10) child:verticalStackSpec]; +} + +@end diff --git a/examples/LayoutSpecExamples/Sample/OverviewViewController.h b/examples/LayoutSpecExamples/Sample/OverviewViewController.h new file mode 100644 index 0000000000..c05e4fd7a2 --- /dev/null +++ b/examples/LayoutSpecExamples/Sample/OverviewViewController.h @@ -0,0 +1,16 @@ +// +// OverviewViewController.h +// Sample +// +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. +// + +#import + + +@interface OverviewViewController : ASViewController + +@end diff --git a/examples/LayoutSpecExamples/Sample/OverviewViewController.m b/examples/LayoutSpecExamples/Sample/OverviewViewController.m new file mode 100644 index 0000000000..e3f44dfb06 --- /dev/null +++ b/examples/LayoutSpecExamples/Sample/OverviewViewController.m @@ -0,0 +1,75 @@ +// +// OverviewViewController.m +// Sample +// +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. +// + +#import "OverviewViewController.h" +#import "LayoutExampleNodes.h" +#import "LayoutExampleViewController.h" +#import "OverviewCellNode.h" + +@interface OverviewViewController () +@property (nonatomic, strong) NSArray *layoutExamples; +@property (nonatomic, strong) ASTableNode *tableNode; +@end + +@implementation OverviewViewController + +#pragma mark - Lifecycle Methods + +- (instancetype)init +{ + _tableNode = [ASTableNode new]; + self = [super initWithNode:_tableNode]; + + if (self) { + self.title = @"Layout Examples"; + self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; + + _tableNode.delegate = self; + _tableNode.dataSource = self; + + _layoutExamples = @[[HeaderWithRightAndLeftItems class], + [PhotoWithInsetTextOverlay class], + [PhotoWithOutsetIconOverlay class], + [FlexibleSeparatorSurroundingContent class]]; + } + + return self; +} + +- (void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + + NSIndexPath *indexPath = _tableNode.indexPathForSelectedRow; + if (indexPath != nil) { + [_tableNode deselectRowAtIndexPath:indexPath animated:YES]; + } +} + +#pragma mark - ASTableDelegate, ASTableDataSource + +- (NSInteger)tableNode:(ASTableNode *)tableNode numberOfRowsInSection:(NSInteger)section +{ + return [_layoutExamples count]; +} + +- (ASCellNode *)tableNode:(ASTableNode *)tableNode nodeForRowAtIndexPath:(NSIndexPath *)indexPath +{ + return [[OverviewCellNode alloc] initWithLayoutExampleClass:_layoutExamples[indexPath.row]]; +} + +- (void)tableNode:(ASTableNode *)tableNode didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + Class layoutExampleClass = [[tableNode nodeForRowAtIndexPath:indexPath] layoutExampleClass]; + LayoutExampleViewController *detail = [[LayoutExampleViewController alloc] initWithLayoutExampleClass:layoutExampleClass]; + [self.navigationController pushViewController:detail animated:YES]; +} + +@end diff --git a/examples/LayoutSpecExamples/Sample/Utilities.h b/examples/LayoutSpecExamples/Sample/Utilities.h new file mode 100644 index 0000000000..0fcb0ece91 --- /dev/null +++ b/examples/LayoutSpecExamples/Sample/Utilities.h @@ -0,0 +1,25 @@ +// +// Utilities.h +// Sample +// +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. +// + +#import +#import + +@interface UIColor (Additions) ++ (UIColor *)darkBlueColor; ++ (UIColor *)lightBlueColor; +@end + +@interface UIImage (Additions) +- (UIImage *)makeCircularImageWithSize:(CGSize)size withBorderWidth:(CGFloat)width; +@end + +@interface NSAttributedString (Additions) ++ (NSAttributedString *)attributedStringWithString:(NSString *)string fontSize:(CGFloat)size color:(UIColor *)color; +@end diff --git a/examples/LayoutSpecExamples/Sample/Utilities.m b/examples/LayoutSpecExamples/Sample/Utilities.m new file mode 100644 index 0000000000..74b4ae87a6 --- /dev/null +++ b/examples/LayoutSpecExamples/Sample/Utilities.m @@ -0,0 +1,85 @@ +// +// Utilities.m +// Sample +// +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. +// + +#import "Utilities.h" + +#define StrokeRoundedImages 0 + +@implementation UIColor (Additions) + ++ (UIColor *)darkBlueColor +{ + return [UIColor colorWithRed:18.0/255.0 green:86.0/255.0 blue:136.0/255.0 alpha:1.0]; +} + ++ (UIColor *)lightBlueColor +{ + return [UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0]; +} + +@end + +@implementation UIImage (Additions) + +- (UIImage *)makeCircularImageWithSize:(CGSize)size withBorderWidth:(CGFloat)width +{ + // make a CGRect with the image's size + CGRect circleRect = (CGRect) {CGPointZero, size}; + + // begin the image context since we're not in a drawRect: + UIGraphicsBeginImageContextWithOptions(circleRect.size, NO, 0); + + // create a UIBezierPath circle + UIBezierPath *circle = [UIBezierPath bezierPathWithRoundedRect:circleRect cornerRadius:circleRect.size.width/2]; + + // clip to the circle + [circle addClip]; + + [[UIColor whiteColor] set]; + [circle fill]; + + // draw the image in the circleRect *AFTER* the context is clipped + [self drawInRect:circleRect]; + + // create a border (for white background pictures) + if (width > 0) { + circle.lineWidth = width; + [[UIColor whiteColor] set]; + [circle stroke]; + } + + // get an image from the image context + UIImage *roundedImage = UIGraphicsGetImageFromCurrentImageContext(); + + // end the image context since we're not in a drawRect: + UIGraphicsEndImageContext(); + + return roundedImage; +} + +@end + +@implementation NSAttributedString (Additions) + ++ (NSAttributedString *)attributedStringWithString:(NSString *)string fontSize:(CGFloat)size color:(nullable UIColor *)color +{ + if (string == nil) { + return nil; + } + + NSDictionary *attributes = @{NSForegroundColorAttributeName: color ? : [UIColor blackColor], + NSFontAttributeName: [UIFont boldSystemFontOfSize:size]}; + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string]; + [attributedString addAttributes:attributes range:NSMakeRange(0, string.length)]; + + return attributedString; +} + +@end diff --git a/examples/LayoutSpecExamples/Sample/main.m b/examples/LayoutSpecExamples/Sample/main.m new file mode 100644 index 0000000000..791ef4b743 --- /dev/null +++ b/examples/LayoutSpecExamples/Sample/main.m @@ -0,0 +1,25 @@ +// +// main.m +// Sample +// +// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. +// This source code is licensed under the BSD-style license found in the +// LICENSE file in the root directory of this source tree. An additional grant +// of patent rights can be found in the PATENTS file in the same directory. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +}