Skip to content

Dumb question: How to make the compose Preview rendering works? #143

@duongphuhiep

Description

@duongphuhiep
Image

It seems that val playerState = rememberVideoPlayerState() is not previewable.

Do we have some kind of

val playerState = PreviewableVideoPlayerState()

Or Should I make a abstract wrapper in order to make thing previewable?

// commonMain  
interface VideoPlayerStateInterface {  
    val isPlaying: Boolean  
}  
  
// Real implementation wrapper  
class RealVideoPlayerStateWrapper(  
    private val playerState: VideoPlayerState  
) : VideoPlayerStateInterface {  
    override val isPlaying = playerState.isPlaying 
    ...
}  
  
// Preview implementation  
data class PreviewVideoPlayerState(  
    override val isPlaying: Boolean = false,  
    ...
) : VideoPlayerStateInterface  
  
// My composable now uses the interface  
@Composable  
fun KdroidVideoPlayer(playerState: VideoPlayerStateInterface) {  
    // UI implementation  
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions