1676712240
Path-based routing in SwiftUI
Easy and maintainable app navigation with path-based routing for SwiftUI.
With SwiftUI Router you can power your SwiftUI app with path-based routing. By utilizing a path-based system, navigation in your app becomes more flexible and easier to maintain.
⚠️ During WWDC22 Apple introduced NavigationStack
to SwiftUI. This provides a similar workflow to SwiftUI Router as well as being type-safe. There are however some key differences. It is recommended to try out NavigationStack
before using SwiftUI Router in your project.
In Xcode add the dependency to your project via File > Add Packages > Search or Enter Package URL and use the following url:
https://github.com/frzi/SwiftUIRouter.git
Once added, import the package in your code:
import SwiftUIRouter
Bada bing bada boom you're ready to go.
Below a quick rundown of the available views and objects and their basic features. For further details, please check out the documentation in the Swift files.
Router
Router {
RootView()
}
The entry of a routing environment. Wrap your entire app (or just the part that needs routing) inside a Router
. This view will initialize all necessary environment values needed for routes.
Route
Route("news/*") {
NewsScreen()
}
Route("settings") {
SettingsScreen()
}
Route("user/:id?") { info in
UserScreen(id: info.parameters["id"])
}
A view that will only render its contents if its path matches that of the environment. Use /*
to also match deeper paths. E.g.: the path news/*
will match the following environment paths: /news
, /news/latest
, /news/article/1
etc.
Paths can contain parameters (aka placeholders) that can be read individually. A parameter's name is prefixed with a colon (:
). Additionally, a parameter can be considered optional by suffixing it with a question mark (?
). The parameters are passed down as a [String : String]
in an RouteInformation
object to a Route
's contents.
Note: Parameters may only exist of alphanumeric characters (A-Z, a-z and 0-9) and must start with a letter.
func validateUserID(routeInfo: RouteInformation) -> UUID? {
UUID(routeInfo.parameters["id"] ?? "")
}
Route("user/:id", validator: validateUserID) { userID in
UserScreen(userID: userID)
}
A Route
provides an extra step for validating parameters in a path.
Let's say your Route
has the path /user/:id
. By default, the :id
parameter can be anything. But in this case you only want valid UUIDs. Using a Route
's validator
argument, you're given a chance to validate (and transform) the parameter's value.
A validator is a simple function that's passed a RouteInformation
object (containing the parameters) and returns the transformed value as an optional. The new transformed value is passed down to your view instead of the default RouteInformation
object. If the transformed value is nil
the Route
will prevent rendering its contents.
NavLink
NavLink(to: "/news/latest") {
Text("Latest news")
}
A wrapper around a Button
that will navigate to the given path if pressed.
SwitchRoutes
SwitchRoutes {
Route("latest") {
LatestNewsScreen()
}
Route("article/:id") { info in
NewsArticleScreen(articleID: info.parameters["id"]!)
}
Route(":unknown") {
ErrorScreen()
}
Route {
NewsScreen()
}
}
A view that will only render the first Route
whose path matches the environment path. This is useful if you wish to work with fallbacks. This view can give a slight performance boost as it prevents Route
s from path matching once a previous Route
's path is already resolved.
Navigate
Navigate(to: "/error-404")
This view will automatically navigate to another path once rendered. One may consider using this view in a fallback Route
inside a SwitchRoutes
.
Navigator
@EnvironmentObject var navigator: Navigator
An environment object containg the data of the Router
. With this object you can programmatically navigate to another path, go back in the history stack or go forward.
RouteInformation
@EnvironmentObject var routeInformation: RouteInformation
A lightweight object containing information of the current Route
. A RouteInformation
contains the relative path and a [String : String]
with all the parsed parameters.
This object is passed down by default in a Route
to its contents. It's also accessible as an environment object.
Author: Frzi
Source Code: https://github.com/frzi/SwiftUIRouter
License: MIT license
#swift #router #navigation #routing #path #swiftui
1676712240
Path-based routing in SwiftUI
Easy and maintainable app navigation with path-based routing for SwiftUI.
With SwiftUI Router you can power your SwiftUI app with path-based routing. By utilizing a path-based system, navigation in your app becomes more flexible and easier to maintain.
⚠️ During WWDC22 Apple introduced NavigationStack
to SwiftUI. This provides a similar workflow to SwiftUI Router as well as being type-safe. There are however some key differences. It is recommended to try out NavigationStack
before using SwiftUI Router in your project.
In Xcode add the dependency to your project via File > Add Packages > Search or Enter Package URL and use the following url:
https://github.com/frzi/SwiftUIRouter.git
Once added, import the package in your code:
import SwiftUIRouter
Bada bing bada boom you're ready to go.
Below a quick rundown of the available views and objects and their basic features. For further details, please check out the documentation in the Swift files.
Router
Router {
RootView()
}
The entry of a routing environment. Wrap your entire app (or just the part that needs routing) inside a Router
. This view will initialize all necessary environment values needed for routes.
Route
Route("news/*") {
NewsScreen()
}
Route("settings") {
SettingsScreen()
}
Route("user/:id?") { info in
UserScreen(id: info.parameters["id"])
}
A view that will only render its contents if its path matches that of the environment. Use /*
to also match deeper paths. E.g.: the path news/*
will match the following environment paths: /news
, /news/latest
, /news/article/1
etc.
Paths can contain parameters (aka placeholders) that can be read individually. A parameter's name is prefixed with a colon (:
). Additionally, a parameter can be considered optional by suffixing it with a question mark (?
). The parameters are passed down as a [String : String]
in an RouteInformation
object to a Route
's contents.
Note: Parameters may only exist of alphanumeric characters (A-Z, a-z and 0-9) and must start with a letter.
func validateUserID(routeInfo: RouteInformation) -> UUID? {
UUID(routeInfo.parameters["id"] ?? "")
}
Route("user/:id", validator: validateUserID) { userID in
UserScreen(userID: userID)
}
A Route
provides an extra step for validating parameters in a path.
Let's say your Route
has the path /user/:id
. By default, the :id
parameter can be anything. But in this case you only want valid UUIDs. Using a Route
's validator
argument, you're given a chance to validate (and transform) the parameter's value.
A validator is a simple function that's passed a RouteInformation
object (containing the parameters) and returns the transformed value as an optional. The new transformed value is passed down to your view instead of the default RouteInformation
object. If the transformed value is nil
the Route
will prevent rendering its contents.
NavLink
NavLink(to: "/news/latest") {
Text("Latest news")
}
A wrapper around a Button
that will navigate to the given path if pressed.
SwitchRoutes
SwitchRoutes {
Route("latest") {
LatestNewsScreen()
}
Route("article/:id") { info in
NewsArticleScreen(articleID: info.parameters["id"]!)
}
Route(":unknown") {
ErrorScreen()
}
Route {
NewsScreen()
}
}
A view that will only render the first Route
whose path matches the environment path. This is useful if you wish to work with fallbacks. This view can give a slight performance boost as it prevents Route
s from path matching once a previous Route
's path is already resolved.
Navigate
Navigate(to: "/error-404")
This view will automatically navigate to another path once rendered. One may consider using this view in a fallback Route
inside a SwitchRoutes
.
Navigator
@EnvironmentObject var navigator: Navigator
An environment object containg the data of the Router
. With this object you can programmatically navigate to another path, go back in the history stack or go forward.
RouteInformation
@EnvironmentObject var routeInformation: RouteInformation
A lightweight object containing information of the current Route
. A RouteInformation
contains the relative path and a [String : String]
with all the parsed parameters.
This object is passed down by default in a Route
to its contents. It's also accessible as an environment object.
Author: Frzi
Source Code: https://github.com/frzi/SwiftUIRouter
License: MIT license
1606874142
Base Protocol (BASE) is a token whose price is pegged to the total market cap of all cryptocurrencies at a ratio of 1:1 trillion. BASE allows traders to speculate on the entire crypto industry with one token. The Base Protocol is built on the Ethereum blockchain, integrates a (Chainlink) oracle, and is launching on ((Uniswap)
As cryptocurrency enthusiasts, we’re sometimes divided on which digital assets to buy — bullish on certain projects and bearish on others.
But we all agree on one thing, which is that the overall cryptocurrency industry will achieve long-term growth and future adoption.
The Base Protocol makes it possible to invest with this consensus. BASE allows traders to speculate on the entire industry with one token.
The Base Protocol is the world’s first and only tokenized cryptocurrency market tracker. By holding BASE tokens, users can get exposure to the performance of the entire cryptocurrency market. Unlike the index trackers currently operating in the traditional markets, there is no entry or exit fee or brokerage charges.
Index funds have consistently outperformed actively managed mutual funds. Until the launch of BASE, there was no real cryptocurrency market tracker that tracked the performance of the entire digital asset market. BASE will be useful for institutional investors and traders to diversify and hedge their crypto portfolios. BASE will also help new and existing retail investors to take out the guesswork and get exposed to the growth of all current and future digital assets entering the market.
The BASE token’s underlying protocol creates several additional use cases in DeFi, trading, venture capital, hedge funds and many other business sectors.
The Base Protocol mission is simple — to make it easy for everyone to benefit from the performance of the entire cryptocurrency market in a secure, decentralized and future-proof way.
It’s no doubt that a crypto industry ETF would be a valuable product for investors. But it is very challenging to create such a product through traditional means, as it would be almost impossible to manage portfolio ownership of 5,000+ assets. How would the portfolio manager weigh ownership of each asset as market cap dominance changes? How would they account for newly entering/exiting assets? Who would take on all the associated transaction and custodial fees? There are also various legal limitations that restrict the formation of such an instrument in many countries — and even if it could be formed, it would be a highly centralized product.
By simply pegging price to the total market capitalization of all cryptocurrencies, the Base Protocol cuts through all of these problems. BASE gives holders the same function as a traditional industry ETF without all of the centralized challenges that make such an ETF impossible.
BASE will offer new value for investors in the cryptocurrency ecosystem through an elegantly simple protocol — so valuable and so simple that you might be asking yourself:
How has this not been done before?
The answer is that it wasn’t possible until recently. This project couldn’t be achieved without a robust decentralized blockchain, proven oracle integrations, and new developments in the DeFi space. We founded the Base Protocol to build on these innovations and create BASE; one tokenized asset that represents speculation on all cryptocurrencies.
We’ve seen that there are many individuals who want to invest in cryptocurrencies, but don’t necessarily understand how they work. While the overview for each different crypto asset can be difficult to understand for a new user, the pitch for BASE is simple: it’s the way to invest in all of those crypto assets simultaneously. In this way, the Base Protocol can become an instrumental force in driving new adoption in the blockchain space.
We’ve also noticed that institutional investors have been introducing cryptocurrency investments to their portfolios. These institutions typically invest at a high level with great diversification covering multiple industries. Their cryptocurrency holdings are usually composed of just Bitcoin, or some handful mix of “blue chip” digital assets. By holding BASE, these institutions will gain exposure to the entire cryptocurrency industry — an objectively more diversified alternative.
In the same way that Bitcoin is the household name of cryptocurrencies, the Base Protocol aims to become the household name for general cryptocurrency investing. BASE’s vision is to become the primary channel of investment for new/existing cryptocurrency traders and institutional investors.
Would you like to earn token right now! ☞ CLICK HERE
Looking for more information…
☞ Website
☞ Explorer
☞ Source Code
☞ Social Channel
☞ Message Board
☞ Coinmarketcap
Create an Account and Trade NOW
☞ Bittrex
☞ Poloniex
☞ Binance
Thank for visiting and reading this article! I’m highly appreciate your actions! Please share if you liked it!
#blockchain #bitcoin #crypto #base protocol #base
1618289269
Are you looking for the best route planning app solution provider to enhance the fleet management service? Take a look at the SpotnRides route planner app which has sparkling key-features that sharp your logistics service smartly.
#route planning app #route planner app development #build a route planning software #route optimization software 2021
1625495640
Hello Guys 🖐🖐🖐🖐
In this Video I’m going to show how to create a Stylish Scratch Card Animation Effect With Custom Masking in SwiftUI | Scratch to reveal content SwiftUI | SwiftUI Custom View Masking | SwiftUI Custom Animation’s | SwiftUI View Builder’s | SwiftUI Gesture’s | Xcode 12 SwiftUI.
► Source Code: https://www.patreon.com/posts/early-access-52075157
► Support Us
Patreon : https://www.patreon.com/kavsoft
Contributions : https://donorbox.org/kavsoft
Or By Visiting the Link Given Below:
► Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. It’s gives a great experience and I think you should give it a try too https://www.kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=kavsoft&utm_content=description-only
► My MacBook Specs
M1 MacBook Pro(16GB)
Xcode Version: 12.5
macOS Version: 11.4 Big Sur
► Official Website: https://kavsoft.dev
For Any Queries: https://kavsoft.dev/#contact
► Social Platforms
Instagram: https://www.instagram.com/_kavsoft/
Twitter: https://twitter.com/_Kavsoft
► Timestamps
0:00 Intro
0:26 Building Home View
1:56 Building Scratch Card View(View Builder)
Thanks for watching
Make sure to like and Subscribe For More Content !!!
#swiftui #animation's #swiftui
1625488380
Hello Guys 🖐🖐🖐🖐
In this Video I’m going to show how to create a adaptable Cloud App UI for Both iOS & macOS Using SwiftUI | SwiftUI Cloud App UI | SwiftUI macOS App Development | SwiftUI Mac Catalyst Apps | SwiftUI Complex UI | SwiftUI Mac App | SwiftUI Custom Side Bar Menu | SwiftUI Hamburger Menu | SwiftUI Slide Out Menu | Xcode SwiftUI.
► Source Code: https://www.patreon.com/posts/early-access-app-52186632
► Support Us
Patreon : https://www.patreon.com/kavsoft
Contributions : https://donorbox.org/kavsoft
Or By Visiting the Link Given Below:
► Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. It’s gives a great experience and I think you should give it a try too https://www.kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=kavsoft&utm_content=description-only
► My MacBook Specs
M1 MacBook Pro(16GB)
Xcode Version: 12.5
macOS Version: 11.4 Big Sur
► Official Website: https://kavsoft.dev
For Any Queries: https://kavsoft.dev/#contact
► Social Platforms
Instagram: https://www.instagram.com/_kavsoft/
Twitter: https://twitter.com/_Kavsoft
► Timestamps
0:00 Intro
0:42 Building Side Bar Menu
7:54 Building Main Content View
20:32 Building Side View
23:37 Adapting App For iOS
Thanks for watching
Make sure to like and Subscribe For More Content !!!
#swiftui #complex ui #swiftui #ios & macos