https://github.com/myunidays/direkt
https://github.com/myunidays/direkt
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/myunidays/direkt
- Owner: MyUNiDAYS
- License: mit
- Created: 2022-11-25T11:35:17.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-01-10T16:27:23.000Z (over 2 years ago)
- Last Synced: 2024-11-03T02:32:50.712Z (8 months ago)
- Language: Kotlin
- Size: 114 KB
- Stars: 3
- Watchers: 17
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/contributing.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-kotlin-multiplatform - Direkt - Kotlin Multiplatform Router for Android, iOS, Js (Libraries / Architecture)
README
DireKT Kotlin SDK
![]()
![]()
The DireKT Kotlin SDK is a completely decoupled Routing library that is not platform specific.
## Installation
### KMM
```
implementation("com.myunidays:direkt:0.0.5")
```## How to use
We recommend using the coordinator pattern but it's not neccessary.
Create a subclass of the RoutingConfig, expose the screens you want to route and what constructor params they need.
```kotlin
sealed class RootConfig(key: String): RoutingConfig(key) {
object Dashboard: RootConfig("Dashboard")
object Standard: RootConfig("Standard")
}
```Create a function to create those screens.
```kotlin
fun createChild(config: RootConfig): ScreenInterface = when (config) {
RootConfig.Dashboard -> DashboardViewModel()
RootConfig.Standard -> StandardViewModel()
}
```Then create an instance of the RouterImpl or implement the interface Router.
```kotlin
val router = RouterImpl(
RootConfig.Dashboard,
::configForName
)
```To listen to route changes
```kotlin
router.stack.collect { (transition, config) ->
if (transition == Transition.Push) {
println("Pushed route $config")
}
```To request a route change, where RootConfig.Standard is an entry in the config defined before.
```kotlin
router.push(RootConfig.Standard)
```## Examples
In the Examples folder, there is an example using KMM with coordinators targeting iOS and Android.
## Known Issues
Currently, basic support for Deeplinking.
## Contributing
This project is set up as an open source project. As such, if there are any suggestions that you have for features, for improving the code itself, or you have come across any problems; you can raise them and/or suggest changes in implementation.
If you are interested in contributing to this codebase, please follow the contributing guidelines. This contains guides on both contributing directly and raising feature requests or bug reports. Please adhere to our code of conduct when doing any of the above.