Building a Compose-idiomatic CameraX Viewfinder
summary
Built a native Compose viewfinder for CameraX that replaces the stateful Preview wrapper with a stateless Compose API requiring a SurfaceRequest, Modifier, implementation mode (SurfaceView/TextureView) and a mutable coordinate transformer; it composes AndroidExternalSurface/EmbeddedExternalSurface into a TransformSurface that applies CameraX’s TransformationInfo (rotation, mirroring, crop rect) via a matrix and an Offset extension for tap-to-focus mapping, ships an alpha release last week, is Camera2-compatible, and reports better ergonomics and easier integration in real apps.
AI-written summary · about
chapters (14)
- 0:00CameraX Viewfinder intro
- 1:26Core viewfinder requirements
- 4:44Handling frame transforms
- 7:16Compose-idiomatic approach
- 9:25SurfaceProvider explained
- 11:59Traditional Preview challenges
- 13:01Native Compose viewfinder
- 16:56Surface layout in Compose
- 21:13Viewfinder architecture
- 21:54Touch-to-focus mapping
- 24:46Final API and usage
- 26:52Sample app and release
- 27:34Implementation learnings
- 29:01Q&A






