all: refactor Modifier ordering

Drawns on the suggestions outlined in https://chris.banes.dev/always-provide-a-modifier/
This commit is contained in:
Harsh Shandilya 2021-10-25 00:47:52 +05:30
parent 2606f2e79b
commit cfd0725605
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
7 changed files with 15 additions and 14 deletions

View file

@ -41,7 +41,7 @@ fun ClawFab(
targetOffsetY = { fullHeight -> fullHeight },
animationSpec = tween(durationMillis = AnimationDuration, easing = FastOutLinearInEasing),
),
modifier = Modifier.then(modifier),
modifier = modifier,
) {
FloatingActionButton(onClick = { coroutineScope.launch { listState.animateScrollToItem(0) } }) {
Icon(

View file

@ -37,7 +37,7 @@ fun HottestPosts(
listState = listState,
isSaved = isPostSaved,
postActions = postActions,
modifier = Modifier.padding(top = 16.dp).then(modifier),
modifier = modifier.padding(top = 16.dp),
)
}
}

View file

@ -31,7 +31,7 @@ fun NetworkPosts(
val coroutineScope = rememberCoroutineScope()
LazyColumn(
state = listState,
modifier = Modifier.then(modifier),
modifier = modifier,
) {
items(items) { item ->
if (item != null) {

View file

@ -22,6 +22,6 @@ fun ClawAppBar(
modifier = Modifier.padding(horizontal = 16.dp),
)
},
modifier = Modifier.then(modifier),
modifier = modifier,
)
}

View file

@ -24,6 +24,6 @@ actual fun NetworkImage(
},
),
contentDescription = contentDescription,
modifier = Modifier.then(modifier),
modifier = modifier,
)
}

View file

@ -44,7 +44,7 @@ fun LobstersCard(
modifier: Modifier = Modifier,
) {
Card(
modifier = Modifier.background(MaterialTheme.colors.primarySurface).then(modifier),
modifier = modifier.background(MaterialTheme.colors.primarySurface),
onClick = { postActions.viewPost(post.url, post.commentsUrl) },
) {
Column(
@ -100,7 +100,7 @@ fun PostTitle(
text = title,
color = titleColor,
fontWeight = FontWeight.Bold,
modifier = Modifier.then(modifier),
modifier = modifier,
)
}
@ -112,7 +112,7 @@ fun SubmitterName(
modifier: Modifier = Modifier,
) {
Row(
modifier = Modifier.then(modifier),
modifier = modifier,
verticalAlignment = Alignment.CenterVertically,
) {
SubmitterAvatar(
@ -130,11 +130,12 @@ fun SubmitterName(
fun SubmitterAvatar(
avatarUrl: String,
contentDescription: String,
modifier: Modifier = Modifier,
) {
NetworkImage(
url = avatarUrl,
contentDescription = contentDescription,
modifier = Modifier.requiredSize(24.dp).clip(CircleShape),
modifier = modifier.requiredSize(24.dp).clip(CircleShape),
)
}
@ -145,7 +146,7 @@ fun SubmitterNameText(
) {
Text(
text = text,
modifier = Modifier.then(modifier),
modifier = modifier,
)
}
@ -158,7 +159,7 @@ fun SaveButton(
IconToggleButton(
checked = isSaved,
onCheckedChange = { onClick.invoke() },
modifier = Modifier.requiredSize(32.dp).then(modifier),
modifier = modifier.requiredSize(32.dp),
) {
Crossfade(targetState = isSaved) { saved ->
Icon(
@ -177,7 +178,7 @@ fun CommentsButton(
) {
IconButton(
onClick = onClick,
modifier = Modifier.requiredSize(32.dp).then(modifier),
modifier = modifier.requiredSize(32.dp),
) {
Icon(
painter = commentIcon,
@ -193,7 +194,7 @@ fun TagRow(
modifier: Modifier = Modifier,
) {
Box(
modifier = Modifier.then(modifier),
modifier = modifier,
) {
FlowRow(
mainAxisSpacing = 8.dp,

View file

@ -14,7 +14,7 @@ actual fun NetworkImage(
KamelImage(
resource = lazyPainterResource(url),
contentDescription = contentDescription,
modifier = Modifier.then(modifier),
modifier = modifier,
crossfade = true,
)
}