-
Notifications
You must be signed in to change notification settings - Fork 10
Content transition api & predictive back example #125
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b0a2cf6
Add content transition api base
vkatz ea09e1c
Fix doc
vkatz 7d16f01
Fix deteck & api dump
vkatz 734901e
Update animations, fix Wasm initialization
vkatz 9d0dfa2
- add nav listener (#132)
vkatz 36a9722
- minor refactor
vkatz 268b7f0
- minor refactor
vkatz 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
19 changes: 10 additions & 9 deletions
19
example/app/composeApp/src/androidMain/AndroidManifest.xml
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
161 changes: 161 additions & 0 deletions
161
...kotlin/composegears/tiamat/example/content/content/advanced/AdvSharedElementTransition.kt
This file contains hidden or 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,161 @@ | ||
| package composegears.tiamat.example.content.content.advanced | ||
|
|
||
| import androidx.compose.animation.ExperimentalSharedTransitionApi | ||
| import androidx.compose.animation.SharedTransitionLayout | ||
| import androidx.compose.animation.SharedTransitionScope | ||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.border | ||
| import androidx.compose.foundation.layout.* | ||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||
| import androidx.compose.material.icons.Icons | ||
| import androidx.compose.material.icons.automirrored.filled.KeyboardArrowLeft | ||
| import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.CompositionLocalProvider | ||
| import androidx.compose.runtime.staticCompositionLocalOf | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.unit.dp | ||
| import com.composegears.tiamat.* | ||
| import composegears.tiamat.example.ui.core.* | ||
|
|
||
| @OptIn(ExperimentalSharedTransitionApi::class) | ||
| private val LocalSharedTransitionScope = staticCompositionLocalOf<SharedTransitionScope> { error("No scope provided") } | ||
|
|
||
| @OptIn(ExperimentalSharedTransitionApi::class) | ||
| val AdvSharedElementTransition by navDestination<Unit>(ScreenInfo()) { | ||
| Screen("SharedElementTransition") { | ||
| Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { | ||
| val nc = rememberNavController( | ||
| key = "SharedElementTransition nav controller", | ||
| startDestination = AdvSharedElementTransitionScreen1, | ||
| destinations = arrayOf( | ||
| AdvSharedElementTransitionScreen1, | ||
| AdvSharedElementTransitionScreen2, | ||
| AdvSharedElementTransitionScreen3, | ||
| ) | ||
| ) | ||
| SharedTransitionLayout { | ||
| CompositionLocalProvider( | ||
| LocalSharedTransitionScope provides this | ||
| ) { | ||
| Navigation( | ||
| navController = nc, | ||
| modifier = Modifier | ||
| .fillMaxSize() | ||
| .padding(16.dp) | ||
| .border(1.dp, MaterialTheme.colorScheme.outlineVariant, RoundedCornerShape(8.dp)) | ||
| .padding(16.dp), | ||
| contentTransformProvider = { navigationSlideInOut(it) } | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @OptIn(ExperimentalSharedTransitionApi::class) | ||
| private val AdvSharedElementTransitionScreen1 by navDestination<Unit> { | ||
| val nc = navController() | ||
| Box(Modifier.fillMaxSize().padding(16.dp), contentAlignment = Alignment.Center) { | ||
| Column(horizontalAlignment = Alignment.CenterHorizontally) { | ||
| Text("Screen 1", style = MaterialTheme.typography.headlineMedium) | ||
| VSpacer() | ||
| with(LocalSharedTransitionScope.current) { | ||
| Text( | ||
| "This is SHARED element on screen 1", | ||
| modifier = Modifier | ||
| .sharedElement( | ||
| state = rememberSharedContentState("element"), | ||
| animatedVisibilityScope = this@navDestination, | ||
| ) | ||
| .renderInSharedTransitionScopeOverlay() | ||
| .animateEnterExit() | ||
| .background(Color.Green.copy(alpha = 0.3f)) | ||
| .padding(16.dp), | ||
| style = MaterialTheme.typography.bodyLarge | ||
| ) | ||
| } | ||
| VSpacer() | ||
| AppButton( | ||
| "Next", | ||
| endIcon = Icons.AutoMirrored.Default.KeyboardArrowRight, | ||
| onClick = { nc.navigate(AdvSharedElementTransitionScreen2) } | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @OptIn(ExperimentalSharedTransitionApi::class) | ||
| private val AdvSharedElementTransitionScreen2 by navDestination<Unit> { | ||
| val nc = navController() | ||
| Box(Modifier.fillMaxSize().padding(16.dp), contentAlignment = Alignment.Center) { | ||
| Column(horizontalAlignment = Alignment.CenterHorizontally) { | ||
| Text("Screen 2", style = MaterialTheme.typography.headlineMedium) | ||
| VSpacer() | ||
| with(LocalSharedTransitionScope.current) { | ||
| Text( | ||
| "This is SHARED element on screen 2", | ||
| modifier = Modifier | ||
| .sharedElement( | ||
| state = rememberSharedContentState("element"), | ||
| animatedVisibilityScope = this@navDestination, | ||
| ) | ||
| .renderInSharedTransitionScopeOverlay() | ||
| .animateEnterExit() | ||
| .background(Color.Red.copy(alpha = 0.3f)) | ||
| .padding(16.dp), | ||
| style = MaterialTheme.typography.bodyLarge | ||
| ) | ||
| } | ||
| VSpacer() | ||
| Row { | ||
| AppButton( | ||
| "Back", | ||
| startIcon = Icons.AutoMirrored.Default.KeyboardArrowLeft, | ||
| onClick = { nc.back() } | ||
| ) | ||
| HSpacer() | ||
| AppButton( | ||
| "Next", | ||
| endIcon = Icons.AutoMirrored.Default.KeyboardArrowRight, | ||
| onClick = { nc.navigate(AdvSharedElementTransitionScreen3) } | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @OptIn(ExperimentalSharedTransitionApi::class) | ||
| private val AdvSharedElementTransitionScreen3 by navDestination<Unit> { | ||
| val nc = navController() | ||
| Box(Modifier.fillMaxSize().padding(16.dp), contentAlignment = Alignment.Center) { | ||
| Column(horizontalAlignment = Alignment.CenterHorizontally) { | ||
| Text("Screen 3", style = MaterialTheme.typography.headlineMedium) | ||
| VSpacer() | ||
| with(LocalSharedTransitionScope.current) { | ||
| Text( | ||
| "This is SHARED element on screen 3", | ||
| modifier = Modifier | ||
| .sharedElement( | ||
| state = rememberSharedContentState("element"), | ||
| animatedVisibilityScope = this@navDestination, | ||
| ) | ||
| .renderInSharedTransitionScopeOverlay() | ||
| .animateEnterExit() | ||
| .background(Color.Blue.copy(alpha = 0.3f)) | ||
| .padding(16.dp), | ||
| style = MaterialTheme.typography.bodyLarge | ||
| ) | ||
| } | ||
| VSpacer() | ||
| AppButton( | ||
| "Back", | ||
| startIcon = Icons.AutoMirrored.Default.KeyboardArrowLeft, | ||
| onClick = { nc.back() } | ||
| ) | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.