iOS: done #735 (non-modal story notifications)

This commit is contained in:
David Sinclair 2015-10-28 21:50:23 -07:00
parent 42fed5b36d
commit d8f79528dd
5 changed files with 46 additions and 58 deletions

View file

@ -46,10 +46,9 @@ typedef enum {
- (void)show;
- (void)showIn:(float)time;
- (void)showFor:(float)time;
- (void)hide;
- (void)hideAfter:(float)seconds;
- (void)hideNow;
- (void)hideIn:(float)seconds;
@end

View file

@ -204,71 +204,34 @@
CGRect frame = self.frame;
frame.size.width = self.view.frame.size.width;
self.frame = frame;
self.hidden = NO;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:time];
CGRect move = self.frame;
move.origin.y = self.view.frame.size.height - NOTIFIER_HEIGHT - self.offset.y;
self.frame = move;
[UIView commitAnimations];
}
- (void)showFor:(float)time{
showing = YES;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3f];
CGRect move = self.frame;
move.origin.y = self.view.frame.size.height - NOTIFIER_HEIGHT - self.offset.y;
self.frame = move;
[UIView commitAnimations];
[self hideAfter:time];
}
- (void)hideAfter:(float)seconds{
if (!showing) return;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, seconds * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3f];
[UIView setAnimationDelegate: self]; //or some other object that has necessary method
// [UIView setAnimationDidStopSelector: @selector(removeFromSuperview)];
[UIView animateWithDuration:time animations:^{
CGRect move = self.frame;
move.origin.y += NOTIFIER_HEIGHT;
move.origin.y = self.view.frame.size.height - NOTIFIER_HEIGHT - self.offset.y;
self.frame = move;
[UIView commitAnimations];
});
showing = NO;
} completion:nil];
}
- (void)hide {
[self hideIn:0.3f];
}
- (void)hideNow {
[self hideIn:0.0f];
}
- (void)hideIn:(float)seconds {
if (!showing) return;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:seconds];
[UIView setAnimationDelegate: self]; //or some other object that has necessary method
// [UIView setAnimationDidStopSelector: @selector(removeFromSuperview)];
CGRect move = self.frame;
move.origin.y = self.view.frame.size.height - self.offset.y;
self.frame = move;
[UIView commitAnimations];
[UIView animateWithDuration:seconds animations:^{
CGRect move = self.frame;
move.origin.y = self.view.frame.size.height - self.offset.y;
self.frame = move;
} completion:^(BOOL finished) {
self.hidden = YES;
}];
showing = NO;
}

View file

@ -2104,9 +2104,10 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
self.inTextView = YES;
// NSLog(@"Fetching Text: %@", [self.activeStory objectForKey:@"story_title"]);
dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD hideHUDForView:self.webView animated:YES];
MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.webView animated:YES];
HUD.labelText = @"Fetching text...";
// [MBProgressHUD hideHUDForView:self.webView animated:YES];
// MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.webView animated:YES];
// HUD.labelText = @"Fetching text...";
[self.appDelegate.storyPageControl showFetchingTextNotifier];
});
NSString *urlString = [NSString stringWithFormat:@"%@/rss_feeds/original_text",
@ -2122,6 +2123,7 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
}
- (void)failedFetchText:(ASIHTTPRequest *)request {
[self.appDelegate.storyPageControl hideNotifier];
[MBProgressHUD hideHUDForView:self.webView animated:YES];
[self informError:@"Could not fetch text"];
self.inTextView = NO;
@ -2144,6 +2146,7 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
if (![[request.userInfo objectForKey:@"storyId"]
isEqualToString:[self.activeStory objectForKey:@"id"]]) {
[self.appDelegate.storyPageControl hideNotifier];
[MBProgressHUD hideHUDForView:self.webView animated:YES];
self.inTextView = NO;
[appDelegate.storyPageControl setTextButton:self];
@ -2157,6 +2160,7 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
}
self.activeStory = newActiveStory;
[self.appDelegate.storyPageControl hideNotifier];
[MBProgressHUD hideHUDForView:self.webView animated:YES];
self.inTextView = YES;

View file

@ -11,6 +11,7 @@
#import "NewsBlurAppDelegate.h"
#import "WYPopoverController.h"
#import "THCircularProgressView.h"
#import "NBNotifier.h"
@class NewsBlurAppDelegate;
@class ASIHTTPRequest;
@ -75,6 +76,7 @@
@property (assign) BOOL isAnimatedIntoPlace;
@property (assign) BOOL waitingForNextUnreadFromServer;
@property (nonatomic) MBProgressHUD *storyHUD;
@property (nonatomic, strong) NBNotifier *notifier;
@property (nonatomic) NSInteger scrollingToPage;
@property (nonatomic, strong) WYPopoverController *popoverController;
@ -114,6 +116,8 @@
- (void)changeFontSize:(NSString *)fontSize;
- (void)changeLineSpacing:(NSString *)lineSpacing;
- (void)showShareHUD:(NSString *)msg;
- (void)showFetchingTextNotifier;
- (void)hideNotifier;
- (IBAction)showOriginalSubview:(id)sender;

View file

@ -179,6 +179,11 @@
action:@selector(transitionFromFeedDetail)];
self.buttonBack = backButton;
self.notifier = [[NBNotifier alloc] initWithTitle:@"Fetching text..."
inView:self.view
withOffset:CGPointMake(0.0, 0.0 /*self.bottomSize.frame.size.height*/)];
[self.view addSubview:self.notifier];
[self.notifier hideNow];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:
@ -413,6 +418,7 @@
previousPage.pageIndex = -2;
[self changePage:pageIndex animated:NO];
[MBProgressHUD hideHUDForView:self.view animated:YES];
[self.notifier hide];
// self.scrollView.contentOffset = CGPointMake(self.scrollView.frame.size.width * currentPage.pageIndex, 0);
}
@ -431,6 +437,7 @@
[self.scrollView scrollRectToVisible:frame animated:NO];
[MBProgressHUD hideHUDForView:self.view animated:YES];
[self.notifier hide];
}
- (void)refreshHeaders {
@ -1066,6 +1073,17 @@
[[self currentPage] flashCheckmarkHud:messageType];
}
- (void)showFetchingTextNotifier {
self.notifier.style = NBSyncingStyle;
self.notifier.title = @"Fetching text...";
[self.notifier setProgress:0];
[self.notifier show];
}
- (void)hideNotifier {
[self.notifier hide];
}
#pragma mark -
#pragma mark Story Traversal