Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit 95cd0cc

Browse files
authored
Merge pull request #90 from android/yaraki/MotionCompose-update
MotionCompose: Update dependencies
2 parents d7d507d + 4eab851 commit 95cd0cc

File tree

10 files changed

+60
-89
lines changed

10 files changed

+60
-89
lines changed

MotionCompose/app/build.gradle

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ plugins {
2020
}
2121

2222
android {
23-
compileSdk 31
23+
compileSdk 32
2424

2525
defaultConfig {
2626
applicationId 'com.example.android.compose.motion'
2727
minSdk 21
28-
targetSdk 31
28+
targetSdk 32
2929
versionCode 1
3030
versionName '1.0'
3131
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
@@ -60,23 +60,22 @@ android {
6060
}
6161

6262
dependencies {
63-
implementation 'androidx.core:core-ktx:1.7.0'
63+
implementation 'androidx.core:core-ktx:1.8.0'
6464
implementation "androidx.compose.ui:ui:$compose_version"
65-
implementation 'androidx.compose.material3:material3:1.0.0-alpha02'
65+
implementation 'androidx.compose.material3:material3:1.0.0-alpha13'
6666
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
67-
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
67+
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
6868
implementation 'androidx.activity:activity-compose:1.4.0'
69-
implementation 'androidx.constraintlayout:constraintlayout-compose:1.0.0-rc02'
69+
implementation 'androidx.constraintlayout:constraintlayout-compose:1.0.1'
7070

71-
def accompanist_version = '0.22.0-rc'
71+
def accompanist_version = '0.24.10-beta'
7272
implementation "com.google.accompanist:accompanist-flowlayout:$accompanist_version"
73-
implementation "com.google.accompanist:accompanist-insets-ui:$accompanist_version"
7473
implementation "com.google.accompanist:accompanist-placeholder:$accompanist_version"
7574

76-
def lifecycle_version = '2.4.0'
75+
def lifecycle_version = '2.4.1'
7776
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
7877

79-
implementation "androidx.paging:paging-compose:1.0.0-alpha14"
78+
implementation "androidx.paging:paging-compose:1.0.0-alpha15"
8079

8180
testImplementation 'junit:junit:4.13.2'
8281
androidTestImplementation 'com.google.truth:truth:1.1.3'

MotionCompose/app/src/main/java/com/example/android/compose/motion/demo/SimpleScaffold.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ import androidx.compose.foundation.layout.Box
2020
import androidx.compose.foundation.layout.BoxScope
2121
import androidx.compose.foundation.layout.fillMaxSize
2222
import androidx.compose.foundation.layout.padding
23+
import androidx.compose.foundation.layout.statusBarsPadding
2324
import androidx.compose.material3.ExperimentalMaterial3Api
2425
import androidx.compose.material3.Scaffold
2526
import androidx.compose.material3.SmallTopAppBar
2627
import androidx.compose.material3.Text
2728
import androidx.compose.runtime.Composable
2829
import androidx.compose.ui.Modifier
29-
import com.google.accompanist.insets.LocalWindowInsets
30-
import com.google.accompanist.insets.rememberInsetsPaddingValues
3130

3231
@OptIn(ExperimentalMaterial3Api::class)
3332
@Composable
@@ -43,18 +42,15 @@ fun SimpleScaffold(
4342
Text(text = title)
4443
},
4544
modifier = Modifier
46-
.padding(
47-
rememberInsetsPaddingValues(
48-
insets = LocalWindowInsets.current.systemBars,
49-
applyBottom = false
50-
)
51-
)
45+
.statusBarsPadding()
5246
)
5347
},
5448
modifier = modifier
55-
) {
49+
) { padding ->
5650
Box(
57-
modifier = Modifier.fillMaxSize()
51+
modifier = Modifier
52+
.fillMaxSize()
53+
.padding(padding)
5854
) {
5955
content()
6056
}

MotionCompose/app/src/main/java/com/example/android/compose/motion/demo/fadethrough/FadeThroughDemo.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import androidx.compose.material.icons.Icons
4242
import androidx.compose.material.icons.filled.Favorite
4343
import androidx.compose.material.icons.filled.Share
4444
import androidx.compose.material3.Button
45-
import androidx.compose.material3.ExperimentalMaterial3Api
4645
import androidx.compose.material3.Icon
4746
import androidx.compose.material3.IconButton
4847
import androidx.compose.material3.MaterialTheme
@@ -68,7 +67,6 @@ import com.example.android.compose.motion.demo.Demo
6867
import com.example.android.compose.motion.demo.SimpleScaffold
6968
import com.example.android.compose.motion.ui.MotionComposeTheme
7069

71-
@OptIn(ExperimentalMaterial3Api::class)
7270
@Composable
7371
fun FadeThroughDemo() {
7472
SimpleScaffold(title = Demo.FadeThrough.title) {

MotionCompose/app/src/main/java/com/example/android/compose/motion/demo/loading/LoadingDemo.kt

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ import androidx.compose.animation.core.keyframes
2626
import androidx.compose.animation.core.tween
2727
import androidx.compose.foundation.Image
2828
import androidx.compose.foundation.layout.Row
29+
import androidx.compose.foundation.layout.WindowInsets
30+
import androidx.compose.foundation.layout.asPaddingValues
2931
import androidx.compose.foundation.layout.fillMaxSize
3032
import androidx.compose.foundation.layout.fillMaxWidth
33+
import androidx.compose.foundation.layout.navigationBars
3134
import androidx.compose.foundation.layout.padding
3235
import androidx.compose.foundation.layout.size
36+
import androidx.compose.foundation.layout.statusBarsPadding
3337
import androidx.compose.foundation.lazy.LazyColumn
3438
import androidx.compose.foundation.shape.CircleShape
3539
import androidx.compose.material.icons.Icons
@@ -63,8 +67,6 @@ import androidx.paging.compose.collectAsLazyPagingItems
6367
import androidx.paging.compose.itemsIndexed
6468
import com.example.android.compose.motion.demo.Cheese
6569
import com.example.android.compose.motion.demo.Demo
66-
import com.google.accompanist.insets.LocalWindowInsets
67-
import com.google.accompanist.insets.rememberInsetsPaddingValues
6870
import com.google.accompanist.placeholder.PlaceholderHighlight
6971
import com.google.accompanist.placeholder.fade
7072
import com.google.accompanist.placeholder.placeholder
@@ -91,20 +93,13 @@ private fun LoadingDemoContent(
9193
cheeses: LazyPagingItems<Cheese>,
9294
onRefresh: () -> Unit
9395
) {
94-
val systemBars = LocalWindowInsets.current.systemBars
9596
Scaffold(
9697
topBar = {
9798
SmallTopAppBar(
9899
title = {
99100
Text(text = Demo.Loading.title)
100101
},
101-
modifier = Modifier
102-
.padding(
103-
rememberInsetsPaddingValues(
104-
insets = systemBars,
105-
applyBottom = false
106-
)
107-
),
102+
modifier = Modifier.statusBarsPadding(),
108103
actions = {
109104
IconButton(onClick = onRefresh) {
110105
Icon(
@@ -115,14 +110,13 @@ private fun LoadingDemoContent(
115110
}
116111
)
117112
}
118-
) {
113+
) { padding ->
119114
val startTimeMillis = remember(cheeses) { SystemClock.uptimeMillis() }
120115
LazyColumn(
121-
modifier = Modifier.fillMaxSize(),
122-
contentPadding = rememberInsetsPaddingValues(
123-
insets = systemBars,
124-
applyTop = false
125-
)
116+
modifier = Modifier
117+
.fillMaxSize()
118+
.padding(padding),
119+
contentPadding = WindowInsets.navigationBars.asPaddingValues()
126120
) {
127121
itemsIndexed(items = cheeses) { index, cheese ->
128122
// Calculate the offset used to animate the placeholder.

MotionCompose/app/src/main/java/com/example/android/compose/motion/demo/sharedaxis/SharedAxisDemo.kt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import androidx.compose.foundation.layout.Column
3838
import androidx.compose.foundation.layout.Row
3939
import androidx.compose.foundation.layout.aspectRatio
4040
import androidx.compose.foundation.layout.fillMaxWidth
41+
import androidx.compose.foundation.layout.navigationBarsPadding
4142
import androidx.compose.foundation.layout.padding
4243
import androidx.compose.foundation.layout.size
4344
import androidx.compose.foundation.layout.wrapContentSize
@@ -71,8 +72,6 @@ import com.example.android.compose.motion.demo.CheeseNames
7172
import com.example.android.compose.motion.demo.Demo
7273
import com.example.android.compose.motion.demo.SimpleScaffold
7374
import com.example.android.compose.motion.ui.MotionComposeTheme
74-
import com.google.accompanist.insets.LocalWindowInsets
75-
import com.google.accompanist.insets.rememberInsetsPaddingValues
7675

7776
@Composable
7877
fun SharedAxisDemo() {
@@ -249,18 +248,10 @@ private fun PageContent(
249248
page: Page,
250249
modifier: Modifier = Modifier
251250
) {
252-
val systemBars = LocalWindowInsets.current.systemBars
253251
Column(
254252
modifier = modifier
255253
.verticalScroll(rememberScrollState())
256-
.padding(
257-
rememberInsetsPaddingValues(
258-
insets = systemBars,
259-
applyStart = false,
260-
applyTop = false,
261-
additionalBottom = 16.dp
262-
)
263-
),
254+
.navigationBarsPadding(),
264255
verticalArrangement = Arrangement.spacedBy(16.dp)
265256
) {
266257
Image(

MotionCompose/app/src/main/java/com/example/android/compose/motion/demo/sharedtransform/SharedTransformDemo.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import androidx.compose.foundation.layout.size
3333
import androidx.compose.foundation.layout.widthIn
3434
import androidx.compose.foundation.shape.CircleShape
3535
import androidx.compose.foundation.shape.RoundedCornerShape
36-
import androidx.compose.material.Divider
36+
import androidx.compose.material3.Divider
3737
import androidx.compose.material3.MaterialTheme
3838
import androidx.compose.material3.Surface
3939
import androidx.compose.material3.Text
@@ -131,7 +131,7 @@ private fun DemoCard(
131131
Color.Transparent
132132
}
133133
}
134-
Divider( // TODO: Replace with Material3 Divider when it's available.
134+
Divider(
135135
modifier = Modifier.constrainAs(divider) {
136136
top.linkTo(content.bottom)
137137
start.linkTo(parent.start)

MotionCompose/app/src/main/java/com/example/android/compose/motion/ui/Main.kt

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,23 @@ import androidx.compose.runtime.saveable.rememberSaveable
2525
import androidx.compose.runtime.setValue
2626
import com.example.android.compose.motion.demo.Demo
2727
import com.example.android.compose.motion.ui.home.Home
28-
import com.google.accompanist.insets.ProvideWindowInsets
2928

3029
@Composable
3130
fun Main() {
32-
ProvideWindowInsets {
33-
MotionComposeTheme {
34-
var currentDemo: Demo? by rememberSaveable {
35-
mutableStateOf(null)
36-
}
37-
Crossfade(targetState = currentDemo) { targetDemo ->
38-
if (targetDemo == null) {
39-
Home(
40-
onDemoSelected = { demo ->
41-
currentDemo = demo
42-
}
43-
)
44-
} else {
45-
targetDemo.content()
46-
BackHandler { currentDemo = null }
47-
}
31+
MotionComposeTheme {
32+
var currentDemo: Demo? by rememberSaveable {
33+
mutableStateOf(null)
34+
}
35+
Crossfade(targetState = currentDemo) { targetDemo ->
36+
if (targetDemo == null) {
37+
Home(
38+
onDemoSelected = { demo ->
39+
currentDemo = demo
40+
}
41+
)
42+
} else {
43+
targetDemo.content()
44+
BackHandler { currentDemo = null }
4845
}
4946
}
5047
}

MotionCompose/app/src/main/java/com/example/android/compose/motion/ui/Theme.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import androidx.compose.ui.graphics.Color
3030
import androidx.compose.ui.graphics.toArgb
3131
import androidx.compose.ui.platform.LocalContext
3232
import androidx.compose.ui.platform.LocalView
33-
import androidx.core.view.ViewCompat
33+
import androidx.core.view.WindowCompat
3434

3535
val Purple80 = Color(0xFFD0BCFF)
3636
val PurpleGrey80 = Color(0xFFCCC2DC)
@@ -69,8 +69,9 @@ fun MotionComposeTheme(
6969
val view = LocalView.current
7070
if (!view.isInEditMode) {
7171
SideEffect {
72-
(view.context as Activity).window.statusBarColor = colorScheme.primary.toArgb()
73-
ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = darkTheme
72+
val window = (view.context as Activity).window
73+
window.statusBarColor = colorScheme.primary.toArgb()
74+
WindowCompat.getInsetsController(window, view)?.isAppearanceLightStatusBars = darkTheme
7475
}
7576
}
7677

MotionCompose/app/src/main/java/com/example/android/compose/motion/ui/home/Home.kt

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@ package com.example.android.compose.motion.ui.home
1919
import androidx.compose.foundation.border
2020
import androidx.compose.foundation.layout.Arrangement
2121
import androidx.compose.foundation.layout.Column
22+
import androidx.compose.foundation.layout.WindowInsets
23+
import androidx.compose.foundation.layout.asPaddingValues
2224
import androidx.compose.foundation.layout.fillMaxSize
2325
import androidx.compose.foundation.layout.fillMaxWidth
26+
import androidx.compose.foundation.layout.navigationBars
2427
import androidx.compose.foundation.layout.padding
28+
import androidx.compose.foundation.layout.statusBarsPadding
2529
import androidx.compose.foundation.lazy.LazyColumn
2630
import androidx.compose.foundation.lazy.items
2731
import androidx.compose.foundation.shape.RoundedCornerShape
28-
import androidx.compose.material.ripple.rememberRipple
2932
import androidx.compose.material3.ExperimentalMaterial3Api
3033
import androidx.compose.material3.MaterialTheme
3134
import androidx.compose.material3.Scaffold
@@ -41,34 +44,29 @@ import com.example.android.compose.motion.R
4144
import com.example.android.compose.motion.demo.Demo
4245
import com.example.android.compose.motion.ui.MotionComposeTheme
4346
import com.google.accompanist.flowlayout.FlowRow
44-
import com.google.accompanist.insets.LocalWindowInsets
45-
import com.google.accompanist.insets.rememberInsetsPaddingValues
4647

4748
@OptIn(ExperimentalMaterial3Api::class)
4849
@Composable
4950
fun Home(
5051
onDemoSelected: (demo: Demo) -> Unit
5152
) {
53+
WindowInsets
5254
Scaffold(
5355
topBar = {
5456
SmallTopAppBar(
5557
title = {
5658
Text(text = stringResource(R.string.app_name))
5759
},
5860
modifier = Modifier
59-
.padding(
60-
rememberInsetsPaddingValues(
61-
insets = LocalWindowInsets.current.systemBars,
62-
applyBottom = false
63-
)
64-
)
61+
.statusBarsPadding()
6562
)
6663
}
67-
) {
64+
) { innerPadding ->
6865
DemoList(
6966
onDemoSelected = onDemoSelected,
7067
modifier = Modifier
7168
.fillMaxSize()
69+
.padding(innerPadding)
7270
)
7371
}
7472
}
@@ -80,10 +78,7 @@ private fun DemoList(
8078
) {
8179
LazyColumn(
8280
modifier = modifier,
83-
contentPadding = rememberInsetsPaddingValues(
84-
insets = LocalWindowInsets.current.systemBars,
85-
applyTop = false
86-
),
81+
contentPadding = WindowInsets.navigationBars.asPaddingValues(),
8782
verticalArrangement = Arrangement.spacedBy(8.dp)
8883
) {
8984
items(items = Demo.values()) { demo ->
@@ -98,6 +93,7 @@ private fun DemoList(
9893
}
9994
}
10095

96+
@OptIn(ExperimentalMaterial3Api::class)
10197
@Composable
10298
private fun DemoCard(
10399
demo: Demo,
@@ -108,8 +104,7 @@ private fun DemoCard(
108104
modifier = modifier,
109105
tonalElevation = 2.dp,
110106
shape = RoundedCornerShape(16.dp),
111-
onClick = onClick,
112-
indication = rememberRipple()
107+
onClick = onClick
113108
) {
114109
Column(
115110
modifier = Modifier.padding(16.dp),

MotionCompose/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
buildscript {
1818
ext {
19-
compose_version = '1.1.0-rc01'
19+
compose_version = '1.2.0-beta03'
2020
}
2121
}
2222

2323
plugins {
2424
id 'com.android.application' version '7.2.1' apply false
2525
id 'com.android.library' version '7.2.1' apply false
26-
id 'org.jetbrains.kotlin.android' version '1.6.0' apply false
26+
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
2727
}
2828

2929
task clean(type: Delete) {

0 commit comments

Comments
 (0)