User List Screen¶
Use the User List Screen screen to list the onboarded user on the device so that the user can choose one to Sign-In.
Definition¶
@Composable
fun <T> LocalUserListScreen(
@StringRes title: Int = R.string.local_user_list_title,
users: LazyPagingItems<LocalUserModel<T>>,
onItemClick: (T) -> Unit = {},
onBackButtonClick: () -> Unit = {},
onSearch: (String) -> Unit = {},
onCreateNewAccount: ViewClickListener = {},
) { ... }
abstract class LocalUserModel<T> {
abstract fun getName(): String
abstract fun getEmail(): String
abstract fun getData(): T
abstract fun isCurrent(): Boolean
open fun getUserType(): LocalUserType = LocalUserType.NORMAL
open fun getId(): String = getName()
}
enum class LocalUserType {
NORMAL, USER_GROUP
}
This screen shows the users in a paginated list. Refer to the Android paging component document for the details.
Example¶
composable("screen_local_user_list") {
val items = demoViewModel.demoUsers.collectAsLazyPagingItems()
LocalUserListScreen(
users = items,
onItemClick = {
Toast.makeText(context, it.email, Toast.LENGTH_SHORT).show()
},
onBackButtonClick = { navController.popBackStack() }
)
}
Last update: February 20, 2023