Add Example-iOS in ObjC

Summary:
Related issue: [#425](https://github.com/Instagram/IGListKit/issues/425)

- [ ] All tests pass. Demo project builds and runs.
- [ ] I added tests, an experiment, or detailed why my change isn't tested.
- [ ] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [ ] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/446

Differential Revision: D4589989

Pulled By: rnystrom

fbshipit-source-id: df91f10e0896dfe2f39a643f68e7ebd91e8461cb
This commit is contained in:
charles
2017-02-20 16:11:56 -08:00
committed by Facebook Github Bot
parent 640b67ebb4
commit 1f33a77412
23 changed files with 890 additions and 3 deletions

View File

@@ -55,6 +55,16 @@
29D2E4AD1DD69B6000CD255D /* DisplaySectionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D2E4AC1DD69B6000CD255D /* DisplaySectionController.swift */; };
29D2E4AF1DD69C0E00CD255D /* DisplayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D2E4AE1DD69C0E00CD255D /* DisplayViewController.swift */; };
29D873561E0C539700A6BA95 /* StackedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D873551E0C539700A6BA95 /* StackedViewController.swift */; };
56C05B691E49B2120026DB39 /* ObjcDemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 56C05B681E49B2120026DB39 /* ObjcDemoViewController.m */; };
56C05B6C1E49B2E80026DB39 /* UserInfoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 56C05B6B1E49B2E80026DB39 /* UserInfoCell.m */; };
56C05B721E49B32A0026DB39 /* CommentCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 56C05B711E49B32A0026DB39 /* CommentCell.m */; };
56C05B751E49B33C0026DB39 /* InteractiveCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 56C05B741E49B33C0026DB39 /* InteractiveCell.m */; };
56C05B781E49B3A50026DB39 /* PhotoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 56C05B771E49B3A50026DB39 /* PhotoCell.m */; };
56C05B7B1E49B4030026DB39 /* UserInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 56C05B7A1E49B4030026DB39 /* UserInfo.m */; };
56C05B7E1E49B49C0026DB39 /* UserInfoSectionController.m in Sources */ = {isa = PBXBuildFile; fileRef = 56C05B7D1E49B49C0026DB39 /* UserInfoSectionController.m */; };
56C05B811E49B4AB0026DB39 /* ImageSectionController.m in Sources */ = {isa = PBXBuildFile; fileRef = 56C05B801E49B4AB0026DB39 /* ImageSectionController.m */; };
56C05B841E49B4B40026DB39 /* CommentSectionController.m in Sources */ = {isa = PBXBuildFile; fileRef = 56C05B831E49B4B40026DB39 /* CommentSectionController.m */; };
56C05B871E49B4C40026DB39 /* InteractiveSectionController.m in Sources */ = {isa = PBXBuildFile; fileRef = 56C05B861E49B4C40026DB39 /* InteractiveSectionController.m */; };
696C69AF297B6455C862314F /* Pods_IGListKitTodayExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D64E902433068998DDE711FB /* Pods_IGListKitTodayExample.framework */; };
75B39B8327726E4F6AA04B13 /* Pods_IGListKitMessageExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 60AF908234A48B4187E68DAB /* Pods_IGListKitMessageExample.framework */; };
814F1E00410200822610BB49 /* Pods_IGListKitExamples.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52A8DC2D07A93D7AA55BC993 /* Pods_IGListKitExamples.framework */; };
@@ -175,6 +185,27 @@
4125DCD99578FDEF3C373BA0 /* Pods-IGListKitExamples.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IGListKitExamples.release.xcconfig"; path = "Pods/Target Support Files/Pods-IGListKitExamples/Pods-IGListKitExamples.release.xcconfig"; sourceTree = "<group>"; };
45D6CC137030027019AE64D8 /* Pods-IGListKitTodayExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IGListKitTodayExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-IGListKitTodayExample/Pods-IGListKitTodayExample.debug.xcconfig"; sourceTree = "<group>"; };
52A8DC2D07A93D7AA55BC993 /* Pods_IGListKitExamples.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_IGListKitExamples.framework; sourceTree = BUILT_PRODUCTS_DIR; };
56C05B661E49B2110026DB39 /* IGListKitExamples-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "IGListKitExamples-Bridging-Header.h"; sourceTree = "<group>"; };
56C05B671E49B2120026DB39 /* ObjcDemoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjcDemoViewController.h; sourceTree = "<group>"; };
56C05B681E49B2120026DB39 /* ObjcDemoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjcDemoViewController.m; sourceTree = "<group>"; };
56C05B6A1E49B2E80026DB39 /* UserInfoCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserInfoCell.h; sourceTree = "<group>"; };
56C05B6B1E49B2E80026DB39 /* UserInfoCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserInfoCell.m; sourceTree = "<group>"; };
56C05B701E49B32A0026DB39 /* CommentCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommentCell.h; sourceTree = "<group>"; };
56C05B711E49B32A0026DB39 /* CommentCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommentCell.m; sourceTree = "<group>"; };
56C05B731E49B33C0026DB39 /* InteractiveCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InteractiveCell.h; sourceTree = "<group>"; };
56C05B741E49B33C0026DB39 /* InteractiveCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InteractiveCell.m; sourceTree = "<group>"; };
56C05B761E49B3A50026DB39 /* PhotoCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoCell.h; sourceTree = "<group>"; };
56C05B771E49B3A50026DB39 /* PhotoCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoCell.m; sourceTree = "<group>"; };
56C05B791E49B4030026DB39 /* UserInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserInfo.h; sourceTree = "<group>"; };
56C05B7A1E49B4030026DB39 /* UserInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserInfo.m; sourceTree = "<group>"; };
56C05B7C1E49B49C0026DB39 /* UserInfoSectionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserInfoSectionController.h; sourceTree = "<group>"; };
56C05B7D1E49B49C0026DB39 /* UserInfoSectionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserInfoSectionController.m; sourceTree = "<group>"; };
56C05B7F1E49B4AB0026DB39 /* ImageSectionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageSectionController.h; sourceTree = "<group>"; };
56C05B801E49B4AB0026DB39 /* ImageSectionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageSectionController.m; sourceTree = "<group>"; };
56C05B821E49B4B40026DB39 /* CommentSectionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommentSectionController.h; sourceTree = "<group>"; };
56C05B831E49B4B40026DB39 /* CommentSectionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommentSectionController.m; sourceTree = "<group>"; };
56C05B851E49B4C40026DB39 /* InteractiveSectionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InteractiveSectionController.h; sourceTree = "<group>"; };
56C05B861E49B4C40026DB39 /* InteractiveSectionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InteractiveSectionController.m; sourceTree = "<group>"; };
5CA315001853FD08906AD911 /* Pods-IGListKitTodayExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IGListKitTodayExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-IGListKitTodayExample/Pods-IGListKitTodayExample.release.xcconfig"; sourceTree = "<group>"; };
60AF908234A48B4187E68DAB /* Pods_IGListKitMessageExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_IGListKitMessageExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
821BC4B51DB8B3DC00172ED0 /* StoryboardViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StoryboardViewController.swift; sourceTree = "<group>"; };
@@ -271,6 +302,14 @@
821BC4B91DB8B61200172ED0 /* StoryboardLabelSectionController.swift */,
2942FF8B1D9F39E00015D24B /* UserSectionController.swift */,
2981BA361DB869FF00A987F9 /* WorkingRangeSectionController.swift */,
56C05B7C1E49B49C0026DB39 /* UserInfoSectionController.h */,
56C05B7D1E49B49C0026DB39 /* UserInfoSectionController.m */,
56C05B7F1E49B4AB0026DB39 /* ImageSectionController.h */,
56C05B801E49B4AB0026DB39 /* ImageSectionController.m */,
56C05B821E49B4B40026DB39 /* CommentSectionController.h */,
56C05B831E49B4B40026DB39 /* CommentSectionController.m */,
56C05B851E49B4C40026DB39 /* InteractiveSectionController.h */,
56C05B861E49B4C40026DB39 /* InteractiveSectionController.m */,
);
path = SectionControllers;
sourceTree = "<group>";
@@ -333,6 +372,9 @@
821BC4B51DB8B3DC00172ED0 /* StoryboardViewController.swift */,
29C6297A1DCFD857004A5BB1 /* SupplementaryViewController.swift */,
2981BA381DB874BB00A987F9 /* WorkingRangeViewController.swift */,
56C05B671E49B2120026DB39 /* ObjcDemoViewController.h */,
56C05B681E49B2120026DB39 /* ObjcDemoViewController.m */,
56C05B661E49B2110026DB39 /* IGListKitExamples-Bridging-Header.h */,
);
path = ViewControllers;
sourceTree = "<group>";
@@ -357,6 +399,14 @@
821BC4B71DB8B48300172ED0 /* StoryboardCell.swift */,
29C629821DCFDB57004A5BB1 /* UserHeaderView.swift */,
29C629801DCFDAF3004A5BB1 /* UserHeaderView.xib */,
56C05B6A1E49B2E80026DB39 /* UserInfoCell.h */,
56C05B6B1E49B2E80026DB39 /* UserInfoCell.m */,
56C05B701E49B32A0026DB39 /* CommentCell.h */,
56C05B711E49B32A0026DB39 /* CommentCell.m */,
56C05B731E49B33C0026DB39 /* InteractiveCell.h */,
56C05B741E49B33C0026DB39 /* InteractiveCell.m */,
56C05B761E49B3A50026DB39 /* PhotoCell.h */,
56C05B771E49B3A50026DB39 /* PhotoCell.m */,
);
path = Views;
sourceTree = "<group>";
@@ -367,6 +417,8 @@
29C6297C1DCFD8E5004A5BB1 /* FeedItem.swift */,
296DD75C1DD21ADA00206780 /* SelectionModel.swift */,
2991F91D1D7BB30C00B0C58F /* User.swift */,
56C05B791E49B4030026DB39 /* UserInfo.h */,
56C05B7A1E49B4030026DB39 /* UserInfo.m */,
);
path = Models;
sourceTree = "<group>";
@@ -537,7 +589,7 @@
TargetAttributes = {
2961B3891D68B031001C9451 = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0820;
ProvisioningStyle = Automatic;
};
95F7F9101DE5006B00A64FEE = {
@@ -727,9 +779,11 @@
files = (
299068281D75BFEC00A62888 /* MixedDataViewController.swift in Sources */,
299B54001D6BD6630074A202 /* SearchViewController.swift in Sources */,
56C05B7E1E49B49C0026DB39 /* UserInfoSectionController.m in Sources */,
2961B3AE1D68B0B5001C9451 /* SpinnerCell.swift in Sources */,
296DD7591DD2174200206780 /* NibSelfSizingCell.swift in Sources */,
296DD7531DD2147500206780 /* SelfSizingCellsViewController.swift in Sources */,
56C05B691E49B2120026DB39 /* ObjcDemoViewController.m in Sources */,
2961B3B01D68B28E001C9451 /* SearchCell.swift in Sources */,
2942FF8C1D9F39E00015D24B /* DemoSectionController.swift in Sources */,
2981BA351DB868A500A987F9 /* ImageCell.swift in Sources */,
@@ -740,11 +794,14 @@
29D2E4AF1DD69C0E00CD255D /* DisplayViewController.swift in Sources */,
2942FF911D9F39E00015D24B /* LabelSectionController.swift in Sources */,
2981BA391DB874BB00A987F9 /* WorkingRangeViewController.swift in Sources */,
56C05B841E49B4B40026DB39 /* CommentSectionController.m in Sources */,
29C629831DCFDB57004A5BB1 /* UserHeaderView.swift in Sources */,
2961B3AC1D68B0B5001C9451 /* LoadMoreViewController.swift in Sources */,
26271C941DAE9F050073E116 /* NibCell.swift in Sources */,
2991F9191D7BADC900B0C58F /* CenterLabelCell.swift in Sources */,
29628F141D91905A0026B15A /* DetailLabelCell.swift in Sources */,
56C05B811E49B4AB0026DB39 /* ImageSectionController.m in Sources */,
56C05B751E49B33C0026DB39 /* InteractiveCell.m in Sources */,
2991F9301D7BC0E400B0C58F /* EmptyViewController.swift in Sources */,
29D2E4AD1DD69B6000CD255D /* DisplaySectionController.swift in Sources */,
2991F91E1D7BB30C00B0C58F /* User.swift in Sources */,
@@ -753,12 +810,14 @@
2942FF941D9F39E00015D24B /* UserSectionController.swift in Sources */,
29459C001DBE48E200F05375 /* DiffTableViewController.swift in Sources */,
2991F92C1D7BBE5400B0C58F /* RemoveCell.swift in Sources */,
56C05B871E49B4C40026DB39 /* InteractiveSectionController.m in Sources */,
2942FF8D1D9F39E00015D24B /* EmbeddedSectionController.swift in Sources */,
29C6297B1DCFD857004A5BB1 /* SupplementaryViewController.swift in Sources */,
296DD7551DD2150600206780 /* SelfSizingSectionController.swift in Sources */,
2991F9281D7BB9EC00B0C58F /* EmbeddedCollectionViewCell.swift in Sources */,
2942FF8F1D9F39E00015D24B /* GridSectionController.swift in Sources */,
821BC4B81DB8B48300172ED0 /* StoryboardCell.swift in Sources */,
56C05B781E49B3A50026DB39 /* PhotoCell.m in Sources */,
2942FF921D9F39E00015D24B /* RemoveSectionController.swift in Sources */,
26271C8E1DAE9D3F0073E116 /* SingleSectionViewController.swift in Sources */,
2961B3AD1D68B0B5001C9451 /* LabelCell.swift in Sources */,
@@ -767,11 +826,14 @@
2961B3AB1D68B0B5001C9451 /* DemosViewController.swift in Sources */,
296DD75D1DD21ADA00206780 /* SelectionModel.swift in Sources */,
29C6297D1DCFD8E5004A5BB1 /* FeedItem.swift in Sources */,
56C05B6C1E49B2E80026DB39 /* UserInfoCell.m in Sources */,
821BC4B61DB8B3DC00172ED0 /* StoryboardViewController.swift in Sources */,
296DD7571DD2163800206780 /* ManuallySelfSizingCell.swift in Sources */,
29C6297F1DCFD9E9004A5BB1 /* FeedItemSectionController.swift in Sources */,
2942FF8E1D9F39E00015D24B /* ExpandableSectionController.swift in Sources */,
56C05B721E49B32A0026DB39 /* CommentCell.m in Sources */,
821BC4BA1DB8B61200172ED0 /* StoryboardLabelSectionController.swift in Sources */,
56C05B7B1E49B4030026DB39 /* UserInfo.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -941,7 +1003,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.instagram.IGListKitExamples;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OBJC_BRIDGING_HEADER = "IGListKitExamples/ViewControllers/IGListKitExamples-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
@@ -961,7 +1023,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.instagram.IGListKitExamples;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OBJC_BRIDGING_HEADER = "IGListKitExamples/ViewControllers/IGListKitExamples-Bridging-Header.h";
SWIFT_VERSION = 3.0;
};
name = Release;

View File

@@ -0,0 +1,21 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 <Foundation/Foundation.h>
#import <IGListKit/IGListKit.h>
@interface UserInfo : NSObject <IGListDiffable>
@property (nonatomic, copy) NSString *name;
- (instancetype)initWithName:(NSString *)name;
@end

View File

@@ -0,0 +1,36 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 "UserInfo.h"
@implementation UserInfo
- (instancetype)initWithName:(NSString *)name {
if (self = [super init]) {
self.name = name;
}
return self;
}
#pragma mark - IGListDiffable
- (nonnull id<NSObject>)diffIdentifier {
return self;
}
- (BOOL)isEqualToDiffableObject:(nullable id<IGListDiffable>)object {
return [self isEqual:object];
}
@end

View File

@@ -0,0 +1,19 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 <IGListKit/IGListKit.h>
@interface CommentSectionController : IGListSectionController <IGListSectionType>
@end

View File

@@ -0,0 +1,48 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 "CommentSectionController.h"
#import "CommentCell.h"
@interface CommentSectionController ()
@property (nonatomic, strong) NSString *comment;
@end
@implementation CommentSectionController
#pragma mark - IGListSectionType
- (NSInteger)numberOfItems {
return 1;
}
- (CGSize)sizeForItemAtIndex:(NSInteger)index {
return CGSizeMake(self.collectionContext.containerSize.width, 25);
}
- (UICollectionViewCell *)cellForItemAtIndex:(NSInteger)index {
CommentCell *cell = [self.collectionContext dequeueReusableCellOfClass:[CommentCell class] forSectionController:self atIndex:index];
cell.comment = self.comment;
return cell;
}
- (void)didUpdateToObject:(id)object {
self.comment = object;
}
- (void)didSelectItemAtIndex:(NSInteger)index {
}
@end

View File

@@ -0,0 +1,19 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 <IGListKit/IGListKit.h>
@interface ImageSectionController : IGListSectionController <IGListSectionType>
@end

View File

@@ -0,0 +1,42 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 "ImageSectionController.h"
#import "PhotoCell.h"
@implementation ImageSectionController
#pragma mark - IGListSectionType
- (NSInteger)numberOfItems {
return 1;
}
- (CGSize)sizeForItemAtIndex:(NSInteger)index {
return CGSizeMake(self.collectionContext.containerSize.width, self.collectionContext.containerSize.width);
}
- (UICollectionViewCell *)cellForItemAtIndex:(NSInteger)index {
PhotoCell *cell = [self.collectionContext dequeueReusableCellOfClass:[PhotoCell class] forSectionController:self atIndex:index];
return cell;
}
- (void)didUpdateToObject:(id)object {
}
- (void)didSelectItemAtIndex:(NSInteger)index {
}
@end

View File

@@ -0,0 +1,19 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 <IGListKit/IGListKit.h>
@interface InteractiveSectionController : IGListSectionController <IGListSectionType>
@end

View File

@@ -0,0 +1,43 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 "InteractiveSectionController.h"
#import "InteractiveCell.h"
@implementation InteractiveSectionController
#pragma mark - IGListSectionType
- (NSInteger)numberOfItems {
return 1;
}
- (CGSize)sizeForItemAtIndex:(NSInteger)index {
return CGSizeMake(self.collectionContext.containerSize.width, 41);
}
- (UICollectionViewCell *)cellForItemAtIndex:(NSInteger)index {
InteractiveCell *cell = [self.collectionContext dequeueReusableCellOfClass:[InteractiveCell class] forSectionController:self atIndex:index];
return cell;
}
- (void)didUpdateToObject:(id)object {
}
- (void)didSelectItemAtIndex:(NSInteger)index {
}
@end

View File

@@ -0,0 +1,19 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 <IGListKit/IGListKit.h>
@interface UserInfoSectionController : IGListSectionController <IGListSectionType>
@end

View File

@@ -0,0 +1,50 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 "UserInfoSectionController.h"
#import "UserInfoCell.h"
#import "UserInfo.h"
@interface UserInfoSectionController ()
@property (nonatomic, strong) UserInfo *userInfo;
@end
@implementation UserInfoSectionController
#pragma mark - IGListSectionType
- (NSInteger)numberOfItems {
return 1;
}
- (CGSize)sizeForItemAtIndex:(NSInteger)index {
return CGSizeMake(self.collectionContext.containerSize.width, 41);
}
- (UICollectionViewCell *)cellForItemAtIndex:(NSInteger)index {
UserInfoCell *cell = [self.collectionContext dequeueReusableCellOfClass:[UserInfoCell class] forSectionController:self atIndex:index];
cell.name = self.userInfo.name;
return cell;
}
- (void)didUpdateToObject:(id)object {
self.userInfo = object;
}
- (void)didSelectItemAtIndex:(NSInteger)index {
}
@end

View File

@@ -37,6 +37,7 @@ final class DemosViewController: UIViewController, IGListAdapterDataSource {
DemoItem(name: "Self-sizing cells", controllerClass: SelfSizingCellsViewController.self),
DemoItem(name: "Display delegate", controllerClass: DisplayViewController.self),
DemoItem(name: "Stacked Section Controllers", controllerClass: StackedViewController.self),
DemoItem(name: "Objc Demo", controllerClass: ObjcDemoViewController.self)
]
override func viewDidLoad() {

View File

@@ -0,0 +1,16 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 "ObjcDemoViewController.h"

View File

@@ -0,0 +1,19 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 <UIKit/UIKit.h>
@interface ObjcDemoViewController : UIViewController
@end

View File

@@ -0,0 +1,133 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 "ObjcDemoViewController.h"
#import <IGListKit/IGListKit.h>
#import "UserInfoSectionController.h"
#import "ImageSectionController.h"
#import "InteractiveSectionController.h"
#import "CommentSectionController.h"
#import "UserInfo.h"
#import "PhotoCell.h"
@interface ObjcDemoViewController () <IGListAdapterDataSource>
@property (nonatomic, strong) IGListCollectionView *collectionView;
@property (nonatomic, strong) IGListAdapter *adapter;
@property (nonatomic, strong) NSArray *data;
@end
@implementation ObjcDemoViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setupUI];
}
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
self.collectionView.frame = self.view.bounds;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
#pragma mark - setupUI
- (void)setupUI {
[self.view addSubview:self.collectionView];
self.adapter.collectionView = self.collectionView;
self.adapter.dataSource = self;
}
#pragma mark - IGListAdapterDataSource
- (NSArray<id<IGListDiffable>> *)objectsForListAdapter:(IGListAdapter *)listAdapter {
return self.data;
}
- (IGListSectionController<IGListSectionType> *)listAdapter:(IGListAdapter *)listAdapter sectionControllerForObject:(id)object {
if ([object isKindOfClass:[NSString class]]) {
if ([object isEqualToString:@"Image-Placeholder-String"]) {
return [[ImageSectionController alloc] init];
} else if ([object length]) {
return [[CommentSectionController alloc] init];
} else {
return [[InteractiveSectionController alloc] init];
}
} else {
return [[UserInfoSectionController alloc] init];
}
}
- (UIView *)emptyViewForListAdapter:(IGListAdapter *)listAdapter {
return nil;
}
#pragma mark - Custom Accessors
- (IGListAdapter *)adapter {
if (!_adapter) {
_adapter = [[IGListAdapter alloc] initWithUpdater:[[IGListAdapterUpdater alloc] init]
viewController:self
workingRangeSize:0];
}
return _adapter;
}
- (IGListCollectionView *)collectionView {
if (!_collectionView) {
UICollectionViewLayout *layout = [[UICollectionViewFlowLayout alloc] init];
_collectionView = [[IGListCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
}
return _collectionView;
}
- (NSArray *)data {
if (!_data) {
UserInfo *userA = [[UserInfo alloc] initWithName:@"userA"];
UserInfo *userB = [[UserInfo alloc] initWithName:@"userB"];
UserInfo *userC = [[UserInfo alloc] initWithName:@"userC"];
UserInfo *userD = [[UserInfo alloc] initWithName:@"userD"];
_data = @[userA,
@"Image-Placeholder-String",
@"", @"Luminous triangle",
@"Awesome",
@"Super clean",
@"Stunning shot",
userB,
@"Image-Placeholder-String",
@"",
@"The simplicity here is superb",
@"thanks!", @"That's always so kind of you!",
@"I think you might like this",
userC,
@"Image-Placeholder-String",
@"",
@"So good comment",
userD,
@"Image-Placeholder-String",
@"",
@"hope she might like it.",
@"I love it."];
}
return _data;
}
@end

View File

@@ -0,0 +1,19 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 <UIKit/UIKit.h>
@interface CommentCell : UICollectionViewCell
@property (nonatomic, copy) NSString *comment;
@end

View File

@@ -0,0 +1,59 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 "CommentCell.h"
@interface CommentCell ()
@property (nonatomic, strong) UILabel *commentLabel;
@end
@implementation CommentCell
- (instancetype)init {
if (self = [super init]) {
[self setupSubviews];
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self setupSubviews];
}
return self;
}
- (void)setupSubviews {
self.commentLabel = [[UILabel alloc] init];
self.commentLabel.textColor = [UIColor colorWithRed:0.59 green:0.59 blue:0.57 alpha:1.0];
self.commentLabel.textAlignment = NSTextAlignmentLeft;
self.commentLabel.font = [UIFont systemFontOfSize:11];
[self.contentView addSubview:self.commentLabel];
}
- (void)layoutSubviews {
[super layoutSubviews];
CGFloat left = 8.0;
CGRect bounds = self.contentView.bounds;
self.commentLabel.frame = CGRectMake(left, 0, bounds.size.width - left * 2.0, bounds.size.height);
}
- (void)setComment:(NSString *)comment {
_comment = [comment copy];
self.commentLabel.text = _comment;
}
@end

View File

@@ -0,0 +1,19 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 <UIKit/UIKit.h>
@interface InteractiveCell : UICollectionViewCell
@end

View File

@@ -0,0 +1,85 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 "InteractiveCell.h"
@interface InteractiveCell ()
@property (nonatomic, strong) UIButton *likeButton;
@property (nonatomic, strong) UIButton *commentButton;
@property (nonatomic, strong) UIButton *shareButton;
@property (nonatomic, strong) CALayer *separator;
@end
@implementation InteractiveCell
- (instancetype)init {
if (self = [super init]) {
[self setupSubviews];
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self setupSubviews];
}
return self;
}
- (void)setupSubviews {
UIColor *buttonTitleColor = [UIColor colorWithRed:28/255.0 green:30/255.0 blue:28/255.0 alpha:1.0];
UIFont *titleFont = [UIFont systemFontOfSize:12.0];
self.likeButton = [[UIButton alloc] init];
[self.likeButton setTitle:@"Like" forState:UIControlStateNormal];
[self.likeButton setTitleColor:buttonTitleColor forState:UIControlStateNormal];
[self.likeButton.titleLabel setFont:titleFont];
[self.likeButton sizeToFit];
[self.contentView addSubview:self.likeButton];
self.commentButton = [[UIButton alloc] init];
[self.commentButton setTitle:@"Comment" forState:UIControlStateNormal];
[self.commentButton setTitleColor:buttonTitleColor forState:UIControlStateNormal];
[self.commentButton.titleLabel setFont:titleFont];
[self.commentButton sizeToFit];
[self.contentView addSubview:self.commentButton];
self.shareButton = [[UIButton alloc] init];
[self.shareButton setTitle:@"Share" forState:UIControlStateNormal];
[self.shareButton setTitleColor:buttonTitleColor forState:UIControlStateNormal];
[self.shareButton.titleLabel setFont:titleFont];
[self.shareButton sizeToFit];
[self.contentView addSubview:self.shareButton];
self.separator = [[CALayer alloc] init];
self.separator.backgroundColor = [UIColor colorWithRed:200/255.0 green:199/255.0 blue:204/255.0 alpha:1].CGColor;
[self.contentView.layer addSublayer:self.separator];
}
- (void)layoutSubviews {
[super layoutSubviews];
CGRect bounds = self.contentView.bounds;
CGFloat leftPadding = 8.0;
self.likeButton.frame = CGRectMake(leftPadding, 0, CGRectGetWidth(self.likeButton.frame), bounds.size.height);
self.commentButton.frame = CGRectMake(leftPadding + CGRectGetMaxX(self.likeButton.frame), 0, CGRectGetWidth(self.commentButton.frame), bounds.size.height);
self.shareButton.frame = CGRectMake(leftPadding + CGRectGetMaxX(self.commentButton.frame), 0, CGRectGetWidth(self.shareButton.frame), bounds.size.height);
CGFloat height = 0.5;
self.separator.frame = CGRectMake(leftPadding, bounds.size.height - height, bounds.size.width - leftPadding, height);
}
@end

View File

@@ -0,0 +1,19 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 <UIKit/UIKit.h>
@interface PhotoCell : UICollectionViewCell
@end

View File

@@ -0,0 +1,49 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 "PhotoCell.h"
@interface PhotoCell ()
@property (nonatomic, strong) UIView *view;
@end
@implementation PhotoCell
- (instancetype)init {
if (self = [super init]) {
[self setupSubviews];
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self setupSubviews];
}
return self;
}
- (void)setupSubviews {
self.view = [[UIView alloc] init];
self.view.backgroundColor = [UIColor colorWithRed:4/255.0 green:170/255.0 blue:166/255.0 alpha:1.0];
[self.contentView addSubview:self.view];
}
- (void)layoutSubviews {
[super layoutSubviews];
self.view.frame = self.contentView.frame;
}
@end

View File

@@ -0,0 +1,19 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 <UIKit/UIKit.h>
@interface UserInfoCell : UICollectionViewCell
@property (nonatomic, copy) NSString *name;
@end

View File

@@ -0,0 +1,71 @@
/**
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
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 "UserInfoCell.h"
@interface UserInfoCell ()
@property (nonatomic, strong) UIView *avatarView;
@property (nonatomic, strong) UILabel *nameLabel;
@end
@implementation UserInfoCell
- (instancetype)init {
if (self = [super init]) {
[self setupSubviews];
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self setupSubviews];
}
return self;
}
- (void)setupSubviews {
self.avatarView = [[UIView alloc] init];
self.avatarView.backgroundColor = [UIColor colorWithRed:210/255.0 green:65/255.0 blue:64/255.0 alpha:1.0];
[self.contentView addSubview:self.avatarView];
self.nameLabel = [[UILabel alloc] init];
self.nameLabel.font = [UIFont boldSystemFontOfSize:15];
self.nameLabel.textColor = [UIColor darkTextColor];
self.nameLabel.textAlignment = NSTextAlignmentLeft;
[self.contentView addSubview:self.nameLabel];
}
- (void)layoutSubviews {
[super layoutSubviews];
CGRect bounds = self.contentView.bounds;
CGFloat avatarViewWidth = 25.0;
CGFloat avatarTopSpace = (CGRectGetHeight(bounds) - avatarViewWidth) / 2.0;
CGFloat avatarLeftSpace = 8.0;
self.avatarView.frame = CGRectMake(avatarLeftSpace, avatarTopSpace, avatarViewWidth, avatarViewWidth);
self.avatarView.layer.cornerRadius = MIN(CGRectGetHeight(self.avatarView.frame), CGRectGetWidth(self.avatarView.frame)) / 2.0;
self.avatarView.layer.masksToBounds = YES;
self.nameLabel.frame = CGRectMake(CGRectGetMaxX(self.avatarView.frame) + 8.0, CGRectGetMinY(self.avatarView.frame), CGRectGetWidth(bounds) - CGRectGetMaxX(self.avatarView.frame) - 8.0 * 2, CGRectGetHeight(self.avatarView.frame));
}
- (void)setName:(NSString *)name {
_name = [name copy];
self.nameLabel.text = _name;
}
@end