diff --git a/packages/turbo/ios/RNSession.swift b/packages/turbo/ios/RNSession.swift index 77365744..f9907cc3 100644 --- a/packages/turbo/ios/RNSession.swift +++ b/packages/turbo/ios/RNSession.swift @@ -62,7 +62,7 @@ class RNSession: NSObject { return session }() public lazy var webView: WKWebView = turboSession.webView - + func visitableViewWillAppear(view: RNVisitableView) { self.visitableView = view } diff --git a/packages/turbo/ios/RNSessionConfiguration.swift b/packages/turbo/ios/RNSessionConfiguration.swift index ec04c1fc..015bda7a 100644 --- a/packages/turbo/ios/RNSessionConfiguration.swift +++ b/packages/turbo/ios/RNSessionConfiguration.swift @@ -8,12 +8,13 @@ import Foundation class RNSessionConfiguration { - var webViewConfiguration: WKWebViewConfiguration = WKWebViewConfiguration() - var session: RNSession? = nil { + var sessionDelegate: RNSession? = nil { didSet { updateConfiguration() } } + + var webViewConfiguration: WKWebViewConfiguration = WKWebViewConfiguration() var isScrollEnabled: Bool = true { didSet { updateConfiguration() @@ -21,10 +22,6 @@ class RNSessionConfiguration { } func updateConfiguration() { - if (session == nil){ - return - } - - session?.webView.scrollView.isScrollEnabled = isScrollEnabled + sessionDelegate?.webView.scrollView.isScrollEnabled = isScrollEnabled } } diff --git a/packages/turbo/ios/RNSessionManager.swift b/packages/turbo/ios/RNSessionManager.swift index 0277238b..c308e01a 100644 --- a/packages/turbo/ios/RNSessionManager.swift +++ b/packages/turbo/ios/RNSessionManager.swift @@ -13,7 +13,7 @@ class RNSessionManager: NSObject { private var sessions: [NSString: RNSession] = [:] private var processPool = WKProcessPool() static var shared: RNSessionManager = RNSessionManager() - + func findOrCreateSession(sessionHandle: NSString, sessionConfiguration: RNSessionConfiguration) -> RNSession { if(sessions[sessionHandle] == nil) { sessionConfiguration.webViewConfiguration.processPool = processPool diff --git a/packages/turbo/ios/RNVisitableView.swift b/packages/turbo/ios/RNVisitableView.swift index a7e4bf64..309428fa 100644 --- a/packages/turbo/ios/RNVisitableView.swift +++ b/packages/turbo/ios/RNVisitableView.swift @@ -26,14 +26,14 @@ class RNVisitableView: UIView, RNSessionSubscriber { sessionConfiguration.webViewConfiguration.applicationNameForUserAgent = applicationNameForUserAgent as? String } } - @objc var pullToRefreshEnabled: Bool = true { + @objc var scrollEnabled: Bool = true { didSet { - controller!.visitableView.allowsPullToRefresh = pullToRefreshEnabled + sessionConfiguration.isScrollEnabled = scrollEnabled } } - @objc var scrollEnabled: Bool = true { + @objc var pullToRefreshEnabled: Bool = true { didSet { - sessionConfiguration.isScrollEnabled = scrollEnabled + controller!.visitableView.allowsPullToRefresh = pullToRefreshEnabled } } @objc var onMessage: RCTDirectEventBlock? @@ -54,7 +54,7 @@ class RNVisitableView: UIView, RNSessionSubscriber { private lazy var session: RNSession = { let session = RNSessionManager.shared.findOrCreateSession(sessionHandle: sessionHandle!, sessionConfiguration: sessionConfiguration) - sessionConfiguration.session = session + sessionConfiguration.sessionDelegate = session return session }() private lazy var webView: WKWebView = session.webView