Skip to content

Commit

Permalink
feat: recieved message from hub to disable webview loading (#43)
Browse files Browse the repository at this point in the history
* feat: recieve message from hub to disable webview loading

* feat(hub): animate in after loading (#44)

* feat: recieve message from hub to disable webview loading

* feat: fade in webview on load

* feat: fade in webview on load

* fix(lottie): loop animations

* chore: test estimatedprogress

* chore: revert test estimatedprogress

* chore: cleanup

---------

Co-authored-by: mfmurray <mfmurray@umich.edu>

* chore: consolidate loading states

* fix: added default animateInContent delay

---------

Co-authored-by: Matt Hamann <mhamann@rownd.io>
  • Loading branch information
mfmurray and mhamann committed Feb 27, 2023
1 parent 06ec768 commit c708bed
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<key>Rownd.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
<integer>22</integer>
</dict>
<key>RowndFrameworkTestApp.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>23</integer>
</dict>
<key>RowndTests.xcscheme_^#shared#^_</key>
<dict>
Expand Down
5 changes: 5 additions & 0 deletions Sources/Rownd/Models/RowndHubInteropMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ enum MessageType: String, Codable {
case triggerSignUpWithPasskey = "trigger_sign_up_with_passkey"
case userDataUpdate = "user_data_update"
case tryAgain = "try_again"
case hubLoaded = "hub_loaded"
case unknown

enum CodingKeys: String, CodingKey {
Expand All @@ -76,6 +77,7 @@ enum MessagePayload: Decodable {
case triggerSignInWithApple(TriggerSignInWithAppleMessage)
case triggerSignInWithGoogle(TriggerSignInWithGoogleMessage)
case triggerSignUpWithPasskey
case hubLoaded
case tryAgain

enum CodingKeys: String, CodingKey {
Expand Down Expand Up @@ -121,6 +123,9 @@ enum MessagePayload: Decodable {
case .tryAgain:
self = .tryAgain

case .hubLoaded:
self = .hubLoaded

case .unknown:
self = .unknown
}
Expand Down
21 changes: 19 additions & 2 deletions Sources/Rownd/Views/HubWebView/HubWebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public class HubWebViewController: UIViewController, WKUIDelegate {
webView.backgroundColor = UIColor.clear
webView.scrollView.backgroundColor = UIColor.clear
webView.hack_removeInputAccessory()
webView.alpha = 0
self.modalPresentationStyle = .pageSheet
view = webView
}
Expand Down Expand Up @@ -173,8 +174,15 @@ extension HubWebViewController: WKScriptMessageHandler, WKNavigationDelegate {
webView.backgroundColor = UIColor.clear
webView.scrollView.backgroundColor = UIColor.clear

hubViewController?.setLoading(false)

let webViewOrigin = (webView.url?.absoluteURL.scheme ?? "") + "://" + (webView.url?.absoluteURL.host ?? "")
if (webViewOrigin != Rownd.config.baseUrl) {
// Only disable loading if webView is not from hub
self.animateInContent()
} else {
DispatchQueue.main.asyncAfter(deadline: .now() + 6.0) {
self.animateInContent()
}
}
setFeatureFlagsJS()

if let jsFnOptions = jsFnOptions {
Expand Down Expand Up @@ -280,11 +288,20 @@ extension HubWebViewController: WKScriptMessageHandler, WKNavigationDelegate {
}
case .tryAgain:
startLoading()
case .hubLoaded:
self.animateInContent()
case .unknown:
break
}
} catch {
logger.error("Failed to decode incoming interop message: \(String(describing: error))")
}
}

private func animateInContent() {
UIView.animate(withDuration: 1.0) {
self.webView.alpha = 1.0
self.hubViewController?.setLoading(false)
}
}
}
1 change: 1 addition & 0 deletions Sources/Rownd/framework/Customizations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ open class RowndCustomizations: Encodable {
height: 100
)

aniView.loopMode = .loop
aniView.startAnimating()
return aniView
}
Expand Down

0 comments on commit c708bed

Please sign in to comment.