|
@@ -2,8 +2,10 @@ package org.sirekanyan.outline.feature.keys
|
|
|
|
|
|
|
|
import androidx.compose.foundation.clickable
|
|
import androidx.compose.foundation.clickable
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
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.fillMaxWidth
|
|
|
|
|
+import androidx.compose.foundation.layout.heightIn
|
|
|
import androidx.compose.foundation.layout.padding
|
|
import androidx.compose.foundation.layout.padding
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
import androidx.compose.material3.Text
|
|
import androidx.compose.material3.Text
|
|
@@ -13,19 +15,36 @@ import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.text.style.TextOverflow.Companion.Ellipsis
|
|
import androidx.compose.ui.text.style.TextOverflow.Companion.Ellipsis
|
|
|
import androidx.compose.ui.unit.dp
|
|
import androidx.compose.ui.unit.dp
|
|
|
import org.sirekanyan.outline.api.model.Key
|
|
import org.sirekanyan.outline.api.model.Key
|
|
|
|
|
+import org.sirekanyan.outline.api.model.getHost
|
|
|
import org.sirekanyan.outline.text.formatTraffic
|
|
import org.sirekanyan.outline.text.formatTraffic
|
|
|
|
|
|
|
|
@Composable
|
|
@Composable
|
|
|
-fun KeyContent(key: Key, onClick: () -> Unit) {
|
|
|
|
|
|
|
+fun KeyContent(key: Key, withServer: Boolean, onClick: () -> Unit) {
|
|
|
Row(
|
|
Row(
|
|
|
Modifier
|
|
Modifier
|
|
|
.clickable(onClick = onClick)
|
|
.clickable(onClick = onClick)
|
|
|
.fillMaxWidth()
|
|
.fillMaxWidth()
|
|
|
- .padding(16.dp),
|
|
|
|
|
|
|
+ .heightIn(min = if (withServer) 72.dp else 56.dp)
|
|
|
|
|
+ .padding(horizontal = 16.dp, vertical = 8.dp),
|
|
|
Arrangement.SpaceBetween,
|
|
Arrangement.SpaceBetween,
|
|
|
Alignment.CenterVertically,
|
|
Alignment.CenterVertically,
|
|
|
) {
|
|
) {
|
|
|
- Text(key.accessKey.nameOrDefault, Modifier.weight(1f), overflow = Ellipsis, maxLines = 1)
|
|
|
|
|
|
|
+ Column(Modifier.weight(1f), Arrangement.Center) {
|
|
|
|
|
+ Text(
|
|
|
|
|
+ text = key.accessKey.nameOrDefault,
|
|
|
|
|
+ overflow = Ellipsis,
|
|
|
|
|
+ maxLines = 1,
|
|
|
|
|
+ )
|
|
|
|
|
+ if (withServer) {
|
|
|
|
|
+ Text(
|
|
|
|
|
+ key.server.name.ifEmpty { key.server.getHost() },
|
|
|
|
|
+ overflow = Ellipsis,
|
|
|
|
|
+ maxLines = 1,
|
|
|
|
|
+ style = MaterialTheme.typography.bodyMedium,
|
|
|
|
|
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
key.traffic?.let { traffic ->
|
|
key.traffic?.let { traffic ->
|
|
|
Text(
|
|
Text(
|
|
|
text = formatTraffic(traffic),
|
|
text = formatTraffic(traffic),
|