mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-15 06:27:02 +05:30
common: reintroduce SubmitterAvatar
This commit is contained in:
parent
a8016391c9
commit
a6ae05ae52
1 changed files with 26 additions and 0 deletions
|
@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.requiredSize
|
import androidx.compose.foundation.layout.requiredSize
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.Icon
|
import androidx.compose.material.Icon
|
||||||
import androidx.compose.material.IconButton
|
import androidx.compose.material.IconButton
|
||||||
|
@ -23,6 +24,7 @@ import androidx.compose.material.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.google.accompanist.flowlayout.FlowRow
|
import com.google.accompanist.flowlayout.FlowRow
|
||||||
|
@ -30,6 +32,7 @@ import dev.msfjarvis.claw.common.res.commentIcon
|
||||||
import dev.msfjarvis.claw.common.res.heartBorderIcon
|
import dev.msfjarvis.claw.common.res.heartBorderIcon
|
||||||
import dev.msfjarvis.claw.common.res.heartIcon
|
import dev.msfjarvis.claw.common.res.heartIcon
|
||||||
import dev.msfjarvis.claw.common.theme.titleColor
|
import dev.msfjarvis.claw.common.theme.titleColor
|
||||||
|
import dev.msfjarvis.claw.common.ui.NetworkImage
|
||||||
import dev.msfjarvis.claw.database.local.SavedPost
|
import dev.msfjarvis.claw.database.local.SavedPost
|
||||||
|
|
||||||
val TEST_POST =
|
val TEST_POST =
|
||||||
|
@ -84,6 +87,8 @@ fun LobstersItem(
|
||||||
}
|
}
|
||||||
SubmitterName(
|
SubmitterName(
|
||||||
text = "Submitted by ${post.submitterName}",
|
text = "Submitted by ${post.submitterName}",
|
||||||
|
avatarUrl = post.submitterAvatarUrl,
|
||||||
|
contentDescription = "Submitted by ${post.submitterName}",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,24 +110,45 @@ fun PostTitle(
|
||||||
@Composable
|
@Composable
|
||||||
fun SubmitterName(
|
fun SubmitterName(
|
||||||
text: String,
|
text: String,
|
||||||
|
avatarUrl: String,
|
||||||
|
contentDescription: String,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.then(modifier),
|
modifier = Modifier.then(modifier),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
|
SubmitterAvatar(
|
||||||
|
avatarUrl = avatarUrl,
|
||||||
|
contentDescription = contentDescription,
|
||||||
|
)
|
||||||
SubmitterNameText(
|
SubmitterNameText(
|
||||||
text = text,
|
text = text,
|
||||||
|
modifier = Modifier.padding(start = 4.dp),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun SubmitterAvatar(
|
||||||
|
avatarUrl: String,
|
||||||
|
contentDescription: String,
|
||||||
|
) {
|
||||||
|
NetworkImage(
|
||||||
|
url = avatarUrl,
|
||||||
|
contentDescription = contentDescription,
|
||||||
|
modifier = Modifier.requiredSize(24.dp).clip(CircleShape),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SubmitterNameText(
|
fun SubmitterNameText(
|
||||||
text: String,
|
text: String,
|
||||||
|
modifier: Modifier,
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = text,
|
text = text,
|
||||||
|
modifier = Modifier.then(modifier),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue