mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-06-16 01:44:23 +08:00
Continuing work on layout examples
This commit is contained in:
@@ -346,6 +346,7 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ];
|
||||
// just update the size of the NSTextContainer that is owned by the renderer's internal context object.
|
||||
[self _renderer].constrainedSize = _constrainedSize;
|
||||
|
||||
// TODO: Consider if this should be gated to occur only if _constrainedSize actually changes.
|
||||
[self setNeedsDisplay];
|
||||
|
||||
CGSize size = [self _renderer].size;
|
||||
|
||||
@@ -43,6 +43,12 @@
|
||||
return [self initWithNode:[[ASDisplayNode alloc] init]];
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
ASDisplayNodeAssert(NO, @"ASViewController requires using -initWithNode:");
|
||||
return [self initWithNode:[[ASDisplayNode alloc] init]];
|
||||
}
|
||||
|
||||
- (instancetype)initWithNode:(ASDisplayNode *)node
|
||||
{
|
||||
if (!(self = [super initWithNibName:nil bundle:nil])) {
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
697216351CCD8FB300122312 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 697216341CCD8FB300122312 /* main.m */; };
|
||||
697216381CCD8FB300122312 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 697216371CCD8FB300122312 /* AppDelegate.m */; };
|
||||
697216401CCD8FB300122312 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6972163F1CCD8FB300122312 /* Assets.xcassets */; };
|
||||
697216431CCD8FB300122312 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 697216411CCD8FB300122312 /* LaunchScreen.storyboard */; };
|
||||
6972164E1CCD938A00122312 /* OverviewComponentsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6972164B1CCD938A00122312 /* OverviewComponentsViewController.m */; };
|
||||
6972164F1CCD938A00122312 /* OverviewDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6972164D1CCD938A00122312 /* OverviewDetailViewController.m */; };
|
||||
697216571CCD939000122312 /* OverviewASCollectionNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 697216521CCD939000122312 /* OverviewASCollectionNode.m */; };
|
||||
@@ -26,7 +25,6 @@
|
||||
697216361CCD8FB300122312 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
697216371CCD8FB300122312 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||
6972163F1CCD8FB300122312 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
697216421CCD8FB300122312 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
697216441CCD8FB300122312 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
6972164A1CCD938A00122312 /* OverviewComponentsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverviewComponentsViewController.h; sourceTree = "<group>"; };
|
||||
6972164B1CCD938A00122312 /* OverviewComponentsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OverviewComponentsViewController.m; sourceTree = "<group>"; };
|
||||
@@ -96,7 +94,6 @@
|
||||
80817AC31D309A4800E181DF /* LayoutExamplesViewController.h */,
|
||||
80817AC41D309A4800E181DF /* LayoutExamplesViewController.m */,
|
||||
6972163F1CCD8FB300122312 /* Assets.xcassets */,
|
||||
697216411CCD8FB300122312 /* LaunchScreen.storyboard */,
|
||||
697216441CCD8FB300122312 /* Info.plist */,
|
||||
697216331CCD8FB300122312 /* Supporting Files */,
|
||||
);
|
||||
@@ -140,12 +137,12 @@
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 697216471CCD8FB300122312 /* Build configuration list for PBXNativeTarget "Sample" */;
|
||||
buildPhases = (
|
||||
78A0D09A94A74B3737920EA7 /* 📦 Check Pods Manifest.lock */,
|
||||
78A0D09A94A74B3737920EA7 /* [CP] Check Pods Manifest.lock */,
|
||||
6972162C1CCD8FB300122312 /* Sources */,
|
||||
6972162D1CCD8FB300122312 /* Frameworks */,
|
||||
6972162E1CCD8FB300122312 /* Resources */,
|
||||
267658CA53A0F4A2D24A8438 /* 📦 Embed Pods Frameworks */,
|
||||
84F93825AFB1CA7FBB116BA4 /* 📦 Copy Pods Resources */,
|
||||
267658CA53A0F4A2D24A8438 /* [CP] Embed Pods Frameworks */,
|
||||
84F93825AFB1CA7FBB116BA4 /* [CP] Copy Pods Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -193,7 +190,6 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
697216431CCD8FB300122312 /* LaunchScreen.storyboard in Resources */,
|
||||
697216401CCD8FB300122312 /* Assets.xcassets in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -201,14 +197,14 @@
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
267658CA53A0F4A2D24A8438 /* 📦 Embed Pods Frameworks */ = {
|
||||
267658CA53A0F4A2D24A8438 /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "📦 Embed Pods Frameworks";
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -216,14 +212,14 @@
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
78A0D09A94A74B3737920EA7 /* 📦 Check Pods Manifest.lock */ = {
|
||||
78A0D09A94A74B3737920EA7 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "📦 Check Pods Manifest.lock";
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -231,14 +227,14 @@
|
||||
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;
|
||||
};
|
||||
84F93825AFB1CA7FBB116BA4 /* 📦 Copy Pods Resources */ = {
|
||||
84F93825AFB1CA7FBB116BA4 /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "📦 Copy Pods Resources";
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -266,17 +262,6 @@
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
697216411CCD8FB300122312 /* LaunchScreen.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
697216421CCD8FB300122312 /* Base */,
|
||||
);
|
||||
name = LaunchScreen.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
697216451CCD8FB300122312 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
</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>
|
||||
@@ -60,7 +60,7 @@
|
||||
cellNode.backgroundColor = [UIColor lightGrayColor];
|
||||
|
||||
ASTextNode *textNodeOne = [[ASTextNode alloc] init];
|
||||
textNodeOne.attributedText = [[NSAttributedString alloc] initWithString:@"firstname lastname"];
|
||||
textNodeOne.attributedText = [[NSAttributedString alloc] initWithString:@"first"];
|
||||
|
||||
|
||||
ASTextNode *textNodeTwo = [[ASTextNode alloc] init];
|
||||
@@ -75,14 +75,13 @@
|
||||
ASLayoutSpecBlock layoutSpecBlock = nil;
|
||||
|
||||
// Picture with text overlay
|
||||
if (indexPath.row == 0) {
|
||||
if (indexPath.row == 1) {
|
||||
[cellNode addSubnode:textNodeOne];
|
||||
[cellNode addSubnode:textNodeTwo];
|
||||
[cellNode addSubnode:textNodeThree];
|
||||
[cellNode addSubnode:imageNode];
|
||||
|
||||
imageNode.preferredFrameSize = CGSizeMake(50, 50);
|
||||
imageNode.cornerRadius = 25;
|
||||
|
||||
layoutSpecBlock = ^ASLayoutSpec *(ASDisplayNode * _Nonnull node, ASSizeRange constrainedSize) {
|
||||
ASStackLayoutSpec *verticalStack = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||
@@ -99,9 +98,19 @@
|
||||
|
||||
return insetSpec;
|
||||
};
|
||||
} else if (indexPath.row == 1) {
|
||||
|
||||
|
||||
} else if (indexPath.row == 0) {
|
||||
[cellNode addSubnode:textNodeOne];
|
||||
[cellNode addSubnode:imageNode];
|
||||
|
||||
layoutSpecBlock = ^ASLayoutSpec *(ASDisplayNode * _Nonnull node, ASSizeRange constrainedSize) {
|
||||
|
||||
imageNode.preferredFrameSize = CGSizeMake(50, 50);
|
||||
ASInsetLayoutSpec *textInset = [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(6, 6, 6, 6)
|
||||
child:textNodeOne];
|
||||
|
||||
ASOverlayLayoutSpec *textOverlay = [ASOverlayLayoutSpec overlayLayoutSpecWithChild:imageNode overlay:textNodeOne];
|
||||
return textOverlay;
|
||||
};
|
||||
}
|
||||
|
||||
cellNode.layoutSpecBlock = layoutSpecBlock;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <AsyncDisplayKit/ASViewController.h>
|
||||
|
||||
@protocol ASLayoutSpecListEntry <NSObject>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@interface OverviewComponentsViewController : UIViewController
|
||||
@interface OverviewComponentsViewController : ASViewController
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -103,14 +103,25 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
||||
|
||||
#pragma mark - UIViewController
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
ASTableNode *tableNode = [ASTableNode new];
|
||||
|
||||
if (self = [super initWithNode:tableNode]) {
|
||||
self.tableNode = tableNode;
|
||||
tableNode.delegate = (id<ASTableDelegate>)self;
|
||||
tableNode.dataSource = (id<ASTableDataSource>)self;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.title = @"AsyncDisplayKit";
|
||||
|
||||
|
||||
[self setupData];
|
||||
[self setupTableNode];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
@@ -127,7 +138,6 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
||||
{
|
||||
OverviewDisplayNodeWithSizeBlock *parentNode = nil;
|
||||
ASDisplayNode *childNode = nil;
|
||||
|
||||
|
||||
// Setup Nodes Container
|
||||
// ---------------------------------------------------------------------------------------------------------
|
||||
@@ -463,16 +473,6 @@ typedef ASLayoutSpec *(^OverviewDisplayNodeSizeThatFitsBlock)(ASSizeRange constr
|
||||
self.data = mutableData;
|
||||
}
|
||||
|
||||
- (void)setupTableNode
|
||||
{
|
||||
_tableNode = [ASTableNode new];
|
||||
_tableNode.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
_tableNode.frame = self.view.bounds;
|
||||
_tableNode.delegate = (id<ASTableDelegate>)self;
|
||||
_tableNode.dataSource = (id<ASTableDataSource>)self;
|
||||
[self.view addSubnode:_tableNode];
|
||||
}
|
||||
|
||||
#pragma mark - Parent / Child Helper
|
||||
|
||||
- (OverviewDisplayNodeWithSizeBlock *)parentNodeWithChild:(ASDisplayNode *)child
|
||||
|
||||
Reference in New Issue
Block a user