-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
2,541 additions
and
4 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
Binary file added
BIN
+15.7 KB
...-wasm/src/commonMain/composeResources/drawable/album_amy_shamblen_unsplash.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+40.9 KB
...b-wasm/src/commonMain/composeResources/drawable/album_david_clode_unsplash.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.5 KB
...eb-wasm/src/commonMain/composeResources/drawable/album_efe_kurnaz_unsplash.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11 KB
...web-wasm/src/commonMain/composeResources/drawable/album_ellen_qin_unsplash.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.32 KB
...-wasm/src/commonMain/composeResources/drawable/album_emile_seguin_unsplash.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.23 KB
...ommonMain/composeResources/drawable/album_jean_philippe_delberghe_unsplash.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.8 KB
.../src/commonMain/composeResources/drawable/album_karina_vorozheeva_unsplash.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+22.4 KB
.../src/commonMain/composeResources/drawable/album_kristopher_roller_unsplash.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+32.8 KB
...m/src/commonMain/composeResources/drawable/album_pawel_czerwinski_unsplash.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+23.4 KB
...src/commonMain/composeResources/drawable/album_pawel_czerwinski_unsplash_2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,21 @@ | ||
/* | ||
* Copyright 2024 SOUP | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import androidx.compose.runtime.Composable | ||
|
||
@Composable | ||
fun BackHandler(enabled: Boolean = true, onBack: () -> Unit) { | ||
// do nothing | ||
} |
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
26 changes: 26 additions & 0 deletions
26
sample/web-wasm/src/wasmJsMain/kotlin/soup/compose/material/motion/shared/App.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,26 @@ | ||
/* | ||
* Copyright 2024 SOUP | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package soup.compose.material.motion.shared | ||
|
||
import androidx.compose.runtime.Composable | ||
import soup.compose.material.motion.shared.theme.SampleTheme | ||
|
||
@Composable | ||
fun App() { | ||
SampleTheme { | ||
NavGraph() | ||
} | ||
} |
200 changes: 200 additions & 0 deletions
200
sample/web-wasm/src/wasmJsMain/kotlin/soup/compose/material/motion/shared/HomeScreen.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,200 @@ | ||
/* | ||
* Copyright 2021 SOUP | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package soup.compose.material.motion.shared | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.requiredHeight | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.items | ||
import androidx.compose.material.Divider | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Scaffold | ||
import androidx.compose.material.Text | ||
import androidx.compose.material.TopAppBar | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.dp | ||
import org.jetbrains.compose.ui.tooling.preview.Preview | ||
import soup.compose.material.motion.shared.theme.SampleTheme | ||
|
||
private data class Demo( | ||
val title: String, | ||
val description: String, | ||
val destination: Destination, | ||
) | ||
|
||
private data class Category( | ||
val title: String, | ||
val items: List<Demo>, | ||
) { | ||
companion object { | ||
val items: List<Category> = listOf( | ||
Category( | ||
title = "Additional Examples (Core)", | ||
items = listOf( | ||
Demo( | ||
title = "MaterialSharedAxis", | ||
description = "MaterialSharedAxisScreen", | ||
destination = Destination.MaterialSharedAxis, | ||
), | ||
Demo( | ||
title = "MaterialFadeThrough", | ||
description = "MaterialFadeThroughScreen", | ||
destination = Destination.MaterialFadeThrough, | ||
), | ||
Demo( | ||
title = "MaterialFade", | ||
description = "MaterialFadeScreen", | ||
destination = Destination.MaterialFade, | ||
), | ||
Demo( | ||
title = "MaterialElevationScale", | ||
description = "MaterialElevationScaleScreen", | ||
destination = Destination.MaterialElevationScale, | ||
), | ||
Demo( | ||
title = "Hold", | ||
description = "HoldScreen", | ||
destination = Destination.Hold, | ||
), | ||
Demo( | ||
title = "CircularReveal", | ||
description = "CircularRevealScreen", | ||
destination = Destination.CircularReveal, | ||
), | ||
), | ||
), | ||
Category( | ||
title = "Additional Examples (Navigation)", | ||
items = listOf( | ||
Demo( | ||
title = "AnimatedNavHost", | ||
description = "AnimatedNavHostScreen", | ||
destination = Destination.AnimatedNavHost, | ||
), | ||
), | ||
), | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
fun HomeScreen(onItemClick: (Destination) -> Unit) { | ||
Scaffold( | ||
topBar = { | ||
TopAppBar(title = { Text(text = "Transition for Jetpack Compose") }) | ||
}, | ||
) { contentPadding -> | ||
LazyColumn( | ||
modifier = Modifier.fillMaxSize(), | ||
contentPadding = contentPadding, | ||
) { | ||
item { | ||
Column { | ||
Text( | ||
text = "Description", | ||
modifier = Modifier.padding(start = 16.dp, top = 16.dp, bottom = 16.dp), | ||
style = MaterialTheme.typography.subtitle1, | ||
) | ||
Text( | ||
text = "Transition choreography is a coordinated sequence of motion" + | ||
" that maintains user focus as the interface adapts.", | ||
modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 16.dp), | ||
style = MaterialTheme.typography.body2, | ||
) | ||
HomeDemoItem( | ||
Demo( | ||
title = "Demo", | ||
description = "DemoScreen", | ||
destination = Destination.Demo, | ||
), | ||
onItemClick = onItemClick, | ||
) | ||
} | ||
} | ||
Category.items.forEachIndexed { index, category -> | ||
item( | ||
key = index, | ||
contentType = { "Category" }, | ||
) { | ||
Divider() | ||
HomeCategoryItem(title = category.title) | ||
} | ||
items( | ||
items = category.items, | ||
key = { it.destination.route }, | ||
contentType = { "Demo" }, | ||
) { demo -> | ||
HomeDemoItem(demo, onItemClick = onItemClick) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun HomeCategoryItem( | ||
title: String, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Text( | ||
text = title, | ||
modifier = modifier.padding(start = 16.dp, top = 16.dp), | ||
style = MaterialTheme.typography.subtitle1, | ||
) | ||
} | ||
|
||
@Composable | ||
private fun HomeDemoItem( | ||
demo: Demo, | ||
onItemClick: (Destination) -> Unit, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Column( | ||
verticalArrangement = Arrangement.Center, | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.requiredHeight(64.dp) | ||
.clickable { onItemClick(demo.destination) } | ||
.padding(horizontal = 16.dp), | ||
) { | ||
Text( | ||
text = demo.title, | ||
modifier = Modifier.fillMaxWidth(), | ||
fontWeight = FontWeight.SemiBold, | ||
style = MaterialTheme.typography.body2, | ||
) | ||
Text( | ||
modifier = Modifier.fillMaxWidth(), | ||
text = demo.description, | ||
style = MaterialTheme.typography.caption, | ||
) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun DefaultPreview() { | ||
SampleTheme { | ||
HomeScreen(onItemClick = {}) | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
sample/web-wasm/src/wasmJsMain/kotlin/soup/compose/material/motion/shared/NavGraph.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,100 @@ | ||
/* | ||
* Copyright 2021 SOUP | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package soup.compose.material.motion.shared | ||
|
||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.navigation.compose.NavHost | ||
import androidx.navigation.compose.composable | ||
import androidx.navigation.compose.rememberNavController | ||
import soup.compose.material.motion.animation.materialSharedAxisZIn | ||
import soup.compose.material.motion.animation.materialSharedAxisZOut | ||
import soup.compose.material.motion.shared.circularreveal.CircularRevealScreen | ||
import soup.compose.material.motion.shared.demo.DemoScreen | ||
import soup.compose.material.motion.shared.material.elevationscale.MaterialElevationScaleScreen | ||
import soup.compose.material.motion.shared.material.fade.MaterialFadeScreen | ||
import soup.compose.material.motion.shared.material.fadethrough.MaterialFadeThroughScreen | ||
import soup.compose.material.motion.shared.material.hold.HoldScreen | ||
import soup.compose.material.motion.shared.material.sharedaxis.MaterialSharedAxisScreen | ||
import soup.compose.material.motion.shared.navigation.AnimatedNavHostScreen | ||
|
||
enum class Destination(val route: String) { | ||
Home("Home"), | ||
Demo("Demo"), | ||
MaterialSharedAxis("MaterialSharedAxis"), | ||
MaterialFadeThrough("MaterialFadeThrough"), | ||
MaterialFade("MaterialFade"), | ||
MaterialElevationScale("MaterialElevationScale"), | ||
Hold("Hold"), | ||
CircularReveal("CircularReveal"), | ||
AnimatedNavHost("AnimatedNavHost"), | ||
} | ||
|
||
@Composable | ||
fun NavGraph( | ||
startDestination: String = Destination.Home.route, | ||
) { | ||
val navController = rememberNavController() | ||
val upPress: () -> Unit = { | ||
navController.navigateUp() | ||
} | ||
NavHost( | ||
navController = navController, | ||
startDestination = startDestination, | ||
modifier = Modifier.fillMaxSize(), | ||
enterTransition = { materialSharedAxisZIn(forward = true) }, | ||
exitTransition = { materialSharedAxisZOut(forward = true) }, | ||
popEnterTransition = { materialSharedAxisZIn(forward = false) }, | ||
popExitTransition = { materialSharedAxisZOut(forward = false) }, | ||
) { | ||
composable(Destination.Home.route) { | ||
HomeScreen( | ||
onItemClick = { | ||
navController.navigate(route = it.route) | ||
}, | ||
) | ||
} | ||
composable(Destination.Demo.route) { | ||
DemoScreen(upPress = upPress) | ||
} | ||
|
||
// Core | ||
composable(Destination.MaterialSharedAxis.route) { | ||
MaterialSharedAxisScreen(upPress = upPress) | ||
} | ||
composable(Destination.MaterialFadeThrough.route) { | ||
MaterialFadeThroughScreen(upPress = upPress) | ||
} | ||
composable(Destination.MaterialFade.route) { | ||
MaterialFadeScreen(upPress = upPress) | ||
} | ||
composable(Destination.MaterialElevationScale.route) { | ||
MaterialElevationScaleScreen(upPress = upPress) | ||
} | ||
composable(Destination.Hold.route) { | ||
HoldScreen(upPress = upPress) | ||
} | ||
composable(Destination.CircularReveal.route) { | ||
CircularRevealScreen(upPress = upPress) | ||
} | ||
|
||
// Navigation | ||
composable(Destination.AnimatedNavHost.route) { | ||
AnimatedNavHostScreen(upPress = upPress) | ||
} | ||
} | ||
} |
Oops, something went wrong.