|
| 1 | +// RFGravatarImageView.h |
1 | 2 | // |
2 | | -// RFGravatarImageView.h |
| 3 | +// Copyright (c) 2013-2015 Rudd Fawcett (http://ruddfawcett.com) |
3 | 4 | // |
4 | | -// Created by Rudd Fawcett on 12/10/13. |
5 | | -// Copyright (c) 2013 Rudd Fawcett. All rights reserved. |
| 5 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | +// of this software and associated documentation files (the "Software"), to deal |
| 7 | +// in the Software without restriction, including without limitation the rights |
| 8 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 | +// copies of the Software, and to permit persons to whom the Software is |
| 10 | +// furnished to do so, subject to the following conditions: |
6 | 11 | // |
| 12 | +// The above copyright notice and this permission notice shall be included in |
| 13 | +// all copies or substantial portions of the Software. |
| 14 | +// |
| 15 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 21 | +// THE SOFTWARE. |
7 | 22 |
|
8 | 23 | #import <UIKit/UIKit.h> |
9 | 24 | #import <CommonCrypto/CommonDigest.h> |
10 | 25 | #import <SDWebImage/UIImageView+WebCache.h> |
11 | | - |
12 | | -// Rating of Gravatar |
13 | | - |
14 | | -enum { |
15 | | - GravatarRatingAny, |
16 | | - GravatarRatingG, |
17 | | - GravatarRatingPG, |
18 | | - GravatarRatingR, |
19 | | - GravatarRatingX |
| 26 | +#import <AvailabilityMacros.h> |
| 27 | + |
| 28 | +/** |
| 29 | + * The rating for the gravatar. |
| 30 | + */ |
| 31 | +typedef NS_ENUM(NSUInteger, RFGravatarRating) { |
| 32 | + RFGravatarRatingAny, |
| 33 | + /** |
| 34 | + * A Gravatar rating of G can be displayed. |
| 35 | + */ |
| 36 | + RFGravatarRatingG, |
| 37 | + /** |
| 38 | + * A Gravatar rating of PG can be displayed. |
| 39 | + */ |
| 40 | + RFGravatarRatingPG, |
| 41 | + /** |
| 42 | + * A Gravatar rating of R can be displayed. |
| 43 | + */ |
| 44 | + RFGravatarRatingR, |
| 45 | + /** |
| 46 | + * A Gravatar rating of X can be displayed. |
| 47 | + */ |
| 48 | + RFGravatarRatingX |
20 | 49 | }; |
21 | | -typedef NSUInteger GravatarRatings; |
22 | | - |
23 | | -// Default Gravatar types: http://bit.ly/1cCmtdb |
24 | | - |
25 | | -enum { |
26 | | - DefaultGravatarNone, |
27 | | - DefaultGravatar404, |
28 | | - DefaultGravatarMysteryMan, |
29 | | - DefaultGravatarIdenticon, |
30 | | - DefaultGravatarMonsterID, |
31 | | - DefaultGravatarWavatar, |
32 | | - DefaultGravatarRetro, |
33 | | - DefaultGravatarBlank |
| 50 | + |
| 51 | +/** |
| 52 | + * Default Gravatar types: http://bit.ly/1cCmtdb |
| 53 | + */ |
| 54 | +typedef NS_ENUM(NSUInteger, RFDefaultGravatar) { |
| 55 | + /** |
| 56 | + * No default Gravatar. |
| 57 | + */ |
| 58 | + RFDefaultGravatarNone, |
| 59 | + /** |
| 60 | + * 404 Gravatar. |
| 61 | + */ |
| 62 | + RFDefaultGravatar404, |
| 63 | + /** |
| 64 | + * Myster Man Gravatar. |
| 65 | + */ |
| 66 | + RFDefaultGravatarMysteryMan, |
| 67 | + /** |
| 68 | + * Identicon Gravatar. |
| 69 | + */ |
| 70 | + RFDefaultGravatarIdenticon, |
| 71 | + /** |
| 72 | + * Monster ID Gravatar. |
| 73 | + */ |
| 74 | + RFDefaultGravatarMonsterID, |
| 75 | + /** |
| 76 | + * Wavatar Gravatar. |
| 77 | + */ |
| 78 | + RFDefaultGravatarWavatar, |
| 79 | + /** |
| 80 | + * Retro Gravatar |
| 81 | + */ |
| 82 | + RFDefaultGravatarRetro, |
| 83 | + /** |
| 84 | + * Blank Gravatar. |
| 85 | + */ |
| 86 | + RFDefaultGravatarBlank |
34 | 87 | }; |
35 | | -typedef NSUInteger DefaultGravatars; |
36 | 88 |
|
37 | | -@interface RFGravatarImageView : UIImageView |
38 | 89 |
|
39 | | -// I suppose you could use an NSDictionary for this, but I was lazy - feel free to add. |
| 90 | +@interface RFGravatarImageView : UIImageView |
40 | 91 |
|
41 | | -// User email - you must set this! |
| 92 | +/** |
| 93 | + * User email - you must set this! |
| 94 | + */ |
42 | 95 | @property (readwrite, strong, nonatomic) NSString *email; |
43 | 96 |
|
44 | | -// A placeholder image while SDWebImage fetches the gravatar. |
| 97 | +/** |
| 98 | + * A placeholder image while SDWebImage fetches the gravatar. |
| 99 | + */ |
45 | 100 | @property (readwrite, strong, nonatomic) UIImage *placeholder; |
46 | 101 |
|
47 | | -// The size of the gravatar up to 2048. All gravatars are squares, so you will get 2048x2048. |
| 102 | +/** |
| 103 | + * The size of the gravatar up to 2048. All gravatars are squares, so you will get 2048x2048. |
| 104 | + */ |
48 | 105 | @property (readwrite, nonatomic) NSUInteger size; |
49 | 106 |
|
50 | | -// Rating (G, PG, R, X) of gravatar to allow, helpful for kid-friendly apps. |
51 | | -@property (readwrite, nonatomic) GravatarRatings rating; |
| 107 | +/** |
| 108 | + * Rating (G, PG, R, X) of gravatar to allow, helpful for kid-friendly apps. |
| 109 | + */ |
| 110 | +@property (readwrite, nonatomic) RFGravatarRating rating; |
52 | 111 |
|
53 | | -// If email doesn't have a gravatar, use one of these... http://bit.ly/1cCmtdb |
54 | | -@property (readwrite, nonatomic) DefaultGravatars defaultGravatar; |
| 112 | +/** |
| 113 | + * If email doesn't have a gravatar, use one of these... http://bit.ly/1cCmtdb |
| 114 | + */ |
| 115 | +@property (readwrite, nonatomic) RFDefaultGravatar defaultGravatar; |
55 | 116 |
|
56 | | -// Force a default gravatar, whether or not email has gravatar. Remember to set defaultGravatar too! |
| 117 | +/** |
| 118 | + * Forces a default gravatar, whether or not email has gravatar. Remember to set defaultGravatar too! |
| 119 | + */ |
57 | 120 | @property (readwrite, nonatomic) BOOL forceDefault; |
58 | 121 |
|
59 | | -// Another option to init with a placeholder, so you don't have to do [_imageView setPlaceholder:]. |
| 122 | +/** |
| 123 | + * Another option to init with a placeholder, so you don't have to do [_imageView setPlaceholder:]. |
| 124 | + * |
| 125 | + * @param frame The frame for the imageView. |
| 126 | + * @param placeholder The placeholder image. |
| 127 | + * |
| 128 | + * @return A Gravatar imageView. |
| 129 | + */ |
60 | 130 | - (id)initWithFrame:(CGRect)frame andPlaceholder:(UIImage*)placeholder; |
61 | 131 |
|
62 | | -// A substitute to having to do [_imageView setForceDefault:YES]; and setting the default gravatar. |
63 | | -- (void)forceDefault:(BOOL)forceDefault withDefaultGravatar:(DefaultGravatars)gravatar; |
64 | | - |
65 | | -// Actually loads the gravatar AFTER you have configured all of your options. |
66 | | -- (void)loadGravatar; |
67 | | - |
68 | | -// Load gravatar with completion block |
69 | | -- (void)loadGravatar:(void (^)(void))completed; |
70 | | - |
71 | | -// Refreshes the gravatar, you can set new paramters between loading it and refreshing it. |
72 | | -- (void)refreshGravatar; |
| 132 | +/** |
| 133 | + * A substitute to having to do [_imageView setForceDefault:YES]; and setting the default gravatar. |
| 134 | + * |
| 135 | + * @param forceDefault Whether or not it should force the default gravatar. |
| 136 | + * @param gravatar The type of default gravatar. |
| 137 | + */ |
| 138 | +- (void)forceDefault:(BOOL)forceDefault withDefaultGravatar:(RFDefaultGravatar)gravatar; |
| 139 | + |
| 140 | +/** |
| 141 | + * Loads the gravatar after the required properties have been set. |
| 142 | + */ |
| 143 | +- (void)loadGravatar DEPRECATED_MSG_ATTRIBUTE("Please use load instead"); |
| 144 | + |
| 145 | +/** |
| 146 | + * Loads the gravatar after the required properties have been set. |
| 147 | + */ |
| 148 | +- (void)load; |
| 149 | + |
| 150 | +/** |
| 151 | + * Loads gravatar with completion block. |
| 152 | + * |
| 153 | + * @param completed The completion block. |
| 154 | + */ |
| 155 | +- (void)loadGravatar:(void (^)(void))completed DEPRECATED_MSG_ATTRIBUTE("Please use load: instead."); |
| 156 | + |
| 157 | +/** |
| 158 | + * Loads gravatar with completion block. |
| 159 | + * |
| 160 | + * @param completed The completion block. |
| 161 | + */ |
| 162 | +- (void)load:(void (^)(NSError *error))completed; |
| 163 | + |
| 164 | +/** |
| 165 | + * Refreshes the gravatar, you can set new paramters between loading it and refreshing it. |
| 166 | + */ |
| 167 | +- (void)refreshGravatar DEPRECATED_MSG_ATTRIBUTE("Please use refresh instead."); |
| 168 | + |
| 169 | +/** |
| 170 | + * Refreshes the gravatar, you can set new paramters between loading it and refreshing it. |
| 171 | + */ |
| 172 | +- (void)refresh; |
73 | 173 |
|
74 | 174 | @end |
0 commit comments