Fix BorderlessButtonWithIcon

This commit is contained in:
Andrew 2024-06-12 14:05:34 +09:30
parent f8e3bc7d9a
commit 6df63b034c
3 changed files with 7 additions and 25 deletions

View File

@ -12,12 +12,9 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.primarySurface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
@ -52,7 +49,6 @@ import org.thoughtcrime.securesms.ui.LoadingArcOr
import org.thoughtcrime.securesms.ui.LocalDimensions
import org.thoughtcrime.securesms.ui.PreviewTheme
import org.thoughtcrime.securesms.ui.ThemeResPreviewParameterProvider
import org.thoughtcrime.securesms.ui.baseBold
import org.thoughtcrime.securesms.ui.classicDarkColors
import org.thoughtcrime.securesms.ui.components.AppBar
import org.thoughtcrime.securesms.ui.components.BorderlessButtonWithIcon
@ -166,7 +162,7 @@ fun EnterAccountId(
error = state.error?.string(),
)
if (state.error == null) {
BorderlessButtonSecondary(
BorderlessButtonWithIcon(
text = stringResource(R.string.messageNewDescription),
iconRes = R.drawable.ic_circle_question_mark,
contentColor = classicDarkColors[5],

View File

@ -36,11 +36,11 @@ class NewMessageViewModel @Inject constructor(
private val _qrErrors = Channel<String>()
val qrErrors: Flow<String> = _qrErrors.receiveAsFlow()
private var job: Job? = null
private var loadOnsJob: Job? = null
override fun onChange(value: String) {
job?.cancel()
job = null
loadOnsJob?.cancel()
loadOnsJob = null
_state.update { State(newMessageIdOrOns = value) }
}
@ -58,7 +58,7 @@ class NewMessageViewModel @Inject constructor(
}
private fun createPrivateChatIfPossible(onsNameOrPublicKey: String) {
if (job?.isActive == true) return
if (loadOnsJob?.isActive == true) return
if (PublicKeyValidation.isValid(onsNameOrPublicKey, isPrefixRequired = false)) {
if (PublicKeyValidation.hasValidPrefix(onsNameOrPublicKey)) {
@ -70,7 +70,7 @@ class NewMessageViewModel @Inject constructor(
// This could be an ONS name
_state.update { it.copy(error = null, loading = true) }
job = viewModelScope.launch(Dispatchers.IO) {
loadOnsJob = viewModelScope.launch(Dispatchers.IO) {
try {
withTimeout(5.seconds) {
SnodeAPI.getSessionID(onsNameOrPublicKey).get()

View File

@ -105,7 +105,7 @@ fun OutlineButton(
onClick = onClick,
border = BorderStroke(1.dp, LocalButtonColor.current),
colors = ButtonDefaults.outlinedButtonColors(
contentColor = LocalButtonColor.current,
contentColor = if (enabled) LocalButtonColor.current else Color.Unspecified,
backgroundColor = Color.Unspecified
)
) {
@ -200,20 +200,6 @@ fun FilledButton(
}
}
@Composable
fun BorderlessButtonSecondary(
text: String,
modifier: Modifier = Modifier,
onClick: () -> Unit
) {
BorderlessButton(
text,
modifier = modifier,
contentColor = MaterialTheme.colors.onSurface.copy(ContentAlpha.medium),
onClick = onClick
)
}
@Composable
fun BorderlessButton(
modifier: Modifier = Modifier,