-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new experimental NavigatorScreenLifecycle API
Now, AndroidScreen behavior of AndroidScreenLifecycleOwner is available by default in any Screen for Android targets, this means that no longer will required AndroidScreen to proper Android lifecycle support.
- Loading branch information
1 parent
ef603b2
commit 33e28d2
Showing
14 changed files
with
168 additions
and
3 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
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
File renamed without changes.
9 changes: 9 additions & 0 deletions
9
...ain/kotlin/cafe/adriel/voyager/core/lifecycle/NavigatorScreenLifecycleProvider.android.kt
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,9 @@ | ||
package cafe.adriel.voyager.core.lifecycle | ||
|
||
import cafe.adriel.voyager.androidx.AndroidScreenLifecycleOwner | ||
import cafe.adriel.voyager.core.screen.Screen | ||
|
||
internal actual class DefaultNavigatorScreenLifecycleProvider : NavigatorScreenLifecycleProvider { | ||
actual override fun provide(screen: Screen): List<ScreenLifecycleOwner> = | ||
listOf(AndroidScreenLifecycleOwner.get(screen)) | ||
} |
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
25 changes: 25 additions & 0 deletions
25
...core/src/commonMain/kotlin/cafe/adriel/voyager/core/lifecycle/NavigatorScreenLifecycle.kt
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,25 @@ | ||
package cafe.adriel.voyager.core.lifecycle | ||
|
||
import androidx.compose.runtime.ProvidableCompositionLocal | ||
import androidx.compose.runtime.staticCompositionLocalOf | ||
import cafe.adriel.voyager.core.annotation.ExperimentalVoyagerApi | ||
import cafe.adriel.voyager.core.screen.Screen | ||
|
||
@ExperimentalVoyagerApi | ||
public val LocalNavigatorScreenLifecycleProvider: ProvidableCompositionLocal<NavigatorScreenLifecycleProvider> = | ||
staticCompositionLocalOf { DefaultNavigatorScreenLifecycleProvider() } | ||
|
||
/** | ||
* Can provides a list of ScreenLifecycleOwner for each Screen in the Navigator stack. | ||
*/ | ||
@ExperimentalVoyagerApi | ||
public interface NavigatorScreenLifecycleProvider { | ||
|
||
@ExperimentalVoyagerApi | ||
public fun provide(screen: Screen): List<ScreenLifecycleOwner> | ||
} | ||
|
||
internal expect class DefaultNavigatorScreenLifecycleProvider() : NavigatorScreenLifecycleProvider{ | ||
override fun provide(screen: Screen): List<ScreenLifecycleOwner> | ||
} | ||
|
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
6 changes: 6 additions & 0 deletions
6
...ain/kotlin/cafe/adriel/voyager/core/lifecycle/NavigatorScreenLifecycleProvider.desktop.kt
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,6 @@ | ||
package cafe.adriel.voyager.core.lifecycle | ||
|
||
import cafe.adriel.voyager.core.screen.Screen | ||
internal actual class DefaultNavigatorScreenLifecycleProvider : NavigatorScreenLifecycleProvider { | ||
actual override fun provide(screen: Screen): List<ScreenLifecycleOwner> = emptyList() | ||
} |
6 changes: 6 additions & 0 deletions
6
...c/jsMain/kotlin/cafe.adriel.voyager.core/lifecycle/NavigatorScreenLifecycleProvider.js.kt
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,6 @@ | ||
package cafe.adriel.voyager.core.lifecycle | ||
|
||
import cafe.adriel.voyager.core.screen.Screen | ||
internal actual class DefaultNavigatorScreenLifecycleProvider : NavigatorScreenLifecycleProvider { | ||
actual override fun provide(screen: Screen): List<ScreenLifecycleOwner> = emptyList() | ||
} |
6 changes: 6 additions & 0 deletions
6
...Main/kotlin/cafe.adriel.voyager.core/lifecycle/NavigatorScreenLifecycleProvider.native.kt
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,6 @@ | ||
package cafe.adriel.voyager.core.lifecycle | ||
|
||
import cafe.adriel.voyager.core.screen.Screen | ||
internal actual class DefaultNavigatorScreenLifecycleProvider : NavigatorScreenLifecycleProvider { | ||
actual override fun provide(screen: Screen): List<ScreenLifecycleOwner> = emptyList() | ||
} |
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