Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
zyrouge committed Apr 18, 2024
1 parent 23d5c81 commit fcb409f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalClipboardManager
import io.github.zyrouge.symphony.ui.helpers.ViewContext
import io.github.zyrouge.symphony.utils.copyToClipboardWithToast

@Composable
fun LongPressCopyableText(context: ViewContext, text: String) {
val clipboardManager = LocalClipboardManager.current

Text(
text,
modifier = Modifier.pointerInput(Unit) {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/io/github/zyrouge/symphony/utils/Compose.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package io.github.zyrouge.symphony.utils

import android.content.ClipData
import android.content.ClipboardManager
import android.widget.Toast
import androidx.compose.ui.text.AnnotatedString
import io.github.zyrouge.symphony.ui.helpers.ViewContext

fun <T> wrapInViewContext(fn: (ViewContext) -> T) = fn

fun copyToClipboardWithToast(context: ViewContext, text: String) {
val clipboardManager = context.activity.getSystemService(ClipboardManager::class.java)
clipboardManager.setText(AnnotatedString(text))
clipboardManager.setPrimaryClip(ClipData.newPlainText(null, text))
Toast.makeText(
context.activity,
context.symphony.t.CopiedXToClipboard(text),
Expand Down

0 comments on commit fcb409f

Please sign in to comment.