Clipboard functionality (#239)

This commit is contained in:
Ashutosh Y
2023-11-23 15:46:52 +05:30
committed by GitHub
parent f5eab0cdf9
commit cd4b059551
2 changed files with 54 additions and 0 deletions

View File

@@ -7,7 +7,9 @@
package com.uitron.demo.playground
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@@ -16,6 +18,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material.Button
@@ -27,6 +30,9 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.ClipboardManager
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
@@ -39,6 +45,7 @@ import com.uitron.demo.theme.UiTronTheme
@Composable
fun PlaygroundScreen() {
val clipboardManager: ClipboardManager = LocalClipboardManager.current
val fieldValue = remember { mutableStateOf("") }
Column(
modifier = Modifier
@@ -74,6 +81,17 @@ fun PlaygroundScreen() {
) {
Text(text = stringResource(id = R.string.clear))
}
Image(
painter = painterResource(id = R.drawable.clip_board),
contentDescription = "clipboard",
modifier = Modifier
.height(48.dp)
.width(48.dp)
.padding(start = 8.dp)
.clickable {
fieldValue.value = clipboardManager.getText()?.text.orEmpty()
}
)
}
Spacer(modifier = Modifier.height(20.dp))
Column(

View File

@@ -0,0 +1,36 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="800dp"
android:height="800dp"
android:viewportWidth="606.82"
android:viewportHeight="606.82">
<path
android:pathData="M477.88,79.92h-50.83c-11.91,-7.78 -24.87,-13.45 -36.86,-17.56c-5.59,-14.69 -14.54,-27.92 -26.05,-38.28C347.26,8.88 325.69,0.5 303.41,0.5c-22.28,0 -43.85,8.37 -60.75,23.58c-11.51,10.36 -20.45,23.59 -26.05,38.28c-11.98,4.1 -24.95,9.78 -36.86,17.56h-50.83c-32.06,0 -58.14,26.08 -58.14,58.14v410.12c0,32.06 26.08,58.14 58.14,58.14h348.95c32.06,0 58.14,-26.08 58.14,-58.14V138.06C536.02,106 509.94,79.92 477.88,79.92zM253.88,87.36c0.49,-2.55 1.15,-5.03 1.95,-7.44c7.07,-21.33 25.7,-36.58 47.58,-36.58c21.89,0 40.52,15.24 47.58,36.58c0.8,2.41 1.46,4.89 1.95,7.44c1.12,5.81 5.57,10.38 11.29,11.89c20.77,5.47 37.7,13.66 48.5,23.51c1.7,1.55 3.26,3.15 4.65,4.78c6.85,8.05 1.2,20.42 -9.37,20.42H198.8c-10.57,0 -16.22,-12.37 -9.37,-20.42c1.39,-1.63 2.94,-3.22 4.65,-4.78c10.8,-9.85 27.73,-18.04 48.5,-23.51C248.3,97.74 252.76,93.17 253.88,87.36zM493.18,548.18c0,8.45 -6.85,15.3 -15.3,15.3h-348.95c-8.45,0 -15.3,-6.85 -15.3,-15.3V138.06c0,-8.45 6.85,-15.3 15.3,-15.3h16.17c-0.51,2.12 -0.89,4.28 -1.15,6.47c-1.16,10.08 0.48,20.29 4.75,29.54c4.26,9.23 10.95,17.08 19.35,22.72c9.08,6.09 19.71,9.31 30.74,9.31h209.21c11.03,0 21.66,-3.22 30.73,-9.31c8.4,-5.64 15.09,-13.49 19.35,-22.72c4.27,-9.25 5.91,-19.46 4.75,-29.54c-0.25,-2.19 -0.64,-4.34 -1.15,-6.47h16.17c8.45,0 15.3,6.85 15.3,15.3V548.18L493.18,548.18z"
android:fillColor="#000000"/>
<path
android:pathData="M477.88,606.82H128.93c-32.33,0 -58.64,-26.31 -58.64,-58.64V138.06c0,-32.33 26.31,-58.64 58.64,-58.64h50.68c10.49,-6.84 22.81,-12.71 36.62,-17.45c5.66,-14.75 14.68,-27.98 26.1,-38.26C259.31,8.42 281,0 303.41,0s44.1,8.42 61.08,23.71c11.42,10.28 20.44,23.5 26.1,38.26c13.81,4.75 26.13,10.62 36.62,17.45h50.68c32.33,0 58.64,26.31 58.64,58.64v410.12C536.52,580.51 510.22,606.82 477.88,606.82zM128.93,80.42c-31.78,0 -57.64,25.86 -57.64,57.64v410.12c0,31.78 25.86,57.64 57.64,57.64h348.95c31.78,0 57.64,-25.86 57.64,-57.64V138.06c0,-31.78 -25.86,-57.64 -57.64,-57.64H426.91l-0.13,-0.08c-10.5,-6.86 -22.86,-12.75 -36.75,-17.5l-0.22,-0.08l-0.08,-0.22c-5.59,-14.69 -14.56,-27.86 -25.92,-38.09C347.02,9.33 325.57,1 303.41,1s-43.61,8.33 -60.41,23.45c-11.36,10.23 -20.32,23.4 -25.91,38.09l-0.08,0.22l-0.22,0.08c-13.88,4.75 -26.24,10.64 -36.75,17.5l-0.13,0.08H128.93zM477.88,563.98h-348.95c-8.71,0 -15.8,-7.09 -15.8,-15.8V138.06c0,-8.71 7.09,-15.8 15.8,-15.8h16.81l-0.15,0.62c-0.51,2.13 -0.89,4.29 -1.14,6.41c-1.15,9.99 0.47,20.11 4.71,29.27c4.22,9.14 10.85,16.93 19.18,22.51c9,6.04 19.53,9.23 30.46,9.23h209.21c10.93,0 21.46,-3.19 30.46,-9.23c8.32,-5.58 14.96,-13.37 19.18,-22.51c4.23,-9.16 5.86,-19.28 4.71,-29.27c-0.25,-2.12 -0.63,-4.27 -1.14,-6.41l-0.15,-0.62h16.81c8.71,0 15.8,7.09 15.8,15.8v410.12C493.68,556.89 486.6,563.98 477.88,563.98zM128.93,123.26c-8.16,0 -14.8,6.64 -14.8,14.8v410.12c0,8.16 6.64,14.8 14.8,14.8h348.95c8.16,0 14.8,-6.64 14.8,-14.8V138.06c0,-8.16 -6.64,-14.8 -14.8,-14.8h-15.55c0.45,1.97 0.79,3.96 1.01,5.91c1.17,10.17 -0.48,20.48 -4.79,29.81c-4.3,9.31 -11.05,17.24 -19.53,22.92c-9.16,6.15 -19.89,9.4 -31.01,9.4H198.8c-11.13,0 -21.85,-3.25 -31.01,-9.4c-8.48,-5.69 -15.23,-13.61 -19.53,-22.92c-4.31,-9.33 -5.97,-19.64 -4.79,-29.8c0.23,-1.96 0.57,-3.94 1.01,-5.91H128.93zM408.02,148.45H198.8c-5.07,0 -9.53,-2.85 -11.65,-7.44c-2.13,-4.62 -1.41,-9.91 1.9,-13.8c1.38,-1.61 2.95,-3.24 4.69,-4.82c10.89,-9.93 27.73,-18.1 48.71,-23.63c5.58,-1.47 9.87,-5.98 10.93,-11.5c0.48,-2.5 1.14,-5.03 1.96,-7.51c7.32,-22.08 26.63,-36.92 48.06,-36.92s40.74,14.84 48.06,36.92c0.82,2.48 1.48,5.01 1.96,7.51c1.06,5.51 5.35,10.03 10.93,11.5c20.98,5.53 37.82,13.7 48.71,23.63c1.74,1.58 3.31,3.2 4.69,4.82c3.31,3.89 4.04,9.17 1.9,13.8C417.55,145.6 413.08,148.45 408.02,148.45zM303.41,43.84c-21,0 -39.93,14.56 -47.11,36.24c-0.81,2.44 -1.46,4.92 -1.93,7.38c-1.13,5.89 -5.71,10.71 -11.66,12.27c-20.82,5.49 -37.52,13.58 -48.29,23.4c-1.71,1.56 -3.26,3.15 -4.6,4.73c-3.06,3.59 -3.73,8.47 -1.76,12.73c1.96,4.23 6.07,6.86 10.74,6.86h209.21c4.67,0 8.79,-2.63 10.74,-6.86c1.97,-4.26 1.3,-9.14 -1.76,-12.73c-1.35,-1.59 -2.9,-3.18 -4.6,-4.73c-10.77,-9.82 -27.47,-17.91 -48.29,-23.4c-5.95,-1.57 -10.52,-6.39 -11.66,-12.27c-0.47,-2.46 -1.12,-4.94 -1.93,-7.38C343.34,58.4 324.41,43.84 303.41,43.84z"
android:fillColor="#000000"/>
<path
android:pathData="M303.41,109.26c11.94,0 21.62,-9.68 21.62,-21.62c0,-2.72 -0.51,-5.33 -1.43,-7.73c-3.11,-8.13 -10.98,-13.9 -20.2,-13.9c-9.22,0 -17.08,5.77 -20.19,13.9c-0.92,2.4 -1.43,5 -1.43,7.73C281.79,99.58 291.47,109.26 303.41,109.26z"
android:fillColor="#000000"/>
<path
android:pathData="M303.41,109.76c-12.2,0 -22.12,-9.92 -22.12,-22.12c0,-2.71 0.49,-5.37 1.46,-7.9c3.26,-8.5 11.56,-14.22 20.66,-14.22c9.1,0 17.41,5.71 20.66,14.22c0.97,2.53 1.46,5.19 1.46,7.9C325.53,99.84 315.61,109.76 303.41,109.76zM303.41,66.52c-8.69,0 -16.62,5.45 -19.73,13.57c-0.93,2.42 -1.39,4.96 -1.39,7.55c0,11.65 9.48,21.12 21.12,21.12c11.65,0 21.12,-9.48 21.12,-21.12c0,-2.59 -0.47,-5.13 -1.39,-7.55C320.03,71.98 312.1,66.52 303.41,66.52z"
android:fillColor="#000000"/>
<path
android:pathData="M187.72,278.19H296.66c11.83,0 21.42,-9.59 21.42,-21.42c0,-11.83 -9.59,-21.42 -21.42,-21.42H187.72c-11.83,0 -21.42,9.59 -21.42,21.42C166.3,268.6 175.89,278.19 187.72,278.19z"
android:fillColor="#000000"/>
<path
android:pathData="M296.66,278.69H187.72c-12.09,0 -21.92,-9.83 -21.92,-21.92s9.83,-21.92 21.92,-21.92H296.66c12.09,0 21.92,9.83 21.92,21.92S308.75,278.69 296.66,278.69zM187.72,235.85c-11.53,0 -20.92,9.39 -20.92,20.92c0,11.53 9.39,20.92 20.92,20.92H296.66c11.54,0 20.92,-9.39 20.92,-20.92c0,-11.54 -9.39,-20.92 -20.92,-20.92H187.72z"
android:fillColor="#000000"/>
<path
android:pathData="M419.09,350.87h-231.37c-11.83,0 -21.42,9.59 -21.42,21.42s9.59,21.42 21.42,21.42h231.37c11.83,0 21.42,-9.59 21.42,-21.42S430.92,350.87 419.09,350.87z"
android:fillColor="#000000"/>
<path
android:pathData="M419.09,394.21h-231.37c-12.09,0 -21.92,-9.83 -21.92,-21.92s9.83,-21.92 21.92,-21.92h231.37c12.09,0 21.92,9.83 21.92,21.92S431.18,394.21 419.09,394.21zM187.72,351.37c-11.53,0 -20.92,9.39 -20.92,20.92s9.39,20.92 20.92,20.92h231.37c11.53,0 20.92,-9.39 20.92,-20.92s-9.39,-20.92 -20.92,-20.92H187.72z"
android:fillColor="#000000"/>
<path
android:pathData="M352.89,466.86H187.72c-11.83,0 -21.42,9.59 -21.42,21.42s9.59,21.42 21.42,21.42h165.17c11.83,0 21.42,-9.59 21.42,-21.42S364.72,466.86 352.89,466.86z"
android:fillColor="#000000"/>
<path
android:pathData="M352.89,510.2H187.72c-12.09,0 -21.92,-9.83 -21.92,-21.92s9.83,-21.92 21.92,-21.92h165.17c12.09,0 21.92,9.83 21.92,21.92S364.98,510.2 352.89,510.2zM187.72,467.36c-11.53,0 -20.92,9.39 -20.92,20.92s9.39,20.92 20.92,20.92h165.17c11.53,0 20.92,-9.39 20.92,-20.92s-9.39,-20.92 -20.92,-20.92H187.72z"
android:fillColor="#000000"/>
</vector>