1 //
2 // TWTRComposerViewController.h
3 // TwitterKit
4 //
5 // Copyright (c) 2015 Twitter. All rights reserved.
6 //
7
8 #import <UIKit/UIKit.h>
9 @class TWTRCardConfiguration;
10 @class TWTRComposerTheme;
11 @class TWTRTweet;
12 @protocol TWTRComposerViewControllerDelegate;
13
14 NS_ASSUME_NONNULL_BEGIN
15
16 @interface TWTRComposerViewController : UIViewController
17
18 @property (nonatomic, weak, nullable) id<TWTRComposerViewControllerDelegate> delegate;
19
20 /**
21 * A theme to use for the composer. If nil will default to the light theme.
22 */
23 @property (nonatomic, null_resettable) TWTRComposerTheme *theme;
24
25 /**
26 * An array of hashtags that will be added to the composer. This property must be
27 * set before the composer's view is loaded. If any hashtags are not valid they will
28 * be ignored.
29 * Hashtags must come in the form @[@"#fabric", @"#twitter"].
30 */
31 @property (nonatomic, copy, nullable) NSArray *hashtags;
32
33 /**
34 * Use initWithUserID: instead.
35 */
36 - (instancetype)init NS_UNAVAILABLE;
37
38 /**
39 * Returns a fully initialized version of the composer.
40 *
41 * @param userID The ID of the user that is tweeting
42 */
43 - (instancetype)initWithUserID:(NSString *)userID;
44
45 /**
46 * Returns a fully initialized version of the composer which will tweet with a card.
47 *
48 * @param userID The ID of the user that is tweeting the card
49 * @param cardConfig The card configuration that will be associated with this Tweet
50 */
51 - (instancetype)initWithUserID:(NSString *)userID cardConfiguration:(nullable TWTRCardConfiguration *)cardConfig;
52
53 @end
54
55 @protocol TWTRComposerViewControllerDelegate <NSObject>
56
57 @optional
58 /**
59 * Called when the user taps the cancel button. This method will be called after the view controller is dismissed.
60 */
61 - (void)composerDidCancel:(TWTRComposerViewController *)controller;
62
63 /**
64 * Called when the user successfully sends a Tweet. The resulting Tweet object is returned.
65 * This method is called after the view controller is dimsissed.
66 */
67 - (void)composerDidSucceed:(TWTRComposerViewController *)controller withTweet:(TWTRTweet *)tweet;
68
69 /**
70 * This method is called if the composer is not able to send the Tweet.
71 * The view controller will not be dismissed automatically if this method is called.
72 */
73 - (void)composerDidFail:(TWTRComposerViewController *)controller withError:(NSError *)error;
74
75 @end
76
77 NS_ASSUME_NONNULL_END