Skip to content

Commit f46b279

Browse files
committed
Clean up line length modifications and add trailing commas
1 parent 6b3c64f commit f46b279

File tree

6 files changed

+48
-56
lines changed

6 files changed

+48
-56
lines changed

compose/snippets/src/main/java/com/example/compose/snippets/adaptivelayouts/SampleSupportingPaneScaffold.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,10 @@ fun SampleNavigableSupportingPaneScaffoldFull() {
7373
.safeContentPadding()
7474
.background(Color.Red)
7575
) {
76-
if (
77-
scaffoldNavigator
78-
.scaffoldValue[SupportingPaneScaffoldRole.Supporting] ==
79-
PaneAdaptedValue.Hidden
80-
) {
76+
val shouldShowSupportingPane =
77+
scaffoldNavigator.scaffoldValue[SupportingPaneScaffoldRole.Supporting] ==
78+
PaneAdaptedValue.Hidden
79+
if (shouldShowSupportingPane) {
8180
Button(
8281
modifier = Modifier
8382
.wrapContentSize(),
@@ -151,7 +150,7 @@ fun SampleNavigableSupportingPaneScaffoldSimplified() {
151150
mainPane = {
152151
MainPane(
153152
shouldShowSupportingPaneButton =
154-
scaffoldNavigator.scaffoldValue.secondary == PaneAdaptedValue.Hidden,
153+
scaffoldNavigator.scaffoldValue.secondary == PaneAdaptedValue.Hidden,
155154
onNavigateToSupportingPane = {
156155
scope.launch {
157156
scaffoldNavigator.navigateTo(ThreePaneScaffoldRole.Secondary)

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ private fun AnimatedVisibilitySharedElementShortenedExample() {
9090
.fillMaxSize()
9191
.background(Color.LightGray.copy(alpha = 0.5f))
9292
.padding(16.dp),
93-
verticalArrangement = Arrangement.spacedBy(8.dp)
93+
verticalArrangement = Arrangement.spacedBy(8.dp),
9494
// [END_EXCLUDE]
9595
) {
9696
items(listSnacks) { snack ->
9797
AnimatedVisibility(
9898
visible = snack != selectedSnack,
9999
enter = fadeIn() + scaleIn(),
100100
exit = fadeOut() + scaleOut(),
101-
modifier = Modifier.animateItem()
101+
modifier = Modifier.animateItem(),
102102
) {
103103
Box(
104104
modifier = Modifier
@@ -123,7 +123,7 @@ private fun AnimatedVisibilitySharedElementShortenedExample() {
123123
),
124124
onClick = {
125125
selectedSnack = snack
126-
}
126+
},
127127
)
128128
}
129129
}
@@ -134,7 +134,7 @@ private fun AnimatedVisibilitySharedElementShortenedExample() {
134134
snack = selectedSnack,
135135
onConfirmClick = {
136136
selectedSnack = null
137-
}
137+
},
138138
)
139139
}
140140
// [END android_compose_shared_elements_animated_visibility]
@@ -144,19 +144,19 @@ private fun AnimatedVisibilitySharedElementShortenedExample() {
144144
fun SharedTransitionScope.SnackEditDetails(
145145
snack: Snack?,
146146
modifier: Modifier = Modifier,
147-
onConfirmClick: () -> Unit
147+
onConfirmClick: () -> Unit,
148148
) {
149149
AnimatedContent(
150150
modifier = modifier,
151151
targetState = snack,
152152
transitionSpec = {
153153
fadeIn() togetherWith fadeOut()
154154
},
155-
label = "SnackEditDetails"
155+
label = "SnackEditDetails",
156156
) { targetSnack ->
157157
Box(
158158
modifier = Modifier.fillMaxSize(),
159-
contentAlignment = Alignment.Center
159+
contentAlignment = Alignment.Center,
160160
) {
161161
if (targetSnack != null) {
162162
Box(
@@ -165,7 +165,7 @@ fun SharedTransitionScope.SnackEditDetails(
165165
.clickable {
166166
onConfirmClick()
167167
}
168-
.background(Color.Black.copy(alpha = 0.5f))
168+
.background(Color.Black.copy(alpha = 0.5f)),
169169
)
170170
Column(
171171
modifier = Modifier
@@ -176,10 +176,10 @@ fun SharedTransitionScope.SnackEditDetails(
176176
),
177177
animatedVisibilityScope = this@AnimatedContent,
178178
clipInOverlayDuringTransition =
179-
OverlayClip(shapeForSharedElement)
179+
OverlayClip(shapeForSharedElement),
180180
)
181181
.background(Color.White, shapeForSharedElement)
182-
.clip(shapeForSharedElement)
182+
.clip(shapeForSharedElement),
183183
) {
184184

185185
SnackContents(
@@ -196,7 +196,7 @@ fun SharedTransitionScope.SnackEditDetails(
196196
Modifier
197197
.fillMaxWidth()
198198
.padding(bottom = 8.dp, end = 8.dp),
199-
horizontalArrangement = Arrangement.End
199+
horizontalArrangement = Arrangement.End,
200200
) {
201201
TextButton(onClick = { onConfirmClick() }) {
202202
Text(text = "Save changes")
@@ -212,7 +212,7 @@ fun SharedTransitionScope.SnackEditDetails(
212212
fun SnackContents(
213213
snack: Snack,
214214
modifier: Modifier = Modifier,
215-
onClick: () -> Unit
215+
onClick: () -> Unit,
216216
) {
217217
Column(
218218
modifier = modifier
@@ -221,22 +221,22 @@ fun SnackContents(
221221
indication = null
222222
) {
223223
onClick()
224-
}
224+
},
225225
) {
226226
Image(
227227
painter = painterResource(id = snack.image),
228228
modifier = Modifier
229229
.fillMaxWidth()
230230
.aspectRatio(20f / 9f),
231231
contentScale = ContentScale.Crop,
232-
contentDescription = null
232+
contentDescription = null,
233233
)
234234
Text(
235235
text = snack.name,
236236
modifier = Modifier
237237
.wrapContentWidth()
238238
.padding(8.dp),
239-
style = MaterialTheme.typography.titleSmall
239+
style = MaterialTheme.typography.titleSmall,
240240
)
241241
}
242242
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ fun SharedElement_PredictiveBack() {
7070
val navController = rememberNavController()
7171
NavHost(
7272
navController = navController,
73-
startDestination = "home"
73+
startDestination = "home",
7474
) {
7575
composable("home") {
7676
HomeScreen(
7777
this@SharedTransitionLayout,
7878
this@composable,
79-
{ navController.navigate("details/$it") }
79+
{ navController.navigate("details/$it") },
8080
)
8181
}
8282
composable(
8383
"details/{item}",
84-
arguments = listOf(navArgument("item") { type = NavType.IntType })
84+
arguments = listOf(navArgument("item") { type = NavType.IntType }),
8585
) { backStackEntry ->
8686
val id = backStackEntry.arguments?.getInt("item")
8787
val snack = listSnacks[id!!]
@@ -92,7 +92,7 @@ fun SharedElement_PredictiveBack() {
9292
this@composable,
9393
{
9494
navController.navigate("home")
95-
}
95+
},
9696
)
9797
}
9898
}
@@ -105,7 +105,7 @@ fun DetailsScreen(
105105
snack: Snack,
106106
sharedTransitionScope: SharedTransitionScope,
107107
animatedContentScope: AnimatedContentScope,
108-
onBackPressed: () -> Unit
108+
onBackPressed: () -> Unit,
109109
) {
110110
with(sharedTransitionScope) {
111111
Column(
@@ -126,7 +126,7 @@ fun DetailsScreen(
126126
animatedVisibilityScope = animatedContentScope
127127
)
128128
.aspectRatio(1f)
129-
.fillMaxWidth()
129+
.fillMaxWidth(),
130130
)
131131
Text(
132132
text = snack.name,
@@ -137,7 +137,7 @@ fun DetailsScreen(
137137
.rememberSharedContentState(key = "text-$id"),
138138
animatedVisibilityScope = animatedContentScope
139139
)
140-
.fillMaxWidth()
140+
.fillMaxWidth(),
141141
)
142142
}
143143
}
@@ -153,7 +153,7 @@ fun HomeScreen(
153153
modifier = Modifier
154154
.fillMaxSize()
155155
.padding(8.dp),
156-
verticalArrangement = Arrangement.spacedBy(8.dp)
156+
verticalArrangement = Arrangement.spacedBy(8.dp),
157157
) {
158158
itemsIndexed(listSnacks) { index, item ->
159159
Row(
@@ -195,6 +195,6 @@ fun HomeScreen(
195195
data class Snack(
196196
val name: String,
197197
val description: String,
198-
@DrawableRes val image: Int
198+
@DrawableRes val image: Int,
199199
)
200200
// [END android_compose_shared_element_predictive_back]

compose/snippets/src/main/java/com/example/compose/snippets/components/SwipeToDismissBox.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fun SwipeToDismissBoxExamples() {
7070
// [START android_compose_components_todoitem]
7171
data class TodoItem(
7272
val itemDescription: String,
73-
var isItemDone: Boolean = false
73+
var isItemDone: Boolean = false,
7474
)
7575
// [END android_compose_components_todoitem]
7676

@@ -88,7 +88,7 @@ fun TodoListItem(
8888
else if (it == EndToStart) onRemove(todoItem)
8989
// Reset item when toggling done status
9090
it != StartToEnd
91-
}
91+
},
9292
)
9393

9494
SwipeToDismissBox(
@@ -126,11 +126,11 @@ fun TodoListItem(
126126
}
127127
Settled -> {}
128128
}
129-
}
129+
},
130130
) {
131131
ListItem(
132132
headlineContent = { Text(todoItem.itemDescription) },
133-
supportingContent = { Text("swipe me to update or remove.") }
133+
supportingContent = { Text("swipe me to update or remove.") },
134134
)
135135
}
136136
}
@@ -143,14 +143,14 @@ private fun SwipeItemExample() {
143143
val todoItems = remember {
144144
mutableStateListOf(
145145
TodoItem("Pay bills"), TodoItem("Buy groceries"),
146-
TodoItem("Go to gym"), TodoItem("Get dinner")
146+
TodoItem("Go to gym"), TodoItem("Get dinner"),
147147
)
148148
}
149149

150150
LazyColumn {
151151
items(
152152
items = todoItems,
153-
key = { it.itemDescription }
153+
key = { it.itemDescription },
154154
) { todoItem ->
155155
TodoListItem(
156156
todoItem = todoItem,
@@ -160,7 +160,7 @@ private fun SwipeItemExample() {
160160
onRemove = { todoItem ->
161161
todoItems -= todoItem
162162
},
163-
modifier = Modifier.animateItem()
163+
modifier = Modifier.animateItem(),
164164
)
165165
}
166166
}
@@ -181,7 +181,7 @@ fun TodoListItemWithAnimation(
181181
else if (it == EndToStart) onRemove(todoItem)
182182
// Reset item when toggling done status
183183
it != StartToEnd
184-
}
184+
},
185185
)
186186

187187
SwipeToDismissBox(
@@ -210,7 +210,7 @@ fun TodoListItemWithAnimation(
210210
}
211211
.wrapContentSize(Alignment.CenterStart)
212212
.padding(12.dp),
213-
tint = Color.White
213+
tint = Color.White,
214214
)
215215
}
216216
EndToStart -> {
@@ -228,7 +228,7 @@ fun TodoListItemWithAnimation(
228228
)
229229
.wrapContentSize(Alignment.CenterEnd)
230230
.padding(12.dp),
231-
tint = Color.White
231+
tint = Color.White,
232232
)
233233
}
234234
Settled -> {}
@@ -238,7 +238,7 @@ fun TodoListItemWithAnimation(
238238
OutlinedCard(shape = RectangleShape) {
239239
ListItem(
240240
headlineContent = { Text(todoItem.itemDescription) },
241-
supportingContent = { Text("swipe me to update or remove.") }
241+
supportingContent = { Text("swipe me to update or remove.") },
242242
)
243243
}
244244
}
@@ -252,14 +252,14 @@ private fun SwipeItemWithAnimationExample() {
252252
val todoItems = remember {
253253
mutableStateListOf(
254254
TodoItem("Pay bills"), TodoItem("Buy groceries"),
255-
TodoItem("Go to gym"), TodoItem("Get dinner")
255+
TodoItem("Go to gym"), TodoItem("Get dinner"),
256256
)
257257
}
258258

259259
LazyColumn {
260260
items(
261261
items = todoItems,
262-
key = { it.itemDescription }
262+
key = { it.itemDescription },
263263
) { todoItem ->
264264
TodoListItemWithAnimation(
265265
todoItem = todoItem,
@@ -269,7 +269,7 @@ private fun SwipeItemWithAnimationExample() {
269269
onRemove = { todoItem ->
270270
todoItems -= todoItem
271271
},
272-
modifier = Modifier.animateItem()
272+
modifier = Modifier.animateItem(),
273273
)
274274
}
275275
}

compose/snippets/src/main/java/com/example/compose/snippets/graphics/ShapesSnippets.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,14 +352,7 @@ private fun MorphOnClick() {
352352
}
353353

354354
// [START android_compose_shapes_polygon_compose_shape]
355-
fun RoundedPolygon.getBounds() = calculateBounds().let {
356-
Rect(
357-
left = it[0],
358-
top = it[1],
359-
right = it[2],
360-
bottom = it[3],
361-
)
362-
}
355+
fun RoundedPolygon.getBounds() = calculateBounds().let { Rect(it[0], it[1], it[2], it[3]) }
363356
class RoundedPolygonShape(
364357
private val polygon: RoundedPolygon,
365358
private var matrix: Matrix = Matrix()

compose/snippets/src/main/java/com/example/compose/snippets/lists/LazyListSnippets.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,14 +461,14 @@ private fun LazyItemAnimationWithSpec() {
461461
LazyColumn {
462462
items(books, key = { it.id }) {
463463
Row(
464-
Modifier.animateItem(
464+
modifier = Modifier.animateItem(
465465
fadeInSpec = tween(durationMillis = 250),
466466
fadeOutSpec = tween(durationMillis = 100),
467467
placementSpec = spring(
468468
stiffness = Spring.StiffnessLow,
469-
dampingRatio = Spring.DampingRatioMediumBouncy
470-
)
471-
)
469+
dampingRatio = Spring.DampingRatioMediumBouncy,
470+
),
471+
),
472472
) {
473473
// ...
474474
}

0 commit comments

Comments
 (0)