Skip to content

Commit

Permalink
Third pass at detail
Browse files Browse the repository at this point in the history
  • Loading branch information
nbradbury committed Sep 30, 2024
1 parent fb003fb commit 5cc702d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ import coil.compose.AsyncImage
import coil.request.ImageRequest
import org.wordpress.android.R
import org.wordpress.android.ui.compose.theme.M3Theme
import uniffi.wp_api.UserWithEditContext

@Composable
fun UserAvatar(avatarUrl: String?) {
if (avatarUrl.isNullOrEmpty()) {
fun UserAvatar(user: UserWithEditContext) {
val avatarUrl = user.avatarUrls?.values?.firstOrNull() ?: ""
if (avatarUrl.isEmpty()) {
Icon(
imageVector = ImageVector.vectorResource(id = R.drawable.ic_user_placeholder_primary_24),
contentDescription = null,
Expand Down Expand Up @@ -120,3 +122,5 @@ fun UserScreen(
}
}
}

val userScreenPaddingDp = 16.dp
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,18 @@ private fun UserLazyRow(
) {
LazyRow(
modifier = Modifier
.padding(all = 16.dp)
.padding(all = userScreenPaddingDp)
.fillMaxWidth()
.clickable { onUserClick(user) }
) {
item {
val avatarUrl = user.avatarUrls?.values?.firstOrNull() ?: ""
UserAvatar(avatarUrl)
UserAvatar(user)
}

item {
Column(
modifier = Modifier
.padding(start = 16.dp)
.padding(start = userScreenPaddingDp)
) {
Text(
text = user.name,
Expand Down Expand Up @@ -146,17 +145,16 @@ private fun UserDetail(
) {
Row(
modifier = Modifier
.padding(all = 16.dp)
.padding(all = userScreenPaddingDp)
.fillMaxWidth()
) {
Column {
val avatarUrl = user.avatarUrls?.values?.firstOrNull() ?: ""
UserAvatar(avatarUrl)
UserAvatar(user)
}

Column(
modifier = Modifier
.padding(start = 16.dp)
.padding(start = userScreenPaddingDp)
) {
UserDetailSection(title = stringResource(R.string.name)) {
UserDetailRow(
Expand Down Expand Up @@ -196,7 +194,9 @@ private fun UserDetail(
UserDetailSection(title = stringResource(R.string.about_the_user)) {
UserDetailRow(
label = stringResource(R.string.biographical_info),
text = user.description,
text = user.description.ifEmpty {
stringResource(R.string.biographical_info_empty)
},
isMultiline = true
)
}
Expand All @@ -213,10 +213,10 @@ private fun UserDetailSection(
text = title,
style = MaterialTheme.typography.titleLarge,
)
Spacer(modifier = Modifier.height(16.dp))
Spacer(modifier = Modifier.height(userScreenPaddingDp))
content()
HorizontalDivider(thickness = 1.dp)
Spacer(modifier = Modifier.height(16.dp))
Spacer(modifier = Modifier.height(userScreenPaddingDp))
}

@Composable
Expand All @@ -235,7 +235,7 @@ private fun UserDetailRow(
maxLines = if (isMultiline) 10 else 1,
overflow = TextOverflow.Ellipsis
)
Spacer(modifier = Modifier.height(16.dp))
Spacer(modifier = Modifier.height(userScreenPaddingDp))
}

@Composable
Expand Down
1 change: 1 addition & 0 deletions WordPress/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2988,6 +2988,7 @@
<string name="website">Website</string>
<string name="about_the_user">About the user</string>
<string name="biographical_info">Biographical Info</string>
<string name="biographical_info_empty">None given</string>

<!--Account Settings-->
<string name="account_settings">Account Settings</string>
Expand Down

0 comments on commit 5cc702d

Please sign in to comment.