Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes 1191767 - Do not manually handle keyboard overlapping with WKWebView #877

Merged
merged 1 commit into from Aug 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 7 additions & 41 deletions Client/Frontend/Settings/SettingsContentViewController.swift
Expand Up @@ -90,15 +90,20 @@ class SettingsContentViewController: UIViewController, WKNavigationDelegate {

self.webView = makeWebView()
view.addSubview(webView)
self.webView.snp_remakeConstraints { make in
make.edges.equalTo(self.view)
}

// Destructuring let causes problems.
let ret = makeInterstitialViews()
self.interstitialView = ret.0
self.interstitialSpinnerView = ret.1
self.interstitialErrorView = ret.2

view.addSubview(interstitialView)
layoutInnerViews()
self.interstitialView.snp_remakeConstraints { make in
make.edges.equalTo(self.view)
}

startLoading()
}

Expand Down Expand Up @@ -165,42 +170,3 @@ class SettingsContentViewController: UIViewController, WKNavigationDelegate {
self.isLoaded = true
}
}

extension SettingsContentViewController: KeyboardHelperDelegate {
private func layoutInnerViews() {
let keyboardHeight = KeyboardHelper.defaultHelper.currentState?.intersectionHeightForView(self.webView) ?? 0

self.webView.snp_remakeConstraints { make in
make.left.right.top.equalTo(self.view)
make.bottom.equalTo(self.view).offset(-keyboardHeight)
}
if !isLoaded {
// If the page has loaded, the interstitial view will have been removed.
self.interstitialView.snp_remakeConstraints { make in
make.left.right.top.equalTo(self.view)
make.bottom.equalTo(self.view).offset(-keyboardHeight)
}
}
}

func keyboardHelper(keyboardHelper: KeyboardHelper, keyboardWillShowWithState state: KeyboardState) {
animateInnerViewsWithKeyboard(state)
}

func keyboardHelper(keyboardHelper: KeyboardHelper, keyboardDidShowWithState state: KeyboardState) {
animateInnerViewsWithKeyboard(state)
}

func keyboardHelper(keyboardHelper: KeyboardHelper, keyboardWillHideWithState state: KeyboardState) {
animateInnerViewsWithKeyboard(state)
}

private func animateInnerViewsWithKeyboard(keyboardState: KeyboardState) {
layoutInnerViews()

UIView.animateWithDuration(keyboardState.animationDuration, delay: 0.0, options: UIViewAnimationOptions.CurveEaseIn, animations: {
self.view.layoutIfNeeded()
}, completion: nil)
}
}

1 change: 0 additions & 1 deletion FxAClient/Frontend/SignIn/FxAContentViewController.swift
Expand Up @@ -41,7 +41,6 @@ class FxAContentViewController: SettingsContentViewController, WKScriptMessageHa
}

override func viewDidLoad() {
KeyboardHelper.defaultHelper.addDelegate(self)
super.viewDidLoad()
}

Expand Down