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 |
@class TWTRTweet; |
|
20 |
@protocol TWTRComposerViewControllerDelegate; |
|
21 |
|
|
22 |
NS_ASSUME_NONNULL_BEGIN |
|
23 |
|
|
24 |
/** |
|
25 |
* Composer interface to allow users to compose & send Tweets from |
|
26 |
* inside an app. |
|
27 |
* |
|
28 |
* It is the developers' responsibility to ensure that there exists a |
|
29 |
* logged in Twitter user before creating a `TWTRComposerViewController`. |
|
30 |
* |
|
31 |
* See: https://dev.twitter.com/twitterkit/ios/compose-tweets#presenting-a-basic-composer |
|
32 |
* |
|
33 |
* Initial Text |
|
34 |
* If you wish to add default mentions to the Tweet, add them to the |
|
35 |
* beginning of `initialText`. |
|
36 |
* |
|
37 |
* If you wish to add default hashtags or links to the Tweet, |
|
38 |
* add them at the end of `initialText`. |
|
39 |
*/ |
|
40 |
@interface TWTRComposerViewController : UIViewController |
|
41 |
|
|
42 |
/** |
|
43 |
* The delegate for this composer view controller. |
|
44 |
*/ |
|
45 |
@property (nonatomic, weak) id<TWTRComposerViewControllerDelegate> delegate; |
|
46 |
|
|
47 |
/** |
|
48 |
* Create an empty composer view controller. The developer must handle ensuring |
|
49 |
* that a logged in Twitter user exists before creating this controller. |
|
50 |
*/ |
|
51 |
+ (instancetype)emptyComposer; |
|
52 |
|
|
53 |
/** |
|
54 |
* Initialize a composer with pre-filled text and an image or video attachment. |
|
55 |
* Requires a logged in Twitter user. |
|
56 |
* |
|
57 |
* @param initialText (optional) Text with which to pre-fill the composer text. |
|
58 |
* @param image (optional) Image to add as an attachment. |
|
59 |
* @param videoURL (optional) Video URL to add as an attachment. Of the form of `assets-library`. |
|
60 |
* |
|
61 |
* Note: Only one type of attachment (image or video) may be added. |
|
62 |
*/ |
|
63 |
- (instancetype)initWithInitialText:(nullable NSString *)initialText image:(nullable UIImage *)image videoURL:(nullable NSURL *)videoURL; |
|
64 |
|
655e66
|
65 |
/** |
H |
66 |
* Initialize a composer with pre-filled text and an image or video attachment. |
|
67 |
* |
|
68 |
* @param initialText (optional) Text with which to pre-fill the composer text. |
|
69 |
* @param image (required) Image (or preview image) to add as an attachment. |
|
70 |
* @param videoData (optional) NSData for video asset to add as an attachment. |
|
71 |
* |
|
72 |
* Note: Preview image is required if videoData parameter is passed. |
|
73 |
*/ |
|
74 |
- (instancetype)initWithInitialText:(nullable NSString *)initialText image:(nullable UIImage *)image videoData:(nullable NSData *)videoData; |
|
75 |
|
a0a843
|
76 |
- (instancetype)init NS_UNAVAILABLE; |
H |
77 |
|
|
78 |
@end |
|
79 |
|
|
80 |
@protocol TWTRComposerViewControllerDelegate <NSObject> |
|
81 |
|
|
82 |
@optional |
|
83 |
/** |
|
84 |
* Called when the user taps the cancel button. This method will be called after the view controller is dismissed. |
|
85 |
*/ |
|
86 |
- (void)composerDidCancel:(TWTRComposerViewController *)controller; |
|
87 |
|
|
88 |
/** |
|
89 |
* Called when the user successfully sends a Tweet. The resulting Tweet object is returned. |
|
90 |
* This method is called after the view controller is dimsissed and the API response is |
|
91 |
* received. |
|
92 |
*/ |
|
93 |
- (void)composerDidSucceed:(TWTRComposerViewController *)controller withTweet:(TWTRTweet *)tweet; |
|
94 |
|
|
95 |
/** |
|
96 |
* This method is called if the composer is not able to send the Tweet. |
|
97 |
* The view controller will not be dismissed automatically if this method is called. |
|
98 |
*/ |
|
99 |
- (void)composerDidFail:(TWTRComposerViewController *)controller withError:(NSError *)error; |
|
100 |
|
|
101 |
@end |
|
102 |
|
|
103 |
NS_ASSUME_NONNULL_END |