Skip to content

Commit ad3b729

Browse files
authored
optimize import and fix indentation (#107)
* optimize import for MotionLayoutDemo.kt * fix indentation
1 parent 6ae0cb8 commit ad3b729

File tree

1 file changed

+83
-90
lines changed

1 file changed

+83
-90
lines changed

app/src/main/java/com/guru/composecookbook/ui/home/motionlayout/MotionLayoutDemo.kt

Lines changed: 83 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,18 @@ import androidx.compose.foundation.Image
66
import androidx.compose.foundation.background
77
import androidx.compose.foundation.clickable
88
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
129
import androidx.compose.material.Button
13-
import androidx.compose.material.Icon
1410
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
1811
import androidx.compose.runtime.*
1912
import androidx.compose.ui.Modifier
20-
import androidx.compose.ui.draw.clip
2113
import androidx.compose.ui.graphics.Color
2214
import androidx.compose.ui.layout.layoutId
2315
import androidx.compose.ui.res.painterResource
24-
import androidx.compose.ui.text.style.TextAlign
2516
import androidx.compose.ui.tooling.preview.Preview
2617
import androidx.compose.ui.unit.dp
27-
import androidx.compose.ui.unit.sp
28-
import androidx.compose.ui.zIndex
2918
import androidx.constraintlayout.compose.ConstraintSet
3019
import androidx.constraintlayout.compose.MotionLayout
31-
import androidx.constraintlayout.compose.layoutId
3220
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
3621

3722
@Preview(group = "motion7")
3823
@Composable
@@ -56,47 +41,47 @@ private fun ButtonsMotionExample() {
5641
ConstraintSet(
5742
""" {
5843
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]
6449
},
6550
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]
7156
},
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]
7863
}
7964
} """
8065
),
8166
ConstraintSet(
8267
""" {
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]
8873
},
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]
9479
},
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]
10085
}
10186
} """
10287
),
@@ -107,20 +92,20 @@ private fun ButtonsMotionExample() {
10792
.background(Color.White)
10893
) {
10994
Button(
110-
onClick = { animateButton = !animateButton }, modifier = Modifier.layoutId
111-
("button1")
95+
onClick = { animateButton = !animateButton },
96+
modifier = Modifier.layoutId("button1")
11297
) {
11398
Text(text = "Button1")
11499
}
115100
Button(
116-
onClick = { animateButton = !animateButton }, modifier = Modifier.layoutId
117-
("button2")
101+
onClick = { animateButton = !animateButton },
102+
modifier = Modifier.layoutId("button2")
118103
) {
119104
Text(text = "Button2")
120105
}
121106
Button(
122-
onClick = { animateButton = !animateButton }, modifier = Modifier.layoutId
123-
("button3")
107+
onClick = { animateButton = !animateButton },
108+
modifier = Modifier.layoutId("button3")
124109
) {
125110
Text(text = "Button3")
126111
}
@@ -138,51 +123,51 @@ private fun ImageMotionExample() {
138123
MotionLayout(
139124
ConstraintSet(
140125
""" {
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]
145130
},
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]
150135
},
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]
155140
},
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]
160145
}
161146
} """
162147
),
163148
ConstraintSet(
164149
""" {
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]
169154
},
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]
174159
},
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]
180165
},
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]
186171
}
187172
} """
188173
),
@@ -191,19 +176,27 @@ private fun ImageMotionExample() {
191176
.fillMaxSize()
192177
.background(Color.White)
193178
) {
194-
Image(painter = painterResource(id = albums[0].imageId), contentDescription = "",
179+
Image(
180+
painter = painterResource(id = albums[0].imageId),
181+
contentDescription = "",
195182
modifier = Modifier
196183
.layoutId("image1")
197184
.clickable { animateImage = !animateImage })
198-
Image(painter = painterResource(id = albums[1].imageId), contentDescription = "",
185+
Image(
186+
painter = painterResource(id = albums[1].imageId),
187+
contentDescription = "",
199188
modifier = Modifier
200189
.layoutId("image2")
201190
.clickable { animateImage = !animateImage })
202-
Image(painter = painterResource(id = albums[2].imageId), contentDescription = "",
191+
Image(
192+
painter = painterResource(id = albums[2].imageId),
193+
contentDescription = "",
203194
modifier = Modifier
204195
.layoutId("image3")
205196
.clickable { animateImage = !animateImage })
206-
Image(painter = painterResource(id = albums[3].imageId), contentDescription = "",
197+
Image(
198+
painter = painterResource(id = albums[3].imageId),
199+
contentDescription = "",
207200
modifier = Modifier
208201
.layoutId("image4")
209202
.clickable { animateImage = !animateImage })

0 commit comments

Comments
 (0)