Skip to content

Commit

Permalink
allow users to tweet gists as well
Browse files Browse the repository at this point in the history
  • Loading branch information
trivektor committed Dec 24, 2013
1 parent 20a542b commit 8a26f94
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Binary file not shown.
4 changes: 3 additions & 1 deletion Gitos-iPad/Controllers/Gist/GistViewController.h
Expand Up @@ -7,10 +7,11 @@
// //


#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <Social/Social.h>
#import "Gist.h" #import "Gist.h"
#import "User.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 *detailsTable;
@property (nonatomic, strong) IBOutlet UITableView *filesTable; @property (nonatomic, strong) IBOutlet UITableView *filesTable;
Expand All @@ -30,5 +31,6 @@
- (void)prepareActionOptionsForStatus:(NSNotification *)notification; - (void)prepareActionOptionsForStatus:(NSNotification *)notification;
- (void)showAvailableActions; - (void)showAvailableActions;
- (void)updateStarredStatus; - (void)updateStarredStatus;
- (void)postToTwitter:(NSObject *)object;


@end @end
11 changes: 8 additions & 3 deletions Gitos-iPad/Controllers/Gist/GistViewController.m
Expand Up @@ -200,7 +200,7 @@ - (void)prepareActionOptionsForStatus:(NSNotification *)notification
delegate:self delegate:self
cancelButtonTitle:@"" cancelButtonTitle:@""
destructiveButtonTitle:nil 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"] UIBarButtonItem *actionsButton = [[UIBarButtonItem alloc] initWithTitle:[NSString fontAwesomeIconStringForIconIdentifier:@"icon-share"]
style:UIBarButtonItemStyleBordered style:UIBarButtonItemStyleBordered
Expand Down Expand Up @@ -236,7 +236,7 @@ - (void)updateStarredStatus
delegate:self delegate:self
cancelButtonTitle:@"" cancelButtonTitle:@""
destructiveButtonTitle:nil destructiveButtonTitle:nil
otherButtonTitles:starOption, @"View on Github", nil]; otherButtonTitles:starOption, @"View on Github", @"Tweet This Gist", nil];
} }


- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
Expand All @@ -251,10 +251,15 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger
// Star a gist // Star a gist
[currentUser starGist:gist]; [currentUser starGist:gist];
} }
} else if (buttonIndex == 2) { } else if ([[actionOptions buttonTitleAtIndex:buttonIndex] isEqualToString:@"View on Github"]) {
WebsiteViewController *websiteController = [[WebsiteViewController alloc] init]; WebsiteViewController *websiteController = [[WebsiteViewController alloc] init];
websiteController.requestedUrl = [gist getHtmlUrl]; websiteController.requestedUrl = [gist getHtmlUrl];
[self.navigationController pushViewController:websiteController animated:YES]; [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];
} }
} }


Expand Down

0 comments on commit 8a26f94

Please sign in to comment.