carson-katri / router Goto Github PK
View Code? Open in Web Editor NEWType-safe routing in SwiftUI
Type-safe routing in SwiftUI
The standard for names in Swift is camelCase, but most websites use kebab-case for URL components. I see three different ways to reconcile this:
I think a combination of 2 and 3 would be best, providing sensible defaults while allowing users to potentially port existing URLs over to Tokamak, but I’m willing to have my mind changed!
I'm not sure how this would work yet, but it would be great if the router either supported the native NavigationView
and NavigationLink
types or introduced new RoutableNavigation
and RoutableLink
(names to bikeshed) types that behaved in a similar way with support for NavigationView
layout and transitions. Maybe it is supported already? I haven't had a chance to explore the source code yet, feel free to close this then.
The xcworkspace is present but the xcodeproj isn’t so there’s no way to run the demo.
Updating https://github.com/carson-katri/router
Updating https://github.com/wickwirew/Runtime
Updating https://github.com/swiftwasm/JavaScriptKit.git
Updating https://github.com/TokamakUI/Tokamak
Updating https://github.com/TokamakUI/OpenCombine.git
Updating https://github.com/swiftwasm/OpenCombineJS.git
Everything is already up-to-date
[1/55] Compiling OpenCombine DebugHook.swift
/Users/jimmyhoughjr/Documents/nscbr/.build/checkouts/router/Sources/Router/Helpers/EnvironmentObject+exists.swift:1:8: error: no such module 'SwiftUI'
import SwiftUI
^
[2/69] Compiling OpenCombine FilterProducer.swift
/Users/jimmyhoughjr/Documents/nscbr/.build/checkouts/router/Sources/Router/Helpers/EnvironmentObject+exists.swift:1:8: error: no such module 'SwiftUI'
import SwiftUI
^
[3/120] Compiling OpenCombine ConnectablePublisher.swift
/Users/jimmyhoughjr/Documents/nscbr/.build/checkouts/router/Sources/Router/Helpers/EnvironmentObject+exists.swift:1:8: error: no such module 'SwiftUI'
import SwiftUI
^
[4/120] Compiling OpenCombine CurrentValueSubject.swift
/Users/jimmyhoughjr/Documents/nscbr/.build/checkouts/router/Sources/Router/Helpers/EnvironmentObject+exists.swift:1:8: error: no such module 'SwiftUI'
import SwiftUI
^
[5/120] Compiling OpenCombine Codable.swift
/Users/jimmyhoughjr/Documents/nscbr/.build/checkouts/router/Sources/Router/Helpers/EnvironmentObject+exists.swift:1:8: error: no such module 'SwiftUI'
import SwiftUI
^
[6/120] Compiling OpenCombine CombineIdentifier.swift
/Users/jimmyhoughjr/Documents/nscbr/.build/checkouts/router/Sources/Router/Helpers/EnvironmentObject+exists.swift:1:8: error: no such module 'SwiftUI'
import SwiftUI
^
[7/120] Compiling OpenCombine AnySubscriber.swift
/Users/jimmyhoughjr/Documents/nscbr/.build/checkouts/router/Sources/Router/Helpers/EnvironmentObject+exists.swift:1:8: error: no such module 'SwiftUI'
import SwiftUI
^
[8/120] Compiling OpenCombine Cancellable.swift
/Users/jimmyhoughjr/Documents/nscbr/.build/checkouts/router/Sources/Router/Helpers/EnvironmentObject+exists.swift:1:8: error: no such module 'SwiftUI'
import SwiftUI
^
[9/120] Compiling OpenCombine CustomCombineIdentifierConvertible.swift
/Users/jimmyhoughjr/Documents/nscbr/.build/checkouts/router/Sources/Router/Helpers/EnvironmentObject+exists.swift:1:8: error: no such module 'SwiftUI'
import SwiftUI
^
[10/120] Compiling OpenCombine Future.swift
/Users/jimmyhoughjr/Documents/nscbr/.build/checkouts/router/Sources/Router/Helpers/EnvironmentObject+exists.swift:1:8: error: no such module 'SwiftUI'
import SwiftUI
^
[11/120] Compiling OpenCombine AnyCancellable.swift
/Users/jimmyhoughjr/Documents/nscbr/.build/checkouts/router/Sources/Router/Helpers/EnvironmentObject+exists.swift:1:8: error: no such module 'SwiftUI'
import SwiftUI
^
[12/120] Compiling OpenCombine AnyPublisher.swift
/Users/jimmyhoughjr/Documents/nscbr/.build/checkouts/router/Sources/Router/Helpers/EnvironmentObject+exists.swift:1:8: error: no such module 'SwiftUI'
import SwiftUI
^
[13/120] Compiling OpenCombine ConduitBase.swift
/Users/jimmyhoughjr/Documents/nscbr/.build/checkouts/router/Sources/Router/Helpers/EnvironmentObject+exists.swift:1:8: error: no such module 'SwiftUI'
import SwiftUI
^
[14/120] Compiling OpenCombine ConduitList.swift
/Users/jimmyhoughjr/Documents/nscbr/.build/checkouts/router/Sources/Router/Helpers/EnvironmentObject+exists.swift:1:8: error: no such module 'SwiftUI'
import SwiftUI
This would, for instance, allow setting the WindowGroup
title based on the current Route:
struct MyApp : App {
@State private var activeRoute: AppRoutes = .defaultRoute
var body: some Scene {
WindowGroup(title(for: activeRoute)) {
Router(activeRoute: $activeRoute) {
...
}
}
}
}
Can also open the possibility of navigating programmatically:
struct MyApp : App {
@State private var activeRoute: AppRoutes = .defaultRoute
var body: some Scene {
WindowGroup {
Router(activeRoute: $activeRoute) {
...
}
}.onOpenUrl {
activeRoute = ...
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.