[SES-1203] Disable radio buttons

This commit is contained in:
andrew 2023-10-20 13:32:16 +10:30
parent 8399771d5d
commit a9467c7b96
2 changed files with 4 additions and 1 deletions

View File

@ -49,6 +49,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.viewinterop.AndroidView
import org.session.libsession.utilities.recipients.Recipient
import org.session.libsession.utilities.runIf
import org.thoughtcrime.securesms.components.ProfilePictureView
import org.thoughtcrime.securesms.conversation.disappearingmessages.ui.OptionsCard
import kotlin.math.min
@ -150,7 +151,7 @@ fun <T> TitledRadioButton(option: RadioOption<T>, onClick: () -> Unit) {
Row(
horizontalArrangement = Arrangement.spacedBy(16.dp),
modifier = Modifier
.clickable { if (!option.selected) onClick() }
.runIf(option.enabled) { clickable { if (!option.selected) onClick() } }
.heightIn(min = 60.dp)
.padding(horizontal = 32.dp)
.contentDescription(option.contentDescription)

View File

@ -367,6 +367,8 @@ object Util {
}
}
fun <T, R> T.runIf(condition: Boolean, block: T.() -> R): R where T: R = if (condition) block() else this
fun <T, K: Any> Iterable<T>.associateByNotNull(
keySelector: (T) -> K?
) = associateByNotNull(keySelector) { it }