From 391a78c948c677d676bc2b1036b05c4599cfb087 Mon Sep 17 00:00:00 2001 From: "Gleb O. Ivaniczkij" Date: Sat, 24 Aug 2024 16:01:45 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B7=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=B9=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cit_is_bot/ui/components/TextCheckbox.kt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/components/TextCheckbox.kt 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