Load and manage Central Hub user profiles, shared bets, and profile privacy settings.
CentralHubProfileProvider gives you access to profile details, avatar URLs, shared bets, and privacy updates.
The provider can supply:
class ProfileViewModel : ViewModel(), KoinComponent {
private val profileProvider: CentralHubProfileProvider = get()
val profileState = profileProvider.profileState
fun loadProfile(userId: String) {
profileProvider.getUserData(userId)
data class CentralHubProfileState(
val user: User,
val isMyProfile: Boolean,
val isPrivate: Boolean,
val isFollowed: Boolean,
val followersCount: Int,
val followingCount: Int,
val inspirations: Int,
val reach: Int,
val sharedBets:
@Composable
fun ProfileScreen(
userId: String,
viewModel: ProfileViewModel = viewModel(),
) {
val state by viewModel.profileState.collectAsStateWithLifecycle()
LaunchedEffect(userId) {
viewModel.loadProfile(userId)
}
Column {
AsyncImage(
model = viewModel.getAvatarUrl(state.user.id),
contentDescription = "User avatar",
)
Text(state.user.username)
Row {
Text("Followers: ${state.followersCount}")
Text("Following: ${state.followingCount}")
Text("Inspirations: ${state.inspirations}")
Text("Reach: ${state.reach}")
}
}
}