-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/main' into feat/kmp_lifecycle_owner
# Conflicts: # voyager-core/src/androidMain/kotlin/cafe/adriel/voyager/androidx/AndroidScreenLifecycleOwner.kt
- Loading branch information
Showing
73 changed files
with
2,551 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Docs Publish | ||
on: | ||
push: | ||
branches: [main, mkdocs] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
|
||
build: | ||
name: Docs Publish | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Fetch Sources | ||
uses: actions/checkout@v3 | ||
|
||
# Documentation publishing | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Build mkdocs | ||
run: | | ||
pip3 install -r .github/workflows/mkdocs-requirements.txt | ||
mkdocs build | ||
- name: Deploy 🚀 | ||
if: success() | ||
uses: JamesIves/github-pages-deploy-action@releases/v3 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }} | ||
BRANCH: gh-pages # The branch the action should deploy to. | ||
FOLDER: site # The folder the action should deploy. | ||
SINGLE_COMMIT: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
click==8.1.7 | ||
future==1.0.0 | ||
Jinja2==3.1.3 | ||
livereload==2.6.3 | ||
lunr==0.7.0.post1 | ||
MarkupSafe==2.1.5 | ||
mkdocs==1.5.3 | ||
mkdocs-macros-plugin==1.0.5 | ||
mkdocs-material==9.5.18 | ||
mkdocs-material-extensions==1.3.1 | ||
mkdocs-minify-plugin==0.7.1 | ||
Pygments==2.17.2 | ||
pymdown-extensions==10.8.1 | ||
python-dateutil==2.9.0.post0 | ||
PyYAML==6.0.1 | ||
repackage==0.7.3 | ||
six==1.16.0 | ||
termcolor==2.4.0 | ||
tornado==6.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Hilt integration | ||
|
||
!!! success | ||
To use the `getViewModel` you should first import `cafe.adriel.voyager:voyager-hilt` (see [Setup](../setup.md)). | ||
|
||
### @Inject | ||
|
||
Add `@HiltViewModel` and `@Inject` annotations to your `ViewModel`. | ||
|
||
```kotlin | ||
@HiltViewModel | ||
class HomeViewModel @Inject constructor() : ViewModel() { | ||
// ... | ||
} | ||
``` | ||
|
||
Call `getViewModel()` to get a new instance. | ||
|
||
```kotlin | ||
class HomeScreen : Screen { | ||
|
||
@Composable | ||
override fun Content() { | ||
val screenModel = getViewModel<HomeScreenModel>() | ||
// ... | ||
} | ||
} | ||
``` | ||
|
||
### @AssistedInject | ||
|
||
Currently there's no Assisted Injection support for Hilt ViewModels ([issue](https://github.com/google/dagger/issues/2287)). | ||
|
||
### Sample | ||
|
||
!!! info | ||
Sample code [here](https://github.com/adrielcafe/voyager/tree/main/samples/android/src/main/java/cafe/adriel/voyager/sample/hiltIntegration). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Android ViewModel | ||
|
||
```kotlin | ||
class PostListScreen : Screen { | ||
|
||
@Composable | ||
override fun Content() { | ||
val viewModel = viewModel<PostListViewModel>() | ||
// ... | ||
} | ||
} | ||
``` | ||
|
||
By default Voyager provides its own `LocalViewModelStoreOwner` and `LocalSavedStateRegistryOwner`, that way you can safely create `ViewModel`s without depending on `Activity` or `Fragment`. | ||
|
||
!!! info | ||
Voyager provides a similar implementation, the [ScreenModel](../screenmodel/README.md), which does the same as `ViewModel` but also works with [Compose Multiplatform](https://github.com/jetbrains/compose-jb). | ||
|
||
### Sample | ||
|
||
![](../media/assets/navigation-android.gif) | ||
|
||
!!! info | ||
Source code [here](https://github.com/adrielcafe/voyager/tree/main/samples/android/src/main/java/cafe/adriel/voyager/sample/androidViewModel). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# ViewModel KMP | ||
|
||
Since 1.1.0-beta01 we have introduce a experimental API for ViewModel KMP. It is under the package `cafe.adriel.voyager:voyager-lifecycle-kmp` (see [Setup](../setup.md)). | ||
|
||
You will need to call `ProvideNavigatorLifecycleKMPSupport` before all `Navigator` calls and it will be working out of the box. | ||
|
||
```kotlin | ||
@Composable | ||
fun MainView() { | ||
ProvideNavigatorLifecycleKMPSupport { | ||
Navigator(...) | ||
} | ||
} | ||
|
||
class MyScreen : Screen { | ||
@Composable | ||
fun Content() { | ||
val myViewModel = viewModel { MyScreenViewModel() } | ||
} | ||
} | ||
``` | ||
|
||
## Navigator scoped ViewModel | ||
|
||
Voyager 1.1.0-beta01 also have introduced the support for Navigator scoped ViewModel and Lifecycle. | ||
This will make easy to share a ViewModel cross screen of the same navigator. | ||
|
||
```kotlin | ||
class MyScreen : Screen { | ||
@Composable | ||
fun Content() { | ||
val myViewModel = navigatorViewModel { MyScreenViewModel() } | ||
} | ||
} | ||
``` | ||
|
||
## Lifecycle KMP | ||
|
||
This version also brings the Lifecycle events for Screen lifecycle in KMP, now is possible to | ||
a generic third party API that listen to Lifecycle of a Screen in KMP. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Back press | ||
|
||
By default, Voyager will handle back presses but you can override its behavior. Use the `onBackPressed` to manually handle it: return `true` to pop the current screen, or false otherwise. To disable, just set to `null`. | ||
|
||
```kotlin | ||
setContent { | ||
Navigator( | ||
initialScreen = HomeScreen, | ||
onBackPressed = { currentScreen -> | ||
false // won't pop the current screen | ||
// true will pop, default behavior | ||
} | ||
// To disable: | ||
// onBackPressed = null | ||
) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Community Projects Catalog | ||
|
||
## Open source libraries with Voyager extensions | ||
|
||
- [Kotlin Routing](https://github.com/programadorthi/kotlin-routing): An extensible and multiplatform routing system powered by Ktor | ||
- [Rinku](https://github.com/theolm/Rinku): Deep Link Handling for Kotlin Multiplatform | ||
|
||
## Open source projects using Voyager | ||
|
||
- [ClimateTraceKMP](https://github.com/joreilly/ClimateTraceKMP): Kotlin/Compose Multiplatform project to show climate related emission data from https://climatetrace.org/data. | ||
- [Suwayomi-JUI](https://github.com/Suwayomi/Suwayomi-JUI): A free and open source manga reader to read manga from a Suwayomi-Server instance. | ||
- [TimePlanner](https://github.com/v1tzor/TimePlanner): Mobile app for planning tasks for the day with multimodule architecture, MVI, Compose, Room, Voyager, AlarmManager, Notification, Charts | ||
- [KMP-News-App](https://github.com/momintahir/KMP-News-App): This application demonstrates modern Android development with Koin, Ktor, Coroutines, Flows, SQLDelight, Voyager based on Clean Architecture. | ||
- [NationExplorer](https://github.com/Pablit0x/NationExplorer): Compose Multiplatform App for both Android and iOS designed for discovering and learning more about countries | ||
- [KodeRunner](https://github.com/Abhay-cloud/KodeRunner-Multiplatform): Compose Your Code, Anywhere, Anytime. Built using Kotlin Multiplatform & Compose Multiplatform 🚀 | ||
- [Cookit Recipes App](https://github.com/JunydDEV/kmp-recipes-mobile-app): Recipes app for iOS and Android, built with compose multiplatform technology | ||
|
||
## Talks and Tutorials | ||
|
||
### Talks | ||
|
||
- [Painless, Typesafe Jetpack Compose Navigation with Voyager](https://www.droidcon.com/2022/08/02/painless-typesafe-jetpack-compose-navigation-with-voyager/) -> [Source code](https://github.com/kihaki/droidcon_2022_voyager/tree/main) | ||
- [The Missing Library of the Compose Multiverse | Talking Kotlin #130](https://talkingkotlin.com/navigating-the-compose-multiverse-lyricist-and-voyager/) | ||
|
||
## Tutorials | ||
|
||
- [Voyager: Navigation Solution for Compose Multiplatform - iOS and Android | Complete Guide](https://youtu.be/7Xv38k4cCMc) | ||
- [Meet Voyager: A Kotlin Compose Multiplatform Navigation Solution](https://youtu.be/Aww-h7ygo2k) | ||
- [Navigation with Voyager In Jetpack Compose](https://youtu.be/HdXpTXHUTu0) | ||
- PT-BR [Compose Multiplatform - Como Fazer a Navegação entre Telas com a Biblioteca Voyager](https://youtu.be/wiUxyD_7fJU) | ||
|
||
## Community snippets/extensions | ||
|
||
- [iOS SwipeBack](https://github.com/adrielcafe/voyager/issues/144#issuecomment-2085255838) | ||
- [Predictive Back](https://github.com/adrielcafe/voyager/issues/223#issuecomment-2023240129) or [with iOS SwipeBack also](https://github.com/adrielcafe/voyager/issues/144#issuecomment-1961372747) | ||
- [Result passing between screens](https://github.com/adrielcafe/voyager/pull/128#issuecomment-1763034415), follow the comments for more details. | ||
- [Handle Activity onNewIntent](https://github.com/adrielcafe/voyager/issues/149#issuecomment-1557515694) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Deep links | ||
|
||
!!! warning | ||
Currently Voyager does not provided a built in solution to handle Deeplink and URIs. see [#149](https://github.com/adrielcafe/voyager/issues/149) and [#382](https://github.com/adrielcafe/voyager/issues/382) | ||
|
||
You can initialize the `Navigator` with multiple screens, that way, the first visible screen will be the last one and will be possible to return (`pop()`) to the previous screens. | ||
|
||
```kotlin | ||
val postId = getPostIdFromIntent() | ||
|
||
setContent { | ||
Navigator( | ||
HomeScreen, | ||
PostListScreen(), | ||
PostDetailsScreen(postId) | ||
) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Faq | ||
|
||
[iOS Swipe Back support](#ios-swipeback) { #ios-swipeback } | ||
|
||
Voyager does not have a built in support for swipe back yet, we are not 100% conformable with all | ||
solutions that have out there and we think we will better of using a community made solution by copying | ||
to your code base and be able to change as you want your app to behave. | ||
|
||
See this [issue](https://github.com/adrielcafe/voyager/issues/144) each for community build solutions. | ||
|
||
Alternatively, we can also discuss in the future a community build solution using `NavigationController` | ||
under the hood like [`compose-cupertino`](https://github.com/alexzhirkevich/compose-cupertino/blob/master/cupertino-decompose/src/iosMain/kotlin/io/github/alexzhirkevich/cupertino/decompose/UIKitChildren.kt#L192) have implemented for Decompose. | ||
|
||
[Support for predictive back animations](#predictive-back) { #predictive-back } | ||
|
||
Voyager does not have a built in support for predictive back yet, but as well as iOS Swipe Back, the | ||
community have build extensions, and snippets with support, see | ||
[#223](https://github.com/adrielcafe/voyager/issues/223) and [144](https://github.com/adrielcafe/voyager/issues/144). | ||
|
||
[Support for result passing between screens](#result-passing) { #result-passing } | ||
|
||
Voyager does not have a built in support for swipe back yet, we are not 100% conformable with all | ||
solutions that have out there, we encourage to use community made solutions by copying to your | ||
code base and being free to extend as your code base needs. | ||
|
||
See [#128](https://github.com/adrielcafe/voyager/pull/128) comments for community solutions. | ||
|
||
[Deeplink support](./deep-links.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Overview | ||
|
||
![](./media/assets/Sem título-1.png) | ||
|
||
### [Voyager](https://en.wikipedia.org/wiki/USS\_Voyager\_\(Star\_Trek\)): Compose on Warp Speed | ||
|
||
A multiplatform navigation library built for, and seamlessly integrated with, [Jetpack Compose](https://developer.android.com/jetpack/compose). | ||
|
||
Create scalable Single-Activity apps powered by a [pragmatic API](navigation/): | ||
|
||
```kotlin | ||
class HomeScreenModel : ScreenModel { | ||
// ... | ||
} | ||
|
||
class HomeScreen : Screen { | ||
|
||
@Composable | ||
override fun Content() { | ||
val screenModel = rememberScreenModel { HomeScreenModel() } | ||
// ... | ||
} | ||
} | ||
|
||
class SingleActivity : ComponentActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
setContent { | ||
Navigator(HomeScreen()) | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Turn on the Warp Drive and enjoy the voyage 🖖 | ||
|
||
### **Features** | ||
|
||
* [Supported platforms](setup.md#platform-compatibility): Android, iOS, Desktop, Web | ||
* [Linear navigation](navigation/) | ||
* [BottomSheet navigation](navigation/bottomsheet-navigation.md) | ||
* [Tab navigation](navigation/tab-navigation.md) like [Youtube app](https://play.google.com/store/apps/details?id=com.google.android.youtube) | ||
* [Nested navigation](navigation/nested-navigation.md) (multiple stacks, parent navigation) | ||
* [ScreenModel](screenmodel/) (a.k.a ViewModel) integrated with [Koin](screenmodel/koin-integration.md), [Kodein](screenmodel/kodein-integration.md), [Hilt](screenmodel/hilt-integration.md), [Coroutines](screenmodel/coroutines-integration.md), [RxJava](screenmodel/rxjava-integration.md), [LiveData](screenmodel/livedata-integration.md) | ||
* [Android ViewModel](android-viewmodel/) integration (with [Hilt support](android-viewmodel/hilt-integration.md)) | ||
* Type-safe [multi-module navigation](navigation/multi-module-navigation.md) | ||
* State-aware [Stack API](stack-api.md) | ||
* Built-in [transitions](transitions-api) | ||
* [State restoration](state-restoration.md) after Activity recreation | ||
* [Lifecycle](lifecycle.md) callbacks | ||
* [Back press](back-press.md) handling | ||
* [Deep linking](deep-links.md) support | ||
|
||
### Roadmap | ||
|
||
* Wasm support | ||
* Navigator scoped ViewModels | ||
|
||
### Credits | ||
|
||
* Logo by [Icons8](https://icons8.com/icon/SUYSVQr61Q6V/uss-voyager) |
Oops, something went wrong.