@@ -6,33 +6,18 @@ import androidx.compose.foundation.Image
6
6
import androidx.compose.foundation.background
7
7
import androidx.compose.foundation.clickable
8
8
import androidx.compose.foundation.layout.*
9
- import androidx.compose.foundation.lazy.LazyRow
10
- import androidx.compose.foundation.shape.CircleShape
11
- import androidx.compose.foundation.shape.RoundedCornerShape
12
9
import androidx.compose.material.Button
13
- import androidx.compose.material.Icon
14
10
import androidx.compose.material.Text
15
- import androidx.compose.material.icons.Icons
16
- import androidx.compose.material.icons.filled.Close
17
- import androidx.compose.material.icons.filled.PlayArrow
18
11
import androidx.compose.runtime.*
19
12
import androidx.compose.ui.Modifier
20
- import androidx.compose.ui.draw.clip
21
13
import androidx.compose.ui.graphics.Color
22
14
import androidx.compose.ui.layout.layoutId
23
15
import androidx.compose.ui.res.painterResource
24
- import androidx.compose.ui.text.style.TextAlign
25
16
import androidx.compose.ui.tooling.preview.Preview
26
17
import androidx.compose.ui.unit.dp
27
- import androidx.compose.ui.unit.sp
28
- import androidx.compose.ui.zIndex
29
18
import androidx.constraintlayout.compose.ConstraintSet
30
19
import androidx.constraintlayout.compose.MotionLayout
31
- import androidx.constraintlayout.compose.layoutId
32
20
import com.guru.composecookbook.data.AlbumsDataProvider
33
- import com.guru.composecookbook.data.DemoDataProvider
34
- import com.guru.composecookbook.moviesapp.ui.home.components.imageIds
35
- import com.guru.fontawesomecomposelib.FaIcon
36
21
37
22
@Preview(group = " motion7" )
38
23
@Composable
@@ -56,47 +41,47 @@ private fun ButtonsMotionExample() {
56
41
ConstraintSet (
57
42
""" {
58
43
button1: {
59
- width: "spread",
60
- height: 60,
61
- start: ['parent', 'start', 16],
62
- end: ['parent', 'end', 16],
63
- top: ['parent', 'top', 16]
44
+ width: "spread",
45
+ height: 60,
46
+ start: ['parent', 'start', 16],
47
+ end: ['parent', 'end', 16],
48
+ top: ['parent', 'top', 16]
64
49
},
65
50
button2: {
66
- width: "spread",
67
- height: 60,
68
- start: ['parent', 'start', 16],
69
- end: ['parent', 'end', 16],
70
- top: ['button1', 'bottom', 16]
51
+ width: "spread",
52
+ height: 60,
53
+ start: ['parent', 'start', 16],
54
+ end: ['parent', 'end', 16],
55
+ top: ['button1', 'bottom', 16]
71
56
},
72
- button3: {
73
- width: "spread",
74
- height: 60,
75
- start: ['parent', 'start', 16],
76
- end: ['parent', 'end', 16],
77
- top: ['button2', 'bottom', 16]
57
+ button3: {
58
+ width: "spread",
59
+ height: 60,
60
+ start: ['parent', 'start', 16],
61
+ end: ['parent', 'end', 16],
62
+ top: ['button2', 'bottom', 16]
78
63
}
79
64
} """
80
65
),
81
66
ConstraintSet (
82
67
""" {
83
- button1: {
84
- width: 100,
85
- height: 60,
86
- start: ['parent', 'start', 16],
87
- end: ['button2', 'start', 16]
68
+ button1: {
69
+ width: 100,
70
+ height: 60,
71
+ start: ['parent', 'start', 16],
72
+ end: ['button2', 'start', 16]
88
73
},
89
- button2: {
90
- width: 100,
91
- height: 60,
92
- start: ['button1', 'end', 16],
93
- end: ['button2', 'start', 16]
74
+ button2: {
75
+ width: 100,
76
+ height: 60,
77
+ start: ['button1', 'end', 16],
78
+ end: ['button2', 'start', 16]
94
79
},
95
- button3: {
96
- width: 100,
97
- height: 60,
98
- start: ['button2', 'end', 16],
99
- end: ['parent', 'end', 16]
80
+ button3: {
81
+ width: 100,
82
+ height: 60,
83
+ start: ['button2', 'end', 16],
84
+ end: ['parent', 'end', 16]
100
85
}
101
86
} """
102
87
),
@@ -107,20 +92,20 @@ private fun ButtonsMotionExample() {
107
92
.background(Color .White )
108
93
) {
109
94
Button (
110
- onClick = { animateButton = ! animateButton }, modifier = Modifier .layoutId
111
- (" button1" )
95
+ onClick = { animateButton = ! animateButton },
96
+ modifier = Modifier .layoutId (" button1" )
112
97
) {
113
98
Text (text = " Button1" )
114
99
}
115
100
Button (
116
- onClick = { animateButton = ! animateButton }, modifier = Modifier .layoutId
117
- (" button2" )
101
+ onClick = { animateButton = ! animateButton },
102
+ modifier = Modifier .layoutId (" button2" )
118
103
) {
119
104
Text (text = " Button2" )
120
105
}
121
106
Button (
122
- onClick = { animateButton = ! animateButton }, modifier = Modifier .layoutId
123
- (" button3" )
107
+ onClick = { animateButton = ! animateButton },
108
+ modifier = Modifier .layoutId (" button3" )
124
109
) {
125
110
Text (text = " Button3" )
126
111
}
@@ -138,51 +123,51 @@ private fun ImageMotionExample() {
138
123
MotionLayout (
139
124
ConstraintSet (
140
125
""" {
141
- image1: {
142
- width: 150,
143
- height: 150,
144
- start: ['parent', 'start', 16]
126
+ image1: {
127
+ width: 150,
128
+ height: 150,
129
+ start: ['parent', 'start', 16]
145
130
},
146
- image2: {
147
- width: 150,
148
- height: 150,
149
- start: ['parent', 'start', 24]
131
+ image2: {
132
+ width: 150,
133
+ height: 150,
134
+ start: ['parent', 'start', 24]
150
135
},
151
- image3: {
152
- width: 150,
153
- height: 150,
154
- start: ['parent', 'start', 32]
136
+ image3: {
137
+ width: 150,
138
+ height: 150,
139
+ start: ['parent', 'start', 32]
155
140
},
156
- image4: {
157
- width: 150,
158
- height: 150,
159
- start: ['parent', 'start', 40]
141
+ image4: {
142
+ width: 150,
143
+ height: 150,
144
+ start: ['parent', 'start', 40]
160
145
}
161
146
} """
162
147
),
163
148
ConstraintSet (
164
149
""" {
165
- image1: {
166
- width: 150,
167
- height: 150,
168
- start: ['parent', 'start', 16]
150
+ image1: {
151
+ width: 150,
152
+ height: 150,
153
+ start: ['parent', 'start', 16]
169
154
},
170
- image2: {
171
- width: 150,
172
- height: 150,
173
- start: ['image1', 'end', 16]
155
+ image2: {
156
+ width: 150,
157
+ height: 150,
158
+ start: ['image1', 'end', 16]
174
159
},
175
- image3: {
176
- width: 150,
177
- height: 150,
178
- start: ['parent', 'start', 16],
179
- top: ['image1', 'bottom', 16]
160
+ image3: {
161
+ width: 150,
162
+ height: 150,
163
+ start: ['parent', 'start', 16],
164
+ top: ['image1', 'bottom', 16]
180
165
},
181
- image4: {
182
- width: 150,
183
- height: 150,
184
- start: ['image1', 'end', 16],
185
- top: ['image1', 'bottom', 16]
166
+ image4: {
167
+ width: 150,
168
+ height: 150,
169
+ start: ['image1', 'end', 16],
170
+ top: ['image1', 'bottom', 16]
186
171
}
187
172
} """
188
173
),
@@ -191,19 +176,27 @@ private fun ImageMotionExample() {
191
176
.fillMaxSize()
192
177
.background(Color .White )
193
178
) {
194
- Image (painter = painterResource(id = albums[0 ].imageId), contentDescription = " " ,
179
+ Image (
180
+ painter = painterResource(id = albums[0 ].imageId),
181
+ contentDescription = " " ,
195
182
modifier = Modifier
196
183
.layoutId(" image1" )
197
184
.clickable { animateImage = ! animateImage })
198
- Image (painter = painterResource(id = albums[1 ].imageId), contentDescription = " " ,
185
+ Image (
186
+ painter = painterResource(id = albums[1 ].imageId),
187
+ contentDescription = " " ,
199
188
modifier = Modifier
200
189
.layoutId(" image2" )
201
190
.clickable { animateImage = ! animateImage })
202
- Image (painter = painterResource(id = albums[2 ].imageId), contentDescription = " " ,
191
+ Image (
192
+ painter = painterResource(id = albums[2 ].imageId),
193
+ contentDescription = " " ,
203
194
modifier = Modifier
204
195
.layoutId(" image3" )
205
196
.clickable { animateImage = ! animateImage })
206
- Image (painter = painterResource(id = albums[3 ].imageId), contentDescription = " " ,
197
+ Image (
198
+ painter = painterResource(id = albums[3 ].imageId),
199
+ contentDescription = " " ,
207
200
modifier = Modifier
208
201
.layoutId(" image4" )
209
202
.clickable { animateImage = ! animateImage })
0 commit comments