Skip to content

Commit

Permalink
Second pass at detail
Browse files Browse the repository at this point in the history
  • Loading branch information
nbradbury committed Sep 30, 2024
1 parent 4f5adeb commit fb003fb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import uniffi.wp_api.UserWithEditContext
* This is a temporary object to supply a list of users for the self-hosted user list.
* It will be removed once the network request to retrieve users is implemented.
*/
@Suppress("MaxLineLength")
object SampleUsers {
private val sampleUserList = ArrayList<UserWithEditContext>()

Expand All @@ -14,7 +15,6 @@ object SampleUsers {
username = "@sampleUser",
avatarUrls = emptyMap(),
capabilities = emptyMap(),
description = "User description",
email = "[email protected]",
extraCapabilities = emptyMap(),
firstName = "Sample",
Expand All @@ -27,6 +27,7 @@ object SampleUsers {
roles = listOf("admin"),
slug = "sample-user",
url = "example.com",
description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam non quam viverra, viverra est vel, interdum felis. Pellentesque interdum libero quis metus pharetra ullamcorper. Morbi nec libero ligula. Quisque consectetur, purus sit amet lobortis porttitor, ligula ex imperdiet massa, in ullamcorper augue odio sit amet metus. In sollicitudin mauris et risus mollis commodo. Aliquam vel vehicula ante, nec blandit erat. Aenean non turpis porttitor orci fringilla fringilla nec ac nunc. Nulla ultrices urna ut ipsum posuere blandit. Phasellus mauris nulla, tincidunt at leo at, auctor interdum felis. Sed pharetra risus a ullamcorper dictum. Suspendisse pharetra justo molestie risus lobortis facilisis.",
)

// TODO remove the avatar url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down Expand Up @@ -157,16 +158,7 @@ private fun UserDetail(
modifier = Modifier
.padding(start = 16.dp)
) {
/*--------------
NAME
--------------
Username
Role
First name
Last name
Nickname
--------------*/
UserDetailSection(title = stringResource(R.string.name_section)) {
UserDetailSection(title = stringResource(R.string.name)) {
UserDetailRow(
label = stringResource(R.string.username),
text = user.username,
Expand All @@ -189,6 +181,25 @@ private fun UserDetail(
)
// TODO display name is missing from the model
}

UserDetailSection(title = stringResource(R.string.contact_info)) {
UserDetailRow(
label = stringResource(R.string.email),
text = user.email,
)
UserDetailRow(
label = stringResource(R.string.website),
text = user.url,
)
}

UserDetailSection(title = stringResource(R.string.about_the_user)) {
UserDetailRow(
label = stringResource(R.string.biographical_info),
text = user.description,
isMultiline = true
)
}
}
}
}
Expand All @@ -205,12 +216,14 @@ private fun UserDetailSection(
Spacer(modifier = Modifier.height(16.dp))
content()
HorizontalDivider(thickness = 1.dp)
Spacer(modifier = Modifier.height(16.dp))
}

@Composable
private fun UserDetailRow(
label: String,
text: String,
isMultiline: Boolean = false,
) {
Text(
text = label,
Expand All @@ -219,6 +232,8 @@ private fun UserDetailRow(
Text(
text = text,
style = MaterialTheme.typography.bodyLarge,
maxLines = if (isMultiline) 10 else 1,
overflow = TextOverflow.Ellipsis
)
Spacer(modifier = Modifier.height(16.dp))
}
Expand Down
7 changes: 5 additions & 2 deletions WordPress/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2982,9 +2982,12 @@


<!-- Self-hosted Users -->
<string name="name_section">Name</string>
<string name="name">Name</string>
<string name="nickname">Nickname</string>

<string name="contact_info">Contact info</string>
<string name="website">Website</string>
<string name="about_the_user">About the user</string>
<string name="biographical_info">Biographical Info</string>

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

0 comments on commit fb003fb

Please sign in to comment.