mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Adding in-app safari reader mode preference. Also adding San Francisco as a story font. Thanks to Will Sigmon (@WSig) for both ideas.
This commit is contained in:
parent
65dc876f87
commit
8df5237e29
9 changed files with 54 additions and 27 deletions
|
@ -60,6 +60,7 @@
|
|||
[self addBundledFontWithName:@"GothamNarrow-Book" styleClass:@"GothamNarrow-Book" displayName:nil];
|
||||
[self addBuiltInFontWithName:@"Helvetica" styleClass:@"NB-helvetica" displayName:nil];
|
||||
[self addBuiltInFontWithName:@"Palatino-Roman" styleClass:@"NB-palatino" displayName:nil];
|
||||
[self addBundledFontWithName:@"SanFrancisco" styleClass:@"NB-sanfrancisco" displayName:@"San Francisco"];
|
||||
[self addBundledFontWithName:@"WhitneySSm-Book" styleClass:@"WhitneySSm-Book" displayName:@"Whitney"];
|
||||
|
||||
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
|
||||
|
@ -134,6 +135,9 @@
|
|||
|
||||
- (void)addBuiltInFontWithName:(NSString *)fontName styleClass:(NSString *)styleClass displayName:(NSString *)displayName {
|
||||
UIFont *font = [UIFont fontWithName:fontName size:16.0];
|
||||
if ([fontName isEqualToString:@"SanFrancisco"]) {
|
||||
font = [UIFont systemFontOfSize:16.0 weight:UIFontWeightRegular];
|
||||
}
|
||||
|
||||
if (font) {
|
||||
if (!displayName) {
|
||||
|
|
|
@ -1731,6 +1731,10 @@
|
|||
self.safariViewController = [[SFSafariViewController alloc] initWithURL:url];
|
||||
self.safariViewController.delegate = self;
|
||||
[navigationController presentViewController:self.safariViewController animated:YES completion:nil];
|
||||
} else if ([storyBrowser isEqualToString:@"inappsafarireader"]) {
|
||||
self.safariViewController = [[SFSafariViewController alloc] initWithURL:url entersReaderIfAvailable:YES];
|
||||
self.safariViewController.delegate = self;
|
||||
[navigationController presentViewController:self.safariViewController animated:YES completion:nil];
|
||||
} else {
|
||||
if (!originalStoryViewController) {
|
||||
originalStoryViewController = [[OriginalStoryViewController alloc] init];
|
||||
|
|
|
@ -1252,8 +1252,9 @@
|
|||
if (appDelegate.storyPageControl.currentPage != self) return;
|
||||
|
||||
int webpageHeight = self.webView.scrollView.contentSize.height;
|
||||
int viewportHeight = self.webView.scrollView.frame.size.height;
|
||||
int viewportHeight = self.view.frame.size.height;
|
||||
int topPosition = self.webView.scrollView.contentOffset.y;
|
||||
int safeBottomMargin = -32;
|
||||
int bottomPosition = webpageHeight - topPosition - viewportHeight;
|
||||
BOOL singlePage = webpageHeight - 200 <= viewportHeight;
|
||||
BOOL atBottom = bottomPosition < 150;
|
||||
|
@ -1274,52 +1275,61 @@
|
|||
}];
|
||||
} else if (singlePage) {
|
||||
appDelegate.storyPageControl.traverseView.alpha = 1;
|
||||
CGRect tvf = appDelegate.storyPageControl.traverseView.frame;
|
||||
if (bottomPosition > 0) {
|
||||
appDelegate.storyPageControl.traverseView.frame = CGRectMake(tvf.origin.x,
|
||||
self.webView.scrollView.frame.size.height - tvf.size.height,
|
||||
tvf.size.width, tvf.size.height);
|
||||
NSLog(@" ---> Bottom position: %d", bottomPosition);
|
||||
if (bottomPosition >= 0) {
|
||||
// appDelegate.storyPageControl.traverseView.frame = CGRectMake(tvf.origin.x,
|
||||
// self.webView.scrollView.frame.size.height - tvf.size.height - safeBottomMargin,
|
||||
// tvf.size.width, tvf.size.height);
|
||||
appDelegate.storyPageControl.traverseBottomConstraint.constant = safeBottomMargin;
|
||||
} else {
|
||||
appDelegate.storyPageControl.traverseView.frame = CGRectMake(tvf.origin.x,
|
||||
(self.webView.scrollView.contentSize.height - self.webView.scrollView.contentOffset.y) - tvf.size.height,
|
||||
tvf.size.width, tvf.size.height);
|
||||
// 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;
|
||||
// appDelegate.storyPageControl.traverseBottomConstraint.constant = safeBottomMargin;
|
||||
}
|
||||
} else if (!singlePage && (atTop && !atBottom)) {
|
||||
// Pin to bottom of viewport, regardless of scrollview
|
||||
appDelegate.storyPageControl.traversePinned = YES;
|
||||
appDelegate.storyPageControl.traverseFloating = NO;
|
||||
CGRect tvf = appDelegate.storyPageControl.traverseView.frame;
|
||||
appDelegate.storyPageControl.traverseView.frame = CGRectMake(tvf.origin.x,
|
||||
self.webView.scrollView.frame.size.height - tvf.size.height,
|
||||
tvf.size.width, tvf.size.height);
|
||||
// appDelegate.storyPageControl.traverseView.frame = CGRectMake(tvf.origin.x,
|
||||
// self.webView.scrollView.frame.size.height - tvf.size.height - safeBottomMargin,
|
||||
// tvf.size.width, tvf.size.height);
|
||||
[appDelegate.storyPageControl.view layoutIfNeeded];
|
||||
|
||||
appDelegate.storyPageControl.traverseBottomConstraint.constant = safeBottomMargin;
|
||||
[UIView animateWithDuration:.3 delay:0
|
||||
options:UIViewAnimationOptionCurveEaseInOut
|
||||
animations:^{
|
||||
[appDelegate.storyPageControl.view layoutIfNeeded];
|
||||
appDelegate.storyPageControl.traverseView.alpha = 1;
|
||||
} completion:nil];
|
||||
} else if (appDelegate.storyPageControl.traverseView.alpha == 1 &&
|
||||
appDelegate.storyPageControl.traversePinned) {
|
||||
// Scroll with bottom of scrollview, but smoothly
|
||||
appDelegate.storyPageControl.traverseFloating = YES;
|
||||
CGRect tvf = appDelegate.storyPageControl.traverseView.frame;
|
||||
[appDelegate.storyPageControl.view layoutIfNeeded];
|
||||
|
||||
appDelegate.storyPageControl.traverseBottomConstraint.constant = safeBottomMargin;
|
||||
[UIView animateWithDuration:.3 delay:0
|
||||
options:UIViewAnimationOptionCurveEaseInOut
|
||||
animations:^{
|
||||
appDelegate.storyPageControl.traverseView.frame = CGRectMake(tvf.origin.x,
|
||||
(self.webView.scrollView.contentSize.height - self.webView.scrollView.contentOffset.y) - tvf.size.height,
|
||||
tvf.size.width, tvf.size.height);
|
||||
// appDelegate.storyPageControl.traverseView.frame = CGRectMake(tvf.origin.x,
|
||||
// (webpageHeight - topPosition) - tvf.size.height - safeBottomMargin,
|
||||
// tvf.size.width, tvf.size.height);
|
||||
[appDelegate.storyPageControl.view layoutIfNeeded];
|
||||
} completion:^(BOOL finished) {
|
||||
appDelegate.storyPageControl.traversePinned = NO;
|
||||
appDelegate.storyPageControl.traversePinned = NO;
|
||||
}];
|
||||
} else {
|
||||
// Scroll with bottom of scrollview
|
||||
appDelegate.storyPageControl.traversePinned = NO;
|
||||
appDelegate.storyPageControl.traverseFloating = YES;
|
||||
appDelegate.storyPageControl.traverseView.alpha = 1;
|
||||
CGRect tvf = appDelegate.storyPageControl.traverseView.frame;
|
||||
appDelegate.storyPageControl.traverseView.frame = CGRectMake(tvf.origin.x,
|
||||
(self.webView.scrollView.contentSize.height - self.webView.scrollView.contentOffset.y) - tvf.size.height,
|
||||
tvf.size.width, tvf.size.height);
|
||||
appDelegate.storyPageControl.traverseBottomConstraint.constant = viewportHeight - (webpageHeight - topPosition) + safeBottomMargin;
|
||||
// appDelegate.storyPageControl.traverseView.frame = CGRectMake(tvf.origin.x,
|
||||
// (webpageHeight - topPosition) - tvf.size.height - safeBottomMargin,
|
||||
// tvf.size.width, tvf.size.height);
|
||||
}
|
||||
|
||||
[self storeScrollPosition:YES];
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
@property (nonatomic) IBOutlet UIBarButtonItem *originalStoryButton;
|
||||
@property (nonatomic, strong) IBOutlet UIBarButtonItem *subscribeButton;
|
||||
@property (nonatomic) IBOutlet UIImageView *dragBarImageView;
|
||||
@property (nonatomic) IBOutlet NSLayoutConstraint *traverseBottomConstraint;
|
||||
@property (readwrite) BOOL traversePinned;
|
||||
@property (readwrite) BOOL traverseFloating;
|
||||
@property (readwrite) CGFloat inTouchMove;
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
@synthesize isAnimatedIntoPlace;
|
||||
@synthesize progressView, progressViewContainer;
|
||||
@synthesize traversePinned, traverseFloating;
|
||||
@synthesize traverseBottomConstraint;
|
||||
|
||||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||
|
@ -750,15 +751,15 @@
|
|||
// }
|
||||
|
||||
// Stick to bottom
|
||||
CGRect tvf = self.traverseView.frame;
|
||||
traversePinned = YES;
|
||||
[UIView animateWithDuration:.24 delay:0
|
||||
options:UIViewAnimationOptionCurveEaseInOut
|
||||
animations:^{
|
||||
[self.traverseView setNeedsLayout];
|
||||
self.traverseView.frame = CGRectMake(tvf.origin.x,
|
||||
self.view.bounds.size.height - tvf.size.height - bottomSizeHeightConstraint.constant,
|
||||
tvf.size.width, tvf.size.height);
|
||||
// self.traverseView.frame = CGRectMake(tvf.origin.x,
|
||||
// self.view.bounds.size.height - tvf.size.height - bottomSizeHeightConstraint.constant - (self.view.safeAreaInsets.bottom - 20),
|
||||
// tvf.size.width, tvf.size.height);
|
||||
self.traverseBottomConstraint.constant = -32;
|
||||
self.traverseView.alpha = 1;
|
||||
self.traversePinned = YES;
|
||||
} completion:^(BOOL finished) {
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="StoryPageControl">
|
||||
<connections>
|
||||
<outlet property="bottomSize" destination="YKz-PZ-s0t" id="P3I-Wx-dLN"/>
|
||||
<outlet property="bottomSizeHeightConstraint" destination="Ugq-XC-pFz" id="N4h-uD-Xai"/>
|
||||
<outlet property="buttonNext" destination="62" id="72"/>
|
||||
<outlet property="buttonPrevious" destination="64" id="67"/>
|
||||
<outlet property="buttonSend" destination="85" id="88"/>
|
||||
|
@ -29,6 +28,7 @@
|
|||
<outlet property="prevNextBackgroundImageView" destination="71" id="S3e-tC-Pbu"/>
|
||||
<outlet property="scrollView" destination="5" id="15"/>
|
||||
<outlet property="textStorySendBackgroundImageView" destination="80" id="1hz-Zr-85e"/>
|
||||
<outlet property="traverseBottomConstraint" destination="rgF-mh-lia" id="ucW-KZ-fN6"/>
|
||||
<outlet property="traverseView" destination="75" id="76"/>
|
||||
<outlet property="view" destination="3" id="22"/>
|
||||
</connections>
|
||||
|
|
|
@ -595,6 +595,7 @@
|
|||
<array>
|
||||
<string>In-app browser</string>
|
||||
<string>In-app Safari</string>
|
||||
<string>In-app Safari Reader Mode</string>
|
||||
<string>Safari</string>
|
||||
<string>Chrome</string>
|
||||
<string>Opera Mini</string>
|
||||
|
@ -606,6 +607,7 @@
|
|||
<array>
|
||||
<string>inapp</string>
|
||||
<string>inappsafari</string>
|
||||
<string>inappsafarireader</string>
|
||||
<string>safari</string>
|
||||
<string>chrome</string>
|
||||
<string>opera_mini</string>
|
||||
|
|
|
@ -615,6 +615,7 @@
|
|||
<array>
|
||||
<string>In-app browser</string>
|
||||
<string>In-app Safari</string>
|
||||
<string>In-app Safari Reader Mode</string>
|
||||
<string>Safari</string>
|
||||
<string>Chrome</string>
|
||||
<string>Opera Mini</string>
|
||||
|
@ -626,6 +627,7 @@
|
|||
<array>
|
||||
<string>inapp</string>
|
||||
<string>inappsafari</string>
|
||||
<string>inappsafarireader</string>
|
||||
<string>safari</string>
|
||||
<string>chrome</string>
|
||||
<string>opera_mini</string>
|
||||
|
|
|
@ -45,6 +45,9 @@
|
|||
.NB-palatino {
|
||||
font-family: "Palatino";
|
||||
}
|
||||
.NB-sanfrancisco {
|
||||
font-family: "-apple-system";
|
||||
}
|
||||
.NB-helvetica {
|
||||
font-family: "Helvetica";
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue