Share intent

This commit is contained in:
Armin Friedl 2024-02-18 22:46:03 +01:00
parent e30f8ae28d
commit 7b68feb311

View file

@ -1,5 +1,6 @@
package net.friedl.android.woot.ui
import android.content.Intent
import android.widget.Toast
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
@ -114,9 +115,11 @@ fun WootTextCardDetail(
Text(
text, modifier = modifier.weight(0.8f, fill = true)
)
IconButton(onClick = {}, modifier = modifier.weight(0.1f)) {
Icon(Icons.Default.Share, contentDescription = "Share")
}
ShareTextButton(
text,
modifier= modifier.weight(0.1f)
)
CopyTextButton(
text,
@ -147,3 +150,25 @@ fun CopyTextButton(
)
}
}
@Composable
fun ShareTextButton(
text: String,
modifier: Modifier = Modifier
) {
val sendIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, text)
type = "text/plain"
}
val shareIntent = Intent.createChooser(sendIntent, null)
val context = LocalContext.current
IconButton(
onClick = {
context.startActivity(shareIntent)
}, modifier = modifier
) {
Icon(Icons.Default.Share, contentDescription = "Share")
}
}