Skip to content

Commit 8abe5cc

Browse files
authored
Compose - beta01 (#270)
* Update to new beta01 version * Apply Spotless * Update shared element text composable * Apply Spotless --------- Co-authored-by: riggaroo <[email protected]>
1 parent 3f7adbe commit 8abe5cc

File tree

6 files changed

+157
-150
lines changed

6 files changed

+157
-150
lines changed

compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/SharedBoundsSnippets.kt

Lines changed: 127 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -53,149 +53,148 @@ import com.example.compose.snippets.R
5353
import com.example.compose.snippets.ui.theme.LavenderLight
5454
import com.example.compose.snippets.ui.theme.RoseLight
5555

56-
private class SharedElementBasicUsage4 {
57-
58-
@Preview
59-
@Composable
60-
private fun SharedElementApp() {
61-
var showDetails by remember {
62-
mutableStateOf(false)
63-
}
64-
SharedTransitionLayout {
65-
AnimatedContent(
66-
showDetails,
67-
label = "basic_transition"
68-
) { targetState ->
69-
if (!targetState) {
70-
MainContent(
71-
onShowDetails = {
72-
showDetails = true
73-
},
74-
animatedVisibilityScope = this@AnimatedContent,
75-
sharedTransitionScope = this@SharedTransitionLayout
76-
)
77-
} else {
78-
DetailsContent(
79-
onBack = {
80-
showDetails = false
81-
},
82-
animatedVisibilityScope = this@AnimatedContent,
83-
sharedTransitionScope = this@SharedTransitionLayout
84-
)
85-
}
56+
@Preview
57+
@Composable
58+
fun SharedBoundsDemo() {
59+
var showDetails by remember {
60+
mutableStateOf(false)
61+
}
62+
SharedTransitionLayout {
63+
AnimatedContent(
64+
showDetails,
65+
label = "basic_transition"
66+
) { targetState ->
67+
if (!targetState) {
68+
MainContent(
69+
onShowDetails = {
70+
showDetails = true
71+
},
72+
animatedVisibilityScope = this@AnimatedContent,
73+
sharedTransitionScope = this@SharedTransitionLayout
74+
)
75+
} else {
76+
DetailsContent(
77+
onBack = {
78+
showDetails = false
79+
},
80+
animatedVisibilityScope = this@AnimatedContent,
81+
sharedTransitionScope = this@SharedTransitionLayout
82+
)
8683
}
8784
}
8885
}
86+
}
8987

90-
// [START android_compose_animations_shared_element_shared_bounds]
91-
@Composable
92-
private fun MainContent(
93-
onShowDetails: () -> Unit,
94-
modifier: Modifier = Modifier,
95-
sharedTransitionScope: SharedTransitionScope,
96-
animatedVisibilityScope: AnimatedVisibilityScope
97-
) {
98-
with(sharedTransitionScope) {
99-
Row(
100-
modifier = Modifier
101-
.padding(8.dp)
102-
.sharedBounds(
103-
rememberSharedContentState(key = "bounds"),
104-
animatedVisibilityScope = animatedVisibilityScope,
105-
enter = fadeIn(),
106-
exit = fadeOut()
107-
)
108-
// [START_EXCLUDE]
109-
.border(1.dp, Color.Gray.copy(alpha = 0.5f), RoundedCornerShape(8.dp))
110-
.background(LavenderLight, RoundedCornerShape(8.dp))
111-
.clickable {
112-
onShowDetails()
113-
}
114-
.padding(8.dp)
115-
// [END_EXCLUDE]
116-
) {
117-
// [START_EXCLUDE]
118-
Image(
119-
painter = painterResource(id = R.drawable.cupcake),
120-
contentDescription = "Cupcake",
121-
modifier = Modifier
122-
.sharedElement(
123-
rememberSharedContentState(key = "image"),
124-
animatedVisibilityScope = animatedVisibilityScope
125-
)
126-
.size(100.dp)
127-
.clip(CircleShape),
128-
contentScale = ContentScale.Crop
88+
// [START android_compose_animations_shared_element_shared_bounds]
89+
@Composable
90+
private fun MainContent(
91+
onShowDetails: () -> Unit,
92+
modifier: Modifier = Modifier,
93+
sharedTransitionScope: SharedTransitionScope,
94+
animatedVisibilityScope: AnimatedVisibilityScope
95+
) {
96+
with(sharedTransitionScope) {
97+
Row(
98+
modifier = Modifier
99+
.padding(8.dp)
100+
.sharedBounds(
101+
rememberSharedContentState(key = "bounds"),
102+
animatedVisibilityScope = animatedVisibilityScope,
103+
enter = fadeIn(),
104+
exit = fadeOut(),
105+
resizeMode = SharedTransitionScope.ResizeMode.ScaleToBounds()
129106
)
130-
Text(
131-
"Cupcake", fontSize = 21.sp,
132-
modifier = Modifier.sharedBounds(
133-
rememberSharedContentState(key = "title"),
107+
// [START_EXCLUDE]
108+
.border(1.dp, Color.Gray.copy(alpha = 0.5f), RoundedCornerShape(8.dp))
109+
.background(LavenderLight, RoundedCornerShape(8.dp))
110+
.clickable {
111+
onShowDetails()
112+
}
113+
.padding(8.dp)
114+
// [END_EXCLUDE]
115+
) {
116+
// [START_EXCLUDE]
117+
Image(
118+
painter = painterResource(id = R.drawable.cupcake),
119+
contentDescription = "Cupcake",
120+
modifier = Modifier
121+
.sharedElement(
122+
rememberSharedContentState(key = "image"),
134123
animatedVisibilityScope = animatedVisibilityScope
135124
)
125+
.size(100.dp)
126+
.clip(CircleShape),
127+
contentScale = ContentScale.Crop
128+
)
129+
Text(
130+
"Cupcake", fontSize = 21.sp,
131+
modifier = Modifier.sharedBounds(
132+
rememberSharedContentState(key = "title"),
133+
animatedVisibilityScope = animatedVisibilityScope
136134
)
137-
// [END_EXCLUDE]
138-
}
135+
)
136+
// [END_EXCLUDE]
139137
}
140138
}
139+
}
141140

142-
@Composable
143-
private fun DetailsContent(
144-
modifier: Modifier = Modifier,
145-
onBack: () -> Unit,
146-
sharedTransitionScope: SharedTransitionScope,
147-
animatedVisibilityScope: AnimatedVisibilityScope
148-
) {
149-
with(sharedTransitionScope) {
150-
Column(
151-
modifier = Modifier
152-
.sharedBounds(
153-
rememberSharedContentState(key = "bounds"),
154-
animatedVisibilityScope = animatedVisibilityScope,
155-
enter = fadeIn(),
156-
exit = fadeOut()
157-
)
158-
// [START_EXCLUDE]
159-
.padding(top = 200.dp, start = 16.dp, end = 16.dp)
160-
.border(1.dp, Color.Gray.copy(alpha = 0.5f), RoundedCornerShape(8.dp))
161-
.background(RoseLight, RoundedCornerShape(8.dp))
162-
.clickable {
163-
onBack()
164-
}
165-
.padding(8.dp)
166-
// [END_EXCLUDE]
167-
168-
) {
169-
// [START_EXCLUDE]
170-
Image(
171-
painter = painterResource(id = R.drawable.cupcake),
172-
contentDescription = "Cupcake",
173-
modifier = Modifier
174-
.sharedElement(
175-
rememberSharedContentState(key = "image"),
176-
animatedVisibilityScope = animatedVisibilityScope
177-
)
178-
.size(200.dp)
179-
.clip(CircleShape),
180-
contentScale = ContentScale.Crop
141+
@Composable
142+
private fun DetailsContent(
143+
modifier: Modifier = Modifier,
144+
onBack: () -> Unit,
145+
sharedTransitionScope: SharedTransitionScope,
146+
animatedVisibilityScope: AnimatedVisibilityScope
147+
) {
148+
with(sharedTransitionScope) {
149+
Column(
150+
modifier = Modifier
151+
.padding(top = 200.dp, start = 16.dp, end = 16.dp)
152+
.sharedBounds(
153+
rememberSharedContentState(key = "bounds"),
154+
animatedVisibilityScope = animatedVisibilityScope,
155+
enter = fadeIn(),
156+
exit = fadeOut(),
157+
resizeMode = SharedTransitionScope.ResizeMode.ScaleToBounds()
181158
)
182-
Text(
183-
"Cupcake", fontSize = 28.sp,
184-
modifier = Modifier.sharedBounds(
185-
rememberSharedContentState(key = "title"),
159+
// [START_EXCLUDE]
160+
.border(1.dp, Color.Gray.copy(alpha = 0.5f), RoundedCornerShape(8.dp))
161+
.background(RoseLight, RoundedCornerShape(8.dp))
162+
.clickable {
163+
onBack()
164+
}
165+
.padding(8.dp)
166+
// [END_EXCLUDE]
167+
168+
) {
169+
// [START_EXCLUDE]
170+
Image(
171+
painter = painterResource(id = R.drawable.cupcake),
172+
contentDescription = "Cupcake",
173+
modifier = Modifier
174+
.sharedElement(
175+
rememberSharedContentState(key = "image"),
186176
animatedVisibilityScope = animatedVisibilityScope
187177
)
178+
.size(200.dp)
179+
.clip(CircleShape),
180+
contentScale = ContentScale.Crop
181+
)
182+
Text(
183+
"Cupcake", fontSize = 28.sp,
184+
modifier = Modifier.sharedBounds(
185+
rememberSharedContentState(key = "title"),
186+
animatedVisibilityScope = animatedVisibilityScope
188187
)
189-
Text(
190-
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sit amet lobortis velit. " +
191-
"Lorem ipsum dolor sit amet, consectetur adipiscing elit." +
192-
" Curabitur sagittis, lectus posuere imperdiet facilisis, nibh massa " +
193-
"molestie est, quis dapibus orci ligula non magna. Pellentesque rhoncus " +
194-
"hendrerit massa quis ultricies. Curabitur congue ullamcorper leo, at maximus"
195-
)
196-
// [END_EXCLUDE]
197-
}
188+
)
189+
Text(
190+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sit amet lobortis velit. " +
191+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit." +
192+
" Curabitur sagittis, lectus posuere imperdiet facilisis, nibh massa " +
193+
"molestie est, quis dapibus orci ligula non magna. Pellentesque rhoncus " +
194+
"hendrerit massa quis ultricies. Curabitur congue ullamcorper leo, at maximus"
195+
)
196+
// [END_EXCLUDE]
198197
}
199198
}
200-
// [END android_compose_animations_shared_element_shared_bounds]
201199
}
200+
// [END android_compose_animations_shared_element_shared_bounds]

compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/SharedElementCommonUseCaseSnippets.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import androidx.annotation.DrawableRes
2222
import androidx.compose.animation.AnimatedVisibility
2323
import androidx.compose.animation.ExperimentalSharedTransitionApi
2424
import androidx.compose.animation.SharedTransitionLayout
25+
import androidx.compose.animation.SharedTransitionScope
2526
import androidx.compose.animation.fadeIn
2627
import androidx.compose.animation.fadeOut
2728
import androidx.compose.foundation.layout.size
@@ -89,8 +90,9 @@ private fun SharedElementTypicalUseText() {
8990
key = "shared Text"
9091
),
9192
animatedVisibilityScope = this,
92-
enter = fadeIn() + scaleInSharedContentToBounds(),
93-
exit = fadeOut() + scaleOutSharedContentToBounds()
93+
enter = fadeIn(),
94+
exit = fadeOut(),
95+
resizeMode = SharedTransitionScope.ResizeMode.ScaleToBounds()
9496
)
9597
)
9698
// [END android_compose_shared_element_text_tip]

compose/snippets/src/main/java/com/example/compose/snippets/touchinput/userinteractions/UserInteractions.kt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -261,25 +261,17 @@ fun MyAppTheme(content: @Composable () -> Unit) {
261261
}
262262
// [END android_compose_userinteractions_localusefallbackrippleimplementation_app_theme]
263263

264-
// [START android_compose_userinteractions_disabled_ripple_configuration]
265-
@OptIn(ExperimentalMaterialApi::class)
266-
private val DisabledRippleConfiguration =
267-
RippleConfiguration(isEnabled = false)
268-
269-
// [START_EXCLUDE]
270264
@OptIn(ExperimentalMaterialApi::class)
271265
@Composable
272266
private fun MyComposableDisabledRippleConfig() {
273-
// [END_EXCLUDE]
274-
CompositionLocalProvider(LocalRippleConfiguration provides DisabledRippleConfiguration) {
267+
// [START android_compose_userinteractions_disabled_ripple_configuration]
268+
CompositionLocalProvider(LocalRippleConfiguration provides null) {
275269
Button {
276270
// ...
277271
}
278272
}
279-
// [START_EXCLUDE silent]
273+
// [END android_compose_userinteractions_disabled_ripple_configuration]
280274
}
281-
// [END_EXCLUDE]
282-
// [END android_compose_userinteractions_disabled_ripple_configuration]
283275

284276
// [START android_compose_userinteractions_my_ripple_configuration]
285277
@OptIn(ExperimentalMaterialApi::class)

gradle.properties

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,20 @@
1111
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1212
# org.gradle.parallel=true
1313
#Mon May 22 14:59:56 BST 2023
14-
android.enableJetifier=false
14+
org.gradle.jvmargs=-Xmx2048m
15+
16+
# Turn on parallel compilation, caching and on-demand configuration
17+
org.gradle.configureondemand=true
18+
org.gradle.caching=true
19+
org.gradle.parallel=true
20+
21+
# AndroidX package structure to make it clearer which packages are bundled with the
22+
# Android operating system, and which are packaged with your app's APK
23+
# https://developer.android.com/topic/libraries/support-library/androidx-rn
1524
android.useAndroidX=true
16-
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
17-
org.gradle.unsafe.configuration-cache=true
25+
26+
# Kotlin code style for this project: "official" or "obsolete":
27+
kotlin.code.style=official
28+
29+
# Enable R8 full mode.
30+
android.enableR8.fullMode=true

gradle/libs.versions.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[versions]
22
accompanist = "0.32.0"
3-
androidGradlePlugin = "8.2.2"
3+
androidGradlePlugin = "8.4.0"
44
androidx-activity-compose = "1.9.0-alpha03"
55
androidx-appcompat = "1.6.1"
6-
androidx-compose-bom = "2024.04.01"
6+
androidx-compose-bom = "2024.05.00"
77
androidx-compose-ui-test = "1.7.0-alpha03"
88
androidx-constraintlayout = "2.1.4"
99
androidx-constraintlayout-compose = "1.0.1"
@@ -23,7 +23,7 @@ coil = "2.5.0"
2323
# @keep
2424
compileSdk = "34"
2525
compose-compiler = "1.5.4"
26-
compose-latest = "1.7.0-alpha07"
26+
compose-latest = "1.7.0-beta01"
2727
coroutines = "1.7.3"
2828
google-maps = "18.2.0"
2929
gradle-versions = "0.51.0"
@@ -52,7 +52,7 @@ accompanist-theme-adapter-material = { module = "com.google.accompanist:accompan
5252
accompanist-theme-adapter-material3 = { module = "com.google.accompanist:accompanist-themeadapter-material3", version.ref = "accompanist" }
5353
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity-compose" }
5454
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
55-
androidx-compose-animation-graphics = { module = "androidx.compose.animation:animation-graphics" }
55+
androidx-compose-animation-graphics = { module = "androidx.compose.animation:animation-graphics" , version.ref = "compose-latest" }
5656
androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "androidx-compose-bom" }
5757
androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose-latest" }
5858
androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout", version.ref = "compose-latest" }
@@ -67,7 +67,7 @@ androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" }
6767
androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" }
6868
androidx-compose-ui = { module = "androidx.compose.ui:ui" }
6969
androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts" }
70-
androidx-graphics-shapes = "androidx.graphics:graphics-shapes:1.0.0-alpha05"
70+
androidx-graphics-shapes = "androidx.graphics:graphics-shapes:1.0.0-beta01"
7171
androidx-compose-ui-graphics = { module = "androidx.compose.ui:ui-graphics" }
7272
androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test" }
7373
androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" }

gradle/wrapper/gradle-wrapper.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
#Tue May 14 19:06:12 BST 2024
12
distributionBase=GRADLE_USER_HOME
23
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
45
networkTimeout=10000
56
validateDistributionUrl=true
67
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)