Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Composable
- fun CapturableScreen() {
- val captureController = rememberCaptureController()
- Column(modifier = Modifier.fillMaxSize()) {
- Button(onClick = { captureController.capture() }) {
- Text(text = "Take screenshot")
- }
- CapturableScreen(captureController)
- }
- }
- @Composable
- private fun CapturableScreen(
- captureController: CaptureController,
- postCreationViewModel: PostCreationViewModel = viewModel()
- ) {
- Capturable(
- controller = captureController,
- onCaptured = { bitmap, error ->
- if (bitmap != null) {
- Utils.saveImage(bitmap.asAndroidBitmap())
- }
- if (error != null) {
- Log.e("CaptureError", "Error: ${error.message} ${error.stackTrace.joinToString()}")
- }
- }
- ) {
- Content()
- }
- }
- @Composable
- private fun Content() {
- val scrollState = rememberScrollState()
- val text = remember {
- "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor " +
- "incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis" +
- " nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." +
- " Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore" +
- " eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt" +
- " in culpa qui officia deserunt mollit anim id est laborum."
- }
- Column(
- verticalArrangement = Arrangement.Center,
- horizontalAlignment = Alignment.CenterHorizontally,
- modifier = Modifier
- .fillMaxSize()
- .background(Color.White)
- .verticalScroll(scrollState)
- ) {
- Text(
- text = text,
- color = Color.Black,
- fontSize = 18.sp,
- )
- Box(
- modifier = Modifier
- .size(100.dp)
- .background(Color.Black)
- )
- Text(
- text = text,
- color = Color.Black,
- fontSize = 18.sp,
- )
- Box(
- modifier = Modifier
- .size(100.dp)
- .background(Color.Black)
- )
- Text(
- text = text,
- color = Color.Black,
- fontSize = 18.sp,
- )
- Box(
- modifier = Modifier
- .size(100.dp)
- .background(Color.Black)
- )
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement