mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-04-23 11:27:56 +08:00
add more examples
This commit is contained in:
@@ -218,19 +218,15 @@
|
||||
764D83D51C8EA515009B4FB8 /* AsyncDisplayKit+Debug.h in Headers */ = {isa = PBXBuildFile; fileRef = 764D83D21C8EA515009B4FB8 /* AsyncDisplayKit+Debug.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
764D83D61C8EA515009B4FB8 /* AsyncDisplayKit+Debug.m in Sources */ = {isa = PBXBuildFile; fileRef = 764D83D31C8EA515009B4FB8 /* AsyncDisplayKit+Debug.m */; };
|
||||
767E7F8E1C90191D0066C000 /* AsyncDisplayKit+Debug.m in Sources */ = {isa = PBXBuildFile; fileRef = 764D83D31C8EA515009B4FB8 /* AsyncDisplayKit+Debug.m */; };
|
||||
76A64B6B1CA8CD4900967B8F /* ASLayoutableInspectorCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 76A64B691CA8CD4900967B8F /* ASLayoutableInspectorCell.h */; };
|
||||
76A64B6C1CA8CD4900967B8F /* ASLayoutableInspectorCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 76A64B691CA8CD4900967B8F /* ASLayoutableInspectorCell.h */; };
|
||||
76A64B6D1CA8CD4900967B8F /* ASLayoutableInspectorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 76A64B6A1CA8CD4900967B8F /* ASLayoutableInspectorCell.m */; };
|
||||
76A64B6E1CA8CD4900967B8F /* ASLayoutableInspectorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 76A64B6A1CA8CD4900967B8F /* ASLayoutableInspectorCell.m */; };
|
||||
76C078261C9F455F00E37AB1 /* ASLayoutSpec+Debug.h in Headers */ = {isa = PBXBuildFile; fileRef = 76C078241C9F455E00E37AB1 /* ASLayoutSpec+Debug.h */; };
|
||||
76C078271C9F455F00E37AB1 /* ASLayoutSpec+Debug.h in Headers */ = {isa = PBXBuildFile; fileRef = 76C078241C9F455E00E37AB1 /* ASLayoutSpec+Debug.h */; };
|
||||
76C078281C9F455F00E37AB1 /* ASLayoutSpec+Debug.m in Sources */ = {isa = PBXBuildFile; fileRef = 76C078251C9F455E00E37AB1 /* ASLayoutSpec+Debug.m */; };
|
||||
76C078291C9F455F00E37AB1 /* ASLayoutSpec+Debug.m in Sources */ = {isa = PBXBuildFile; fileRef = 76C078251C9F455E00E37AB1 /* ASLayoutSpec+Debug.m */; };
|
||||
76C0782C1C9F459C00E37AB1 /* ASLayoutableInspectorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 76C0782A1C9F459C00E37AB1 /* ASLayoutableInspectorNode.h */; };
|
||||
76C0782D1C9F459C00E37AB1 /* ASLayoutableInspectorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 76C0782A1C9F459C00E37AB1 /* ASLayoutableInspectorNode.h */; };
|
||||
76C0782E1C9F459C00E37AB1 /* ASLayoutableInspectorNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 76C0782B1C9F459C00E37AB1 /* ASLayoutableInspectorNode.m */; };
|
||||
76C0782F1C9F459C00E37AB1 /* ASLayoutableInspectorNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 76C0782B1C9F459C00E37AB1 /* ASLayoutableInspectorNode.m */; };
|
||||
76E5FDFA1CA8EF12000164C0 /* ASLayoutableInspectorCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 76E5FDF81CA8EF12000164C0 /* ASLayoutableInspectorCell.h */; };
|
||||
76E5FDFB1CA8EF12000164C0 /* ASLayoutableInspectorCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 76E5FDF81CA8EF12000164C0 /* ASLayoutableInspectorCell.h */; };
|
||||
76E5FDFC1CA8EF12000164C0 /* ASLayoutableInspectorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 76E5FDF91CA8EF12000164C0 /* ASLayoutableInspectorCell.m */; };
|
||||
76E5FDFD1CA8EF12000164C0 /* ASLayoutableInspectorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 76E5FDF91CA8EF12000164C0 /* ASLayoutableInspectorCell.m */; };
|
||||
@@ -1911,12 +1907,15 @@
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 058D09D2195D04C000B7D73C /* Build configuration list for PBXNativeTarget "AsyncDisplayKitTests" */;
|
||||
buildPhases = (
|
||||
984076B20AEB7145F89C1603 /* 📦 Check Pods Manifest.lock */,
|
||||
2E61B6A0DB0F436A9DDBE86F /* [CP] Check Pods Manifest.lock */,
|
||||
058D09B8195D04C000B7D73C /* Sources */,
|
||||
058D09B9195D04C000B7D73C /* Frameworks */,
|
||||
058D09BA195D04C000B7D73C /* Resources */,
|
||||
3B9D88CDF51B429C8409E4B6 /* [CP] Copy Pods Resources */,
|
||||
B130AB1AC0A1E5162E211C19 /* [CP] Embed Pods Frameworks */,
|
||||
7FB76552D76CCFC44DED9CBC /* 📦 Embed Pods Frameworks */,
|
||||
C679B9DDCBA9F4DAF2104989 /* 📦 Copy Pods Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -2047,6 +2046,36 @@
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AsyncDisplayKitTests/Pods-AsyncDisplayKitTests-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
7FB76552D76CCFC44DED9CBC /* 📦 Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "📦 Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AsyncDisplayKitTests/Pods-AsyncDisplayKitTests-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
984076B20AEB7145F89C1603 /* 📦 Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "📦 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;
|
||||
};
|
||||
B130AB1AC0A1E5162E211C19 /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -2062,6 +2091,21 @@
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AsyncDisplayKitTests/Pods-AsyncDisplayKitTests-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
C679B9DDCBA9F4DAF2104989 /* 📦 Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "📦 Copy Pods Resources";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AsyncDisplayKitTests/Pods-AsyncDisplayKitTests-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
@@ -2251,7 +2295,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
76C078291C9F455F00E37AB1 /* ASLayoutSpec+Debug.m in Sources */,
|
||||
DE4843DB1C93EAB100A1F33B /* ASDisplayNodeLayoutContext.mm in Sources */,
|
||||
DE4843DB1C93EAB100A1F33B /* ASLayoutTransition.mm in Sources */,
|
||||
9C70F2091CDABA36007D6C76 /* ASViewController.mm in Sources */,
|
||||
8BBBAB8D1CEBAF1E00107FC6 /* ASDefaultPlaybackButton.m in Sources */,
|
||||
DE4843DB1C93EAB100A1F33B /* ASLayoutTransition.mm in Sources */,
|
||||
|
||||
@@ -14,9 +14,10 @@
|
||||
7602C7651CA4F83100D0D917 /* Utilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 7602C7641CA4F83100D0D917 /* Utilities.m */; };
|
||||
7602C7671CA4FB5300D0D917 /* resizeHandle.png in Resources */ = {isa = PBXBuildFile; fileRef = 7602C7661CA4FB5300D0D917 /* resizeHandle.png */; };
|
||||
76466F321C9DFFC4006C4D2D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 76466F2B1C9DFFC4006C4D2D /* AppDelegate.m */; };
|
||||
76466F341C9DFFC4006C4D2D /* PlaygroundNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 76466F2F1C9DFFC4006C4D2D /* PlaygroundNode.m */; };
|
||||
76466F341C9DFFC4006C4D2D /* PhotoPostNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 76466F2F1C9DFFC4006C4D2D /* PhotoPostNode.m */; };
|
||||
76466F351C9DFFC4006C4D2D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 76466F311C9DFFC4006C4D2D /* ViewController.m */; };
|
||||
76F58D5C1C9E15C1004512CC /* PlaygroundContainerNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 76F58D5B1C9E15C1004512CC /* PlaygroundContainerNode.m */; };
|
||||
80A6A5181D88F08F00473431 /* LayoutExampleNodes.m in Sources */ = {isa = PBXBuildFile; fileRef = 80A6A5171D88F08F00473431 /* LayoutExampleNodes.m */; };
|
||||
B971D066CC023A00C53D8575 /* libPods-Sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 54A6EB3DE8D9A9EC4AE2867D /* libPods-Sample.a */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
@@ -36,12 +37,14 @@
|
||||
7602C7661CA4FB5300D0D917 /* resizeHandle.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = resizeHandle.png; sourceTree = "<group>"; };
|
||||
76466F2A1C9DFFC4006C4D2D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
76466F2B1C9DFFC4006C4D2D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||
76466F2E1C9DFFC4006C4D2D /* PlaygroundNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaygroundNode.h; sourceTree = "<group>"; };
|
||||
76466F2F1C9DFFC4006C4D2D /* PlaygroundNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlaygroundNode.m; sourceTree = "<group>"; };
|
||||
76466F2E1C9DFFC4006C4D2D /* PhotoPostNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoPostNode.h; sourceTree = "<group>"; };
|
||||
76466F2F1C9DFFC4006C4D2D /* PhotoPostNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoPostNode.m; sourceTree = "<group>"; };
|
||||
76466F301C9DFFC4006C4D2D /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
|
||||
76466F311C9DFFC4006C4D2D /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
|
||||
76F58D5A1C9E15C1004512CC /* PlaygroundContainerNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaygroundContainerNode.h; sourceTree = "<group>"; };
|
||||
76F58D5B1C9E15C1004512CC /* PlaygroundContainerNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlaygroundContainerNode.m; sourceTree = "<group>"; };
|
||||
80A6A5161D88F08F00473431 /* LayoutExampleNodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutExampleNodes.h; sourceTree = "<group>"; };
|
||||
80A6A5171D88F08F00473431 /* LayoutExampleNodes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LayoutExampleNodes.m; sourceTree = "<group>"; };
|
||||
C068F1D3F0CC317E895FCDAB /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
FDF496F367580DF9280D36EA /* 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 = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
@@ -88,8 +91,10 @@
|
||||
76466F311C9DFFC4006C4D2D /* ViewController.m */,
|
||||
76F58D5A1C9E15C1004512CC /* PlaygroundContainerNode.h */,
|
||||
76F58D5B1C9E15C1004512CC /* PlaygroundContainerNode.m */,
|
||||
76466F2E1C9DFFC4006C4D2D /* PlaygroundNode.h */,
|
||||
76466F2F1C9DFFC4006C4D2D /* PlaygroundNode.m */,
|
||||
76466F2E1C9DFFC4006C4D2D /* PhotoPostNode.h */,
|
||||
76466F2F1C9DFFC4006C4D2D /* PhotoPostNode.m */,
|
||||
80A6A5161D88F08F00473431 /* LayoutExampleNodes.h */,
|
||||
80A6A5171D88F08F00473431 /* LayoutExampleNodes.m */,
|
||||
7602C7631CA4F83100D0D917 /* Utilities.h */,
|
||||
7602C7641CA4F83100D0D917 /* Utilities.m */,
|
||||
05E2128419D4DB510098F589 /* Supporting Files */,
|
||||
@@ -255,9 +260,10 @@
|
||||
76466F321C9DFFC4006C4D2D /* AppDelegate.m in Sources */,
|
||||
05E2128719D4DB510098F589 /* main.m in Sources */,
|
||||
7602C7651CA4F83100D0D917 /* Utilities.m in Sources */,
|
||||
76466F341C9DFFC4006C4D2D /* PlaygroundNode.m in Sources */,
|
||||
76466F341C9DFFC4006C4D2D /* PhotoPostNode.m in Sources */,
|
||||
76F58D5C1C9E15C1004512CC /* PlaygroundContainerNode.m in Sources */,
|
||||
76466F351C9DFFC4006C4D2D /* ViewController.m in Sources */,
|
||||
80A6A5181D88F08F00473431 /* LayoutExampleNodes.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -18,10 +18,19 @@
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict/>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
|
||||
40
examples/ASLayoutSpecPlayground/Sample/LayoutExampleNodes.h
Normal file
40
examples/ASLayoutSpecPlayground/Sample/LayoutExampleNodes.h
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// LayoutExampleNodes.h
|
||||
// Sample
|
||||
//
|
||||
// Created by Hannah Troisi on 9/13/16.
|
||||
// Copyright © 2016 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import <AsyncDisplayKit/AsyncDisplayKit.h>
|
||||
|
||||
@interface LayoutExampleNode : ASDisplayNode
|
||||
|
||||
- (NSAttributedString *)usernameAttributedStringWithFontSize:(CGFloat)size;
|
||||
- (NSAttributedString *)locationAttributedStringWithFontSize:(CGFloat)size;
|
||||
- (NSAttributedString *)uploadDateAttributedStringWithFontSize:(CGFloat)size;
|
||||
- (NSAttributedString *)likesAttributedStringWithFontSize:(CGFloat)size;
|
||||
- (NSAttributedString *)descriptionAttributedStringWithFontSize:(CGFloat)size;
|
||||
|
||||
@end
|
||||
|
||||
@interface HorizontalStackWithSpacer : LayoutExampleNode
|
||||
|
||||
@property (nonatomic, strong) ASTextNode *usernameTextNode;
|
||||
@property (nonatomic, strong) ASTextNode *postTimeTextNode;
|
||||
|
||||
@end
|
||||
|
||||
@interface PhotoWithInsetTextOverlay : LayoutExampleNode
|
||||
|
||||
@property (nonatomic, strong) ASNetworkImageNode *avatarImageNode;
|
||||
@property (nonatomic, strong) ASTextNode *usernameTextNode;
|
||||
|
||||
@end
|
||||
|
||||
@interface PhotoWithOutsetIconOverlay : LayoutExampleNode
|
||||
|
||||
@property (nonatomic, strong) ASNetworkImageNode *photoImageNode;
|
||||
@property (nonatomic, strong) ASNetworkImageNode *plusIconImageNode;
|
||||
|
||||
@end
|
||||
203
examples/ASLayoutSpecPlayground/Sample/LayoutExampleNodes.m
Normal file
203
examples/ASLayoutSpecPlayground/Sample/LayoutExampleNodes.m
Normal file
@@ -0,0 +1,203 @@
|
||||
//
|
||||
// LayoutExampleNodes.m
|
||||
// Sample
|
||||
//
|
||||
// Created by Hannah Troisi on 9/13/16.
|
||||
// Copyright © 2016 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LayoutExampleNodes.h"
|
||||
#import "Utilities.h"
|
||||
|
||||
#define USER_IMAGE_HEIGHT 60
|
||||
#define HORIZONTAL_BUFFER 10
|
||||
#define VERTICAL_BUFFER 5
|
||||
#define FONT_SIZE 20
|
||||
|
||||
@implementation LayoutExampleNode
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.usesImplicitHierarchyManagement = YES;
|
||||
self.shouldVisualizeLayoutSpecs = YES;
|
||||
self.shouldCacheLayoutSpec = YES;
|
||||
self.backgroundColor = [UIColor whiteColor];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - helper methods
|
||||
|
||||
- (NSAttributedString *)usernameAttributedStringWithFontSize:(CGFloat)size
|
||||
{
|
||||
return [NSAttributedString attributedStringWithString:@"hannahmbanana"
|
||||
fontSize:size
|
||||
color:[UIColor darkBlueColor]
|
||||
firstWordColor:nil];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)locationAttributedStringWithFontSize:(CGFloat)size
|
||||
{
|
||||
return [NSAttributedString attributedStringWithString:@"San Fransisco, CA"
|
||||
fontSize:size
|
||||
color:[UIColor lightBlueColor]
|
||||
firstWordColor:nil];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)uploadDateAttributedStringWithFontSize:(CGFloat)size
|
||||
{
|
||||
return [NSAttributedString attributedStringWithString:@"30m"
|
||||
fontSize:size
|
||||
color:[UIColor lightGrayColor]
|
||||
firstWordColor:nil];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)likesAttributedStringWithFontSize:(CGFloat)size
|
||||
{
|
||||
return [NSAttributedString attributedStringWithString:@"♥︎ 17 likes"
|
||||
fontSize:size
|
||||
color:[UIColor darkBlueColor]
|
||||
firstWordColor:nil];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)descriptionAttributedStringWithFontSize:(CGFloat)size
|
||||
{
|
||||
NSString *string = [NSString stringWithFormat:@"hannahmbanana check out this cool pic from the internet!"];
|
||||
NSAttributedString *attrString = [NSAttributedString attributedStringWithString:string
|
||||
fontSize:size
|
||||
color:[UIColor darkGrayColor]
|
||||
firstWordColor:[UIColor darkBlueColor]];
|
||||
return attrString;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation HorizontalStackWithSpacer
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
_usernameTextNode = [[ASTextNode alloc] init];
|
||||
_usernameTextNode.attributedString = [self usernameAttributedStringWithFontSize:FONT_SIZE];
|
||||
|
||||
_postTimeTextNode = [[ASTextNode alloc] init];
|
||||
_postTimeTextNode.attributedString = [self uploadDateAttributedStringWithFontSize:FONT_SIZE];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||
{
|
||||
_usernameTextNode.flexShrink = YES;
|
||||
|
||||
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
||||
spacer.flexGrow = YES;
|
||||
spacer.flexShrink = YES;
|
||||
|
||||
// horizontal stack
|
||||
ASStackLayoutSpec *headerStackSpec = [ASStackLayoutSpec horizontalStackLayoutSpec];
|
||||
headerStackSpec.alignItems = ASStackLayoutAlignItemsCenter; // center items vertically in horizontal stack
|
||||
headerStackSpec.justifyContent = ASStackLayoutJustifyContentStart; // justify content to the left side of the header stack
|
||||
headerStackSpec.flexShrink = YES;
|
||||
headerStackSpec.flexGrow = YES;
|
||||
[headerStackSpec setChildren:@[_usernameTextNode, spacer, _postTimeTextNode]];
|
||||
|
||||
// inset horizontal stack
|
||||
UIEdgeInsets insets = UIEdgeInsetsMake(0, HORIZONTAL_BUFFER, 0, HORIZONTAL_BUFFER);
|
||||
ASInsetLayoutSpec *headerInsetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:headerStackSpec];
|
||||
headerInsetSpec.flexShrink = YES;
|
||||
headerInsetSpec.flexGrow = YES;
|
||||
|
||||
return headerInsetSpec;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation PhotoWithInsetTextOverlay
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
_avatarImageNode = [[ASNetworkImageNode alloc] init];
|
||||
_avatarImageNode.URL = [NSURL URLWithString:@"https://s-media-cache-ak0.pinimg.com/avatars/503h_1458880322_140.jpg"];
|
||||
|
||||
_usernameTextNode = [[ASTextNode alloc] init];
|
||||
_usernameTextNode.maximumNumberOfLines = 2;
|
||||
_usernameTextNode.truncationAttributedString = [NSAttributedString attributedStringWithString:@"..."
|
||||
fontSize:12
|
||||
color:[UIColor whiteColor]
|
||||
firstWordColor:nil];
|
||||
_usernameTextNode.attributedString = [NSAttributedString attributedStringWithString:@"this is a long text description for an image"
|
||||
fontSize:FONT_SIZE/2.0
|
||||
color:[UIColor whiteColor]
|
||||
firstWordColor:nil];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||
{
|
||||
_avatarImageNode.preferredFrameSize = CGSizeMake(USER_IMAGE_HEIGHT*2, USER_IMAGE_HEIGHT*2);
|
||||
ASStaticLayoutSpec *backgroundImageStaticSpec = [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[_avatarImageNode]];
|
||||
|
||||
UIEdgeInsets insets = UIEdgeInsetsMake(INFINITY, 12, 12, 12);
|
||||
ASInsetLayoutSpec *textInset = [ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:_usernameTextNode];
|
||||
|
||||
ASOverlayLayoutSpec *textOverlay = [ASOverlayLayoutSpec overlayLayoutSpecWithChild:backgroundImageStaticSpec overlay:textInset];
|
||||
|
||||
return textOverlay;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation PhotoWithOutsetIconOverlay
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
|
||||
_photoImageNode = [[ASNetworkImageNode alloc] init];
|
||||
_photoImageNode.URL = [NSURL URLWithString:@"http://farm4.static.flickr.com/3691/10155174895_8c815250a0_m.jpg"];
|
||||
|
||||
_plusIconImageNode = [[ASNetworkImageNode alloc] init];
|
||||
_plusIconImageNode.URL = [NSURL URLWithString:@"http://www.icon100.com/up/3327/256/32-PLus-button.png"];
|
||||
|
||||
[_plusIconImageNode setImageModificationBlock:^UIImage *(UIImage *image) { // FIXME: in framework autocomplete for setImageModificationBlock line seems broken
|
||||
CGSize profileImageSize = CGSizeMake(USER_IMAGE_HEIGHT, USER_IMAGE_HEIGHT);
|
||||
return [image makeCircularImageWithSize:profileImageSize withBorderWidth:10];
|
||||
}];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||
{
|
||||
_plusIconImageNode.preferredFrameSize = CGSizeMake(40, 40);
|
||||
_photoImageNode.preferredFrameSize = CGSizeMake(150, 150);
|
||||
|
||||
CGFloat x = _photoImageNode.preferredFrameSize.width;
|
||||
CGFloat y = 0;
|
||||
|
||||
_plusIconImageNode.layoutPosition = CGPointMake(x, y);
|
||||
_photoImageNode.layoutPosition = CGPointMake(_plusIconImageNode.preferredFrameSize.height/2.0, _plusIconImageNode.preferredFrameSize.height/2.0);
|
||||
|
||||
ASStaticLayoutSpec *staticLayoutSpec = [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[_photoImageNode, _plusIconImageNode]];
|
||||
|
||||
return staticLayoutSpec;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// PlaygroundNode.h
|
||||
// PhotoPostNode.h
|
||||
// ASLayoutSpecPlayground
|
||||
//
|
||||
// Created by Hannah Troisi on 3/11/16.
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#import "AsyncDisplayKit.h"
|
||||
|
||||
@interface PlaygroundNode : ASDisplayNode
|
||||
@interface PhotoPostNode : ASDisplayNode
|
||||
|
||||
- (instancetype)initWithIndex:(NSUInteger)index;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
//
|
||||
// PlaygroundNode.m
|
||||
// PhotoPostNode.m
|
||||
// ASLayoutSpecPlayground
|
||||
//
|
||||
// Created by Hannah Troisi on 3/11/16.
|
||||
// Copyright © 2016 Hannah Troisi. All rights reserved.
|
||||
//
|
||||
|
||||
#import "PlaygroundNode.h"
|
||||
#import "PhotoPostNode.h"
|
||||
#import "AsyncDisplayKit+Debug.h"
|
||||
#import "Utilities.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#define VERTICAL_BUFFER 5
|
||||
#define FONT_SIZE 20
|
||||
|
||||
@implementation PlaygroundNode
|
||||
@implementation PhotoPostNode
|
||||
{
|
||||
NSUInteger _index;
|
||||
ASNetworkImageNode *_userAvatarImageView;
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
[_userAvatarImageView setImageModificationBlock:^UIImage *(UIImage *image) { // FIXME: in framework autocomplete for setImageModificationBlock line seems broken
|
||||
CGSize profileImageSize = CGSizeMake(USER_IMAGE_HEIGHT, USER_IMAGE_HEIGHT);
|
||||
return [image makeCircularImageWithSize:profileImageSize];
|
||||
return [image makeCircularImageWithSize:profileImageSize withBorderWidth:0];
|
||||
}];
|
||||
|
||||
_userNameLabel = [[ASTextNode alloc] init];
|
||||
@@ -69,8 +69,6 @@
|
||||
_photoDescriptionLabel = [[ASTextNode alloc] init];
|
||||
_photoDescriptionLabel.attributedString = [self descriptionAttributedStringWithFontSize:FONT_SIZE];
|
||||
_photoDescriptionLabel.maximumNumberOfLines = 3;
|
||||
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
@property (nonatomic, weak) id<PlaygroundContainerNodeDelegate> delegate;
|
||||
|
||||
+ (NSUInteger)containerNodeCount;
|
||||
- (instancetype)initWithIndex:(NSUInteger)index;
|
||||
|
||||
@end
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
//
|
||||
|
||||
#import "PlaygroundContainerNode.h"
|
||||
#import "PlaygroundNode.h"
|
||||
#import "LayoutExampleNodes.h"
|
||||
#import "PhotoPostNode.h"
|
||||
#import "ASLayoutableInspectorNode.h" // FIXME: move to ASLayoutSpecDebug
|
||||
#import "AsyncDisplayKit+Debug.h"
|
||||
|
||||
@@ -15,13 +16,29 @@
|
||||
|
||||
@implementation PlaygroundContainerNode
|
||||
{
|
||||
PlaygroundNode *_playgroundNode;
|
||||
ASDisplayNode *_playgroundNode;
|
||||
ASImageNode *_resizeHandle;
|
||||
CGPoint _resizeStartLocation;
|
||||
}
|
||||
|
||||
#pragma mark - Lifecycle
|
||||
|
||||
+ (NSUInteger)containerNodeCount
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
+ (ASDisplayNode *)nodeForIndex:(NSUInteger)index
|
||||
{
|
||||
switch (index) {
|
||||
case 0: return [[HorizontalStackWithSpacer alloc] init];
|
||||
case 1: return [[PhotoWithInsetTextOverlay alloc] init];
|
||||
case 2: return [[PhotoWithOutsetIconOverlay alloc] init];
|
||||
case 3: return [[PhotoPostNode alloc] initWithIndex:0];
|
||||
default: return [[PhotoPostNode alloc] initWithIndex:1];
|
||||
}
|
||||
}
|
||||
|
||||
- (instancetype)initWithIndex:(NSUInteger)index
|
||||
{
|
||||
self = [super init];
|
||||
@@ -30,7 +47,7 @@
|
||||
self.backgroundColor = [UIColor colorWithRed:255/255.0 green:181/255.0 blue:68/255.0 alpha:1];
|
||||
self.usesImplicitHierarchyManagement = YES;
|
||||
|
||||
_playgroundNode = [[PlaygroundNode alloc] initWithIndex:index];
|
||||
_playgroundNode = [[self class] nodeForIndex:index];
|
||||
|
||||
_resizeHandle = [[ASImageNode alloc] init];
|
||||
_resizeHandle.image = [UIImage imageNamed:@"resizeHandle"];
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
@interface UIImage (Additions)
|
||||
|
||||
- (UIImage *)makeCircularImageWithSize:(CGSize)size;
|
||||
- (UIImage *)makeCircularImageWithSize:(CGSize)size withBorderWidth:(CGFloat)width;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
@implementation UIImage (Additions)
|
||||
|
||||
- (UIImage *)makeCircularImageWithSize:(CGSize)size
|
||||
- (UIImage *)makeCircularImageWithSize:(CGSize)size withBorderWidth:(CGFloat)width
|
||||
{
|
||||
// make a CGRect with the image's size
|
||||
CGRect circleRect = (CGRect) {CGPointZero, size};
|
||||
@@ -52,15 +52,18 @@
|
||||
// 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 StrokeRoundedImages
|
||||
circle.lineWidth = 1;
|
||||
[[UIColor darkGrayColor] set];
|
||||
[circle stroke];
|
||||
#endif
|
||||
if (width > 0) {
|
||||
circle.lineWidth = width;
|
||||
[[UIColor whiteColor] set];
|
||||
[circle stroke];
|
||||
}
|
||||
|
||||
// get an image from the image context
|
||||
UIImage *roundedImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
- (NSInteger)numberOfPagesInPagerNode:(ASPagerNode *)pagerNode
|
||||
{
|
||||
return 2;
|
||||
return [PlaygroundContainerNode containerNodeCount];
|
||||
}
|
||||
|
||||
- (ASCellNodeBlock)pagerNode:(ASPagerNode *)pagerNode nodeBlockAtIndex:(NSInteger)index
|
||||
|
||||
Reference in New Issue
Block a user