Skip to content

Commit

Permalink
[Examples] Fix a couple of examples due to API changes recently #triv…
Browse files Browse the repository at this point in the history
…ial (#267)

* Fix ASDKGram example

* Fix some more examples

* Convert Swift example to 3.0

* Fix VerticalWithinHorizontalScrolling

* Fix some headers

* Fix some more API changes

* Remove semicolons
  • Loading branch information
maicki committed May 15, 2017
1 parent 9d84b9e commit 299df0a
Show file tree
Hide file tree
Showing 15 changed files with 149 additions and 153 deletions.
12 changes: 6 additions & 6 deletions examples/ASDKgram/Sample/ImageURLModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
// 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.
// Modifications to this file made after 4/13/2017 are: Copyright (c) 2017-present,
// Pinterest, Inc. 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
//

@interface ImageURLModel : NSObject
Expand Down
20 changes: 10 additions & 10 deletions examples/ASDKgram/Sample/ImageURLModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
// 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.
// Modifications to this file made after 4/13/2017 are: Copyright (c) 2017-present,
// Pinterest, Inc. 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
//

#import "ImageURLModel.h"
Expand All @@ -25,12 +25,12 @@ + (NSString *)imageParameterForClosestImageSize:(CGSize)size
{
BOOL squareImageRequested = (size.width == size.height) ? YES : NO;

NSUInteger imageParameterID;
if (squareImageRequested) {
imageParameterID = [self imageParameterForSquareCroppedSize:size];
NSUInteger imageParameterID = [self imageParameterForSquareCroppedSize:size];
return [NSString stringWithFormat:@"&image_size=%lu", (long)imageParameterID];
} else {
return @"";
}

return [NSString stringWithFormat:@"&image_size=%lu", (long)imageParameterID];
}

// 500px standard cropped image sizes
Expand Down
30 changes: 14 additions & 16 deletions examples/ASDKgram/Sample/PhotoFeedNodeController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
// 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.
// Modifications to this file made after 4/13/2017 are: Copyright (c) 2017-present,
// Pinterest, Inc. 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
//

#import "PhotoFeedNodeController.h"
Expand All @@ -27,12 +27,10 @@
#define AUTO_TAIL_LOADING_NUM_SCREENFULS 2.5

@interface PhotoFeedNodeController () <ASTableDelegate, ASTableDataSource>
@property (nonatomic, strong) ASTableNode *tableNode;
@end

@implementation PhotoFeedNodeController
{
ASTableNode *_tableNode;
}

#pragma mark - Lifecycle

Expand All @@ -42,15 +40,15 @@ - (instancetype)init
{
_tableNode = [[ASTableNode alloc] init];
self = [super initWithNode:_tableNode];

if (self) {
self.navigationItem.title = @"ASDK";
[self.navigationController setNavigationBarHidden:YES];

_tableNode.dataSource = self;
_tableNode.delegate = self;
}

return self;
}

Expand All @@ -59,14 +57,14 @@ - (instancetype)init
- (void)loadView
{
[super loadView];
_tableNode.view.leadingScreensForBatching = AUTO_TAIL_LOADING_NUM_SCREENFULS; // overriding default of 2.0

self.tableNode.leadingScreensForBatching = AUTO_TAIL_LOADING_NUM_SCREENFULS; // overriding default of 2.0
}

- (void)loadPageWithContext:(ASBatchContext *)context
{
[self.photoFeed requestPageWithCompletionBlock:^(NSArray *newPhotos){

[self insertNewRows:newPhotos];
[self requestCommentsForPhotos:newPhotos];
if (context) {
Expand Down Expand Up @@ -107,7 +105,7 @@ - (ASCellNodeBlock)tableNode:(ASTableNode *)tableNode nodeBlockForRowAtIndexPath
PhotoCellNode *cellNode = [[PhotoCellNode alloc] initWithPhotoObject:photoModel];
return cellNode;
};

return ASCellNodeBlock;
}

Expand Down
14 changes: 7 additions & 7 deletions examples/CatDealsCollectionView/Sample/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// 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.
// Modifications to this file made after 4/13/2017 are: Copyright (c) 2017-present,
// Pinterest, Inc. 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
//

#import "ViewController.h"
Expand Down Expand Up @@ -84,7 +84,7 @@ - (void)viewDidLoad
[super viewDidLoad];

// set any collectionView properties here (once the node's backing view is loaded)
_collectionNode.view.leadingScreensForBatching = 2;
_collectionNode.leadingScreensForBatching = 2;
[self fetchMoreCatsWithCompletion:nil];
}

Expand Down
24 changes: 7 additions & 17 deletions examples/CustomCollectionView-Swift/Sample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,16 @@
//
// 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.
// LICENSE file in the /ASDK-Licenses directory of this source tree. An additional
// grant of patent rights can be found in the PATENTS file in the same directory.
//
// Modifications to this file made after 4/13/2017 are: Copyright (c) 2017-present,
// Pinterest, Inc. 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.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import UIKit
import AsyncDisplayKit
Expand Down Expand Up @@ -49,24 +44,19 @@ class ViewController: ASViewController<ASCollectionNode>, MosaicCollectionViewLa
}
}

_collectionNode.dataSource = self;
_collectionNode.delegate = self;
_collectionNode.backgroundColor = UIColor.white
_collectionNode.dataSource = self
_collectionNode.delegate = self
_collectionNode.layoutInspector = _layoutInspector
_collectionNode.registerSupplementaryNode(ofKind: UICollectionElementKindSectionHeader)
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

deinit {
_collectionNode.dataSource = nil;
_collectionNode.delegate = nil;
}

override func viewDidLoad() {
super.viewDidLoad()
_collectionNode.view.layoutInspector = _layoutInspector
_collectionNode.view.isScrollEnabled = true
}

Expand All @@ -84,7 +74,7 @@ class ViewController: ASViewController<ASCollectionNode>, MosaicCollectionViewLa
let textInsets = UIEdgeInsets(top: 11, left: 0, bottom: 11, right: 0)
let textCellNode = ASTextCellNode(attributes: textAttributes as! [AnyHashable : Any], insets: textInsets)
textCellNode.text = String(format: "Section %zd", indexPath.section + 1)
return textCellNode;
return textCellNode
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ - (ASCollectionLayoutState *)calculateLayoutWithContext:(ASCollectionLayoutConte

CGFloat contentHeight = [[[columnHeights lastObject] firstObject] floatValue];
CGSize contentSize = CGSizeMake(layoutWidth, contentHeight);
return [[ASCollectionLayoutState alloc] initWithElements:elements contentSize:contentSize elementToLayoutArrtibutesMap:attrsMap];
return [[ASCollectionLayoutState alloc] initWithContext:context contentSize:contentSize elementToLayoutAttributesTable:attrsMap];
}

- (CGFloat)_widthForSection:(NSUInteger)section withLayoutWidth:(CGFloat)layoutWidth
Expand Down
3 changes: 1 addition & 2 deletions examples/CustomCollectionView/Sample/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ - (instancetype)init
_collectionNode = [[ASCollectionNode alloc] initWithLayoutDelegate:layoutDelegate layoutFacilitator:nil];
_collectionNode.dataSource = self;
_collectionNode.delegate = self;
_collectionNode.backgroundColor = [UIColor whiteColor];
_collectionNode.layoutInspector = self;

if (!(self = [super initWithNode:_collectionNode]))
return nil;
Expand All @@ -72,7 +72,6 @@ - (void)viewDidLoad
{
[super viewDidLoad];

_collectionNode.view.layoutInspector = self;
[_collectionNode.view registerClass:[ImageCollectionViewCell class] forCellWithReuseIdentifier:kReuseIdentifier];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
// 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.
// Modifications to this file made after 4/13/2017 are: Copyright (c) 2017-present,
// Pinterest, Inc. 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
//

#import <AsyncDisplayKit/AsyncDisplayKit.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
// 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.
// Modifications to this file made after 4/13/2017 are: Copyright (c) 2017-present,
// Pinterest, Inc. 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
//

#import "RandomCoreGraphicsNode.h"
Expand Down Expand Up @@ -46,8 +46,7 @@ + (void)drawRect:(CGRect)bounds withParameters:(id<NSObject>)parameters isCancel
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (CFArrayRef)colors, locations);

CGGradientDrawingOptions drawingOptions;
CGContextDrawLinearGradient(ctx, gradient, CGPointZero, CGPointMake(bounds.size.width, bounds.size.height), drawingOptions);
CGContextDrawLinearGradient(ctx, gradient, CGPointZero, CGPointMake(bounds.size.width, bounds.size.height), 0);

CGGradientRelease(gradient);
CGColorSpaceRelease(colorSpace);
Expand Down
6 changes: 3 additions & 3 deletions examples/Swift/Sample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
TargetAttributes = {
050E7C6D19D22E19004363C2 = {
CreatedOnToolsVersion = 6.0.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0830;
};
};
};
Expand Down Expand Up @@ -322,7 +322,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.AsyncDisplayKit.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -335,7 +335,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.AsyncDisplayKit.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
22 changes: 11 additions & 11 deletions examples/Swift/Sample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
//
// 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.
// LICENSE file in the /ASDK-Licenses 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.
// Modifications to this file made after 4/13/2017 are: Copyright (c) 2017-present,
// Pinterest, Inc. 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
//

import UIKit
Expand All @@ -22,9 +22,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let window = UIWindow(frame: UIScreen.mainScreen().bounds)
window.backgroundColor = UIColor.whiteColor()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let window = UIWindow(frame: UIScreen.main.bounds)
window.backgroundColor = UIColor.white
window.rootViewController = UINavigationController(rootViewController: ViewController());
window.makeKeyAndVisible()
self.window = window
Expand Down
Loading

0 comments on commit 299df0a

Please sign in to comment.