diff --git a/media/ios/Classes/FeedDetailViewController.m b/media/ios/Classes/FeedDetailViewController.m index 779a9eb23..b13ca63b8 100644 --- a/media/ios/Classes/FeedDetailViewController.m +++ b/media/ios/Classes/FeedDetailViewController.m @@ -99,6 +99,7 @@ titleImageBarButton = [UIBarButtonItem alloc]; self.notifier = [[NBNotifier alloc] initWithTitle:@"Fetching stories..." inView:self.view]; + [self.view addSubview:self.notifier]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { @@ -198,6 +199,8 @@ } [self performSelector:@selector(fadeSelectedCell) withObject:self afterDelay:0.4]; } + + [self.notifier setNeedsLayout]; } - (void)viewDidAppear:(BOOL)animated { diff --git a/media/ios/Classes/NBNotifier.h b/media/ios/Classes/NBNotifier.h index a13c983e9..b98cd41c5 100644 --- a/media/ios/Classes/NBNotifier.h +++ b/media/ios/Classes/NBNotifier.h @@ -26,6 +26,7 @@ typedef enum { @property (nonatomic, strong) NSString *_text; @property (nonatomic) NBNotifierStyle style; @property (nonatomic, strong) UIView *view; +@property (nonatomic) CGPoint offset; @property (nonatomic, strong) UIView *accessoryView; @property (nonatomic, strong) NSString *title; @property (nonatomic, assign) BOOL showing; @@ -33,8 +34,11 @@ typedef enum { - (id)initWithTitle:(NSString *)title; - (id)initWithTitle:(NSString *)title inView:(UIView *)view; +- (id)initWithTitle:(NSString *)title inView:(UIView *)view withOffset:(CGPoint)offset; - (id)initWithTitle:(NSString *)title inView:(UIView *)view style:(NBNotifierStyle)style; +- (id)initWithTitle:(NSString *)title inView:(UIView *)view style:(NBNotifierStyle)style withhOffset:(CGPoint)offset; +- (void) didChangedOrientation:(NSNotification *)sender; - (void)setAccessoryView:(UIView *)view animated:(BOOL)animated; - (void)setProgress:(float)value; - (void)setTitle:(id)title animated:(BOOL)animated; diff --git a/media/ios/Classes/NBNotifier.m b/media/ios/Classes/NBNotifier.m index 5335b0ef1..cd66ffb9e 100644 --- a/media/ios/Classes/NBNotifier.m +++ b/media/ios/Classes/NBNotifier.m @@ -36,6 +36,7 @@ @synthesize accessoryView, title = _title, style = _style, view = _view; @synthesize showing; @synthesize progressBar; +@synthesize offset = _offset; + (void)initialize { if (self == [NBNotifier class]) { @@ -58,16 +59,25 @@ } - (id)initWithTitle:(NSString *)title inView:(UIView *)view { - return [self initWithTitle:title inView:view style:NBLoadingStyle]; + return [self initWithTitle:title inView:view style:NBLoadingStyle withOffset:CGPointZero]; +} + +- (id)initWithTitle:(NSString *)title inView:(UIView *)view withOffset:(CGPoint)offset { + return [self initWithTitle:title inView:view style:NBLoadingStyle withOffset:offset]; } - (id)initWithTitle:(NSString *)title inView:(UIView *)view style:(NBNotifierStyle)style { + return [self initWithTitle:title inView:view style:NBLoadingStyle withOffset:CGPointZero]; +} + +- (id)initWithTitle:(NSString *)title inView:(UIView *)view style:(NBNotifierStyle)style withOffset:(CGPoint)offset{ - if (self = [super initWithFrame:CGRectMake(0, view.bounds.size.height, view.bounds.size.width, NOTIFIER_HEIGHT)]){ + if (self = [super initWithFrame:CGRectMake(0, view.bounds.size.height - offset.y, view.bounds.size.width, NOTIFIER_HEIGHT)]){ self.backgroundColor = [UIColor clearColor]; self.style = style; + self.offset = offset; _txtLabel = [[UILabel alloc]initWithFrame:CGRectMake(32, 12, self.frame.size.width - 32, 20)]; [_txtLabel setFont:[UIFont fontWithName: @"Helvetica" size: 16]]; @@ -92,11 +102,24 @@ self.progressBar.progressTintColor = UIColorFromRGB(0xA0B0A6); self.progressBar.hidden = YES; [self addSubview:self.progressBar]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangedOrientation:) name:UIDeviceOrientationDidChangeNotification object:nil]; } return self; } +- (void) setNeedsLayout { + [super setNeedsLayout]; + [self didChangedOrientation:nil]; +} + +- (void) didChangedOrientation:(NSNotification *)sender { +// UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; + [self setView:self.view]; + self.progressBar.frame = CGRectMake(self.frame.size.width - 60 - 12, 14, 60, 6); +} + - (void)setAccessoryView:(UIView *)__accessoryView{ @@ -119,7 +142,7 @@ } - (void)setProgress:(float)value { - [self.progressBar setProgress:value animated:YES]; + [self.progressBar setProgress:value animated:(self.style == NBSyncingProgressStyle)]; } - (void)setTitle:(NSString *)title { @@ -154,9 +177,12 @@ - (void)setView:(UIView *)view { _view = view; - self.frame = CGRectMake(0, view.bounds.size.height, view.bounds.size.width, NOTIFIER_HEIGHT); - - [view addSubview:self]; + NSLog(@"Notifier view: %@ / %@", NSStringFromCGRect(view.bounds), NSStringFromCGPoint(self.offset)); + if (self.showing) { + self.frame = CGRectMake(0, view.bounds.size.height - self.offset.y - self.frame.size.height, view.bounds.size.width, NOTIFIER_HEIGHT); + } else { + self.frame = CGRectMake(0, view.bounds.size.height - self.offset.y, view.bounds.size.width, NOTIFIER_HEIGHT); + } } - (void)show { @@ -170,7 +196,7 @@ [UIView setAnimationDuration:time]; CGRect move = self.frame; - move.origin.y = self.view.frame.size.height - NOTIFIER_HEIGHT; + move.origin.y = self.view.frame.size.height - NOTIFIER_HEIGHT - self.offset.y; self.frame = move; [UIView commitAnimations]; @@ -183,7 +209,7 @@ [UIView setAnimationDuration:0.3f]; CGRect move = self.frame; - move.origin.y = self.view.frame.size.height - NOTIFIER_HEIGHT; + move.origin.y = self.view.frame.size.height - NOTIFIER_HEIGHT - self.offset.y; self.frame = move; [UIView commitAnimations]; @@ -226,7 +252,7 @@ CGRect move = self.frame; - move.origin.y = self.view.frame.size.height; + move.origin.y = self.view.frame.size.height - self.offset.y; self.frame = move; [UIView commitAnimations]; diff --git a/media/ios/Classes/NewsBlurViewController.m b/media/ios/Classes/NewsBlurViewController.m index f7a9a1df0..0294c4012 100644 --- a/media/ios/Classes/NewsBlurViewController.m +++ b/media/ios/Classes/NewsBlurViewController.m @@ -231,7 +231,8 @@ static const CGFloat kFolderTitleHeight = 28; appDelegate.activeClassifiers = [NSMutableDictionary dictionary]; - self.notifier = [[NBNotifier alloc] initWithTitle:@"Fetching stories..." inView:self.feedTitlesTable]; + self.notifier = [[NBNotifier alloc] initWithTitle:@"Fetching stories..." inView:self.view withOffset:CGPointMake(0, self.feedViewToolbar.frame.size.height)]; + [self.view insertSubview:self.notifier belowSubview:self.feedViewToolbar]; } - (void)viewWillAppear:(BOOL)animated { @@ -294,9 +295,10 @@ static const CGFloat kFolderTitleHeight = 28; [self redrawUnreadCounts]; [self.feedTitlesTable selectRowAtIndexPath:self.currentRowAtIndexPath animated:NO - scrollPosition:UITableViewScrollPositionNone]; + scrollPosition:UITableViewScrollPositionNone]; + [self.notifier setNeedsLayout]; } - + } - (void)viewDidAppear:(BOOL)animated { @@ -349,6 +351,7 @@ static const CGFloat kFolderTitleHeight = 28; - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { [self.feedTitlesTable reloadData]; + [self.notifier setNeedsLayout]; } - (void)didReceiveMemoryWarning { @@ -376,7 +379,8 @@ static const CGFloat kFolderTitleHeight = 28; self.feedViewToolbar.frame = (CGRect){CGPointMake(0.f, CGRectGetHeight(self.view.bounds) - toolbarSize.height), toolbarSize}; } self.innerView.frame = (CGRect){CGPointZero, CGSizeMake(CGRectGetWidth(self.view.bounds), CGRectGetMinY(self.feedViewToolbar.frame))}; - + self.notifier.offset = CGPointMake(0, self.feedViewToolbar.frame.size.height); + int height = 16; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && UIInterfaceOrientationIsLandscape(interfaceOrientation)) { @@ -1610,6 +1614,7 @@ heightForHeaderInSection:(NSInteger)section { [self.notifier hide]; self.notifier.style = NBSyncingStyle; self.notifier.title = @"Syncing stories..."; + [self.notifier setProgress:0]; [self.notifier show]; } @@ -1638,7 +1643,7 @@ heightForHeaderInSection:(NSInteger)section { } - (void)hideNotifier { - [self.notifier hide]; +// [self.notifier hide]; } @end \ No newline at end of file