Share your betslips with the Central Hub community and browse bets shared by others.
Share your betslip with the community using CentralHubBetShareProvider. You can add an optional comment and control whether to display your stake amount.
The BetPayload contains all bet details including selections, odds, stake, and potential winnings.
class CentralHubViewModel : ViewModel(), KoinComponent {
private val betShareProvider: CentralHubBetShareProvider = get()
suspend fun shareBet(
betPayload: BetPayload,
comment: String?,
showStake: Boolean
) {
betShareProvider.createBetShare(
betPayload = betPayload,
comment = comment,
showStake = showStake,
onSuccess = { /* Handle success */ },
onFailure = { error -> /* Handle error */ }
)
}
}Use CentralHubBetsProvider to browse shared bets from the community. The provider supports:
The state flow automatically updates with new bet shares and supports incremental loading.
BetShareFilterType.ALL
Display all shared bets from the entire community.
BetShareFilterType.FOLLOWERS_BETS
Show only bet shares from users you follow.
BetShareFilterType.MY_SHARED_BETS
Display only your own shared bets.
BetShareFilterType.MY_CONVERSATIONS
Show bet shares where you've participated in conversations.
BetShareFilterType.WINNING_BETS
Display only winning bet shares.
BetShareSortType.CREATED
Sort by creation time (most recent first).
BetShareSortType.COMMENT_COUNT
Sort by number of comments (most commented first).
BetShareSortType.COPY_COUNT
Sort by number of times copied (most popular first).
class BetsViewModel : ViewModel(), KoinComponent {
private val betsProvider: CentralHubBetsProvider = get()
val betsState = betsProvider.state
fun loadBets(
filterType: BetShareFilterType,
sortType: BetShareSortType
) {
betsProvider.loadBetShares(filterType, sortType)
}
fun loadMore(
filterType: BetShareFilterType,
sortType: BetShareSortType
) {
betsProvider.loadMoreBetShares(filterType, sortType)
}
}Compose UI:
@Composable
fun BetsFeed(viewModel: BetsViewModel = viewModel()) {
val state by viewModel.betsState
.collectAsStateWithLifecycle()
LazyColumn {
items(state.sharedBets) { betShare ->
BetShareCard(betShare)
}
if (!state.allDataLoaded) {
item {
LoadMoreButton {
viewModel.loadMore(
BetShareFilterType.ALL,
BetShareSortType.CREATED
)
}
}
}
}
}Represents a shared betslip with all associated data:
data class BetShare(
val id: String,
val messageId: String?,
val channelId: String?,
val content: String, // Optional comment
val numOfUnreadComments: Int,
val numOfAllComments: Int,
val userFollowersCount: Int?,
val betPayload: BetPayload, // Bet details
val isMy: Boolean, // Is this my bet?
val betShareCopyCount: Int, // Times copied
val user: User, // Bet author
val createdAt: Long,
val showStake: Boolean,
val comments: List<MessageReply>,
val reactions: List<Reaction>,
)State for browsing shared bets:
data class CentralHubBetsState(
val sharedBets: List<BetShare>,
val loadingState: LoadingStatus,
val previousPageLoadingStatus: LoadingStatus,
val allDataLoaded: Boolean,
)