Skip to content

Commit

Permalink
Add some notes and deprecation messages
Browse files Browse the repository at this point in the history
  • Loading branch information
pinarol committed Mar 28, 2024
1 parent fe2575c commit a196a9c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Sources/WordPressUI/Extensions/Gravatar/Gravatar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Foundation
/// Helper Enum that specifies all of the available Gravatar Image Ratings
/// TODO: Convert into a pure Swift String Enum. It's done this way to maintain ObjC Compatibility
///
@available(*, deprecated, message: "Use `Rating` from the Gravatar iOS SDK. See: https://github.com/Automattic/Gravatar-SDK-iOS.")
@objc
public enum GravatarRatings: Int {
case g
Expand Down Expand Up @@ -30,12 +31,14 @@ public enum GravatarRatings: Int {
/// Helper Enum that specifies some of the options for default images
/// To see all available options, visit : https://en.gravatar.com/site/implement/images/
///
@available(*, deprecated, message: "Use `DefaultAvatarOption` from the Gravatar iOS SDK. See: https://github.com/Automattic/Gravatar-SDK-iOS.")
public enum GravatarDefaultImage: String {
case fileNotFound = "404"
case mp
case identicon
}

@available(*, deprecated, message: "Use `AvatarURL` from the Gravatar iOS SDK. See: https://github.com/Automattic/Gravatar-SDK-iOS")
public struct Gravatar {
fileprivate struct Defaults {
static let scheme = "https"
Expand Down
3 changes: 3 additions & 0 deletions Sources/WordPressUI/Extensions/UIImageView+Gravatar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extension UIImageView {
/// - email: the user's email
/// - rating: expected image rating
///
/// This method uses deprecated types. Check out the UIImageView extension from the Gravatar iOS SDK as an alternative to download images. See: https://github.com/Automattic/Gravatar-SDK-iOS.
@objc
public func downloadGravatarWithEmail(_ email: String, rating: GravatarRatings) {
downloadGravatarWithEmail(email, rating: rating, placeholderImage: .gravatarPlaceholderImage)
Expand All @@ -41,6 +42,7 @@ extension UIImageView {
/// - rating: expected image rating
/// - placeholderImage: Image to be used as Placeholder
///
/// This method uses deprecated types. Check out the UIImageView extension from the Gravatar iOS SDK as an alternative to download images. See: https://github.com/Automattic/Gravatar-SDK-iOS.
@objc
public func downloadGravatarWithEmail(_ email: String, rating: GravatarRatings = .default, placeholderImage: UIImage = .gravatarPlaceholderImage) {
let gravatarURL = Gravatar.gravatarUrl(for: email, size: gravatarDefaultSize(), rating: rating)
Expand Down Expand Up @@ -88,6 +90,7 @@ extension UIImageView {
/// - animate: enable/disable fade in animation
/// - failure: Callback block to be invoked when an error occurs while fetching the Gravatar image
///
/// This method uses deprecated types. Check out the UIImageView extension from the Gravatar iOS SDK as an alternative to download images. See: https://github.com/Automattic/Gravatar-SDK-iOS.
public func downloadGravatar(_ gravatar: Gravatar?, placeholder: UIImage, animate: Bool, failure: ((Error?) -> Void)? = nil) {
guard let gravatar = gravatar else {
self.image = placeholder
Expand Down

0 comments on commit a196a9c

Please sign in to comment.