Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
679fe5a
Configure circle ci
flovilmart Jan 10, 2018
94d8cda
nits
flovilmart Jan 10, 2018
b39fe82
Use xcode 9.1
flovilmart Jan 10, 2018
6b12af5
use 9.0
flovilmart Jan 10, 2018
4a1d689
use ruby 2.3
flovilmart Jan 10, 2018
d04da40
Bumps test targets to 10.3.1
flovilmart Jan 10, 2018
01c8bee
test other config
flovilmart Jan 10, 2018
0718fb1
nits
flovilmart Jan 10, 2018
4f6e2ef
use workflow
flovilmart Jan 10, 2018
0df8e81
rename
flovilmart Jan 10, 2018
91015e5
nit
flovilmart Jan 10, 2018
6adaa26
nit
flovilmart Jan 10, 2018
ef76d53
Use proper Apple TV
flovilmart Jan 10, 2018
ca55fe4
nit
flovilmart Jan 10, 2018
d036b82
Run cocoapods and carthage nightly
flovilmart Jan 10, 2018
940174c
Integrate ParseFacebookUtils in this repo
flovilmart Jan 14, 2018
db55292
Run tests for facebook_utils
flovilmart Jan 14, 2018
d90ec50
Use 10.3.1 for tests
flovilmart Jan 14, 2018
09dcbaa
Adds TwitterUtils
flovilmart Jan 15, 2018
50ecd95
Test all
flovilmart Jan 15, 2018
0bc0b69
Upload to codecov
flovilmart Jan 15, 2018
54e72ea
nits
flovilmart Jan 15, 2018
e2ed15d
Better config
flovilmart Jan 15, 2018
41c2e44
Codecov options
flovilmart Jan 15, 2018
3dfc01f
Stores test results
flovilmart Jan 15, 2018
9c45622
Smaller matrix
flovilmart Jan 15, 2018
fabc26c
Proper test results paths
flovilmart Jan 15, 2018
a69ef55
Update Readmes
flovilmart Jan 15, 2018
f602c4c
Bump version, run travis only for deployments
flovilmart Jan 15, 2018
28ebe5d
Bumps version to 1.16.0
flovilmart Jan 15, 2018
decda41
Run Jazzy and deploy docs on master merges
flovilmart Jan 15, 2018
032120e
Update README
flovilmart Jan 15, 2018
04002c0
Better codecov configuration
flovilmart Jan 15, 2018
ea2a984
Adds ParseUI
flovilmart Jan 15, 2018
4bd679a
Fixes buildM
flovilmart Jan 15, 2018
0ffc111
Adds ability to run carthage / pods optionally
flovilmart Jan 15, 2018
941d0ed
fix
flovilmart Jan 15, 2018
344b9bc
Fix circleCI shield
flovilmart Jan 15, 2018
a4aeefb
nit
flovilmart Jan 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adds ParseUI
  • Loading branch information
flovilmart committed Jan 15, 2018
commit ea2a984aed40f8291124e97cf925012e3d2d1117
7 changes: 7 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ jobs:
- run: bash <(curl -s https://codecov.io/bash)
- store_test_results:
path: build/reports
parseui:
<<: *defaults
steps:
- checkout
- run: *prepare
- run: bundle exec rake test:parseui:all
deployment:
<<: *defaults
steps:
Expand Down Expand Up @@ -92,6 +98,7 @@ workflows:
- macos
- facebook_utils
- twitter_utils
- parseui
- jazzy
nightly:
jobs:
Expand Down
29 changes: 29 additions & 0 deletions Parse.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,33 @@ Pod::Spec.new do |s|
s.libraries = 'z', 'sqlite3'
s.dependency 'Parse/Core'
end

s.subspec 'UI' do |s|
s.platform = :ios
s.requires_arc = true
s.ios.deployment_target = '9.0'
s.source_files = "ParseUI/**/*.{h,m}"
s.exclude_files = 'ParseUI/ParseUIDemo/**/*', 'ParseUI/Other/ParseUI.h'
s.public_header_files = 'ParseUI/Classes/LogInViewController/*.h',
'ParseUI/Classes/SignUpViewController/*.h',
'ParseUI/Classes/QueryTableViewController/*.h',
'ParseUI/Classes/QueryCollectionViewController/*.h',
'ParseUI/Classes/ProductTableViewController/*.h',
'ParseUI/Classes/Views/*.h',
'ParseUI/Classes/Cells/*.h',
'ParseUI/Other/*.h'
s.resource_bundles = { 'ParseUI' => ['ParseUI/Resources/Localization/*.lproj'] }
s.frameworks = 'Foundation',
'UIKit',
'CoreGraphics',
'QuartzCore'
s.dependency 'Parse/Core'
end

# prepare command for parseUI
s.prepare_command = <<-CMD
ruby ParseUI/Scripts/convert_images.rb \
ParseUI/Resources/Images/ \
ParseUI/Generated/PFResources
CMD
end
3 changes: 3 additions & 0 deletions Parse.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions ParseFacebookUtils/ParseFacebookUtils.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
4A9A9502200D1462005D8F4B /* Parse.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A9A9503200D1462005D8F4B /* Parse.framework */; };
4AAEAA41200BE19A00AA7479 /* OCMock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AAEAA42200BE19A00AA7479 /* OCMock.framework */; };
4AAEAA43200BE26C00AA7479 /* Bolts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AAEAA45200BE26C00AA7479 /* Bolts.framework */; };
4AAEAA44200BE26C00AA7479 /* Parse.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AAEAA46200BE26C00AA7479 /* Parse.framework */; };
4AAEAA4F200BED7A00AA7479 /* Bolts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AAEAA51200BED7A00AA7479 /* Bolts.framework */; };
4AAEAA50200BED7A00AA7479 /* Parse.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AAEAA52200BED7A00AA7479 /* Parse.framework */; };
4AAEAA5F200C020E00AA7479 /* PFFacebookUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 813DFC841AB2510300F25A08 /* PFFacebookUtils.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -116,6 +116,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
4A9A9501200D144F005D8F4B /* Parse.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Parse.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4A9A9503200D1462005D8F4B /* Parse.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Parse.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4AAEAA42200BE19A00AA7479 /* OCMock.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = OCMock.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4AAEAA45200BE26C00AA7479 /* Bolts.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Bolts.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4AAEAA46200BE26C00AA7479 /* Parse.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Parse.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -194,7 +196,6 @@
81FE7F721C1778FC00E6BD34 /* ParseFacebookUtilsV4-tvOS.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "ParseFacebookUtilsV4-tvOS.xcconfig"; sourceTree = "<group>"; };
81FE7F8B1C17790400E6BD34 /* ParseFacebookUtilsV4.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ParseFacebookUtilsV4.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D2AAC07E0554694100DB518D /* ParseFacebookUtilsV4.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ParseFacebookUtilsV4.framework; sourceTree = BUILT_PRODUCTS_DIR; };
EE2574ED5D739401DB71A44B /* Pods_ParseFacebookUtilsV4_UnitTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ParseFacebookUtilsV4_UnitTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F52CD64A1B5838560051AB86 /* ParseFacebookUtilsV4-iOS.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "ParseFacebookUtilsV4-iOS.xcconfig"; sourceTree = "<group>"; };
F52CD64B1B5838620051AB86 /* ParseFacebookUtilsV4-UnitTests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "ParseFacebookUtilsV4-UnitTests.xcconfig"; sourceTree = "<group>"; };
F52CD64C1B58386F0051AB86 /* ParseFacebookTestApplicationV4.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ParseFacebookTestApplicationV4.xcconfig; sourceTree = "<group>"; };
Expand Down Expand Up @@ -271,8 +272,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
4A9A9502200D1462005D8F4B /* Parse.framework in Frameworks */,
4AAEAA43200BE26C00AA7479 /* Bolts.framework in Frameworks */,
4AAEAA44200BE26C00AA7479 /* Parse.framework in Frameworks */,
81DA69311AB25A36008C3B7F /* FBSDKCoreKit.framework in Frameworks */,
81DA69321AB25A37008C3B7F /* FBSDKLoginKit.framework in Frameworks */,
);
Expand Down Expand Up @@ -318,6 +319,8 @@
0867D69AFE84028FC02AAC07 /* Frameworks */ = {
isa = PBXGroup;
children = (
4A9A9503200D1462005D8F4B /* Parse.framework */,
4A9A9501200D144F005D8F4B /* Parse.framework */,
4AAEAABA200C103B00AA7479 /* SystemConfiguration.framework */,
4AAEAAB8200C103500AA7479 /* Security.framework */,
4AAEAAB6200C103000AA7479 /* CoreLocation.framework */,
Expand Down Expand Up @@ -347,7 +350,6 @@
4AAEAA42200BE19A00AA7479 /* OCMock.framework */,
813DFC8F1AB2513D00F25A08 /* User Frameworks */,
813DFC8E1AB2513300F25A08 /* System Frameworks */,
EE2574ED5D739401DB71A44B /* Pods_ParseFacebookUtilsV4_UnitTests.framework */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down
24 changes: 16 additions & 8 deletions ParseTwitterUtils/ParseTwitterUtils.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
/* Begin PBXBuildFile section */
06D00BAB1BC78F23005BAA6F /* ParseTwitterUtils.strings in Resources */ = {isa = PBXBuildFile; fileRef = 06D00BAD1BC78F23005BAA6F /* ParseTwitterUtils.strings */; };
06D00BB51BC790F3005BAA6F /* PFTwitterLocalization.h in Headers */ = {isa = PBXBuildFile; fileRef = 06D00BB41BC790F3005BAA6F /* PFTwitterLocalization.h */; };
4A9A94F8200D12A2005D8F4B /* Bolts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A9A94FA200D12A2005D8F4B /* Bolts.framework */; };
4A9A94F9200D12A2005D8F4B /* Parse.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A9A94FB200D12A2005D8F4B /* Parse.framework */; };
4A9A94FC200D12C9005D8F4B /* Bolts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A9A94FE200D12C9005D8F4B /* Bolts.framework */; };
4A9A94FD200D12C9005D8F4B /* Parse.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A9A94FF200D12C9005D8F4B /* Parse.framework */; };
4AAEAAC6200C2B7B00AA7479 /* Bolts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AAEAAC8200C2B7B00AA7479 /* Bolts.framework */; };
4AAEAAC7200C2B7B00AA7479 /* Parse.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AAEAAC9200C2B7B00AA7479 /* Parse.framework */; };
4AAEAACA200C2BBB00AA7479 /* OCMock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AAEAACB200C2BBB00AA7479 /* OCMock.framework */; };
4AAEAACC200C2C5B00AA7479 /* Bolts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AAEAACE200C2C5B00AA7479 /* Bolts.framework */; };
4AAEAAD0200C2C6600AA7479 /* Parse.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AAEAAD1200C2C6600AA7479 /* Parse.framework */; };
8135E4951B4B6A0E0092F452 /* PF_Twitter_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 8135E48E1B4B6A0E0092F452 /* PF_Twitter_Private.h */; };
8135E4961B4B6A0E0092F452 /* PFTwitterAuthenticationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 8135E48F1B4B6A0E0092F452 /* PFTwitterAuthenticationProvider.h */; };
8135E4971B4B6A0E0092F452 /* PFTwitterAuthenticationProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 8135E4901B4B6A0E0092F452 /* PFTwitterAuthenticationProvider.m */; };
Expand Down Expand Up @@ -44,12 +46,10 @@
8168312B1D1E16F000315E21 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8168312A1D1E16F000315E21 /* SystemConfiguration.framework */; };
8168312F1D1E16F700315E21 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8168312E1D1E16F700315E21 /* AudioToolbox.framework */; };
816831331D1E16FE00315E21 /* Social.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 816831321D1E16FE00315E21 /* Social.framework */; };
816831651D1E184A00315E21 /* Parse.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8168314A1D1E183200315E21 /* Parse.framework */; };
816832521D1E1A7900315E21 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8168311C1D1E16DC00315E21 /* Security.framework */; };
816832591D1E1A7E00315E21 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8168312A1D1E16F000315E21 /* SystemConfiguration.framework */; };
8168325E1D1E1A8600315E21 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 816831231D1E16E700315E21 /* libsqlite3.tbd */; };
8168326A1D1E1A8B00315E21 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8168312E1D1E16F700315E21 /* AudioToolbox.framework */; };
816832B41D1E1CCB00315E21 /* Bolts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8168329D1D1E1CB500315E21 /* Bolts.framework */; };
817A37CB1B4B741A00129AFA /* PF_OAuthCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 817A37C91B4B741A00129AFA /* PF_OAuthCore.h */; };
817A37CC1B4B741A00129AFA /* PF_OAuthCore.m in Sources */ = {isa = PBXBuildFile; fileRef = 817A37CA1B4B741A00129AFA /* PF_OAuthCore.m */; };
819DAAD61BB5EC79002BDE2B /* PFTwitterAlertView.h in Headers */ = {isa = PBXBuildFile; fileRef = 819DAAD41BB5EC79002BDE2B /* PFTwitterAlertView.h */; };
Expand Down Expand Up @@ -280,6 +280,10 @@
/* Begin PBXFileReference section */
06D00BAE1BC78F29005BAA6F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/ParseTwitterUtils.strings; sourceTree = "<group>"; };
06D00BB41BC790F3005BAA6F /* PFTwitterLocalization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFTwitterLocalization.h; sourceTree = "<group>"; };
4A9A94FA200D12A2005D8F4B /* Bolts.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Bolts.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4A9A94FB200D12A2005D8F4B /* Parse.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Parse.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4A9A94FE200D12C9005D8F4B /* Bolts.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Bolts.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4A9A94FF200D12C9005D8F4B /* Parse.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Parse.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4AAEAAC8200C2B7B00AA7479 /* Bolts.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Bolts.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4AAEAAC9200C2B7B00AA7479 /* Parse.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Parse.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4AAEAACB200C2BBB00AA7479 /* OCMock.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = OCMock.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -377,8 +381,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
816832B41D1E1CCB00315E21 /* Bolts.framework in Frameworks */,
816831651D1E184A00315E21 /* Parse.framework in Frameworks */,
4A9A94F8200D12A2005D8F4B /* Bolts.framework in Frameworks */,
4A9A94F9200D12A2005D8F4B /* Parse.framework in Frameworks */,
816831331D1E16FE00315E21 /* Social.framework in Frameworks */,
8168312F1D1E16F700315E21 /* AudioToolbox.framework in Frameworks */,
8168312B1D1E16F000315E21 /* SystemConfiguration.framework in Frameworks */,
Expand All @@ -396,8 +400,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
4AAEAAD0200C2C6600AA7479 /* Parse.framework in Frameworks */,
4AAEAACC200C2C5B00AA7479 /* Bolts.framework in Frameworks */,
4A9A94FC200D12C9005D8F4B /* Bolts.framework in Frameworks */,
4A9A94FD200D12C9005D8F4B /* Parse.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -433,6 +437,10 @@
0867D69AFE84028FC02AAC07 /* Frameworks */ = {
isa = PBXGroup;
children = (
4A9A94FE200D12C9005D8F4B /* Bolts.framework */,
4A9A94FF200D12C9005D8F4B /* Parse.framework */,
4A9A94FA200D12A2005D8F4B /* Bolts.framework */,
4A9A94FB200D12A2005D8F4B /* Parse.framework */,
4AAEAAD1200C2C6600AA7479 /* Parse.framework */,
4AAEAACE200C2C5B00AA7479 /* Bolts.framework */,
4AAEAACF200C2C5B00AA7479 /* Bolts.framework */,
Expand Down
66 changes: 66 additions & 0 deletions ParseUI/Classes/Cells/PFCollectionViewCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2014, Parse, LLC. All rights reserved.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
* copy, modify, and distribute this software in source code or binary form for use
* in connection with the web services and APIs provided by Parse.
*
* As with any software that integrates with the Parse platform, your use of
* this software is subject to the Parse Terms of Service
* [https://www.parse.com/about/terms]. This copyright notice shall be
* included in all copies or substantial portions of the software.
*
* 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 THE AUTHORS OR
* COPYRIGHT HOLDERS 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>

#ifdef COCOAPODS
#import "ParseUIConstants.h"
#else
#import <ParseUI/ParseUIConstants.h>
#endif


NS_ASSUME_NONNULL_BEGIN

@class PFImageView;
@class PFObject;

/**
The `PFCollectionViewCell` class represents a collection view cell which can
download and display remote images stored on Parse as well as has a default simple text label.
*/
@interface PFCollectionViewCell : UICollectionViewCell

/**
A simple lazy-loaded label for the collection view cell.
*/
@property (nonatomic, strong, readonly) UILabel *textLabel;

/**
The lazy-loaded imageView of the collection view cell.

@see PFImageView
*/
@property (nonatomic, strong, readonly) PFImageView *imageView;

/**
This method should update all the relevant information inside a subclass of `PFCollectionViewCell`.

This method is automatically called by `PFQueryCollectionViewController` whenever the cell
should display new information. By default this method does nothing.

@param object An instance of `PFObject` to update from.
*/
- (void)updateFromObject:(nullable PFObject *)object;

@end

NS_ASSUME_NONNULL_END
97 changes: 97 additions & 0 deletions ParseUI/Classes/Cells/PFCollectionViewCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright (c) 2014, Parse, LLC. All rights reserved.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
* copy, modify, and distribute this software in source code or binary form for use
* in connection with the web services and APIs provided by Parse.
*
* As with any software that integrates with the Parse platform, your use of
* this software is subject to the Parse Terms of Service
* [https://www.parse.com/about/terms]. This copyright notice shall be
* included in all copies or substantial portions of the software.
*
* 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 THE AUTHORS OR
* COPYRIGHT HOLDERS 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 "PFCollectionViewCell.h"

#import "PFImageView.h"
#import "PFRect.h"

@implementation PFCollectionViewCell

@synthesize imageView = _imageView;
@synthesize textLabel = _textLabel;

#pragma mark -
#pragma mark UIView

- (void)layoutSubviews {
[super layoutSubviews];

const CGRect bounds = self.contentView.bounds;

CGRect imageViewFrame = CGRectZero;
if (_imageView && _imageView.image){
imageViewFrame = PFRectMakeWithSizeCenteredInRect(PFSizeMin(_imageView.image.size, bounds.size),
bounds);
}
CGRect textLabelFrame = CGRectZero;
if (_textLabel) {
CGSize maxImageViewSize = CGSizeMake(CGRectGetWidth(bounds), CGRectGetHeight(bounds) / 3.0f * 2.0f);
CGSize imageViewSize = PFSizeMin(imageViewFrame.size, maxImageViewSize);

imageViewFrame = PFRectMakeWithSizeCenteredInRect(imageViewSize, PFRectMakeWithSize(maxImageViewSize));
CGFloat textLabelTopInset = (CGRectIsEmpty(imageViewFrame) ? 0.0f : CGRectGetMaxY(imageViewFrame));

textLabelFrame = PFRectMakeWithOriginSize(CGPointMake(0.0f, textLabelTopInset),
CGSizeMake(CGRectGetWidth(bounds), CGRectGetHeight(bounds) - textLabelTopInset));
}

// Adapt content mode of _imageView to fit the image in bounds if the layout frame is smaller or center if it's bigger.
if (!CGRectIsEmpty(imageViewFrame)) {
if (CGRectContainsRect(PFRectMakeWithSize(_imageView.image.size), PFRectMakeWithSize(imageViewFrame.size))) {
_imageView.contentMode = UIViewContentModeScaleAspectFit;
} else {
_imageView.contentMode = UIViewContentModeCenter;
}
}

_imageView.frame = CGRectIntegral(imageViewFrame);
_textLabel.frame = CGRectIntegral(textLabelFrame);
}

#pragma mark -
#pragma mark Update

- (void)updateFromObject:(PFObject *)object {
// Do nothing
}

#pragma mark -
#pragma mark Accessors

- (PFImageView *)imageView {
if (!_imageView) {
_imageView = [[PFImageView alloc] initWithFrame:CGRectZero];
[self.contentView addSubview:_imageView];
}
return _imageView;
}

- (UILabel *)textLabel {
if (!_textLabel) {
_textLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_textLabel.numberOfLines = 0;
[self.contentView addSubview:_textLabel];
}
return _textLabel;
}

@end
Loading