adding initial SHARE and COMMENT abilities

This commit is contained in:
Roy Yang 2012-06-22 22:57:17 -07:00
parent 32f164b79f
commit 77db3063e0
4 changed files with 192 additions and 14 deletions

View file

@ -101,7 +101,7 @@
// TODO make it a user setting to persist on app close
// set default x coordinate for feedDetailY
self.feedDetailPortraitYCoordinate = 600;
self.feedDetailPortraitYCoordinate = 960;
[window makeKeyAndVisible];
[feedsViewController fetchFeedList:YES];
@ -421,9 +421,7 @@
- (void)adjustStoryDetailWebView:(BOOL)init:(BOOL)checkLayout {
UINavigationController *navController = self.navigationController;
if (UIInterfaceOrientationIsPortrait(splitStoryDetailViewController.interfaceOrientation)) {
NSLog(@"The feedDetailPortraitYCoordinate in adjustStoryDetailWebView is: %i", self.feedDetailPortraitYCoordinate);
if (UIInterfaceOrientationIsPortrait(splitStoryDetailViewController.interfaceOrientation)) {
if( (960 - self.feedDetailPortraitYCoordinate) < 44 ) {
feedDetailViewController.view.frame = CGRectMake(0,
self.feedDetailPortraitYCoordinate + (44 - (960 - self.feedDetailPortraitYCoordinate)),
@ -434,7 +432,6 @@
self.feedDetailPortraitYCoordinate,
768,
960 - self.feedDetailPortraitYCoordinate);
}
// the storyDetailView is full screen

View file

@ -11,8 +11,11 @@
@interface ShareViewController : UIViewController <ASIHTTPRequestDelegate> {
NewsBlurAppDelegate *appDelegate;
}
@property (retain, nonatomic) IBOutlet UIImageView *siteFavicon;
@property (retain, nonatomic) IBOutlet UILabel *siteInformation;
@property (retain, nonatomic) IBOutlet UITextView *commentField;
@property (nonatomic, retain) IBOutlet NewsBlurAppDelegate *appDelegate;
@ -20,4 +23,6 @@
- (IBAction)doToggleButton:(id)sender;
- (IBAction)doShareThisStory:(id)sender;
@end

View file

@ -8,11 +8,14 @@
#import "ShareViewController.h"
#import "NewsBlurAppDelegate.h"
#import "StoryDetailViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "ASIHTTPRequest.h"
@implementation ShareViewController
@synthesize siteFavicon;
@synthesize siteInformation;
@synthesize commentField;
@synthesize appDelegate;
@ -38,23 +41,42 @@
- (void)viewDidUnload
{
[self setCommentField:nil];
[self setSiteInformation:nil];
[self setSiteFavicon:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (void)viewWillAppear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
NSString *siteInfoString = [NSString stringWithFormat:@"%@: %@",
[appDelegate.activeFeed objectForKey:@"feed_title"],
[appDelegate.activeStory objectForKey:@"story_title"]];
[self.siteInformation setText:siteInfoString];
}
- (void)dealloc {
[appDelegate release];
[commentField release];
[siteInformation release];
[siteFavicon release];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
- (IBAction)doCancelButton:(id)sender {
[commentField resignFirstResponder];
[appDelegate hideShareView];
}
@ -82,8 +104,12 @@
NSURL *url = [NSURL URLWithString:urlString];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:feedIdStr forKey:@"feed_id"];
[request setPostValue:storyIdStr forKey:@"story_id"];
[request setPostValue:@"Hello World" forKey:@"comments"];
[request setPostValue:storyIdStr forKey:@"story_id"];
NSString *comments = commentField.text;
if (comments) {
[request setPostValue:comments forKey:@"comments"];
}
[request setDelegate:self];
[request setDidFinishSelector:@selector(finishAddComment:)];
[request setDidFailSelector:@selector(requestFailed:)];
@ -93,6 +119,7 @@
- (void)finishAddComment:(ASIHTTPRequest *)request {
NSLog(@"%@", [request responseString]);
NSLog(@"Successfully added.");
[commentField resignFirstResponder];
[appDelegate hideShareView];
}
@ -101,4 +128,52 @@
NSLog(@"Error: %@", error);
}
-(void)keyboardWillHide:(NSNotification*)notification
{
NSDictionary *userInfo = notification.userInfo;
NSTimeInterval duration = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
UIViewAnimationCurve curve = [[userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue];
CGRect keyboardFrame = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGRect shareViewFrame = self.view.frame;
CGRect storyDetailViewFrame = appDelegate.storyDetailViewController.view.frame;
NSLog(@"Keyboard y is %f", keyboardFrame.size.height);
shareViewFrame.origin.y = shareViewFrame.origin.y + keyboardFrame.size.height;
storyDetailViewFrame.size.height = storyDetailViewFrame.size.height + keyboardFrame.size.height;
[UIView animateWithDuration:duration
delay:0
options:UIViewAnimationOptionBeginFromCurrentState | curve
animations:^{
self.view.frame = shareViewFrame;
appDelegate.storyDetailViewController.view.frame = storyDetailViewFrame;
} completion:nil];
}
-(void)keyboardWillShow:(NSNotification*)notification
{
NSDictionary *userInfo = notification.userInfo;
NSTimeInterval duration = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
UIViewAnimationCurve curve = [[userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue];
CGRect keyboardFrame = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGRect shareViewFrame = self.view.frame;
CGRect storyDetailViewFrame = appDelegate.storyDetailViewController.view.frame;
NSLog(@"Keyboard y is %f", keyboardFrame.size.height);
shareViewFrame.origin.y = shareViewFrame.origin.y - keyboardFrame.size.height;
storyDetailViewFrame.size.height = storyDetailViewFrame.size.height - keyboardFrame.size.height;
[UIView animateWithDuration:duration
delay:0
options:UIViewAnimationOptionBeginFromCurrentState | curve
animations:^{
self.view.frame = shareViewFrame;
appDelegate.storyDetailViewController.view.frame = storyDetailViewFrame;
} completion:nil];
}
@end

View file

@ -95,7 +95,7 @@
<bool key="IBUIMultipleTouchEnabled">YES</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<bool key="IBUIShowsHorizontalScrollIndicator">NO</bool>
<string key="IBUIText">Optional Comment</string>
<string key="IBUIText"/>
<object class="IBUITextInputTraits" key="IBUITextInputTraits">
<int key="IBUIAutocapitalizationType">2</int>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
@ -161,6 +161,7 @@
<string key="NSFrame">{{554, 203}, {60, 60}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
@ -188,7 +189,7 @@
<object class="IBUIImageView" id="163383208">
<reference key="NSNextResponder" ref="766721923"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{155, 79}, {16, 16}}</string>
<string key="NSFrame">{{155, 64}, {16, 16}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="249744356"/>
@ -203,10 +204,10 @@
<object class="IBUILabel" id="249744356">
<reference key="NSNextResponder" ref="766721923"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{179, 76}, {166, 21}}</string>
<string key="NSFrame">{{179, 61}, {351, 21}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="993868796"/>
<reference key="NSNextKeyView" ref="670048759"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
@ -214,7 +215,7 @@
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<string key="IBUIText">Site Name: Story Title</string>
<object class="NSColor" key="IBUITextColor">
<object class="NSColor" key="IBUITextColor" id="990279131">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MCAwIDAAA</bytes>
</object>
@ -231,6 +232,66 @@
<int key="NSfFlags">16</int>
</object>
</object>
<object class="IBUILabel" id="670048759">
<reference key="NSNextResponder" ref="766721923"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{155, 96}, {84, 21}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="189558015"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<string key="IBUIText">Comments</string>
<reference key="IBUITextColor" ref="990279131"/>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">0</int>
<float key="IBUIMinimumFontSize">10</float>
<object class="IBUIFontDescription" key="IBUIFontDescription">
<int key="type">1</int>
<double key="pointSize">13</double>
</object>
<object class="NSFont" key="IBUIFont">
<string key="NSName">Helvetica</string>
<double key="NSSize">13</double>
<int key="NSfFlags">16</int>
</object>
</object>
<object class="IBUILabel" id="189558015">
<reference key="NSNextResponder" ref="766721923"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{446, 96}, {84, 21}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="993868796"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<string key="IBUIText">Optional</string>
<object class="NSColor" key="IBUITextColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC4zMzMzMzMzMzMzAA</bytes>
</object>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">0</int>
<float key="IBUIMinimumFontSize">10</float>
<int key="IBUITextAlignment">2</int>
<object class="IBUIFontDescription" key="IBUIFontDescription">
<int key="type">1</int>
<double key="pointSize">11</double>
</object>
<object class="NSFont" key="IBUIFont">
<string key="NSName">Helvetica</string>
<double key="NSSize">11</double>
<int key="NSfFlags">16</int>
</object>
</object>
</array>
<string key="NSFrameSize">{768, 300}</string>
<reference key="NSSuperview"/>
@ -269,6 +330,22 @@
</object>
<int key="connectionID">29</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">siteInformation</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="249744356"/>
</object>
<int key="connectionID">31</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">siteFavicon</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="163383208"/>
</object>
<int key="connectionID">32</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doShareThisStory:</string>
@ -328,11 +405,13 @@
<reference key="object" ref="766721923"/>
<array class="NSMutableArray" key="children">
<reference ref="975114462"/>
<reference ref="993868796"/>
<reference ref="161540210"/>
<reference ref="505763753"/>
<reference ref="163383208"/>
<reference ref="249744356"/>
<reference ref="993868796"/>
<reference ref="189558015"/>
<reference ref="670048759"/>
</array>
<reference key="parent" ref="0"/>
</object>
@ -386,6 +465,16 @@
<reference key="object" ref="249744356"/>
<reference key="parent" ref="766721923"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">33</int>
<reference key="object" ref="670048759"/>
<reference key="parent" ref="766721923"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">34</int>
<reference key="object" ref="189558015"/>
<reference key="parent" ref="766721923"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@ -405,12 +494,14 @@
<real value="1" key="21.IBUIButtonInspectorSelectedStateConfigurationMetadataKey"/>
<string key="27.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="28.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="33.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="34.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">30</int>
<int key="maxID">34</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -1335,6 +1426,8 @@
<dictionary class="NSMutableDictionary" key="outlets">
<string key="appDelegate">NewsBlurAppDelegate</string>
<string key="commentField">UITextView</string>
<string key="siteFavicon">UIImageView</string>
<string key="siteInformation">UILabel</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="appDelegate">
@ -1345,6 +1438,14 @@
<string key="name">commentField</string>
<string key="candidateClassName">UITextView</string>
</object>
<object class="IBToOneOutletInfo" key="siteFavicon">
<string key="name">siteFavicon</string>
<string key="candidateClassName">UIImageView</string>
</object>
<object class="IBToOneOutletInfo" key="siteInformation">
<string key="name">siteInformation</string>
<string key="candidateClassName">UILabel</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>