commit | author | age
|
655e66
|
1 |
/* |
H |
2 |
* Copyright (C) 2017 Twitter, Inc. |
|
3 |
* |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
* |
|
16 |
*/ |
a0a843
|
17 |
|
H |
18 |
#import <UIKit/UIKit.h> |
|
19 |
|
|
20 |
NS_ASSUME_NONNULL_BEGIN |
|
21 |
|
|
22 |
typedef NS_ENUM(NSUInteger, TWTRMediaEntitySizeResizingMode) { |
|
23 |
TWTRMediaEntitySizeResizingModeFit, |
|
24 |
TWTRMediaEntitySizeResizingModeCrop, |
|
25 |
}; |
|
26 |
|
655e66
|
27 |
FOUNDATION_EXTERN NSString *NSStringFromTWTRMediaEntitySizeResizingMode(TWTRMediaEntitySizeResizingMode resizingMode); |
H |
28 |
FOUNDATION_EXTERN TWTRMediaEntitySizeResizingMode TWTRMediaEntitySizeResizingModeFromString(NSString *resizingModeString); |
a0a843
|
29 |
|
H |
30 |
@interface TWTRMediaEntitySize : NSObject <NSCoding> |
|
31 |
|
|
32 |
/** |
|
33 |
* The name of the size. 'large', 'medium', etc. |
|
34 |
*/ |
|
35 |
@property (nonatomic, copy, readonly) NSString *name; |
|
36 |
|
|
37 |
/** |
|
38 |
* Resize mode of the image size e.g. Fit, Crop. |
|
39 |
*/ |
|
40 |
@property (nonatomic, readonly) TWTRMediaEntitySizeResizingMode resizingMode; |
|
41 |
|
|
42 |
/** |
|
43 |
* The actual size. |
|
44 |
*/ |
|
45 |
@property (nonatomic, readonly) CGSize size; |
|
46 |
|
|
47 |
- (instancetype)init NS_UNAVAILABLE; |
|
48 |
|
|
49 |
/** |
|
50 |
* Designated initializer. |
|
51 |
* |
|
52 |
* @param name The name of the size. If nil will default to the empty string. |
|
53 |
* @param resizingMode The resizing mode of this entity size. |
|
54 |
* @param size The size of the entity. |
|
55 |
*/ |
|
56 |
- (instancetype)initWithName:(NSString *)name resizingMode:(TWTRMediaEntitySizeResizingMode)resizingMode size:(CGSize)size NS_DESIGNATED_INITIALIZER; |
|
57 |
|
|
58 |
- (BOOL)isEqualToMediaEntitySize:(TWTRMediaEntitySize *)otherSize; |
|
59 |
|
|
60 |
/** |
|
61 |
* Returns a dictionary of valid `TWTRMediaEntitySize` instances from the Twitter API response for media sizes. |
|
62 |
* |
|
63 |
* @param dictionary A parsed dictionary of media sizes from the Twitter API response |
|
64 |
* |
|
65 |
* @return Dictionary of parsed `TWTRMediaEntitySize` instances keyed by size name. |
|
66 |
*/ |
|
67 |
+ (NSDictionary *)mediaEntitySizesWithJSONDictionary:(NSDictionary *)dictionary; |
|
68 |
|
|
69 |
@end |
|
70 |
|
|
71 |
NS_ASSUME_NONNULL_END |