Skip to content

Commit

Permalink
Mimic existing people layour
Browse files Browse the repository at this point in the history
  • Loading branch information
nbradbury committed Sep 26, 2024
1 parent 09b88e8 commit defb4b1
Showing 1 changed file with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
Expand Down Expand Up @@ -78,7 +79,11 @@ private fun UserList(users: List<UserWithEditContext>) {

@Composable
fun UserRow(user: UserWithEditContext) {
Row(modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp)) {
Row(
modifier = Modifier
.padding(horizontal = 16.dp, vertical = 12.dp)
.fillMaxWidth()
) {
Column(
modifier = Modifier.align(Alignment.CenterVertically)
) {
Expand Down Expand Up @@ -109,22 +114,29 @@ fun UserRow(user: UserWithEditContext) {
modifier = Modifier
.padding(start = 16.dp)
.align(Alignment.CenterVertically)
.weight(0.7F)
) {
Text(
text = user.username,
text = user.name,
style = MaterialTheme.typography.bodyLarge,
)
Spacer(modifier = Modifier.height(2.dp))
Text(
text = user.name,
text = user.username,
style = MaterialTheme.typography.bodyMedium
)
if (user.roles.isNotEmpty()) {
Spacer(modifier = Modifier.height(2.dp))
}
if (user.roles.isNotEmpty()) {
Column(
modifier = Modifier
.padding(start = 16.dp)
.weight(0.3F)
) {
Text(
text = user.roles.joinToString(", "),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.outline
color = MaterialTheme.colorScheme.outline,
modifier = Modifier.align(Alignment.End)
)
}
}
Expand Down Expand Up @@ -249,7 +261,7 @@ fun ProgressPreview() {

private val sampleUser1 = UserWithEditContext(
id = 1,
username = "sampleUser",
username = "@sampleUser",
avatarUrls = emptyMap(),
capabilities = emptyMap(),
description = "User description",
Expand All @@ -270,7 +282,7 @@ private val sampleUser1 = UserWithEditContext(
// TODO remove the avatar url
private val sampleUser2 = UserWithEditContext(
id = 2,
username = "sampleUser",
username = "@sampleUserWithALongUserName",
avatarUrls = mapOf("sampleUserTwo" to "https://nickbradbury.com/wp-content/uploads/2022/03/1394-2.jpg"),
capabilities = emptyMap(),
description = "User description",
Expand All @@ -283,10 +295,11 @@ private val sampleUser2 = UserWithEditContext(
name = "Sample User",
nickname = "User nickname",
registeredDate = "2023-01-01",
roles = listOf("admin"),
roles = listOf("contributor"),
slug = "sample-user",
url = "example.com",
)

val sampleUserList = listOf(
sampleUser1,
sampleUser2,
Expand Down

0 comments on commit defb4b1

Please sign in to comment.