mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-20 19:18:37 +00:00
Fix backup row disabled state in settings.
This commit is contained in:
committed by
Michelle Tang
parent
2ba08965d2
commit
6aa6b490b5
@@ -15,6 +15,7 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.res.vectorResource
|
||||
@@ -23,6 +24,7 @@ import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import org.signal.core.ui.compose.DayNightPreviews
|
||||
import org.signal.core.ui.compose.Previews
|
||||
import org.signal.core.ui.compose.Rows
|
||||
import org.signal.core.ui.compose.horizontalGutters
|
||||
import org.signal.core.ui.compose.theme.SignalTheme
|
||||
import org.thoughtcrime.securesms.R
|
||||
@@ -35,6 +37,7 @@ import org.thoughtcrime.securesms.R
|
||||
fun TextWithBetaLabel(
|
||||
text: String,
|
||||
textStyle: TextStyle = TextStyle.Default,
|
||||
enabled: Boolean = true,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
FlowRow(
|
||||
@@ -45,7 +48,9 @@ fun TextWithBetaLabel(
|
||||
Text(
|
||||
text = text,
|
||||
style = textStyle,
|
||||
modifier = Modifier.align(Alignment.CenterVertically)
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterVertically)
|
||||
.alpha(if (enabled) 1f else Rows.DISABLED_ALPHA)
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.Beta__beta_title).uppercase(),
|
||||
@@ -56,6 +61,7 @@ fun TextWithBetaLabel(
|
||||
.padding(vertical = 6.dp)
|
||||
.background(color = MaterialTheme.colorScheme.surfaceVariant, shape = RoundedCornerShape(28.dp))
|
||||
.padding(horizontal = 12.dp, vertical = 4.dp)
|
||||
.alpha(if (enabled) 1f else Rows.DISABLED_ALPHA)
|
||||
.align(Alignment.CenterVertically)
|
||||
)
|
||||
}
|
||||
@@ -96,6 +102,14 @@ fun BetaLabelPreview() {
|
||||
}
|
||||
}
|
||||
|
||||
@DayNightPreviews
|
||||
@Composable
|
||||
fun BetaLabelDisabledPreview() {
|
||||
Previews.Preview {
|
||||
TextWithBetaLabel("Signal Backups", enabled = false)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(locale = "de")
|
||||
@Composable
|
||||
fun LongTextBetaLabelPreview() {
|
||||
|
||||
@@ -418,7 +418,8 @@ private fun AppSettingsContent(
|
||||
text = {
|
||||
TextWithBetaLabel(
|
||||
text = stringResource(R.string.preferences_chats__backups),
|
||||
textStyle = MaterialTheme.typography.bodyLarge
|
||||
textStyle = MaterialTheme.typography.bodyLarge,
|
||||
enabled = isRegisteredAndUpToDate
|
||||
)
|
||||
},
|
||||
icon = {
|
||||
@@ -720,6 +721,43 @@ private fun AppSettingsContentPreview() {
|
||||
}
|
||||
}
|
||||
|
||||
@DayNightPreviews
|
||||
@Composable
|
||||
private fun AppSettingsContentUnregisteredPreview() {
|
||||
Previews.Preview {
|
||||
AppSettingsContent(
|
||||
self = BioRecipientState(
|
||||
Recipient(
|
||||
systemContactName = "Miles Morales",
|
||||
profileName = ProfileName.fromParts("Miles", "Morales ❤\uFE0F"),
|
||||
isSelf = true,
|
||||
e164Value = "+15555555555",
|
||||
usernameValue = "miles.98",
|
||||
aboutEmoji = "❤\uFE0F",
|
||||
about = "About",
|
||||
isResolving = false
|
||||
)
|
||||
),
|
||||
state = AppSettingsState(
|
||||
isPrimaryDevice = true,
|
||||
unreadPaymentsCount = 5,
|
||||
hasExpiredGiftBadge = true,
|
||||
allowUserToGoToDonationManagementScreen = true,
|
||||
userUnregistered = true,
|
||||
clientDeprecated = false,
|
||||
showInternalPreferences = true,
|
||||
showPayments = true,
|
||||
showAppUpdates = true,
|
||||
backupFailureState = BackupFailureState.OUT_OF_STORAGE_SPACE
|
||||
),
|
||||
bannerManager = BannerManager(
|
||||
banners = listOf(TestBanner())
|
||||
),
|
||||
callbacks = EmptyCallbacks
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@DayNightPreviews
|
||||
@Composable
|
||||
private fun BioRowPreview() {
|
||||
|
||||
@@ -53,6 +53,8 @@ import org.signal.core.ui.compose.Rows.TextAndLabel
|
||||
|
||||
object Rows {
|
||||
|
||||
const val DISABLED_ALPHA = 0.4f
|
||||
|
||||
/**
|
||||
* Link row that positions [text] and optional [label] in a [TextAndLabel] to the side of an [icon] on the right.
|
||||
*/
|
||||
@@ -554,7 +556,7 @@ object Rows {
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.alpha(if (enabled) 1f else 0.4f)
|
||||
.alpha(if (enabled) 1f else DISABLED_ALPHA)
|
||||
.weight(1f)
|
||||
) {
|
||||
if (text != null) {
|
||||
|
||||
Reference in New Issue
Block a user