jeongmin / Composely

A collection of Compose UI widgets and functionalities to simplify and enhance your Android app development.
Apache License 2.0
4 stars 0 forks source link

[Feature] Add functionality to capture Composable as an image #1

Open jeongmin opened 1 month ago

jeongmin commented 1 month ago

Description:

We need to implement a feature that allows capturing a Composable as an image. This will be useful for sharing UI states, debugging, and creating snapshots for documentation.

Goals:

1.  Capture the current state of a Composable and save it as an image.
2.  Provide options for different image formats (e.g., PNG, JPEG).
3.  Ensure the feature works across different screen densities and sizes.

Steps:

1.  Research the best approach to capture Composable content.
2.  Implement a utility function to handle the capture process.
3.  Add unit tests to verify the functionality.
4.  Update documentation with usage examples.

Acceptance Criteria:

•   A utility function that captures and saves a Composable as an image.
•   Supports multiple image formats.
•   Tested across various screen densities and sizes.
•   Documentation updated with examples.

Additional Context:

This feature will enhance the usability of the library by providing an easy way to capture and share UI states.

jeongmin commented 3 weeks ago

I found that new API support for saving contents of a composable to bitmap. But it does not work on some devices and it is still in the beta stage.

https://developer.android.com/develop/ui/compose/graphics/draw/modifiers?hl=en#composable-to-bitmap