diff --git a/FacebookSwift.xcodeproj/project.pbxproj b/FacebookSwift.xcodeproj/project.pbxproj index 11e14856..3213cbe4 100644 --- a/FacebookSwift.xcodeproj/project.pbxproj +++ b/FacebookSwift.xcodeproj/project.pbxproj @@ -33,7 +33,7 @@ 813C9CFA1D1DBFA000288BFA /* LoginButton.Tooltip.swift in Sources */ = {isa = PBXBuildFile; fileRef = 813C9CF91D1DBFA000288BFA /* LoginButton.Tooltip.swift */; }; 815DEBCC1D024ADD000370CA /* GraphRequestProtocol.Bridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 815DEBCB1D024ADD000370CA /* GraphRequestProtocol.Bridge.swift */; }; 816B75A71D07AEB70012AC43 /* GraphRequestDataAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 816B75A61D07AEB70012AC43 /* GraphRequestDataAttachment.swift */; }; - 817021AE1D18DE1500ECE7AC /* UserProfilePictureView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 817021AD1D18DE1500ECE7AC /* UserProfilePictureView.swift */; }; + 817021AE1D18DE1500ECE7AC /* UserProfile.PictureView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 817021AD1D18DE1500ECE7AC /* UserProfile.PictureView.swift */; }; 817A0A0E1D07CE8A00FD423A /* GraphRequestResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 817A0A0D1D07CE8A00FD423A /* GraphRequestResult.swift */; }; 81AB8A871D36D43100066F63 /* FBSDKCoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81AB8A3D1D36D41700066F63 /* FBSDKCoreKit.framework */; }; 81AB8A941D36D44C00066F63 /* FBSDKCoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81AB8A3D1D36D41700066F63 /* FBSDKCoreKit.framework */; }; @@ -384,7 +384,7 @@ 81654DD51D356E9A006401F1 /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 81654DD61D356E9A006401F1 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 816B75A61D07AEB70012AC43 /* GraphRequestDataAttachment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphRequestDataAttachment.swift; sourceTree = ""; }; - 817021AD1D18DE1500ECE7AC /* UserProfilePictureView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserProfilePictureView.swift; sourceTree = ""; }; + 817021AD1D18DE1500ECE7AC /* UserProfile.PictureView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserProfile.PictureView.swift; sourceTree = ""; }; 817A0A0D1D07CE8A00FD423A /* GraphRequestResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphRequestResult.swift; sourceTree = ""; }; 81AB8A091D36D41700066F63 /* FBSDKCoreKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = FBSDKCoreKit.xcodeproj; path = "../Carthage/Checkouts/facebook-ios-sdk/FBSDKCoreKit/FBSDKCoreKit.xcodeproj"; sourceTree = ""; }; 81AB8A0C1D36D41700066F63 /* FBSDKLoginKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = FBSDKLoginKit.xcodeproj; path = "../Carthage/Checkouts/facebook-ios-sdk/FBSDKLoginKit/FBSDKLoginKit.xcodeproj"; sourceTree = ""; }; @@ -906,7 +906,7 @@ isa = PBXGroup; children = ( 81FC4EF11D068564003F3A46 /* UserProfile.swift */, - 817021AD1D18DE1500ECE7AC /* UserProfilePictureView.swift */, + 817021AD1D18DE1500ECE7AC /* UserProfile.PictureView.swift */, ); path = UserProfile; sourceTree = ""; @@ -1273,7 +1273,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 817021AE1D18DE1500ECE7AC /* UserProfilePictureView.swift in Sources */, + 817021AE1D18DE1500ECE7AC /* UserProfile.PictureView.swift in Sources */, 810192B61D01305400B9E881 /* SDKLoggingBehavior.swift in Sources */, 81FC4CBB1D0674F4003F3A46 /* PublishPermission.swift in Sources */, 810192B51D01305400B9E881 /* ApplicationDelegate.swift in Sources */, diff --git a/Sources/Core/UserProfile/UserProfile.PictureView.swift b/Sources/Core/UserProfile/UserProfile.PictureView.swift new file mode 100644 index 00000000..af0f37a3 --- /dev/null +++ b/Sources/Core/UserProfile/UserProfile.PictureView.swift @@ -0,0 +1,90 @@ +// Copyright (c) 2016-present, Facebook, Inc. 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 Facebook. +// +// As with any software that integrates with the Facebook platform, your use of +// this software is subject to the Facebook Developer Principles and Policies +// [http://developers.facebook.com/policy/]. 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 Foundation +import UIKit + +import FBSDKCoreKit.FBSDKProfilePictureView + +extension UserProfile { + + /// A view to display a profile picture. + public class PictureView: UIView { + + private let sdkProfilePictureView = FBSDKProfilePictureView(frame: .zero) + + /// The aspect ratio of the source image of the profile picture. + public var pictureAspectRatio = UserProfile.PictureAspectRatio.Square { + didSet { + sdkProfilePictureView.pictureMode = pictureAspectRatio.sdkPictureMode + } + } + + /// The user id to show the picture for. + public var userId = "me" { + didSet { + sdkProfilePictureView.profileID = userId + } + } + + /** + Create a new instance of `UserProfilePictureView`. + + - parameter frame: Optional frame rectangle for the view, measured in points. + - parameter profile: Optional profile to display a picture for. Default: `UserProfile.current`. + */ + public init(frame: CGRect = .zero, profile: UserProfile? = nil) { + super.init(frame: frame) + + if let profile = profile { + userId = profile.userId + } + setupSDKProfilePictureView() + } + + /** + Create a new instance of `UserProfilePictureView` from an encoded interface file. + + - parameter decoder: The coder to initialize from. + */ + public required init?(coder decoder: NSCoder) { + super.init(coder: decoder) + setupSDKProfilePictureView() + } + + /** + Explicitly marks the receiver as needing to update the image. + + This method is called whenever any properties that affect the source image are modified, + but this can also be used to trigger a manual update of the image if it needs to be re-downloaded. + */ + public func setNeedsImageUpdate() { + sdkProfilePictureView.setNeedsImageUpdate() + } + } +} + +extension UserProfile.PictureView { + + private func setupSDKProfilePictureView() { + sdkProfilePictureView.frame = bounds + sdkProfilePictureView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight] + addSubview(sdkProfilePictureView) + setNeedsImageUpdate() // Trigger the update to refresh the image, just in case. + } +} diff --git a/Sources/Core/UserProfile/UserProfilePictureView.swift b/Sources/Core/UserProfile/UserProfilePictureView.swift deleted file mode 100644 index 0d74c073..00000000 --- a/Sources/Core/UserProfile/UserProfilePictureView.swift +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2016-present, Facebook, Inc. 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 Facebook. -// -// As with any software that integrates with the Facebook platform, your use of -// this software is subject to the Facebook Developer Principles and Policies -// [http://developers.facebook.com/policy/]. 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 Foundation -import UIKit - -import FBSDKCoreKit.FBSDKProfilePictureView - -/// A view to display a profile picture. -public class UserProfilePictureView: UIView { - - private let sdkProfilePictureView = FBSDKProfilePictureView(frame: .zero) - - /// The aspect ratio of the source image of the profile picture. - public var pictureAspectRatio = UserProfile.PictureAspectRatio.Square { - didSet { - sdkProfilePictureView.pictureMode = pictureAspectRatio.sdkPictureMode - } - } - - /// The user id to show the picture for. - public var userId = "me" { - didSet { - sdkProfilePictureView.profileID = userId - } - } - - /** - Create a new instance of `UserProfilePictureView`. - - - parameter frame: Optional frame rectangle for the view, measured in points. - - parameter profile: Optional profile to display a picture for. Default: `UserProfile.current`. - */ - public init(frame: CGRect = .zero, profile: UserProfile? = nil) { - super.init(frame: frame) - - if let profile = profile { - userId = profile.userId - } - setupSDKProfilePictureView() - } - - /** - Create a new instance of `UserProfilePictureView` from an encoded interface file. - - - parameter decoder: The coder to initialize from. - */ - public required init?(coder decoder: NSCoder) { - super.init(coder: decoder) - setupSDKProfilePictureView() - } - - /** - Explicitly marks the receiver as needing to update the image. - - This method is called whenever any properties that affect the source image are modified, - but this can also be used to trigger a manual update of the image if it needs to be re-downloaded. - */ - public func setNeedsImageUpdate() { - sdkProfilePictureView.setNeedsImageUpdate() - } -} - -extension UserProfilePictureView { - private func setupSDKProfilePictureView() { - sdkProfilePictureView.frame = bounds - sdkProfilePictureView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight] - addSubview(sdkProfilePictureView) - setNeedsImageUpdate() // Trigger the update to refresh the image, just in case. - } -}