Add set button contentDescription

This commit is contained in:
andrew 2023-11-30 09:10:06 +10:30
parent a5a226b468
commit eecea12c17
2 changed files with 8 additions and 6 deletions

View File

@ -21,6 +21,7 @@ import androidx.compose.ui.unit.sp
import network.loki.messenger.R import network.loki.messenger.R
import network.loki.messenger.libsession_util.util.ExpiryMode import network.loki.messenger.libsession_util.util.ExpiryMode
import org.thoughtcrime.securesms.ui.Callbacks import org.thoughtcrime.securesms.ui.Callbacks
import org.thoughtcrime.securesms.ui.GetString
import org.thoughtcrime.securesms.ui.NoOpCallbacks import org.thoughtcrime.securesms.ui.NoOpCallbacks
import org.thoughtcrime.securesms.ui.OptionsCard import org.thoughtcrime.securesms.ui.OptionsCard
import org.thoughtcrime.securesms.ui.OutlineButton import org.thoughtcrime.securesms.ui.OutlineButton
@ -62,7 +63,7 @@ fun DisappearingMessages(
} }
if (state.showSetButton) OutlineButton( if (state.showSetButton) OutlineButton(
stringResource(R.string.disappearing_messages_set_button_title), GetString(R.string.disappearing_messages_set_button_title),
modifier = Modifier modifier = Modifier
.align(Alignment.CenterHorizontally) .align(Alignment.CenterHorizontally)
.padding(bottom = 20.dp), .padding(bottom = 20.dp),

View File

@ -186,15 +186,16 @@ fun <T> TitledRadioButton(option: RadioOption<T>, onClick: () -> Unit) {
} }
@Composable @Composable
fun Modifier.contentDescription(text: GetString): Modifier { fun Modifier.contentDescription(text: GetString?): Modifier {
val context = LocalContext.current val context = LocalContext.current
return semantics { contentDescription = text(context) } return text?.let { semantics { contentDescription = it(context) } } ?: this
} }
@Composable @Composable
fun OutlineButton(text: String, modifier: Modifier = Modifier, onClick: () -> Unit) { fun OutlineButton(text: GetString, contentDescription: GetString? = text, modifier: Modifier = Modifier, onClick: () -> Unit) {
OutlinedButton( OutlinedButton(
modifier = modifier.size(108.dp, 34.dp), modifier = modifier.size(108.dp, 34.dp)
.contentDescription(contentDescription),
onClick = onClick, onClick = onClick,
border = BorderStroke(1.dp, LocalExtraColors.current.prominentButtonColor), border = BorderStroke(1.dp, LocalExtraColors.current.prominentButtonColor),
shape = RoundedCornerShape(50), // = 50% percent shape = RoundedCornerShape(50), // = 50% percent
@ -203,7 +204,7 @@ fun OutlineButton(text: String, modifier: Modifier = Modifier, onClick: () -> Un
backgroundColor = MaterialTheme.colors.background backgroundColor = MaterialTheme.colors.background
) )
){ ){
Text(text = text) Text(text = text())
} }
} }