mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: add encryption status icon and dialog to node list items
This commit is contained in:
parent
587c6c91f4
commit
22b1cf0f16
7 changed files with 87 additions and 3 deletions
|
|
@ -0,0 +1,42 @@
|
|||
package com.geeksville.mesh.ui.components
|
||||
|
||||
import androidx.compose.material.Icon
|
||||
import androidx.compose.material.IconButton
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.KeyOff
|
||||
import androidx.compose.material.icons.filled.Lock
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.rememberVectorPainter
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.geeksville.mesh.R
|
||||
|
||||
@Composable
|
||||
fun NodeKeyStatusIcon(
|
||||
hasPKC: Boolean,
|
||||
mismatchKey: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
onClick: () -> Unit = {},
|
||||
) = IconButton(
|
||||
onClick = onClick,
|
||||
modifier = modifier,
|
||||
) {
|
||||
val (icon, tint) = when {
|
||||
mismatchKey -> rememberVectorPainter(Icons.Default.KeyOff) to Color.Red
|
||||
hasPKC -> rememberVectorPainter(Icons.Default.Lock) to Color.Green
|
||||
else -> painterResource(R.drawable.ic_lock_open_right_24) to Color.Yellow
|
||||
}
|
||||
Icon(
|
||||
painter = icon,
|
||||
contentDescription = stringResource(
|
||||
id = when {
|
||||
mismatchKey -> R.string.encryption_error
|
||||
hasPKC -> R.string.encryption_pkc
|
||||
else -> R.string.encryption_psk
|
||||
}
|
||||
),
|
||||
tint = tint,
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue