-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/copy-response-buttons' into 'main'
copy response buttons See merge request products/hello-http!16
- Loading branch information
Showing
9 changed files
with
396 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...vmMain/kotlin/com/sunnychung/application/multiplatform/hellohttp/ux/FloatingCopyButton.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.sunnychung.application.multiplatform.hellohttp.ux | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalClipboardManager | ||
import androidx.compose.ui.text.AnnotatedString | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import com.sunnychung.application.multiplatform.hellohttp.AppContext | ||
import com.sunnychung.application.multiplatform.hellohttp.util.log | ||
import com.sunnychung.application.multiplatform.hellohttp.ux.local.LocalColor | ||
|
||
@Composable | ||
fun FloatingCopyButton(textToCopy: String, size: Dp = 20.dp, innerPadding: Dp = 4.dp, modifier: Modifier = Modifier) { | ||
val colours = LocalColor.current | ||
val clipboardManager = LocalClipboardManager.current | ||
AppImageButton( | ||
resource = "copy-to-clipboard.svg", | ||
size = size + innerPadding * 2, | ||
innerPadding = PaddingValues(innerPadding), | ||
color = colours.copyButton, | ||
onClick = { | ||
log.d { "Copied $textToCopy" } | ||
clipboardManager.setText(AnnotatedString(textToCopy)) | ||
AppContext.ErrorMessagePromptViewModel.showSuccessMessage("Copied text") | ||
}, | ||
modifier = modifier | ||
.background(colours.backgroundFloatingButton, RoundedCornerShape(4.dp)) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.