Skip to content

Instantly share code, notes, and snippets.

@codingwitharul
Last active July 18, 2025 06:17
Show Gist options
  • Select an option

  • Save codingwitharul/46927be5caea7b65f3deda880964e37a to your computer and use it in GitHub Desktop.

Select an option

Save codingwitharul/46927be5caea7b65f3deda880964e37a to your computer and use it in GitHub Desktop.
/commonMain/common/Camera.kt
sealed class CameraEvent {
object Init : CameraEvent()
object CaptureImage : CameraEvent()
object SwitchCamera : CameraEvent()
}
abstract class CameraCallback {
private val _event = Channel<CameraEvent>()
val eventFlow: Flow<CameraEvent> get() = _event.receiveAsFlow()
suspend fun sendEvent(event: CameraEvent) {
this._event.send(event)
}
abstract fun onCaptureImage(image: Path?)
}
@Composable
expect fun CameraView(callback: CameraCallback)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment