Skip to content

Commit

Permalink
Bug 229528 - Fix content offset at about screen
Browse files Browse the repository at this point in the history
  • Loading branch information
akarataev committed Aug 30, 2019
1 parent 6e10dc1 commit 883e82c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Wikipedia/Code/AboutViewController.m
Expand Up @@ -96,6 +96,12 @@ - (void)wmf_preventTextFromExpandingOnRotation {
[self evaluateJavaScript:@"document.body.style['-webkit-text-size-adjust'] = 'none';" completionHandler:nil];
}

- (void)wmf_setDocumentScrollTopWith:(CGFloat)offset {
CGFloat yScrollTop = self.iOS12yOffsetHack + offset;
NSString *format = @"document.body.scrollTop = %f;";
[self evaluateJavaScript:[NSString stringWithFormat:format, yScrollTop] completionHandler:nil];
}

@end

@interface AboutViewController ()
Expand Down Expand Up @@ -175,6 +181,15 @@ - (NSString *)title {
return WMFLocalizedStringWithDefaultValue(@"about-title", nil, nil, @"About", @"Title for credits page\n{{Identical|About}}");
}

#pragma mark - Web View Configuration

- (void)updateWebViewContentOffset {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
CGFloat barHeight = self.navigationController.navigationBar.frame.size.height;
[self.webView wmf_setDocumentScrollTopWith:barHeight];
});
}

#pragma mark - Accessors

- (NSDictionary *)data {
Expand Down Expand Up @@ -298,6 +313,7 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati
- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation {
if (!([[self class] isLicenseURL:[webView URL]] || [[self class] isLicenseRedirectURL:[webView URL]])) {
[self injectAboutPageContentIntoWebView:webView];
[self updateWebViewContentOffset];
} else {
[webView wmf_preventTextFromExpandingOnRotation];
}
Expand Down
3 changes: 2 additions & 1 deletion Wikipedia/Code/AboutViewController.plist
Expand Up @@ -138,6 +138,7 @@ THE SOFTWARE.</string>
<string>André Costa</string>
<string>Anthony Borba</string>
<string>Antoine Musso</string>
<string>Alexey Karataev</string>
<string>Barbara Martina Rodeker</string>
<string>bart-kneepkens</string>
<string>Bernd Sitzmann</string>
Expand All @@ -154,7 +155,7 @@ THE SOFTWARE.</string>
<string>David Xia</string>
<string>Dmitry Brant</string>
<string>Elena Tonkovidova</string>
<string>Ethan Holshouser</string>
<string>Ethan Holshouser</string>
<string>Gabicoware</string>
<string>Gianmarco Salerno</string>
<string>Hua Zhenyu</string>
Expand Down

0 comments on commit 883e82c

Please sign in to comment.