mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-08-04 20:34:14 +01:00
Force quick restore QR code to have a white background.
This commit is contained in:
@@ -214,6 +214,19 @@ fun SignalTheme(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the light color scheme to [content] regardless of the ambient theme, leaving typography and shapes untouched.
|
||||
*/
|
||||
@Composable
|
||||
fun ForceLightColors(content: @Composable () -> Unit) {
|
||||
CompositionLocalProvider(LocalExtendedColors provides lightExtendedColors) {
|
||||
MaterialTheme(
|
||||
colorScheme = lightColorScheme,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
private fun TypographyPreview() {
|
||||
|
||||
+65
-61
@@ -41,6 +41,7 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.testTag
|
||||
@@ -57,6 +58,7 @@ import org.signal.core.ui.compose.QrCode
|
||||
import org.signal.core.ui.compose.QrCodeData
|
||||
import org.signal.core.ui.compose.Scaffolds
|
||||
import org.signal.core.ui.compose.SignalIcons
|
||||
import org.signal.core.ui.compose.theme.ForceLightColors
|
||||
import org.signal.registration.R
|
||||
import org.signal.registration.RegistrationDependencies
|
||||
import org.signal.registration.screens.OnePaneRegistrationScaffold
|
||||
@@ -240,75 +242,77 @@ private fun QrCodePane(
|
||||
.padding(24.dp),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.background(MaterialTheme.colorScheme.surface)
|
||||
.padding(16.dp),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
AnimatedContent(
|
||||
targetState = state.qrState,
|
||||
contentKey = { it::class },
|
||||
transitionSpec = { fadeIn() togetherWith fadeOut() using SizeTransform { _, _ -> snap() } },
|
||||
label = "qr-code-state"
|
||||
) { qrState ->
|
||||
when (qrState) {
|
||||
is QrState.Loaded -> {
|
||||
QrCode(
|
||||
data = qrState.qrCodeData,
|
||||
foregroundColor = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.fillMaxSize()
|
||||
)
|
||||
}
|
||||
|
||||
QrState.Loading -> {
|
||||
CircularProgressIndicator(modifier = Modifier.size(48.dp))
|
||||
}
|
||||
|
||||
QrState.Scanned -> {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.QuickRestoreQRScreen__scanned),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center
|
||||
ForceLightColors {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.background(Color.White)
|
||||
.padding(16.dp),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
AnimatedContent(
|
||||
targetState = state.qrState,
|
||||
contentKey = { it::class },
|
||||
transitionSpec = { fadeIn() togetherWith fadeOut() using SizeTransform { _, _ -> snap() } },
|
||||
label = "qr-code-state"
|
||||
) { qrState ->
|
||||
when (qrState) {
|
||||
is QrState.Loaded -> {
|
||||
QrCode(
|
||||
data = qrState.qrCodeData,
|
||||
foregroundColor = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.fillMaxSize()
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
QrState.Loading -> {
|
||||
CircularProgressIndicator(modifier = Modifier.size(48.dp))
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = { onEvent(QuickRestoreQrEvents.RetryQrCode) },
|
||||
modifier = Modifier.testTag(TestTags.QUICK_RESTORE_QR_RETRY_BUTTON)
|
||||
QrState.Scanned -> {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Text(stringResource(R.string.QuickRestoreQRScreen__retry))
|
||||
Text(
|
||||
text = stringResource(R.string.QuickRestoreQRScreen__scanned),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Button(
|
||||
onClick = { onEvent(QuickRestoreQrEvents.RetryQrCode) },
|
||||
modifier = Modifier.testTag(TestTags.QUICK_RESTORE_QR_RETRY_BUTTON)
|
||||
) {
|
||||
Text(stringResource(R.string.QuickRestoreQRScreen__retry))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QrState.Failed -> {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.QuickRestoreQRScreen__failed),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Button(
|
||||
onClick = { onEvent(QuickRestoreQrEvents.RetryQrCode) },
|
||||
modifier = Modifier.testTag(TestTags.QUICK_RESTORE_QR_RETRY_BUTTON)
|
||||
QrState.Failed -> {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Text(stringResource(R.string.QuickRestoreQRScreen__retry))
|
||||
Text(
|
||||
text = stringResource(R.string.QuickRestoreQRScreen__failed),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Button(
|
||||
onClick = { onEvent(QuickRestoreQrEvents.RetryQrCode) },
|
||||
modifier = Modifier.testTag(TestTags.QUICK_RESTORE_QR_RETRY_BUTTON)
|
||||
) {
|
||||
Text(stringResource(R.string.QuickRestoreQRScreen__retry))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b0496551c8c7a7768468833253fddef023a0e547c06746e0ffd9e3a0cb8a6049
|
||||
size 112669
|
||||
oid sha256:fc6c32e0d4d410112c91f424666ce0cc7cd5d9695ae17e5cc69fd2dd460e026b
|
||||
size 109062
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:00a2997559098f566c4b3d70f76665c5e8ece0ad6a8da8d531a66648a16a134d
|
||||
size 112671
|
||||
oid sha256:00c6591424c4532bbf5795ae59059f253ae377c82268c8f331233ff2ba419415
|
||||
size 109442
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c4c59fc6980165d0091a23fb693e921a66f21d55aab2e96644f6c741c9ea1bb1
|
||||
size 113073
|
||||
oid sha256:a22d3b4347ce3bf20eea80ca196799b10944b80ff21fb684c664ec9935113d24
|
||||
size 109248
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1fbc20145753a724987d7ea0938aa13909d9cbe790f58632d73f317b6011d293
|
||||
size 44521
|
||||
oid sha256:be44cb594246c1bb31f3625b67ae9ccead9d219c73d607fc502685fb09afd021
|
||||
size 42574
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6e42e85fc57808cafba09c11b0d263d735c0af1236ae2925ac20e5aa26ce8ec2
|
||||
size 44715
|
||||
oid sha256:2fe679f8360799ec57a482e5ec72a7e3da4c0c6695cf951373d6a7fde8690dae
|
||||
size 42967
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f7993b81f50720441a358c9d4fc77d4a993b0a0b0cc233f0d8b4cbb87223f22e
|
||||
size 76926
|
||||
oid sha256:1ec3dcca1e4eee5c07053eed128eed9bde582fbcb96711f934ac2fcead7404f9
|
||||
size 73177
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7c4b5761233b5bb65bb55bfae5bee2d539744c07551a75e67652195255575889
|
||||
size 105797
|
||||
oid sha256:f67168c7c5609ef77b288d7600e14c78d43416d24025a5c7090fd91435731894
|
||||
size 102144
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2a5cca7b632c4bba56bd54375aec989afcf2010c832da4fd1d0f8e30a28db825
|
||||
size 101052
|
||||
oid sha256:73b4de1c0b95fcd604c1bd5c029e55e4367e9df8da0d6641a34e85d430936ad4
|
||||
size 97529
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:141a851c1f2f1e27cb2a1ebbe3aa67cf5aea1a01b62fdf005692a245890afb46
|
||||
size 101200
|
||||
oid sha256:68e4130572f9c53c6eb1bcfd0ae286d5de5f212dc0ad1121ed851370495082ce
|
||||
size 97988
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9b2e296378341fbd83b3975f9a66db3883054a0232e3924389fe8d1dba84b5b5
|
||||
size 102501
|
||||
oid sha256:ebe49be56ab895889377cf1bd112bc7fa9f865fb1b749f304c358ae8923de791
|
||||
size 98647
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:363c4bcd26da5e0fd661e738adad3ec2fb8b6ed908d5e2139c71b7a52678b27a
|
||||
size 120803
|
||||
oid sha256:c242cca2b87216f4a58820a8e0d3d498835cd2e30442cd7ae5f24985b137531d
|
||||
size 117126
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:82e4e0c6b1a81d3a8773125020ec28e37542bf969002373f5cd7b3863ae1cfa5
|
||||
size 120842
|
||||
oid sha256:802cdee27d8819f6cada1c7089b2beeb99d3894172d79b867bb9e5dd074d2991
|
||||
size 117528
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f6b636ab77f69ffb9abef253b10f79b8a12b2d91116c76a3afb36ac9373bebf3
|
||||
size 116747
|
||||
oid sha256:cbcb10a053e0dc8eda6d2efc5dee5a0dad392348056094245c294744d8bc4dfe
|
||||
size 112897
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1d2d407a3eb0b32ecde50574445367a6ac42ab72e495094f9da3f013da0b3858
|
||||
size 116823
|
||||
oid sha256:622ce5e63be7573b02a008c348ee9abd577f8a023dc0c5c4d28a9396d9d23752
|
||||
size 113187
|
||||
|
||||
Reference in New Issue
Block a user