Skip to content

Commit

Permalink
Option to configure "default" view controller
Browse files Browse the repository at this point in the history
  • Loading branch information
joemasilotti committed Dec 12, 2023
1 parent dbc4ca8 commit 1d573f0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Source/Turbo Navigator/TurboNavigator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public class TurboNavigator {
private func controller(for proposal: VisitProposal) -> UIViewController? {
switch delegate.handle(proposal: proposal) {
case .accept:
VisitableViewController(url: proposal.url)
Turbo.config.defaultViewController.self.init(url: proposal.url)
case .acceptCustom(let customViewController):
customViewController
case .reject:
Expand Down
4 changes: 4 additions & 0 deletions Source/Turbo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ public class TurboConfig {
/// Include "Turbo Native" to use `turbo_native_app?` on your Rails server.
public var userAgent = "Turbo Native iOS"

/// The view controller used in `TurboNavigator` for web requests. Must be
/// a `VisitableViewController` or subclass.
public var defaultViewController = VisitableViewController.self

/// Optionally customize the web views used by each Turbo Session.
/// Ensure you return a new instance each time.
public var makeCustomWebView: WebViewBlock = { (configuration: WKWebViewConfiguration) in
Expand Down
2 changes: 1 addition & 1 deletion Source/Visitable/VisitableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open class VisitableViewController: UIViewController, Visitable {
open weak var visitableDelegate: VisitableDelegate?
open var visitableURL: URL!

public convenience init(url: URL) {
public required convenience init(url: URL) {
self.init()
self.visitableURL = url
}
Expand Down

0 comments on commit 1d573f0

Please sign in to comment.