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

Improve open view with animation and fix web view size in the first appear #124

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions ReCaptcha/Classes/ReCaptcha.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ public class ReCaptcha {

Starts the challenge validation
*/
public func validate(on view: UIView, resetOnError: Bool = true, completion: @escaping (ReCaptchaResult) -> Void) {
public func validate(on view: UIView, animated: Bool = false, resetOnError: Bool = true, completion: @escaping (ReCaptchaResult) -> Void) {
manager.shouldResetOnError = resetOnError
manager.completion = completion

manager.validate(on: view)
manager.validate(on: view, animated: animated)
}


Expand Down
11 changes: 10 additions & 1 deletion ReCaptcha/Classes/ReCaptchaWebViewManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,23 @@ internal class ReCaptchaWebViewManager {

Starts the challenge validation
*/
func validate(on view: UIView) {
func validate(on view: UIView, animated: Bool = false) {
#if DEBUG
guard !shouldSkipForTests else {
completion?(.token(""))
return
}
#endif
if animated {
webView.alpha = 0

UIView.animate(withDuration: 0.2, delay: .zero, options: [.transitionCrossDissolve]) {
self.webView.alpha = 1
}
}
webView.isHidden = false
webView.frame = view.frame

view.addSubview(webView)

executeJS(command: .execute)
Expand Down