-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make scene provide an AnimatedContentScope to the composable content #312
Merged
Tlaster
merged 2 commits into
Tlaster:master
from
StylianosGakis:stylianos/provide-animated-content-scope
Apr 19, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 2 additions & 1 deletion
3
precompose/src/commonMain/kotlin/moe/tlaster/precompose/navigation/route/ComposeRoute.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
20 changes: 19 additions & 1 deletion
20
precompose/src/commonMain/kotlin/moe/tlaster/precompose/navigation/route/FloatingRoute.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 |
---|---|---|
@@ -1,9 +1,27 @@ | ||
package moe.tlaster.precompose.navigation.route | ||
|
||
import androidx.compose.animation.AnimatedContentScope | ||
import androidx.compose.runtime.Composable | ||
import moe.tlaster.precompose.navigation.BackStackEntry | ||
|
||
internal class FloatingRoute( | ||
override val content: @Composable (BackStackEntry) -> Unit, | ||
override val content: @Composable AnimatedContentScope.(BackStackEntry) -> Unit, | ||
override val route: String, | ||
) : ComposeRoute, ComposeFloatingRoute | ||
|
||
@Deprecated( | ||
message = """ | ||
Used as a backwards compatible for the old RouteBuilder APIs which do not expect the content to | ||
be an extension function on AnimatedContentScope | ||
""", | ||
level = DeprecationLevel.WARNING, | ||
) | ||
internal fun floatingRouteWithoutAnimatedContent( | ||
route: String, | ||
content: @Composable (BackStackEntry) -> Unit, | ||
): FloatingRoute { | ||
return FloatingRoute( | ||
route = route, | ||
content = { entry -> content(entry) }, | ||
) | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to do something like what androidx.navigation does here https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavGraphBuilder.kt;l=57-60?q=%22ComposeNavigator.Destination(provider%22 which calls this internal deprecated function here https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:navigation/navigation-compose/src/main/java/androidx/navigation/compose/ComposeNavigator.kt;l=106-110 but for them it worked because the API also changed in a meaningful way besides just adding the AnimatedContentScope.
In our case here if I add it as a secondary constructor then there's ambiguity between the two of them and it's impossible to differentiate between the two. So I opted for an internal deprecated function to exist solely for this purpose.