Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Support other casings for view-controller #76

Conversation

seanpdoyle
Copy link
Contributor

The decision to use dash-casing for the view-controller property matches the multi-word precedent set by the Turbo iOS examples. However, the Turbo Android examples uses snake_casing.

It's unlikely that an Android app and an iOS app will share exact copies of a path configuration file's structure and data. However, it's possible that they'd share a similar server-side backend to generate those files, or a shared naming convention across those files.

The view-controller appears to be the only multi-word key expected and supported out-of-the-box, with the expectation that other keys can be used to inform bespoke features in app-specific contexts.

This commit expands that support to match other naming conventions, mainly snake_case and camelCase.

The decision to use dash-casing for the `view-controller` property
matches the multi-word precedent set by the [Turbo iOS examples][].
However, the [Turbo Android examples][] uses snake_casing.

It's unlikely that an Android app and an iOS app will share exact copies
of a path configuration file's structure and data. However, it's
possible that they'd share a similar server-side backend to generate
those files, or a shared naming convention across those files.

The `view-controller` appears to be the only multi-word key expected and
supported out-of-the-box, with the expectation that other keys can be
used to inform bespoke features in app-specific contexts.

This commit expands that support to match other naming conventions,
mainly snake_case and camelCase.

[Turbo iOS examples]: https://github.com/hotwired/turbo-ios/blob/c9d060fcdec136c3808cd0764e956d375012c6fb/Docs/PathConfiguration.md#path-configuration
[Turbo Android examples]: https://github.com/hotwired/turbo-android/blob/bf945e18aed3d5749c9efc6e228d98bc012878af/docs/PATH-CONFIGURATION.md#path-configuration
if let viewController = properties["view-controller"] as? String {
return viewController
}
let viewControllers = ["view-controller", "view_controller", "viewController"].map { properties[$0] }.filter { $0 as? String }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am an amateur Swift developer reaching for Ruby-isms. If there's a more idiomatic way to do this, I'd love to learn it!

Copy link
Owner

@joemasilotti joemasilotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! Other options are coming so it's a great idea to have this in place now before those are added.

There might be a more "Swift-y" way to do this, I'm going to dig in.

@joemasilotti
Copy link
Owner

Hey Sean, after discussing with the other maintainers we've decided to consolidate case. Everything, across both platforms, will use snake case moving forward. This better matches Rails routes and requires the least amount of change across iOS and Android.

You can check out the turbo-navigator branch if you'd like to see how everything is handled and take it for a spin. I'm hoping to merge that in pretty soon!

Thanks for the PR, it kicked off a good discussion. And I think we are in a much better spot because of it.

@seanpdoyle seanpdoyle deleted the support-view-controller-property-name-casing branch December 13, 2023 14:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants