From 120f27861ab4a4da14bab37b5d5c130b612ab777 Mon Sep 17 00:00:00 2001 From: George A Date: Tue, 18 Apr 2017 11:01:26 +0200 Subject: [PATCH 1/2] Updated copyright notices --- .../Sample/AppDelegate.swift | 19 +++++++++++-------- .../Sample/ImageCellNode.swift | 19 +++++++++++-------- .../Sample/MosaicCollectionViewLayout.swift | 19 +++++++++++-------- .../Sample/ViewController.swift | 19 +++++++++++-------- 4 files changed, 44 insertions(+), 32 deletions(-) mode change 100644 => 100755 examples/CustomCollectionView-Swift/Sample/MosaicCollectionViewLayout.swift diff --git a/examples/CustomCollectionView-Swift/Sample/AppDelegate.swift b/examples/CustomCollectionView-Swift/Sample/AppDelegate.swift index 13e0670d1..fb029b2dd 100644 --- a/examples/CustomCollectionView-Swift/Sample/AppDelegate.swift +++ b/examples/CustomCollectionView-Swift/Sample/AppDelegate.swift @@ -2,19 +2,22 @@ // AppDelegate.swift // Sample // -// Created by Rajeev Gupta on 11/9/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. +// 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 // -// 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. +// 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 diff --git a/examples/CustomCollectionView-Swift/Sample/ImageCellNode.swift b/examples/CustomCollectionView-Swift/Sample/ImageCellNode.swift index 52f8fdb55..93179c006 100644 --- a/examples/CustomCollectionView-Swift/Sample/ImageCellNode.swift +++ b/examples/CustomCollectionView-Swift/Sample/ImageCellNode.swift @@ -2,19 +2,22 @@ // ImageCellNode.swift // Sample // -// Created by Rajeev Gupta on 11/9/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. +// 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 // -// 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. +// 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 diff --git a/examples/CustomCollectionView-Swift/Sample/MosaicCollectionViewLayout.swift b/examples/CustomCollectionView-Swift/Sample/MosaicCollectionViewLayout.swift old mode 100644 new mode 100755 index a8770d528..96c9eae85 --- a/examples/CustomCollectionView-Swift/Sample/MosaicCollectionViewLayout.swift +++ b/examples/CustomCollectionView-Swift/Sample/MosaicCollectionViewLayout.swift @@ -2,19 +2,22 @@ // MosaicCollectionViewLayout // Sample // -// Created by Rajeev Gupta on 11/9/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. +// 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 // -// 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. +// 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 Foundation diff --git a/examples/CustomCollectionView-Swift/Sample/ViewController.swift b/examples/CustomCollectionView-Swift/Sample/ViewController.swift index c325f8bc2..a010188b1 100644 --- a/examples/CustomCollectionView-Swift/Sample/ViewController.swift +++ b/examples/CustomCollectionView-Swift/Sample/ViewController.swift @@ -2,19 +2,22 @@ // ViewController.swift // Sample // -// Created by Rajeev Gupta on 11/9/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. +// 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 // -// 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. +// 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 From 2eb45cf8efed33227fa796b8092c4305a79070cf Mon Sep 17 00:00:00 2001 From: George A Date: Tue, 18 Apr 2017 11:02:15 +0200 Subject: [PATCH 2/2] Fixed crash and removed storyboard --- .../Sample.xcodeproj/project.pbxproj | 12 --------- .../Sample/AppDelegate.swift | 7 +++++ .../Sample/Base.lproj/Main.storyboard | 26 ------------------- .../Sample/ImageCellNode.swift | 3 --- .../Sample/Info.plist | 2 -- .../Sample/ViewController.swift | 25 +++++++++--------- 6 files changed, 19 insertions(+), 56 deletions(-) mode change 100644 => 100755 examples/CustomCollectionView-Swift/Sample.xcodeproj/project.pbxproj delete mode 100644 examples/CustomCollectionView-Swift/Sample/Base.lproj/Main.storyboard mode change 100644 => 100755 examples/CustomCollectionView-Swift/Sample/Info.plist diff --git a/examples/CustomCollectionView-Swift/Sample.xcodeproj/project.pbxproj b/examples/CustomCollectionView-Swift/Sample.xcodeproj/project.pbxproj old mode 100644 new mode 100755 index 186ac5b21..1ecfa3fb9 --- a/examples/CustomCollectionView-Swift/Sample.xcodeproj/project.pbxproj +++ b/examples/CustomCollectionView-Swift/Sample.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ 27F2D2683285DCB73EE734BB /* Pods_Sample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F7DA4A9952245B7E9BA8201F /* Pods_Sample.framework */; }; 5D823AD51DD3B7770075E14A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D823AD41DD3B7770075E14A /* AppDelegate.swift */; }; 5D823AD71DD3B7770075E14A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D823AD61DD3B7770075E14A /* ViewController.swift */; }; - 5D823ADA1DD3B7770075E14A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5D823AD81DD3B7770075E14A /* Main.storyboard */; }; 5D823ADC1DD3B7770075E14A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5D823ADB1DD3B7770075E14A /* Assets.xcassets */; }; 5D823ADF1DD3B7770075E14A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5D823ADD1DD3B7770075E14A /* LaunchScreen.storyboard */; }; 5D823AE71DD3B7D30075E14A /* MosaicCollectionViewLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D823AE61DD3B7D30075E14A /* MosaicCollectionViewLayout.swift */; }; @@ -21,7 +20,6 @@ 5D823AD11DD3B7770075E14A /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 5D823AD41DD3B7770075E14A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 5D823AD61DD3B7770075E14A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; - 5D823AD91DD3B7770075E14A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 5D823ADB1DD3B7770075E14A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 5D823ADE1DD3B7770075E14A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 5D823AE01DD3B7770075E14A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -78,7 +76,6 @@ 5D823AD61DD3B7770075E14A /* ViewController.swift */, 5D823AE81DD3B7D70075E14A /* ImageCellNode.swift */, 5D823AE61DD3B7D30075E14A /* MosaicCollectionViewLayout.swift */, - 5D823AD81DD3B7770075E14A /* Main.storyboard */, 5D823ADB1DD3B7770075E14A /* Assets.xcassets */, 5D823ADD1DD3B7770075E14A /* LaunchScreen.storyboard */, 5D823AE01DD3B7770075E14A /* Info.plist */, @@ -159,7 +156,6 @@ files = ( 5D823ADF1DD3B7770075E14A /* LaunchScreen.storyboard in Resources */, 5D823ADC1DD3B7770075E14A /* Assets.xcassets in Resources */, - 5D823ADA1DD3B7770075E14A /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -228,14 +224,6 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ - 5D823AD81DD3B7770075E14A /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 5D823AD91DD3B7770075E14A /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; 5D823ADD1DD3B7770075E14A /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( diff --git a/examples/CustomCollectionView-Swift/Sample/AppDelegate.swift b/examples/CustomCollectionView-Swift/Sample/AppDelegate.swift index fb029b2dd..7606d4f94 100644 --- a/examples/CustomCollectionView-Swift/Sample/AppDelegate.swift +++ b/examples/CustomCollectionView-Swift/Sample/AppDelegate.swift @@ -30,6 +30,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. + let window = UIWindow(frame: UIScreen.main.bounds) + window.backgroundColor = .white + window.rootViewController = ViewController() + window.makeKeyAndVisible() + + self.window = window + return true } diff --git a/examples/CustomCollectionView-Swift/Sample/Base.lproj/Main.storyboard b/examples/CustomCollectionView-Swift/Sample/Base.lproj/Main.storyboard deleted file mode 100644 index 273375fc7..000000000 --- a/examples/CustomCollectionView-Swift/Sample/Base.lproj/Main.storyboard +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/CustomCollectionView-Swift/Sample/ImageCellNode.swift b/examples/CustomCollectionView-Swift/Sample/ImageCellNode.swift index 93179c006..ecd0e358b 100644 --- a/examples/CustomCollectionView-Swift/Sample/ImageCellNode.swift +++ b/examples/CustomCollectionView-Swift/Sample/ImageCellNode.swift @@ -32,9 +32,6 @@ class ImageCellNode: ASCellNode { } override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec { - let imageSize = imageNode.image?.size - print("imageNode= \(imageNode.bounds), image=\(imageSize)") - var imageRatio: CGFloat = 0.5 if imageNode.image != nil { imageRatio = (imageNode.image?.size.height)! / (imageNode.image?.size.width)! diff --git a/examples/CustomCollectionView-Swift/Sample/Info.plist b/examples/CustomCollectionView-Swift/Sample/Info.plist old mode 100644 new mode 100755 index 38e98af23..b8901eef4 --- a/examples/CustomCollectionView-Swift/Sample/Info.plist +++ b/examples/CustomCollectionView-Swift/Sample/Info.plist @@ -22,8 +22,6 @@ UILaunchStoryboardName LaunchScreen - UIMainStoryboardFile - Main UIRequiredDeviceCapabilities armv7 diff --git a/examples/CustomCollectionView-Swift/Sample/ViewController.swift b/examples/CustomCollectionView-Swift/Sample/ViewController.swift index a010188b1..b6954c9b9 100644 --- a/examples/CustomCollectionView-Swift/Sample/ViewController.swift +++ b/examples/CustomCollectionView-Swift/Sample/ViewController.swift @@ -23,19 +23,19 @@ import UIKit import AsyncDisplayKit -class ViewController: UIViewController, MosaicCollectionViewLayoutDelegate, ASCollectionDataSource, ASCollectionDelegate { +class ViewController: ASViewController, MosaicCollectionViewLayoutDelegate, ASCollectionDataSource, ASCollectionDelegate { var _sections = [[UIImage]]() - let _collectionNode: ASCollectionNode! + let _collectionNode: ASCollectionNode let _layoutInspector = MosaicCollectionViewLayoutInspector() let kNumberOfImages: UInt = 14 - - required init?(coder aDecoder: NSCoder) { + + init() { let layout = MosaicCollectionViewLayout() layout.numberOfColumns = 3; layout.headerHeight = 44; _collectionNode = ASCollectionNode(frame: CGRect.zero, collectionViewLayout: layout) - super.init(coder: aDecoder) + super.init(node: _collectionNode) layout.delegate = self _sections.append([]); @@ -51,12 +51,14 @@ class ViewController: UIViewController, MosaicCollectionViewLayoutDelegate, ASCo _collectionNode.dataSource = self; _collectionNode.delegate = self; - _collectionNode.view.layoutInspector = _layoutInspector _collectionNode.backgroundColor = UIColor.white - _collectionNode.view.isScrollEnabled = true _collectionNode.registerSupplementaryNode(ofKind: UICollectionElementKindSectionHeader) } + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + deinit { _collectionNode.dataSource = nil; _collectionNode.delegate = nil; @@ -64,13 +66,10 @@ class ViewController: UIViewController, MosaicCollectionViewLayoutDelegate, ASCo override func viewDidLoad() { super.viewDidLoad() - self.view.addSubnode(_collectionNode!) - } - - override func viewWillLayoutSubviews() { - _collectionNode.frame = self.view.bounds; + _collectionNode.view.layoutInspector = _layoutInspector + _collectionNode.view.isScrollEnabled = true } - + func collectionNode(_ collectionNode: ASCollectionNode, nodeForItemAt indexPath: IndexPath) -> ASCellNode { let image = _sections[indexPath.section][indexPath.item] return ImageCellNode(with: image)