@@ -24,6 +24,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
2424import androidx.compose.material3.FloatingActionButton
2525import androidx.compose.material3.HorizontalDivider
2626import androidx.compose.material3.Icon
27+ import androidx.compose.material3.IconButton
2728import androidx.compose.material3.MaterialTheme
2829import androidx.compose.material3.Scaffold
2930import androidx.compose.material3.Text
@@ -38,16 +39,19 @@ import androidx.compose.runtime.setValue
3839import androidx.compose.ui.Alignment
3940import androidx.compose.ui.Modifier
4041import androidx.compose.ui.graphics.Color
42+ import androidx.compose.ui.platform.LocalContext
4143import androidx.compose.ui.res.painterResource
4244import androidx.compose.ui.res.stringResource
4345import androidx.compose.ui.unit.Dp
4446import androidx.compose.ui.unit.dp
4547import com.nextcloud.client.assistant.AssistantViewModel
4648import com.nextcloud.client.assistant.model.AssistantScreenState
49+ import com.nextcloud.utils.extensions.getActivity
4750import com.owncloud.android.R
4851import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
4952import com.owncloud.android.lib.resources.assistant.v2.model.TranslationLanguage
5053import com.owncloud.android.lib.resources.assistant.v2.model.toTranslationLanguages
54+ import com.owncloud.android.utils.ClipboardUtil
5155
5256@Suppress(" LongMethod" )
5357@OptIn(ExperimentalMaterial3Api ::class )
@@ -59,12 +63,13 @@ fun TranslationScreen(selectedTaskType: TaskTypeData?, viewModel: AssistantViewM
5963 mutableStateOf(
6064 TranslationSideState (
6165 text = textToTranslate,
62- language = languages?.originLanguages?.firstOrNull()
66+ language = languages?.originLanguages?.firstOrNull(),
67+ isTarget = false
6368 )
6469 )
6570 }
6671 var targetState by remember {
67- mutableStateOf(TranslationSideState (language = languages?.targetLanguages?.firstOrNull()))
72+ mutableStateOf(TranslationSideState (language = languages?.targetLanguages?.firstOrNull(), isTarget = true ))
6873 }
6974
7075 BackHandler {
@@ -132,6 +137,7 @@ fun TranslationScreen(selectedTaskType: TaskTypeData?, viewModel: AssistantViewM
132137 }
133138}
134139
140+ @Suppress(" LongMethod" )
135141@Composable
136142private fun TranslationSection (
137143 labelId : Int ,
@@ -141,6 +147,8 @@ private fun TranslationSection(
141147 maxDp : Dp ,
142148 onStateChange : (TranslationSideState ) -> Unit
143149) {
150+ val activity = LocalContext .current.getActivity()
151+
144152 Row (
145153 modifier = Modifier
146154 .padding(16 .dp)
@@ -179,11 +187,22 @@ private fun TranslationSection(
179187 )
180188 }
181189 }
190+
191+ if (state.isTarget && state.text.isNotBlank()) {
192+ Spacer (modifier = Modifier .weight(1f ))
193+
194+ IconButton (onClick = {
195+ activity?.let { ClipboardUtil .copyToClipboard(it, state.text, true ) }
196+ }) {
197+ Icon (painter = painterResource(R .drawable.ic_content_copy), contentDescription = " copy button" )
198+ }
199+ }
182200 }
183201
184202 TextField (
185203 value = state.text,
186204 onValueChange = { onStateChange(state.copy(text = it)) },
205+ readOnly = state.isTarget,
187206 modifier = Modifier
188207 .fillMaxWidth()
189208 .heightIn(min = 120 .dp, max = maxDp),
0 commit comments