From 72a541d64ec242ff768f6b52a0e9445be3641782 Mon Sep 17 00:00:00 2001 From: ch8n Date: Sat, 16 Oct 2021 11:06:47 +0530 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9A=99=20added=20share=20action=20dropbo?= =?UTF-8?q?x?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/NotyKT.iml | 9 + .../composeapp/src/main/AndroidManifest.xml | 11 ++ .../component/action/NotyActions.kt | 51 ++++++ .../ui/screens/NoteDetailsScreen.kt | 113 +++++++++--- .../noty/composeapp/utils/BitmapView.kt | 173 ++++++++++++++++++ .../src/main/res/drawable/share_image.xml | 30 +++ .../src/main/res/drawable/share_text.xml | 61 ++++++ .../app/src/main/res/xml/provider_paths.xml | 8 + 8 files changed, 433 insertions(+), 23 deletions(-) create mode 100644 .idea/NotyKT.iml create mode 100644 noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/utils/BitmapView.kt create mode 100644 noty-android/app/composeapp/src/main/res/drawable/share_image.xml create mode 100644 noty-android/app/composeapp/src/main/res/drawable/share_text.xml create mode 100644 noty-android/app/src/main/res/xml/provider_paths.xml diff --git a/.idea/NotyKT.iml b/.idea/NotyKT.iml new file mode 100644 index 00000000..d6ebd480 --- /dev/null +++ b/.idea/NotyKT.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/noty-android/app/composeapp/src/main/AndroidManifest.xml b/noty-android/app/composeapp/src/main/AndroidManifest.xml index 3413c5bd..671632d4 100644 --- a/noty-android/app/composeapp/src/main/AndroidManifest.xml +++ b/noty-android/app/composeapp/src/main/AndroidManifest.xml @@ -29,6 +29,17 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> + + + + + Unit) { ) } +data class ShareActionItem( + val label: String, + val iconId: Int, + val onActionClick: () -> Unit, +) + +@Composable +fun ShareDropdown( + expanded: Boolean, + shareActions: List, + onDismissRequest: () -> Unit +) { + DropdownMenu( + expanded = expanded, + onDismissRequest = onDismissRequest, + modifier = Modifier + .wrapContentHeight() + .width(100.dp) + ) { + shareActions.forEachIndexed { index, shareAction -> + DropdownMenuItem( + onClick = { + shareAction.onActionClick.invoke() + onDismissRequest.invoke() + } + ) { + Row { + Icon( + painter = painterResource(id = shareAction.iconId), + contentDescription = "", + tint = Color.Unspecified, + modifier = Modifier.size(16.dp) + ) + Spacer(modifier = Modifier.width(8.dp)) + Text(text = shareAction.label) + } + } + } + } + +} + @Composable fun ThemeSwitchAction(onToggle: () -> Unit) { val icon = painterResource(R.drawable.ic_day) diff --git a/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/ui/screens/NoteDetailsScreen.kt b/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/ui/screens/NoteDetailsScreen.kt index a32a303d..5f2ce78d 100644 --- a/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/ui/screens/NoteDetailsScreen.kt +++ b/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/ui/screens/NoteDetailsScreen.kt @@ -17,7 +17,10 @@ package dev.shreyaspatil.noty.composeapp.ui.screens import android.app.Activity +import android.content.Context import android.content.Intent +import android.graphics.Bitmap +import android.widget.Toast import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.foundation.background import androidx.compose.foundation.gestures.Orientation @@ -41,6 +44,7 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -53,15 +57,22 @@ import androidx.navigation.NavHostController import dev.shreyaspatil.noty.composeapp.R import dev.shreyaspatil.noty.composeapp.component.action.DeleteAction import dev.shreyaspatil.noty.composeapp.component.action.ShareAction +import dev.shreyaspatil.noty.composeapp.component.action.ShareActionItem +import dev.shreyaspatil.noty.composeapp.component.action.ShareDropdown import dev.shreyaspatil.noty.composeapp.component.dialog.FailureDialog import dev.shreyaspatil.noty.composeapp.component.text.NoteField import dev.shreyaspatil.noty.composeapp.component.text.NoteTitleField +import dev.shreyaspatil.noty.composeapp.utils.BitmapContainer import dev.shreyaspatil.noty.composeapp.utils.ShowToast +import dev.shreyaspatil.noty.composeapp.utils.saveImage +import dev.shreyaspatil.noty.composeapp.utils.shareImageUri import dev.shreyaspatil.noty.core.ui.UIDataState import dev.shreyaspatil.noty.utils.validator.NoteValidator import dev.shreyaspatil.noty.view.viewmodel.NoteDetailViewModel import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.InternalCoroutinesApi +import kotlinx.coroutines.MainScope +import kotlinx.coroutines.launch @ExperimentalAnimationApi @InternalCoroutinesApi @@ -81,6 +92,7 @@ fun NoteDetailsScreen( if (note != null) { var titleText by remember { mutableStateOf(note.title) } var noteText by remember { mutableStateOf(note.note) } + var bitmapCaptureCallback: () -> Bitmap? = { null } Scaffold( topBar = { @@ -109,35 +121,76 @@ fun NoteDetailsScreen( contentColor = MaterialTheme.colors.onPrimary, elevation = 0.dp, actions = { + var dropdownExpanded by remember { mutableStateOf(false) } + val coroutineScope = rememberCoroutineScope() DeleteAction(onClick = { viewModel.deleteNote() }) - ShareAction(onClick = { shareNote(activity, titleText, noteText) }) + ShareAction(onClick = { + dropdownExpanded = true + }) + ShareDropdown( + expanded = dropdownExpanded, + onDismissRequest = { + dropdownExpanded = false + }, + shareActions = listOf( + ShareActionItem( + label = "Text", + iconId = R.drawable.share_image, + onActionClick = { + shareNote(activity, titleText, noteText) + } + ), + ShareActionItem( + label = "Image", + iconId = R.drawable.share_image, + onActionClick = { + coroutineScope.launch { + val bitmap = bitmapCaptureCallback.invoke() + if (bitmap == null) { + Toast.makeText( + activity, + "Something Went Wrong!", + Toast.LENGTH_SHORT + ).show() + return@launch + } + shareNoteImage(bitmap, activity) + } + } + ), + ) + ) } ) }, content = { - Column( - Modifier.scrollable( - rememberScrollState(), - orientation = Orientation.Vertical - ).padding(16.dp) - ) { - NoteTitleField( - modifier = Modifier - .fillMaxWidth() - .background(MaterialTheme.colors.background), - value = titleText, - onTextChange = { titleText = it } - ) + bitmapCaptureCallback = BitmapContainer { + Column( + Modifier + .scrollable( + rememberScrollState(), + orientation = Orientation.Vertical + ) + .padding(16.dp) + ) { + NoteTitleField( + modifier = Modifier + .fillMaxWidth() + .background(MaterialTheme.colors.background), + value = titleText, + onTextChange = { titleText = it } + ) - NoteField( - modifier = Modifier - .fillMaxWidth() - .wrapContentHeight() - .padding(top = 8.dp) - .background(MaterialTheme.colors.background), - value = noteText, - onTextChange = { noteText = it } - ) + NoteField( + modifier = Modifier + .fillMaxWidth() + .wrapContentHeight() + .padding(top = 8.dp) + .background(MaterialTheme.colors.background), + value = noteText, + onTextChange = { noteText = it } + ) + } } }, floatingActionButton = { @@ -186,3 +239,17 @@ fun shareNote(activity: Activity, title: String, note: String) { activity.startActivity(Intent.createChooser(intent, null)) } + +suspend fun shareNoteImage(bitmap: Bitmap, context: Context) { + val uri = saveImage(bitmap, context) + if (uri != null) { + shareImageUri(context, uri) + } else { + Toast.makeText( + context, + "uri is null", + Toast.LENGTH_SHORT + ).show() + } + +} diff --git a/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/utils/BitmapView.kt b/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/utils/BitmapView.kt new file mode 100644 index 00000000..a0bfc860 --- /dev/null +++ b/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/utils/BitmapView.kt @@ -0,0 +1,173 @@ +/* + * Copyright 2020 Shreyas Patil + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package dev.shreyaspatil.noty.composeapp.utils + +import android.content.Context +import android.content.Intent +import android.graphics.Bitmap +import android.net.Uri +import android.util.Log +import android.widget.Toast +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.material.Button +import androidx.compose.material.ButtonDefaults +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.ComposeView +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.compose.ui.viewinterop.AndroidView +import androidx.core.content.FileProvider +import androidx.core.view.drawToBitmap +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.MainScope +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import java.io.File +import java.io.FileOutputStream +import java.io.IOException + +@Composable +fun BitmapContainer( + content: @Composable () -> Unit, +): () -> Bitmap { + + val context = LocalContext.current + val composeView = remember { ComposeView(context) } + var rendered by remember { mutableStateOf(false) } + + fun captureBitmap(): Bitmap { + return composeView.drawToBitmap() + } + + LaunchedEffect(key1 = rendered) { + if (rendered) { + captureBitmap() + } + } + + AndroidView( + factory = { + composeView.apply { + setContent { + content.invoke() + rendered = true + } + } + } + ) + + return ::captureBitmap +} + + +@Preview +@Composable +fun ComposableBitmapPreview() { + val context = LocalContext.current + val colorCount = remember { mutableStateOf(1) } + val (viewBitmap, setViewBitmap) = remember { mutableStateOf(null) } + + Column { + val captureBitmap = BitmapContainer( + content = { + Button( + onClick = { + colorCount.value = colorCount.value + 1 + }, + modifier = Modifier + .fillMaxWidth() + .padding(24.dp) + .height(55.dp), + colors = ButtonDefaults.buttonColors( + backgroundColor = if (colorCount.value % 2 == 0) { + Color.Green + } else { + Color.Red + } + ) + ) { + Text(text = "Pokemon") + } + } + ) + + Button( + onClick = { + MainScope().launch { + val bitmap = captureBitmap.invoke() + val uri = saveImage(bitmap, context) + if (uri != null) { + shareImageUri(context, uri) + } else { + Toast.makeText( + context, + "uri is null", + Toast.LENGTH_SHORT + ).show() + } + } + + }, + modifier = Modifier + .fillMaxWidth() + .padding(24.dp) + .height(55.dp), + ) { + Text(text = "Share") + } + } + +} + + +suspend fun saveImage(image: Bitmap, context: Context): Uri? = + withContext(Dispatchers.IO) { + val imagesFolder = File(context.cacheDir, "images") + var uri: Uri? = null + try { + imagesFolder.mkdirs() + val file = File(imagesFolder, "shared_image.png") + val stream = FileOutputStream(file) + image.compress(Bitmap.CompressFormat.PNG, 90, stream) + stream.flush() + stream.close() + uri = FileProvider.getUriForFile(context, "com.ch8n.fileprovider", file) + } catch (e: IOException) { + Log.d("Error", "IOException while trying to write file for sharing: " + e.message) + } + uri + } + +fun shareImageUri(context: Context, uri: Uri) { + val intent = Intent(Intent.ACTION_SEND) + intent.putExtra(Intent.EXTRA_STREAM, uri) + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) + intent.type = "image/png" + context.startActivity(intent) +} diff --git a/noty-android/app/composeapp/src/main/res/drawable/share_image.xml b/noty-android/app/composeapp/src/main/res/drawable/share_image.xml new file mode 100644 index 00000000..fee83b32 --- /dev/null +++ b/noty-android/app/composeapp/src/main/res/drawable/share_image.xml @@ -0,0 +1,30 @@ + + + + + + diff --git a/noty-android/app/composeapp/src/main/res/drawable/share_text.xml b/noty-android/app/composeapp/src/main/res/drawable/share_text.xml new file mode 100644 index 00000000..d9dda994 --- /dev/null +++ b/noty-android/app/composeapp/src/main/res/drawable/share_text.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + diff --git a/noty-android/app/src/main/res/xml/provider_paths.xml b/noty-android/app/src/main/res/xml/provider_paths.xml new file mode 100644 index 00000000..49ec9abb --- /dev/null +++ b/noty-android/app/src/main/res/xml/provider_paths.xml @@ -0,0 +1,8 @@ + + + + + + From 03b7ded6c188317235772931a50becae825bf4ef Mon Sep 17 00:00:00 2001 From: ch8n Date: Sat, 16 Oct 2021 14:17:20 +0530 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9D=20refactored=20names?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/action/NotyActions.kt | 8 --- .../ui/screens/NoteDetailsScreen.kt | 10 ++- .../noty/composeapp/utils/BitmapView.kt | 4 +- .../src/main/res/drawable/share_image.xml | 30 --------- .../src/main/res/drawable/share_text.xml | 61 ------------------- 5 files changed, 6 insertions(+), 107 deletions(-) delete mode 100644 noty-android/app/composeapp/src/main/res/drawable/share_image.xml delete mode 100644 noty-android/app/composeapp/src/main/res/drawable/share_text.xml diff --git a/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/component/action/NotyActions.kt b/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/component/action/NotyActions.kt index 4a5b8a95..138de319 100644 --- a/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/component/action/NotyActions.kt +++ b/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/component/action/NotyActions.kt @@ -60,7 +60,6 @@ fun ShareAction(onClick: () -> Unit) { data class ShareActionItem( val label: String, - val iconId: Int, val onActionClick: () -> Unit, ) @@ -85,13 +84,6 @@ fun ShareDropdown( } ) { Row { - Icon( - painter = painterResource(id = shareAction.iconId), - contentDescription = "", - tint = Color.Unspecified, - modifier = Modifier.size(16.dp) - ) - Spacer(modifier = Modifier.width(8.dp)) Text(text = shareAction.label) } } diff --git a/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/ui/screens/NoteDetailsScreen.kt b/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/ui/screens/NoteDetailsScreen.kt index 5f2ce78d..98b11deb 100644 --- a/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/ui/screens/NoteDetailsScreen.kt +++ b/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/ui/screens/NoteDetailsScreen.kt @@ -62,7 +62,7 @@ import dev.shreyaspatil.noty.composeapp.component.action.ShareDropdown import dev.shreyaspatil.noty.composeapp.component.dialog.FailureDialog import dev.shreyaspatil.noty.composeapp.component.text.NoteField import dev.shreyaspatil.noty.composeapp.component.text.NoteTitleField -import dev.shreyaspatil.noty.composeapp.utils.BitmapContainer +import dev.shreyaspatil.noty.composeapp.utils.CaptureBitmap import dev.shreyaspatil.noty.composeapp.utils.ShowToast import dev.shreyaspatil.noty.composeapp.utils.saveImage import dev.shreyaspatil.noty.composeapp.utils.shareImageUri @@ -92,7 +92,7 @@ fun NoteDetailsScreen( if (note != null) { var titleText by remember { mutableStateOf(note.title) } var noteText by remember { mutableStateOf(note.note) } - var bitmapCaptureCallback: () -> Bitmap? = { null } + var snapShot: () -> Bitmap? = { null } Scaffold( topBar = { @@ -135,17 +135,15 @@ fun NoteDetailsScreen( shareActions = listOf( ShareActionItem( label = "Text", - iconId = R.drawable.share_image, onActionClick = { shareNote(activity, titleText, noteText) } ), ShareActionItem( label = "Image", - iconId = R.drawable.share_image, onActionClick = { coroutineScope.launch { - val bitmap = bitmapCaptureCallback.invoke() + val bitmap = snapShot.invoke() if (bitmap == null) { Toast.makeText( activity, @@ -164,7 +162,7 @@ fun NoteDetailsScreen( ) }, content = { - bitmapCaptureCallback = BitmapContainer { + snapShot = CaptureBitmap { Column( Modifier .scrollable( diff --git a/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/utils/BitmapView.kt b/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/utils/BitmapView.kt index a0bfc860..60772582 100644 --- a/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/utils/BitmapView.kt +++ b/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/utils/BitmapView.kt @@ -53,7 +53,7 @@ import java.io.FileOutputStream import java.io.IOException @Composable -fun BitmapContainer( +fun CaptureBitmap( content: @Composable () -> Unit, ): () -> Bitmap { @@ -94,7 +94,7 @@ fun ComposableBitmapPreview() { val (viewBitmap, setViewBitmap) = remember { mutableStateOf(null) } Column { - val captureBitmap = BitmapContainer( + val captureBitmap = CaptureBitmap( content = { Button( onClick = { diff --git a/noty-android/app/composeapp/src/main/res/drawable/share_image.xml b/noty-android/app/composeapp/src/main/res/drawable/share_image.xml deleted file mode 100644 index fee83b32..00000000 --- a/noty-android/app/composeapp/src/main/res/drawable/share_image.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - diff --git a/noty-android/app/composeapp/src/main/res/drawable/share_text.xml b/noty-android/app/composeapp/src/main/res/drawable/share_text.xml deleted file mode 100644 index d9dda994..00000000 --- a/noty-android/app/composeapp/src/main/res/drawable/share_text.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - From d3d1d7a1ca37ac5e9fb1deed259b7e5030792cfc Mon Sep 17 00:00:00 2001 From: ch8n Date: Sat, 16 Oct 2021 14:36:35 +0530 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=93=9D=20code=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../noty/composeapp/component/action/NotyActions.kt | 4 ---- .../noty/composeapp/ui/screens/NoteDetailsScreen.kt | 2 -- .../java/dev/shreyaspatil/noty/composeapp/utils/BitmapView.kt | 4 ---- 3 files changed, 10 deletions(-) diff --git a/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/component/action/NotyActions.kt b/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/component/action/NotyActions.kt index 138de319..a9911d38 100644 --- a/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/component/action/NotyActions.kt +++ b/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/component/action/NotyActions.kt @@ -18,9 +18,7 @@ package dev.shreyaspatil.noty.composeapp.component.action import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.material.DropdownMenu @@ -29,7 +27,6 @@ import androidx.compose.material.Icon import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import dev.shreyaspatil.noty.R @@ -89,7 +86,6 @@ fun ShareDropdown( } } } - } @Composable diff --git a/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/ui/screens/NoteDetailsScreen.kt b/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/ui/screens/NoteDetailsScreen.kt index 98b11deb..c4936677 100644 --- a/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/ui/screens/NoteDetailsScreen.kt +++ b/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/ui/screens/NoteDetailsScreen.kt @@ -71,7 +71,6 @@ import dev.shreyaspatil.noty.utils.validator.NoteValidator import dev.shreyaspatil.noty.view.viewmodel.NoteDetailViewModel import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.InternalCoroutinesApi -import kotlinx.coroutines.MainScope import kotlinx.coroutines.launch @ExperimentalAnimationApi @@ -249,5 +248,4 @@ suspend fun shareNoteImage(bitmap: Bitmap, context: Context) { Toast.LENGTH_SHORT ).show() } - } diff --git a/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/utils/BitmapView.kt b/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/utils/BitmapView.kt index 60772582..44290ef0 100644 --- a/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/utils/BitmapView.kt +++ b/noty-android/app/composeapp/src/main/java/dev/shreyaspatil/noty/composeapp/utils/BitmapView.kt @@ -85,7 +85,6 @@ fun CaptureBitmap( return ::captureBitmap } - @Preview @Composable fun ComposableBitmapPreview() { @@ -132,7 +131,6 @@ fun ComposableBitmapPreview() { ).show() } } - }, modifier = Modifier .fillMaxWidth() @@ -142,10 +140,8 @@ fun ComposableBitmapPreview() { Text(text = "Share") } } - } - suspend fun saveImage(image: Bitmap, context: Context): Uri? = withContext(Dispatchers.IO) { val imagesFolder = File(context.cacheDir, "images")