Skip to content

Commit

Permalink
Fix open link on speakers
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Robiez committed Apr 2, 2024
1 parent 6028af1 commit 8a4f277
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ val viewModelModule = module {
factory { SpeakerListViewModel(get()) }
factory { SponsorsViewModel(get()) }
factory { VenueViewModel(get(), get(), get()) }
factory { (speakerId: String) -> SpeakerDetailsViewModel(speakerId, get()) }
factory { (speakerId: String) -> SpeakerDetailsViewModel(speakerId, get(), get()) }
factory { AgendaLayoutViewModel(get()) }
factory { AgendaPagerViewModel(get(), get(), get()) }
factory { (sessionId: String) -> SessionDetailViewModel(sessionId, get(), get(), get(), get(), get(), get(), get()) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.androidmakers.ui.speakers

import com.androidmakers.ui.model.Lce
import fr.androidmakers.domain.interactor.OpenLinkUseCase
import fr.androidmakers.domain.model.SocialsItem
import fr.androidmakers.domain.model.Speaker
import fr.androidmakers.domain.repo.SpeakersRepository
import kotlinx.coroutines.flow.SharingStarted
Expand All @@ -12,7 +14,8 @@ import moe.tlaster.precompose.viewmodel.viewModelScope

class SpeakerDetailsViewModel(
speakerId: String,
speakersRepository: SpeakersRepository
speakersRepository: SpeakersRepository,
private val openLinkUseCase: OpenLinkUseCase,
) : ViewModel() {

val uiState: StateFlow<Lce<SpeakerDetailsUiState>> = speakersRepository
Expand All @@ -31,6 +34,10 @@ class SpeakerDetailsViewModel(
started = SharingStarted.WhileSubscribed(5000L),
initialValue = Lce.Loading
)

fun openSpeakerLink(socialsItem: SocialsItem) {
socialsItem.url?.let { openLinkUseCase(it) }
}
}

data class SpeakerDetailsUiState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.androidmakers.ui.common.SocialButtons
import com.androidmakers.ui.model.Lce
import com.seiko.imageloader.rememberImagePainter
import dev.icerock.moko.resources.compose.stringResource
import fr.androidmakers.domain.model.SocialsItem
import fr.paug.androidmakers.ui.MR


Expand All @@ -49,6 +50,7 @@ fun SpeakerDetailsRoute(
is Lce.Content -> {
SpeakerDetailsScreen(
uiState = state.content,
onSocialItemClick = { speakerDetailsViewModel.openSpeakerLink(it) },
onBackClick = onBackClick
)
}
Expand All @@ -59,6 +61,7 @@ fun SpeakerDetailsRoute(
@Composable
fun SpeakerDetailsScreen(
uiState: SpeakerDetailsUiState,
onSocialItemClick: (SocialsItem) -> Unit,
onBackClick: () -> Unit,
) {
val speaker = uiState.speaker
Expand Down Expand Up @@ -109,9 +112,7 @@ fun SpeakerDetailsScreen(

SocialButtons(
speaker = speaker,
onClickOnItem = { item ->

}
onClickOnItem = onSocialItemClick
)
}
}
Expand Down

0 comments on commit 8a4f277

Please sign in to comment.