#1306 (status bar during fullscreen)

- When the status bar is shown and nav bar hidden, now shows the feed gradient.
- Fixed incorrect scrolling when going to a story that shows the bar.
- Fixed the status bar background not showing up.
- Fixed the traversal buttons sliding down on first appearance.
This commit is contained in:
David Sinclair 2020-05-26 14:13:46 -07:00
parent 5f0023ad51
commit 275b3c4a73
3 changed files with 22 additions and 8 deletions

View file

@ -3314,7 +3314,7 @@
[gradientView addSubview:titleImageView];
} else {
gradientView = [NewsBlurAppDelegate
makeGradientView:CGRectMake(0, -1, rect.size.width, 10)
makeGradientView:CGRectMake(0, rect.origin.y, rect.size.width, 10)
// hard coding the 1024 as a hack for window.frame.size.width
startColor:[feed objectForKey:@"favicon_fade"]
endColor:[feed objectForKey:@"favicon_color"]

View file

@ -602,6 +602,11 @@
}
- (void)drawFeedGradient {
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
BOOL shouldHideStatusBar = [preferences boolForKey:@"story_hide_status_bar"];
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
BOOL shouldOffsetFeedGradient = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && !UIInterfaceOrientationIsLandscape(orientation) && self.navigationController.navigationBarHidden && !shouldHideStatusBar;
CGFloat yOffset = shouldOffsetFeedGradient ? appDelegate.storyPageControl.statusBarBackgroundView.bounds.size.height - 1 : -1;
NSString *feedIdStr = [NSString stringWithFormat:@"%@",
[self.activeStory
objectForKey:@"story_feed_id"]];
@ -614,7 +619,7 @@
self.feedTitleGradient = [appDelegate
makeFeedTitleGradient:feed
withRect:CGRectMake(0, -1, CGRectGetWidth(self.view.bounds), 21)]; // 1024 hack for self.webView.frame.size.width
withRect:CGRectMake(0, yOffset, CGRectGetWidth(self.view.bounds), 21)]; // 1024 hack for self.webView.frame.size.width
self.feedTitleGradient.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.feedTitleGradient.tag = FEED_TITLE_GRADIENT_TAG; // Not attached yet. Remove old gradients, first.
@ -635,7 +640,7 @@
[self.webView insertSubview:feedTitleGradient aboveSubview:self.webView.scrollView];
if (@available(iOS 11.0, *)) {
if (self.view.safeAreaInsets.top > 0.0 && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
if (self.view.safeAreaInsets.top > 0.0 && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && shouldHideStatusBar) {
feedTitleGradient.alpha = self.navigationController.navigationBarHidden ? 1 : 0;
[UIView animateWithDuration:0.3 animations:^{
@ -1404,7 +1409,11 @@
// appDelegate.storyPageControl.traverseView.frame = CGRectMake(tvf.origin.x,
// (webpageHeight - topPosition) - tvf.size.height - safeBottomMargin,
// tvf.size.width, tvf.size.height);
appDelegate.storyPageControl.traverseBottomConstraint.constant = viewportHeight - (webpageHeight - topPosition) + safeBottomMargin;
if (webpageHeight > 0) {
appDelegate.storyPageControl.traverseBottomConstraint.constant = viewportHeight - (webpageHeight - topPosition) + safeBottomMargin;
} else {
appDelegate.storyPageControl.traverseBottomConstraint.constant = safeBottomMargin;
}
// appDelegate.storyPageControl.traverseBottomConstraint.constant = safeBottomMargin;
}
} else if (!singlePage && (atTop && !atBottom)) {

View file

@ -228,6 +228,8 @@
[self.view addConstraint:self.notifier.topOffsetConstraint];
[self.notifier hideNow];
self.traverseBottomConstraint.constant = 50;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:
originalStoryButton,
@ -235,8 +237,6 @@
fontSettingsButton, nil];
}
[self updateTheme];
[self.scrollView addObserver:self forKeyPath:@"contentOffset"
options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld
context:nil];
@ -266,6 +266,8 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self updateTheme];
[self updateAutoscrollButtons];
[self updateTraverseBackground];
[self setNextPreviousButtons];
@ -500,7 +502,7 @@
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
BOOL swipeEnabled = [[userPreferences stringForKey:@"story_detail_swipe_left_edge"]
isEqualToString:@"pop_to_story_list"];;
isEqualToString:@"pop_to_story_list"];
self.navigationController.interactivePopGestureRecognizer.enabled = swipeEnabled;
if (hide) {
@ -1239,7 +1241,10 @@
}
self.scrollView.scrollsToTop = NO;
NSInteger topPosition = currentPage.webView.scrollView.contentOffset.y;
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
BOOL shouldHideStatusBar = [preferences boolForKey:@"story_hide_status_bar"];
NSInteger statusBarOffset = shouldHideStatusBar ? 0 : self.statusBarHeight;
NSInteger topPosition = currentPage.webView.scrollView.contentOffset.y + statusBarOffset;
BOOL canHide = currentPage.canHideNavigationBar && topPosition >= 0;
if (!canHide && self.isHorizontal && self.navigationController.navigationBarHidden) {