|
|
@ -4,28 +4,21 @@
|
|
|
|
package com.tailscale.ipn.ui.util
|
|
|
|
package com.tailscale.ipn.ui.util
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.compose.foundation.clickable
|
|
|
|
import androidx.compose.foundation.clickable
|
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.Row
|
|
|
|
import androidx.compose.foundation.layout.Row
|
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.height
|
|
|
|
import androidx.compose.foundation.layout.height
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
import androidx.compose.foundation.layout.width
|
|
|
|
import androidx.compose.foundation.layout.width
|
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
|
|
|
|
import androidx.compose.material3.Icon
|
|
|
|
import androidx.compose.material3.Icon
|
|
|
|
|
|
|
|
import androidx.compose.material3.ListItem
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
import androidx.compose.material3.Surface
|
|
|
|
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.draw.clip
|
|
|
|
|
|
|
|
import androidx.compose.ui.platform.LocalClipboardManager
|
|
|
|
import androidx.compose.ui.platform.LocalClipboardManager
|
|
|
|
import androidx.compose.ui.res.painterResource
|
|
|
|
import androidx.compose.ui.res.painterResource
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
import androidx.compose.ui.text.AnnotatedString
|
|
|
|
import androidx.compose.ui.text.AnnotatedString
|
|
|
|
import androidx.compose.ui.text.font.FontFamily
|
|
|
|
import androidx.compose.ui.text.font.FontFamily
|
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
|
|
|
|
|
import androidx.compose.ui.text.style.TextOverflow
|
|
|
|
import androidx.compose.ui.text.style.TextOverflow
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
import com.tailscale.ipn.R
|
|
|
|
import com.tailscale.ipn.R
|
|
|
@ -39,44 +32,33 @@ fun ClipboardValueView(
|
|
|
|
fontFamily: FontFamily = FontFamily.Monospace
|
|
|
|
fontFamily: FontFamily = FontFamily.Monospace
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
val localClipboardManager = LocalClipboardManager.current
|
|
|
|
val localClipboardManager = LocalClipboardManager.current
|
|
|
|
Surface(
|
|
|
|
Row {
|
|
|
|
color = MaterialTheme.colorScheme.secondaryContainer,
|
|
|
|
ListItem(
|
|
|
|
modifier = Modifier.clip(shape = RoundedCornerShape(8.dp))) {
|
|
|
|
modifier = Modifier.clickable { localClipboardManager.setText(AnnotatedString(value)) },
|
|
|
|
Row(
|
|
|
|
overlineContent = { title?.let { Text(it, style = MaterialTheme.typography.titleMedium) } },
|
|
|
|
horizontalArrangement =
|
|
|
|
headlineContent = {
|
|
|
|
Arrangement.spacedBy(8.dp, alignment = Alignment.CenterHorizontally),
|
|
|
|
Text(
|
|
|
|
modifier =
|
|
|
|
text = value,
|
|
|
|
Modifier.fillMaxWidth()
|
|
|
|
style = MaterialTheme.typography.bodyMedium,
|
|
|
|
.padding(8.dp)
|
|
|
|
fontFamily = fontFamily,
|
|
|
|
.clickable(onClick = { localClipboardManager.setText(AnnotatedString(value)) }),
|
|
|
|
maxLines = 2,
|
|
|
|
verticalAlignment = Alignment.CenterVertically) {
|
|
|
|
overflow = TextOverflow.Ellipsis)
|
|
|
|
Column(
|
|
|
|
},
|
|
|
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
|
|
|
supportingContent = {
|
|
|
|
modifier = Modifier.fillMaxWidth().weight(10f)) {
|
|
|
|
subtitle?.let { subtitle ->
|
|
|
|
title?.let { title ->
|
|
|
|
Text(
|
|
|
|
Text(
|
|
|
|
subtitle,
|
|
|
|
title,
|
|
|
|
modifier = Modifier.padding(top = 8.dp),
|
|
|
|
style = MaterialTheme.typography.bodyMedium,
|
|
|
|
style = MaterialTheme.typography.bodyMedium,
|
|
|
|
fontWeight = FontWeight.SemiBold)
|
|
|
|
color = MaterialTheme.colorScheme.secondary)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Text(
|
|
|
|
},
|
|
|
|
text = value,
|
|
|
|
trailingContent = {
|
|
|
|
style = MaterialTheme.typography.bodyMedium,
|
|
|
|
Icon(
|
|
|
|
fontFamily = fontFamily,
|
|
|
|
painterResource(R.drawable.clipboard),
|
|
|
|
maxLines = 2,
|
|
|
|
stringResource(R.string.copy_to_clipboard),
|
|
|
|
overflow = TextOverflow.Ellipsis)
|
|
|
|
modifier = Modifier.width(24.dp).height(24.dp),
|
|
|
|
subtitle?.let { subtitle ->
|
|
|
|
tint = ts_color_light_blue)
|
|
|
|
Text(
|
|
|
|
})
|
|
|
|
subtitle,
|
|
|
|
}
|
|
|
|
style = MaterialTheme.typography.bodyMedium,
|
|
|
|
|
|
|
|
color = MaterialTheme.colorScheme.secondary)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
|
|
painterResource(R.drawable.clipboard),
|
|
|
|
|
|
|
|
stringResource(R.string.copy_to_clipboard),
|
|
|
|
|
|
|
|
modifier = Modifier.width(24.dp).height(24.dp),
|
|
|
|
|
|
|
|
tint = ts_color_light_blue)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|