Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Jetpack Compose Reference Assets #90

Open
brocollie08 opened this issue Oct 20, 2022 · 6 comments
Open

Create Jetpack Compose Reference Assets #90

brocollie08 opened this issue Oct 20, 2022 · 6 comments
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest

Comments

@brocollie08
Copy link
Contributor

Currently the Android assets only contain traditional Android view based assets.
Alongside the Composable player patternization, it would be good to have a ComposeReferenceAssetsPlugin containing the same reference assets but as composables using the following pattern

open class ComposableAsset<Data> constructor(assetContext: AssetContext, serializer: KSerializer<Data>, private val content: @Composable (AssetContext, Data) -> Unit) : DecodableAsset<Data>(assetContext, serializer) {
    override fun initView(): View = ComposeView(requireContext()).apply {
        setContent {
            content(assetContext, data)
        }
    }

    override fun View.hydrate() {
        require(this is ComposeView)

        setContent {
            content(assetContext, data)
        }
    }

    @Composable public fun compose() {
        content(assetContext, data)
    }
}

Assets should be rendered with the following compose function

@Composable
fun RenderableAsset.compose(modifier: Modifier = Modifier) {
    if (this is ComposableAsset<*>) Box(
        modifier,
        propagateMinConstraints = true,
    ) {
        compose()
    } else AndroidView(factory = ::FrameLayout, modifier) {
        assetContext.withContext(it.context).build().run { render() } into it
    }
}
@brocollie08 brocollie08 added enhancement New feature or request good first issue Good for newcomers labels Oct 20, 2022
@brocollie08
Copy link
Contributor Author

Relevant #89

@OleDakotaJoe
Copy link

Can I take on this issue? would love to get involved with this project

@chrischan325
Copy link

Hi! I would like to take this on

@brocollie08
Copy link
Contributor Author

@chrischan325 Hey, thanks for your interest in contributing. Do you have enough context to get started?

@chrischan325
Copy link

@brocollie08 I don't think so, first time looking at this project. Any additional context or helpful details would be great!

@brocollie08
Copy link
Contributor Author

I'd recommend first looking through this alongside building the android demo app, get a good sense of how Player works as a whole + android specific assets
Once you have a good understanding of the moving pieces, then you can work on the JPC asset portion

@A1shK A1shK mentioned this issue Jun 10, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest
Projects
None yet
Development

No branches or pull requests

4 participants