mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
- Work in progress; see followup comment.
This commit is contained in:
parent
f7a19397ac
commit
fb3ccf2bfb
6 changed files with 50 additions and 60 deletions
|
@ -53,7 +53,6 @@
|
|||
@property (nonatomic) UISearchBar *searchBar;
|
||||
@property (nonatomic) IBOutlet UIView *messageView;
|
||||
@property (nonatomic) IBOutlet UILabel *messageLabel;
|
||||
@property (nonatomic, strong) id standardInteractivePopGestureDelegate;
|
||||
|
||||
@property (nonatomic, readwrite) BOOL pageFetching;
|
||||
@property (nonatomic, readwrite) BOOL pageFinished;
|
||||
|
|
|
@ -332,10 +332,6 @@
|
|||
|
||||
self.appDelegate = (NewsBlurAppDelegate *)[[UIApplication sharedApplication] delegate];
|
||||
|
||||
if (self.standardInteractivePopGestureDelegate == nil) {
|
||||
self.standardInteractivePopGestureDelegate = self.navigationController.interactivePopGestureRecognizer.delegate;
|
||||
}
|
||||
|
||||
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
|
||||
[self setUserAvatarLayout:orientation];
|
||||
self.finishedAnimatingIn = NO;
|
||||
|
@ -453,10 +449,6 @@
|
|||
- (void)viewDidAppear:(BOOL)animated {
|
||||
[super viewDidAppear:animated];
|
||||
|
||||
if (self.navigationController.interactivePopGestureRecognizer.delegate != self.standardInteractivePopGestureDelegate) {
|
||||
self.navigationController.interactivePopGestureRecognizer.delegate = self.standardInteractivePopGestureDelegate;
|
||||
}
|
||||
|
||||
if (appDelegate.inStoryDetail && self.isPhoneOrCompact) {
|
||||
appDelegate.inStoryDetail = NO;
|
||||
// [appDelegate.storyPageControl resetPages];
|
||||
|
|
|
@ -47,7 +47,6 @@ UIActionSheetDelegate, WKNavigationDelegate> {
|
|||
@property (nonatomic, assign) BOOL inTextView;
|
||||
@property (nonatomic, assign) BOOL isRecentlyUnread;
|
||||
@property (nonatomic) BOOL hasStory;
|
||||
@property (nonatomic, readonly) BOOL canHideNavigationBar;
|
||||
@property (nonatomic, readonly) BOOL isSinglePage;
|
||||
|
||||
@property NSInteger pageIndex;
|
||||
|
|
|
@ -185,7 +185,7 @@
|
|||
- (void)tap:(UITapGestureRecognizer *)gestureRecognizer {
|
||||
// NSLog(@"Gesture tap: %ld (%ld) - %d", (long)gestureRecognizer.state, (long)UIGestureRecognizerStateEnded, inDoubleTap);
|
||||
|
||||
if (gestureRecognizer.state == UIGestureRecognizerStateEnded && gestureRecognizer.numberOfTouches == 1 && appDelegate.storyPageControl.autoscrollAvailable && self.presentedViewController == nil) {
|
||||
if (gestureRecognizer.state == UIGestureRecognizerStateEnded && gestureRecognizer.numberOfTouches == 1 && self.presentedViewController == nil) {
|
||||
CGPoint pt = [self pointForGesture:gestureRecognizer];
|
||||
if (pt.x == CGPointZero.x && pt.y == CGPointZero.y) return;
|
||||
if (inDoubleTap) return;
|
||||
|
@ -196,7 +196,7 @@
|
|||
[webView evaluateJavaScript:[NSString stringWithFormat:@"linkAt(%li, %li, 'id');", (long)pt.x,(long)pt.y] completionHandler:^(NSString *identifier, NSError *error) {
|
||||
[webView evaluateJavaScript:[NSString stringWithFormat:@"linkAt(%li, %li, 'outerHTML');", (long)pt.x,(long)pt.y] completionHandler:^(NSString *outerHTML, NSError *error) {
|
||||
if ([identifier isEqualToString:@"NB-story"] || ![outerHTML containsString:@"NB-"]) {
|
||||
[appDelegate.storyPageControl showAutoscrollBriefly:YES];
|
||||
[appDelegate.storyPageControl tappedStory];
|
||||
}
|
||||
}];
|
||||
}];
|
||||
|
@ -206,7 +206,7 @@
|
|||
|
||||
// Ignore links, videos, and iframes (e.g. embedded YouTube videos).
|
||||
if (![@[@"A", @"VIDEO", @"IFRAME"] containsObject:tagName]) {
|
||||
[appDelegate.storyPageControl showAutoscrollBriefly:YES];
|
||||
[appDelegate.storyPageControl tappedStory];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
@ -613,9 +613,10 @@
|
|||
|
||||
- (void)drawFeedGradient {
|
||||
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
|
||||
BOOL navigationBarHidden = self.navigationController.navigationBarHidden;
|
||||
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;
|
||||
BOOL shouldOffsetFeedGradient = NO; //UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && !UIInterfaceOrientationIsLandscape(orientation) && navigationBarHidden && !shouldHideStatusBar;
|
||||
CGFloat yOffset = shouldOffsetFeedGradient ? appDelegate.storyPageControl.statusBarBackgroundView.bounds.size.height - 1 : -1;
|
||||
NSString *feedIdStr = [NSString stringWithFormat:@"%@",
|
||||
[self.activeStory
|
||||
|
@ -633,6 +634,8 @@
|
|||
self.feedTitleGradient.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
self.feedTitleGradient.tag = FEED_TITLE_GRADIENT_TAG; // Not attached yet. Remove old gradients, first.
|
||||
|
||||
NSLog(@"⚠️ nav hidden: %@, should offset: %@, frame: %@, feedTitleGradient: %@", navigationBarHidden ? @"yes" : @"no", shouldOffsetFeedGradient ? @"yes" : @"no", NSStringFromCGRect(self.webView.scrollView.frame), @(yOffset)); // log
|
||||
|
||||
for (UIView *subview in self.webView.subviews) {
|
||||
if (subview.tag == FEED_TITLE_GRADIENT_TAG) {
|
||||
[subview removeFromSuperview];
|
||||
|
@ -650,7 +653,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 && shouldHideStatusBar) {
|
||||
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:^{
|
||||
|
@ -1384,11 +1387,14 @@
|
|||
BOOL isHorizontal = appDelegate.storyPageControl.isHorizontal;
|
||||
BOOL isNavBarHidden = self.navigationController.navigationBarHidden;
|
||||
|
||||
if (!isHorizontal && appDelegate.storyPageControl.previousPage.pageIndex < 0) {
|
||||
[appDelegate.storyPageControl setNavigationBarHidden:NO];
|
||||
} else if (isHorizontal && topPosition <= minimumTopPositionWhenHidden && isNavBarHidden) {
|
||||
[appDelegate.storyPageControl setNavigationBarHidden:NO];
|
||||
} else if (!nearTop && !isNavBarHidden && self.canHideNavigationBar) {
|
||||
// if (!isHorizontal && appDelegate.storyPageControl.previousPage.pageIndex < 0) {
|
||||
// [appDelegate.storyPageControl setNavigationBarHidden:NO];
|
||||
// } else if (isHorizontal && topPosition <= minimumTopPositionWhenHidden && isNavBarHidden) {
|
||||
// [appDelegate.storyPageControl setNavigationBarHidden:NO];
|
||||
// } else if (!isNavBarHidden && self.canHideNavigationBar) {
|
||||
// [appDelegate.storyPageControl setNavigationBarHidden:YES];
|
||||
// }
|
||||
if (!isNavBarHidden && self.canHideNavigationBar && !nearTop && appDelegate.storyPageControl.autoscrollActive) {
|
||||
[appDelegate.storyPageControl setNavigationBarHidden:YES];
|
||||
}
|
||||
|
||||
|
@ -1910,20 +1916,12 @@
|
|||
}
|
||||
|
||||
- (BOOL)canHideNavigationBar {
|
||||
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone || self.presentedViewController != nil) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (!appDelegate.storyPageControl.wantNavigationBarHidden) {
|
||||
if (!appDelegate.storyPageControl.allowFullscreen) {
|
||||
NSLog(@"canHideNavigationBar: no, toggle is off"); // log
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL canHide = !self.isSinglePage;
|
||||
|
||||
NSLog(@"canHideNavigationBar: %@", canHide ? @"yes" : @"no"); // log
|
||||
|
||||
return canHide;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)isSinglePage {
|
||||
|
|
|
@ -87,7 +87,8 @@
|
|||
@property (nonatomic) MBProgressHUD *storyHUD;
|
||||
@property (nonatomic, strong) NBNotifier *notifier;
|
||||
@property (nonatomic) NSInteger scrollingToPage;
|
||||
@property (nonatomic, readonly) BOOL wantNavigationBarHidden;
|
||||
@property (nonatomic, strong) id standardInteractivePopGestureDelegate;
|
||||
@property (nonatomic, readonly) BOOL allowFullscreen;
|
||||
@property (nonatomic) BOOL forceNavigationBarShown;
|
||||
@property (nonatomic) BOOL currentlyTogglingNavigationBar;
|
||||
@property (nonatomic, readonly) BOOL isHorizontal;
|
||||
|
@ -135,6 +136,7 @@
|
|||
|
||||
- (void)flashCheckmarkHud:(NSString *)messageType;
|
||||
|
||||
- (void)tappedStory;
|
||||
- (void)showAutoscrollBriefly:(BOOL)briefly;
|
||||
- (void)hideAutoscrollAfterDelay;
|
||||
- (void)hideAutoscrollImmediately;
|
||||
|
|
|
@ -276,11 +276,17 @@
|
|||
|
||||
self.currentlyTogglingNavigationBar = NO;
|
||||
|
||||
if (self.standardInteractivePopGestureDelegate == nil) {
|
||||
self.standardInteractivePopGestureDelegate = self.navigationController.interactivePopGestureRecognizer.delegate;
|
||||
}
|
||||
|
||||
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
|
||||
BOOL swipeEnabled = [[userPreferences stringForKey:@"story_detail_swipe_left_edge"]
|
||||
isEqualToString:@"pop_to_story_list"];;
|
||||
self.navigationController.hidesBarsOnSwipe = self.allowFullscreen;
|
||||
self.navigationController.interactivePopGestureRecognizer.enabled = swipeEnabled;
|
||||
|
||||
self.navigationController.interactivePopGestureRecognizer.delegate = self;
|
||||
|
||||
if (self.isPhoneOrCompact) {
|
||||
if (!appDelegate.storiesCollection.isSocialView) {
|
||||
UIImage *titleImage;
|
||||
|
@ -398,7 +404,9 @@
|
|||
[super viewWillDisappear:animated];
|
||||
|
||||
previousPage.view.hidden = YES;
|
||||
self.navigationController.hidesBarsOnSwipe = NO;
|
||||
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
|
||||
self.navigationController.interactivePopGestureRecognizer.delegate = self.standardInteractivePopGestureDelegate;
|
||||
self.autoscrollActive = NO;
|
||||
}
|
||||
|
||||
|
@ -470,7 +478,9 @@
|
|||
BOOL shouldHideStatusBar = [preferences boolForKey:@"story_hide_status_bar"];
|
||||
BOOL isNavBarHidden = self.navigationController.navigationBarHidden;
|
||||
|
||||
self.statusBarBackgroundView.hidden = shouldHideStatusBar || !isNavBarHidden || !appDelegate.isPortrait;
|
||||
self.statusBarBackgroundView.hidden = YES; shouldHideStatusBar || !isNavBarHidden || !appDelegate.isPortrait;
|
||||
|
||||
NSLog(@"⚠️ updateStatusBarState: %@", isNavBarHidden ? @"nav hidden" : @"nav shown"); // log
|
||||
}
|
||||
|
||||
- (BOOL)prefersStatusBarHidden {
|
||||
|
@ -483,7 +493,11 @@
|
|||
return shouldHideStatusBar && isNavBarHidden;
|
||||
}
|
||||
|
||||
- (BOOL)wantNavigationBarHidden {
|
||||
- (BOOL)allowFullscreen {
|
||||
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone || self.presentedViewController != nil) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
return ([preferences boolForKey:@"story_full_screen"] || self.autoscrollAvailable) && !self.forceNavigationBarShown;
|
||||
|
@ -502,17 +516,6 @@
|
|||
|
||||
[self.navigationController setNavigationBarHidden:hide animated:YES];
|
||||
|
||||
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
|
||||
BOOL swipeEnabled = [[userPreferences stringForKey:@"story_detail_swipe_left_edge"]
|
||||
isEqualToString:@"pop_to_story_list"];
|
||||
self.navigationController.interactivePopGestureRecognizer.enabled = swipeEnabled;
|
||||
|
||||
if (hide) {
|
||||
self.navigationController.interactivePopGestureRecognizer.delegate = self;
|
||||
} else if (appDelegate.feedDetailViewController.standardInteractivePopGestureDelegate != nil) {
|
||||
self.navigationController.interactivePopGestureRecognizer.delegate = appDelegate.feedDetailViewController.standardInteractivePopGestureDelegate;
|
||||
}
|
||||
|
||||
CGPoint oldOffset = currentPage.webView.scrollView.contentOffset;
|
||||
CGFloat navHeight = self.navigationController.navigationBar.bounds.size.height;
|
||||
CGFloat statusAdjustment = 20.0;
|
||||
|
@ -1243,16 +1246,6 @@
|
|||
}
|
||||
self.scrollView.scrollsToTop = NO;
|
||||
|
||||
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) {
|
||||
[self setNavigationBarHidden:NO];
|
||||
}
|
||||
|
||||
if (self.isDraggingScrollview || self.scrollingToPage == currentPage.pageIndex) {
|
||||
if (currentPage.pageIndex == -2) return;
|
||||
self.scrollingToPage = -1;
|
||||
|
@ -1567,12 +1560,11 @@
|
|||
}
|
||||
|
||||
- (void)changedFullscreen {
|
||||
BOOL wantHidden = self.wantNavigationBarHidden;
|
||||
BOOL isHidden = self.navigationController.navigationBarHidden;
|
||||
BOOL wantHidden = self.allowFullscreen;
|
||||
|
||||
if (self.currentPage.webView.scrollView.contentOffset.y > 10 || isHidden) {
|
||||
[self setNavigationBarHidden:wantHidden alsoTraverse:YES];
|
||||
}
|
||||
self.navigationController.hidesBarsOnSwipe = self.allowFullscreen;
|
||||
|
||||
[self setNavigationBarHidden:wantHidden alsoTraverse:YES];
|
||||
}
|
||||
|
||||
- (void)changedAutoscroll {
|
||||
|
@ -1702,6 +1694,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)tappedStory {
|
||||
if (self.autoscrollAvailable) {
|
||||
[self showAutoscrollBriefly:YES];
|
||||
} else {
|
||||
[self setNavigationBarHidden: !self.navigationController.navigationBarHidden];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showAutoscrollBriefly:(BOOL)briefly {
|
||||
if (!self.autoscrollAvailable || self.currentPage.webView.scrollView.contentSize.height - 200 <= self.currentPage.view.frame.size.height) {
|
||||
[self hideAutoscrollWithAnimation];
|
||||
|
|
Loading…
Add table
Reference in a new issue