feat(device-initialization, core): Unterstützung für Hilfe-Tooltips, Netzwerk-Interface-Auswahl & Discovery-Radar ergänzt
Signed-off-by: Stefan Mogeritsch <stefan.mo.co@gmail.com>
This commit is contained in:
+43
-4
@@ -1,10 +1,11 @@
|
||||
package at.mocode.frontend.core.designsystem.components
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.HelpOutline
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.key.*
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -31,6 +32,7 @@ fun <T : Enum<T>> MsEnumDropdown(
|
||||
onOptionSelected: (T) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
optionLabel: (T) -> String = { it.name },
|
||||
helpDescription: String? = null,
|
||||
enabled: Boolean = true,
|
||||
isError: Boolean = false,
|
||||
errorMessage: String? = null
|
||||
@@ -46,7 +48,44 @@ fun <T : Enum<T>> MsEnumDropdown(
|
||||
value = selectedOption?.let { optionLabel(it) } ?: "",
|
||||
onValueChange = {},
|
||||
readOnly = true,
|
||||
label = { Text(label, style = MaterialTheme.typography.bodySmall) },
|
||||
label = {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
Text(label, style = MaterialTheme.typography.bodySmall)
|
||||
if (helpDescription != null) {
|
||||
var showHelp by remember { mutableStateOf(false) }
|
||||
Box {
|
||||
IconButton(
|
||||
onClick = { showHelp = !showHelp },
|
||||
modifier = Modifier.size(16.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.HelpOutline,
|
||||
contentDescription = "Hilfe",
|
||||
tint = MaterialTheme.colorScheme.primary.copy(alpha = 0.6f),
|
||||
modifier = Modifier.size(14.dp)
|
||||
)
|
||||
}
|
||||
if (showHelp) {
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
TooltipBox(
|
||||
positionProvider = TooltipDefaults.rememberPlainTooltipPositionProvider(),
|
||||
tooltip = {
|
||||
PlainTooltip {
|
||||
Text(helpDescription)
|
||||
}
|
||||
},
|
||||
state = rememberTooltipState(isPersistent = true)
|
||||
) {
|
||||
// Tooltip wird durch Klick auf das Icon getriggert
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded) },
|
||||
colors = ExposedDropdownMenuDefaults.outlinedTextFieldColors(),
|
||||
modifier = Modifier
|
||||
|
||||
+1
@@ -13,6 +13,7 @@ expect fun MsFilePicker(
|
||||
onFileSelected: (String) -> Unit,
|
||||
fileExtensions: List<String> = emptyList(),
|
||||
directoryOnly: Boolean = false,
|
||||
helpDescription: String? = null,
|
||||
enabled: Boolean = true,
|
||||
modifier: Modifier = Modifier
|
||||
)
|
||||
|
||||
+43
-4
@@ -1,10 +1,11 @@
|
||||
package at.mocode.frontend.core.designsystem.components
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.HelpOutline
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.key.*
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -21,6 +22,7 @@ fun MsStringDropdown(
|
||||
onOptionSelected: (String) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
placeholder: String = "",
|
||||
helpDescription: String? = null,
|
||||
enabled: Boolean = true,
|
||||
isError: Boolean = false,
|
||||
errorMessage: String? = null
|
||||
@@ -36,7 +38,44 @@ fun MsStringDropdown(
|
||||
value = selectedOption,
|
||||
onValueChange = {},
|
||||
readOnly = true,
|
||||
label = { Text(label, style = MaterialTheme.typography.bodySmall) },
|
||||
label = {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
Text(label, style = MaterialTheme.typography.bodySmall)
|
||||
if (helpDescription != null) {
|
||||
var showHelp by remember { mutableStateOf(false) }
|
||||
Box {
|
||||
IconButton(
|
||||
onClick = { showHelp = !showHelp },
|
||||
modifier = Modifier.size(16.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.HelpOutline,
|
||||
contentDescription = "Hilfe",
|
||||
tint = MaterialTheme.colorScheme.primary.copy(alpha = 0.6f),
|
||||
modifier = Modifier.size(14.dp)
|
||||
)
|
||||
}
|
||||
if (showHelp) {
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
TooltipBox(
|
||||
positionProvider = TooltipDefaults.rememberPlainTooltipPositionProvider(),
|
||||
tooltip = {
|
||||
PlainTooltip {
|
||||
Text(helpDescription)
|
||||
}
|
||||
},
|
||||
state = rememberTooltipState(isPersistent = true)
|
||||
) {
|
||||
// Tooltip wird durch Klick auf das Icon getriggert
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
placeholder = { Text(placeholder, style = MaterialTheme.typography.bodySmall) },
|
||||
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded) },
|
||||
colors = ExposedDropdownMenuDefaults.outlinedTextFieldColors(),
|
||||
|
||||
+44
-6
@@ -3,6 +3,8 @@ package at.mocode.frontend.core.designsystem.components
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.HelpOutline
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -27,6 +29,7 @@ fun MsTextField(
|
||||
isError: Boolean = false,
|
||||
errorMessage: String? = null,
|
||||
helperText: String? = null,
|
||||
helpDescription: String? = null,
|
||||
enabled: Boolean = true,
|
||||
readOnly: Boolean = false,
|
||||
singleLine: Boolean = true,
|
||||
@@ -41,12 +44,47 @@ fun MsTextField(
|
||||
|
||||
Column(modifier = modifier) {
|
||||
if (label != null) {
|
||||
Text(
|
||||
text = label,
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = if (isError) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.padding(bottom = 4.dp, start = 4.dp)
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier.padding(bottom = 4.dp, start = 4.dp),
|
||||
verticalAlignment = androidx.compose.ui.Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
Text(
|
||||
text = label,
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = if (isError) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
if (helpDescription != null) {
|
||||
var showHelp by remember { mutableStateOf(false) }
|
||||
Box {
|
||||
IconButton(
|
||||
onClick = { showHelp = !showHelp },
|
||||
modifier = Modifier.size(16.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.HelpOutline,
|
||||
contentDescription = "Hilfe",
|
||||
tint = MaterialTheme.colorScheme.primary.copy(alpha = 0.6f),
|
||||
modifier = Modifier.size(14.dp)
|
||||
)
|
||||
}
|
||||
if (showHelp) {
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
TooltipBox(
|
||||
positionProvider = TooltipDefaults.rememberPlainTooltipPositionProvider(),
|
||||
tooltip = {
|
||||
PlainTooltip {
|
||||
Text(helpDescription)
|
||||
}
|
||||
},
|
||||
state = rememberTooltipState(isPersistent = true)
|
||||
) {
|
||||
// Tooltip wird durch Klick auf das Icon getriggert
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OutlinedTextField(
|
||||
|
||||
+2
@@ -20,6 +20,7 @@ actual fun MsFilePicker(
|
||||
onFileSelected: (String) -> Unit,
|
||||
fileExtensions: List<String>,
|
||||
directoryOnly: Boolean,
|
||||
helpDescription: String?,
|
||||
enabled: Boolean,
|
||||
modifier: Modifier
|
||||
) {
|
||||
@@ -32,6 +33,7 @@ actual fun MsFilePicker(
|
||||
onValueChange = { },
|
||||
readOnly = true,
|
||||
label = label,
|
||||
helpDescription = helpDescription,
|
||||
placeholder = if (directoryOnly) "Verzeichnis wählen..." else "Datei wählen...",
|
||||
modifier = Modifier.weight(1f),
|
||||
enabled = enabled,
|
||||
|
||||
+1
@@ -10,6 +10,7 @@ actual fun MsFilePicker(
|
||||
onFileSelected: (String) -> Unit,
|
||||
fileExtensions: List<String>,
|
||||
directoryOnly: Boolean,
|
||||
helpDescription: String?,
|
||||
enabled: Boolean,
|
||||
modifier: Modifier
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user