Created
March 9, 2026 10:25
-
-
Save armcha/8c84c75ff661897ae0d8b6c06899dcfb to your computer and use it in GitHub Desktop.
Remote Compose — Rendering a Document on Android (RemoteComposePlayer)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Remote Compose — Rendering a document on Android | |
| * | |
| * Wrap RemoteComposePlayer in AndroidView to use in Compose. | |
| * Just pass binary bytes — the player handles everything. | |
| */ | |
| @SuppressLint("RestrictedApiAndroidX") | |
| @Composable | |
| fun RemoteDocumentView( | |
| documentBytes: ByteArray, | |
| modifier: Modifier = Modifier, | |
| onAction: (id: Int, metadata: String?) -> Unit = { _, _ -> }, | |
| ) { | |
| key(documentBytes.contentHashCode()) { | |
| AndroidView( | |
| factory = { ctx -> | |
| RemoteComposePlayer(ctx).apply { | |
| setDocument(documentBytes) | |
| addIdActionListener { id, metadata -> | |
| onAction(id, metadata) | |
| } | |
| } | |
| }, | |
| modifier = modifier | |
| ) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment