-
-
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: public internal apis and navigator saver relocated
- Loading branch information
1 parent
07e50a1
commit ef603b2
Showing
6 changed files
with
58 additions
and
29 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
16 changes: 16 additions & 0 deletions
16
voyager-core/src/commonMain/kotlin/cafe/adriel/voyager/core/annotation/InternalVoyagerApi.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,16 @@ | ||
package cafe.adriel.voyager.core.annotation | ||
|
||
@Target( | ||
allowedTargets = [ | ||
AnnotationTarget.CLASS, | ||
AnnotationTarget.PROPERTY, | ||
AnnotationTarget.FUNCTION, | ||
AnnotationTarget.TYPEALIAS, | ||
AnnotationTarget.CONSTRUCTOR, | ||
] | ||
) | ||
@RequiresOptIn( | ||
level = RequiresOptIn.Level.ERROR, | ||
message = "This API is Voyager Internal. It may be changed in the future without notice." | ||
) | ||
public annotation class InternalVoyagerApi |
3 changes: 1 addition & 2 deletions
3
...igator/internal/NavigatorSaver.android.kt → ...yager/navigator/NavigatorSaver.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
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
32 changes: 32 additions & 0 deletions
32
...or/src/commonMain/kotlin/cafe/adriel/voyager/navigator/internal/NavigatorSaverInternal.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,32 @@ | ||
package cafe.adriel.voyager.navigator.internal | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.ProvidableCompositionLocal | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.saveable.SaveableStateHolder | ||
import androidx.compose.runtime.saveable.rememberSaveable | ||
import androidx.compose.runtime.staticCompositionLocalOf | ||
import cafe.adriel.voyager.core.screen.Screen | ||
import cafe.adriel.voyager.navigator.LocalNavigatorSaver | ||
import cafe.adriel.voyager.navigator.Navigator | ||
import cafe.adriel.voyager.navigator.NavigatorDisposeBehavior | ||
|
||
internal val LocalNavigatorStateHolder: ProvidableCompositionLocal<SaveableStateHolder> = | ||
staticCompositionLocalOf { error("LocalNavigatorStateHolder not initialized") } | ||
|
||
@Composable | ||
internal fun rememberNavigator( | ||
screens: List<Screen>, | ||
disposeBehavior: NavigatorDisposeBehavior, | ||
parent: Navigator?, | ||
): Navigator { | ||
val stateHolder = LocalNavigatorStateHolder.current | ||
val navigatorSaver = LocalNavigatorSaver.current | ||
val saver = remember(navigatorSaver, stateHolder, parent, disposeBehavior) { | ||
navigatorSaver.saver(screens, stateHolder, disposeBehavior, parent) | ||
} | ||
|
||
return rememberSaveable(saver = saver) { | ||
Navigator(screens, stateHolder, disposeBehavior, parent) | ||
} | ||
} |