diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/components/TextCheckbox.kt b/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/components/TextCheckbox.kt new file mode 100644 index 0000000..540ba57 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/components/TextCheckbox.kt @@ -0,0 +1,44 @@ +package ru.csasq.cit_is_bot.ui.components + +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.material3.Checkbox +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.MutableState +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier + +@Composable +fun TextCheckbox( + text: String, + checkboxState: MutableState, +) { + Row( + verticalAlignment = Alignment.CenterVertically, + ) { + val interactionSource = MutableInteractionSource() + Checkbox( + checked = checkboxState.value, + onCheckedChange = { value -> + checkboxState.value = value + }, + interactionSource = interactionSource, + ) + Text( + text = text, + modifier = Modifier + .weight(1f) + .fillMaxHeight() + .clickable( + interactionSource = interactionSource, + indication = null, + onClick = { + checkboxState.value = !checkboxState.value + }, + ), + ) + } +} \ No newline at end of file