Skip to content

Commit

Permalink
fix: minor things
Browse files Browse the repository at this point in the history
  • Loading branch information
pklatka committed Apr 22, 2024
1 parent c549184 commit b258056
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/turbo/ios/RNSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class RNSession: NSObject {
return session
}()
public lazy var webView: WKWebView = turboSession.webView

func visitableViewWillAppear(view: RNVisitableView) {
self.visitableView = view
}
Expand Down
11 changes: 4 additions & 7 deletions packages/turbo/ios/RNSessionConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,20 @@
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()
}
}

func updateConfiguration() {
if (session == nil){
return
}

session?.webView.scrollView.isScrollEnabled = isScrollEnabled
sessionDelegate?.webView.scrollView.isScrollEnabled = isScrollEnabled
}
}
2 changes: 1 addition & 1 deletion packages/turbo/ios/RNSessionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions packages/turbo/ios/RNVisitableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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
Expand Down

0 comments on commit b258056

Please sign in to comment.