Share intent
This commit is contained in:
parent
e30f8ae28d
commit
7b68feb311
1 changed files with 28 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
||||||
package net.friedl.android.woot.ui
|
package net.friedl.android.woot.ui
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
@ -114,9 +115,11 @@ fun WootTextCardDetail(
|
||||||
Text(
|
Text(
|
||||||
text, modifier = modifier.weight(0.8f, fill = true)
|
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(
|
CopyTextButton(
|
||||||
text,
|
text,
|
||||||
|
@ -146,4 +149,26 @@ fun CopyTextButton(
|
||||||
contentDescription = "Copy to clipboard."
|
contentDescription = "Copy to clipboard."
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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")
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue