-
Notifications
You must be signed in to change notification settings - Fork 88
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
Upstream Turbo Navigator #158
base: main
Are you sure you want to change the base?
Conversation
Increase timeout of failed page load to MORE than Turbo.js timeout so it triggers the invalid configuration error.
Co-authored-by: Zoë Smith <[email protected]>
I think we are in a good enough spot with the existing |
Hi there 👋 I use this Previously, I used to initialize the TurboNavigator like this: TurboNavigator(session: session, modalSession: modalSession, delegate: self) Where After upgrading I get the error: It seems like, I can't use the initializer with custom sessions anymore and should use the "convenience initializer" that doesn't require - public init(session: Session, modalSession: Session, delegate: TurboNavigatorDelegate? = nil) {
+ init(session: Session, modalSession: Session, delegate: TurboNavigatorDelegate? = nil) { Just want to ask if this change was intentional and if there is a way to use custom sessions with the current version of TurboNavigator? Thanks in advance! |
Is there a specific usecase you are looking for. I think the API expects customisation of the session to happen via:
The main session and modal session will utilise the results of these closures. They also get setup with a shared process pool. If you use Xcode I recommend looking the dependencies source code at In saying all this. The current setup may not cover your use case so it would be good to know what it is. There also could be some opportunities to contribute to documentation here (I didnt check if all this is covered in the docs). |
@hey-leon thanks for you reply and suggestion! We need the WebView of both the session and modalSession to connect each of them with an instance our own JS-bridge. Note: The existing approach to customize the WebView (by |
Mind if I ask why you need to distinguish between the two? We had some internal discussion and came to the conclusion that a single web view configuration covers all the use cases we could think of. |
Sure! But it's gonna take a line or two to explain 😅 Our situation is the following: We started using Turbo Native early on, without Turbo Navigator or Strada. Our
|
Add bundle parameter to route
Ah, gotcha! Thanks for the explanation. I think you might know what I'm about to say because you said it yourself: "we get the impression that our approach does not adapt very nicely to Strada nor Turbo Navigator." And you're right. With Strada you don't need to know "which web view is which" like you did with a traditional JavaScript bridge. My recommendation is to convert your existing codebase to use Strada. If that's out of the question then you can continue to use turbo-ios without Turbo Navigator. I hope that helps, even if it isn't the answer you might be looking for. |
* Add options parameter * Add animation key to visit proposal * Add modal root view controller access * Change var -> constant * Add default parameter for visit options * Clarify default visit options
Cache based on url feedback
Cache based on url
@joemasilotti I am using this branch in my iOS app and have found I am missing the following behaviour: When a Modal is dismissed, I want to perform a restoration visit in the underlying view. I am a novice Swift developer, and have been struggling to implement this custom behaviour 😅 . I have tried using a subclass of the I hope this all makes sense. Thanks for all the guides and docs ❤️ |
I have figured out a solution to my use case, which is definitely a bit rudimentary, but probably worth sharing. I have a view that is presented in a modal, which can perform a POST request and receive a turbo-stream response. I.e. the modal does not dismiss, and nothing is pushed onto the view stack. When this happens, if the user is to dismiss the modal, I want the underlying view to 'refresh'. I have achieved this by adding a query param to the url of the modal view. This query param is checked when the modal is dismissed, and This might be gross, but I have no shame 😅 (please tell me if there is a better way)
And now for the magic...
|
Any chance this will be merged soon? |
I don't know anything, but am expecting to wait until October for movement, as a key player with this PR, the author, is taking some extended time off for a new baby: https://x.com/joemasilotti/status/1796202085542957493 🎉 I wish him and his wife well...but am keeping an eye on this too 😆 |
Fix refresh behavior
|
||
/// Override to set a custom user agent. | ||
/// - Important: Include "Turbo Native" to use `turbo_native_app?` on your Rails server. | ||
public var userAgent = "Turbo Native iOS" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this get used anywhere? I don't see it referenced anywhere in this repo. It's a bit confusing becuase the demo does this:
turbo-ios/Demo/SceneController.swift
Line 16 in 3ce4f97
Turbo.config.userAgent += " \(Strada.userAgentSubstring(for: BridgeComponent.allTypes))" |
and this:
configuration.applicationNameForUserAgent = userAgent |
As far as I can tell only the latter does anything.
refreshIfTopViewControllerIsVisitable(from: .modal) | ||
} | ||
} else { | ||
navigationController.popViewController(animated: proposal.animated) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess this isn't required here when the presentedViewController
is nil because we aren't displaying a modal window and we will refreshing the previous item in the navigation stack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spotted an issue with using path configuration to control visit animation
|
||
/// Allows the proposal to change the animation status when pushing, popping or presenting. | ||
var animated: Bool { | ||
if let animated = parameters?["animated"] as? Bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be properties["animated"]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch, thanks!
This PR upstreams the Turbo Navigator package.
To-do
TurboConfig
vs.TurboLog
)TurboConfig