Browse files

allow users to tweet gists as well

  • Loading branch information...
1 parent 20a542b commit 8a26f941d2c4bc81afc65edb853bb8ce43cbd579 @trivektor committed Dec 23, 2013
View
BIN ...deproj/project.xcworkspace/xcuserdata/trivuong.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
View
4 Gitos-iPad/Controllers/Gist/GistViewController.h
@@ -7,10 +7,11 @@
//
#import <UIKit/UIKit.h>
+#import <Social/Social.h>
#import "Gist.h"
#import "User.h"
-@interface GistViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, UIActionSheetDelegate>
+@interface GistViewController : GitosViewController <UITableViewDataSource, UITableViewDelegate, UIActionSheetDelegate>
@property (nonatomic, strong) IBOutlet UITableView *detailsTable;
@property (nonatomic, strong) IBOutlet UITableView *filesTable;
@@ -30,5 +31,6 @@
- (void)prepareActionOptionsForStatus:(NSNotification *)notification;
- (void)showAvailableActions;
- (void)updateStarredStatus;
+- (void)postToTwitter:(NSObject *)object;
@end
View
11 Gitos-iPad/Controllers/Gist/GistViewController.m
@@ -200,7 +200,7 @@ - (void)prepareActionOptionsForStatus:(NSNotification *)notification
delegate:self
cancelButtonTitle:@""
destructiveButtonTitle:nil
- otherButtonTitles:starOption, @"Fork", @"View on Github", nil];
+ otherButtonTitles:starOption, @"Fork", @"View on Github", @"Tweet This Gist", nil];
UIBarButtonItem *actionsButton = [[UIBarButtonItem alloc] initWithTitle:[NSString fontAwesomeIconStringForIconIdentifier:@"icon-share"]
style:UIBarButtonItemStyleBordered
@@ -236,7 +236,7 @@ - (void)updateStarredStatus
delegate:self
cancelButtonTitle:@""
destructiveButtonTitle:nil
- otherButtonTitles:starOption, @"View on Github", nil];
+ otherButtonTitles:starOption, @"View on Github", @"Tweet This Gist", nil];
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
@@ -251,10 +251,15 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger
// Star a gist
[currentUser starGist:gist];
}
- } else if (buttonIndex == 2) {
+ } else if ([[actionOptions buttonTitleAtIndex:buttonIndex] isEqualToString:@"View on Github"]) {
WebsiteViewController *websiteController = [[WebsiteViewController alloc] init];
websiteController.requestedUrl = [gist getHtmlUrl];
[self.navigationController pushViewController:websiteController animated:YES];
+ } else if ([[actionOptions buttonTitleAtIndex:buttonIndex] isEqualToString:@"Tweet This Gist"]) {
+ SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
+ [tweetSheet setInitialText:[gist getHtmlUrl]];
+ [tweetSheet addImage:[UIImage imageNamed:@"twitter-logo"]];
+ [self presentViewController:tweetSheet animated:YES completion:nil];
}
}

0 comments on commit 8a26f94

Please sign in to comment.