mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 21:07:04 +05:30
all: refactor Modifier ordering
Drawns on the suggestions outlined in https://chris.banes.dev/always-provide-a-modifier/
This commit is contained in:
parent
2606f2e79b
commit
cfd0725605
7 changed files with 15 additions and 14 deletions
|
@ -41,7 +41,7 @@ fun ClawFab(
|
||||||
targetOffsetY = { fullHeight -> fullHeight },
|
targetOffsetY = { fullHeight -> fullHeight },
|
||||||
animationSpec = tween(durationMillis = AnimationDuration, easing = FastOutLinearInEasing),
|
animationSpec = tween(durationMillis = AnimationDuration, easing = FastOutLinearInEasing),
|
||||||
),
|
),
|
||||||
modifier = Modifier.then(modifier),
|
modifier = modifier,
|
||||||
) {
|
) {
|
||||||
FloatingActionButton(onClick = { coroutineScope.launch { listState.animateScrollToItem(0) } }) {
|
FloatingActionButton(onClick = { coroutineScope.launch { listState.animateScrollToItem(0) } }) {
|
||||||
Icon(
|
Icon(
|
||||||
|
|
|
@ -37,7 +37,7 @@ fun HottestPosts(
|
||||||
listState = listState,
|
listState = listState,
|
||||||
isSaved = isPostSaved,
|
isSaved = isPostSaved,
|
||||||
postActions = postActions,
|
postActions = postActions,
|
||||||
modifier = Modifier.padding(top = 16.dp).then(modifier),
|
modifier = modifier.padding(top = 16.dp),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ fun NetworkPosts(
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
state = listState,
|
state = listState,
|
||||||
modifier = Modifier.then(modifier),
|
modifier = modifier,
|
||||||
) {
|
) {
|
||||||
items(items) { item ->
|
items(items) { item ->
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
|
|
|
@ -22,6 +22,6 @@ fun ClawAppBar(
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
modifier = Modifier.padding(horizontal = 16.dp),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
modifier = Modifier.then(modifier),
|
modifier = modifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,6 @@ actual fun NetworkImage(
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
contentDescription = contentDescription,
|
contentDescription = contentDescription,
|
||||||
modifier = Modifier.then(modifier),
|
modifier = modifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ fun LobstersCard(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier.background(MaterialTheme.colors.primarySurface).then(modifier),
|
modifier = modifier.background(MaterialTheme.colors.primarySurface),
|
||||||
onClick = { postActions.viewPost(post.url, post.commentsUrl) },
|
onClick = { postActions.viewPost(post.url, post.commentsUrl) },
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
|
@ -100,7 +100,7 @@ fun PostTitle(
|
||||||
text = title,
|
text = title,
|
||||||
color = titleColor,
|
color = titleColor,
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
modifier = Modifier.then(modifier),
|
modifier = modifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ fun SubmitterName(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.then(modifier),
|
modifier = modifier,
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
SubmitterAvatar(
|
SubmitterAvatar(
|
||||||
|
@ -130,11 +130,12 @@ fun SubmitterName(
|
||||||
fun SubmitterAvatar(
|
fun SubmitterAvatar(
|
||||||
avatarUrl: String,
|
avatarUrl: String,
|
||||||
contentDescription: String,
|
contentDescription: String,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
NetworkImage(
|
NetworkImage(
|
||||||
url = avatarUrl,
|
url = avatarUrl,
|
||||||
contentDescription = contentDescription,
|
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 = text,
|
text = text,
|
||||||
modifier = Modifier.then(modifier),
|
modifier = modifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +159,7 @@ fun SaveButton(
|
||||||
IconToggleButton(
|
IconToggleButton(
|
||||||
checked = isSaved,
|
checked = isSaved,
|
||||||
onCheckedChange = { onClick.invoke() },
|
onCheckedChange = { onClick.invoke() },
|
||||||
modifier = Modifier.requiredSize(32.dp).then(modifier),
|
modifier = modifier.requiredSize(32.dp),
|
||||||
) {
|
) {
|
||||||
Crossfade(targetState = isSaved) { saved ->
|
Crossfade(targetState = isSaved) { saved ->
|
||||||
Icon(
|
Icon(
|
||||||
|
@ -177,7 +178,7 @@ fun CommentsButton(
|
||||||
) {
|
) {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
modifier = Modifier.requiredSize(32.dp).then(modifier),
|
modifier = modifier.requiredSize(32.dp),
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
painter = commentIcon,
|
painter = commentIcon,
|
||||||
|
@ -193,7 +194,7 @@ fun TagRow(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier.then(modifier),
|
modifier = modifier,
|
||||||
) {
|
) {
|
||||||
FlowRow(
|
FlowRow(
|
||||||
mainAxisSpacing = 8.dp,
|
mainAxisSpacing = 8.dp,
|
||||||
|
|
|
@ -14,7 +14,7 @@ actual fun NetworkImage(
|
||||||
KamelImage(
|
KamelImage(
|
||||||
resource = lazyPainterResource(url),
|
resource = lazyPainterResource(url),
|
||||||
contentDescription = contentDescription,
|
contentDescription = contentDescription,
|
||||||
modifier = Modifier.then(modifier),
|
modifier = modifier,
|
||||||
crossfade = true,
|
crossfade = true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue