diff --git a/WordPress/src/main/java/org/wordpress/android/ui/selfhostedusers/SelfHostedUsersActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/selfhostedusers/SelfHostedUsersActivity.kt index 61f3faccaa8b..a9bec9545d0f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/selfhostedusers/SelfHostedUsersActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/selfhostedusers/SelfHostedUsersActivity.kt @@ -46,7 +46,7 @@ class SelfHostedUsersActivity : LocaleAwareActivity() { viewModel.onCloseClick(this@SelfHostedUsersActivity) }, onUserClick = { user -> - viewModel.onUserClick(this@UserListActivity, site!!, user) + viewModel.onUserClick(user) } ) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/selfhostedusers/SelfHostedUsersScreen.kt b/WordPress/src/main/java/org/wordpress/android/ui/selfhostedusers/SelfHostedUsersScreen.kt index e46d1a58017e..5236407894da 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/selfhostedusers/SelfHostedUsersScreen.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/selfhostedusers/SelfHostedUsersScreen.kt @@ -1,6 +1,7 @@ package org.wordpress.android.ui.selfhostedusers import android.content.res.Configuration +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer @@ -28,8 +29,15 @@ import uniffi.wp_api.UserWithEditContext fun SelfHostedUsersScreen( uiState: StateFlow, onCloseClick: () -> Unit = {}, + onUserClick: (UserWithEditContext) -> Unit = {}, ) { val state = uiState.collectAsState().value + + val title = when(state) { + is SelfHostedUsersViewModel.SelfHostedUserState.UserDetail -> state.user.name + else -> stringResource(R.string.users) + } + val content: @Composable () -> Unit = @Composable { when (state) { is SelfHostedUsersViewModel.SelfHostedUserState.Loading -> { @@ -44,7 +52,7 @@ fun SelfHostedUsersScreen( is SelfHostedUsersViewModel.SelfHostedUserState.UserList -> { if (state.users.isNotEmpty()) { - UserList(state.users) + UserList(state.users, onUserClick) } else { UserEmptyView(stringResource(R.string.no_users)) } @@ -59,28 +67,36 @@ fun SelfHostedUsersScreen( } } } + UserScreen( content = content, - title = stringResource(R.string.users), + title = title, onCloseClick = { onCloseClick() }, isScrollable = state is SelfHostedUsersViewModel.SelfHostedUserState.UserList ) } @Composable -private fun UserList(users: List) { +private fun UserList( + users: List, + onUserClick: (UserWithEditContext) -> Unit +) { for (user in users) { - UserLazyRow(user) + UserLazyRow(user, onUserClick) HorizontalDivider(thickness = 1.dp, modifier = Modifier.padding(start = 80.dp)) } } @Composable -private fun UserLazyRow(user: UserWithEditContext) { +private fun UserLazyRow( + user: UserWithEditContext, + onUserClick: (UserWithEditContext) -> Unit +) { LazyRow( modifier = Modifier .padding(all = 16.dp) .fillMaxWidth() + .clickable { onUserClick(user) } ) { item { val avatarUrl = user.avatarUrls?.values?.firstOrNull() ?: ""