Skip to content

Commit

Permalink
Add full support for iPad
Browse files Browse the repository at this point in the history
  • Loading branch information
rpetrich committed Jan 7, 2011
1 parent 49b1f01 commit 352064b
Show file tree
Hide file tree
Showing 12 changed files with 532 additions and 24 deletions.
9 changes: 5 additions & 4 deletions Classes/Data/Story.m
Expand Up @@ -76,18 +76,19 @@ + (Story *)storyWithDictionary:(NSDictionary *)dict inReddit:(id)reddit
aStory.isSelfReddit = ([aStory.domain rangeOfString:@"self."].location == 0);

UIFont *storyFont = [UIFont boldSystemFontOfSize:14];
CGSize screenSize = [UIScreen mainScreen].bounds.size;
CGFloat height;

height = (CGFloat)([aStory.title sizeWithFont:storyFont constrainedToSize:CGSizeMake(266.0, 1000.0) lineBreakMode:UILineBreakModeTailTruncation]).height;
height = (CGFloat)([aStory.title sizeWithFont:storyFont constrainedToSize:CGSizeMake(screenSize.width - 54.0, 1000.0) lineBreakMode:UILineBreakModeTailTruncation]).height;
[aStory setHeight:height forIndex:PORTRAIT_INDEX];

height = (CGFloat)([aStory.title sizeWithFont:storyFont constrainedToSize:CGSizeMake(266.0-68.0, 1000.0) lineBreakMode:UILineBreakModeTailTruncation]).height;
height = (CGFloat)([aStory.title sizeWithFont:storyFont constrainedToSize:CGSizeMake(screenSize.width - (54.0+68.0), 1000.0) lineBreakMode:UILineBreakModeTailTruncation]).height;
[aStory setHeight:height forIndex:PORTRAIT_THUMBNAIL_INDEX];

height = (CGFloat)[aStory.title sizeWithFont:storyFont constrainedToSize:CGSizeMake(428.0, 1000.0) lineBreakMode:UILineBreakModeTailTruncation].height;
height = (CGFloat)[aStory.title sizeWithFont:storyFont constrainedToSize:CGSizeMake(screenSize.height - 52.0, 1000.0) lineBreakMode:UILineBreakModeTailTruncation].height;
[aStory setHeight:height forIndex:LANDSCAPE_INDEX];

height = (CGFloat)[aStory.title sizeWithFont:storyFont constrainedToSize:CGSizeMake(428.0-68.0, 1000.0) lineBreakMode:UILineBreakModeTailTruncation].height;
height = (CGFloat)[aStory.title sizeWithFont:storyFont constrainedToSize:CGSizeMake(screenSize.height - (52.0+68.0), 1000.0) lineBreakMode:UILineBreakModeTailTruncation].height;
[aStory setHeight:height forIndex:LANDSCAPE_THUMBNAIL_INDEX];

[storyDictionary setObject:aStory forKey:aStory.identifier];
Expand Down
4 changes: 3 additions & 1 deletion Classes/ViewControllers/RootViewController.m
Expand Up @@ -192,7 +192,9 @@ - (void)viewDidLoad {
- (void)viewWillAppear:(BOOL)animated
{
self.navigationBarTintColor = [iRedditAppDelegate redditNavigationBarTintColor];
self.tableView.backgroundColor = [UIColor colorWithRed:229.0/255.0 green:238.0/255.0 blue:1 alpha:1];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
self.tableView.backgroundColor = [UIColor colorWithRed:229.0/255.0 green:238.0/255.0 blue:1 alpha:1];
}
self.tableView.allowsSelectionDuringEditing = NO;
self.tableView.editing = NO;

Expand Down
4 changes: 3 additions & 1 deletion Classes/ViewControllers/SettingsViewController.m
Expand Up @@ -83,7 +83,9 @@ - (void)loadView

self.tableView = [[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped] autorelease];
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.tableView.backgroundColor = [UIColor colorWithRed:229.0/255.0 green:238.0/255.0 blue:1 alpha:1];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
self.tableView.backgroundColor = [UIColor colorWithRed:229.0/255.0 green:238.0/255.0 blue:1 alpha:1];
}

[self.view addSubview:self.tableView];
}
Expand Down
4 changes: 3 additions & 1 deletion Classes/ViewControllers/StoryViewController.h
Expand Up @@ -18,9 +18,11 @@
UIWebView *webview;
UIButton *scoreItem;
UIButton *commentCountItem;
UIBarButtonItem *toggleButtonItem;
UIBarButtonItem *toggleButtonItem;
UIBarButtonItem *moreButtonItem;
UISegmentedControl *segmentedControl;
AlienProgressView *loadingView;
UIActionSheet *currentSheet;

Story *story;
}
Expand Down
45 changes: 31 additions & 14 deletions Classes/ViewControllers/StoryViewController.m
Expand Up @@ -83,7 +83,9 @@ - (void)loadView
self.toggleButtonItem = [items lastObject];

[items addObject:[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease]];
[items addObject:[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share:)] autorelease]];
if (!moreButtonItem)
moreButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share:)];
[items addObject:moreButtonItem];

[self setToolbarItems:items animated:NO];

Expand Down Expand Up @@ -348,25 +350,38 @@ - (IBAction)showStory:(id)sender

- (IBAction)share:(id)sender
{
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@""
delegate:(id <UIActionSheetDelegate>)self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"E-mail Link", @"Open Link in Safari", @"Hide on reddit", @"Save on reddit", @"Save on Instapaper", nil];

actionSheet.actionSheetStyle = UIActionSheetStyleDefault;

[actionSheet showInView:self.navigationController.view];
[actionSheet release];
if (currentSheet) {
[currentSheet dismissWithClickedButtonIndex:currentSheet.cancelButtonIndex animated:YES];
[currentSheet release];
currentSheet = nil;
} else {
currentSheet = [[UIActionSheet alloc]
initWithTitle:@""
delegate:(id <UIActionSheetDelegate>)self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"E-mail Link", @"Open Link in Safari", @"Hide on reddit", @"Save on reddit", @"Save on Instapaper", nil];

currentSheet.actionSheetStyle = UIActionSheetStyleDefault;

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[currentSheet showInView:self.navigationController.view];
} else {
[currentSheet showFromBarButtonItem:moreButtonItem animated:YES];
}
}
}

- (void)actionSheetCancel:(id)sender
{
{
[currentSheet release];
currentSheet = nil;
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
[currentSheet release];
currentSheet = nil;
NSString *url = story.URL;
if (isForComments && story.commentsURL)
url = story.commentsURL;
Expand Down Expand Up @@ -442,7 +457,7 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger
//[[Beacon shared] startSubBeaconWithName:@"instapaper" timeSession:NO];
}
else if(buttonIndex == 4)
[self actionSheetCancel:actionSheet];
[self actionSheetCancel:currentSheet];
}

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
Expand Down Expand Up @@ -644,6 +659,8 @@ - (void)viewDidUnload
- (void)dealloc
{
self.story = nil;
[currentSheet release];
[moreButtonItem release];

[super dealloc];
}
Expand Down
5 changes: 3 additions & 2 deletions Classes/ViewControllers/SubredditViewController.m
Expand Up @@ -55,7 +55,8 @@ - (void)loadView
[super loadView];

// create the tableview
self.view = [[[UIView alloc] initWithFrame:TTApplicationFrame()] autorelease];
CGRect applicationFrame = TTApplicationFrame();
self.view = [[[UIView alloc] initWithFrame:applicationFrame] autorelease];
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

if (tabBar)
Expand All @@ -66,7 +67,7 @@ - (void)loadView

if (showTabBar)
{
tabBar = [[TTTabStrip alloc] initWithFrame:CGRectMake(0, 0, 320, 36)];
tabBar = [[TTTabStrip alloc] initWithFrame:CGRectMake(0, 0, applicationFrame.size.width, 36)];

tabBar.tabItems = [NSArray arrayWithObjects:
[[[TTTabItem alloc] initWithTitle:@" Hot "] autorelease],
Expand Down
Binary file added Default-Landscape.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Default-Portrait.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 352064b

Please sign in to comment.