Fix QRs and radio buttons

This commit is contained in:
Andrew 2024-06-13 10:11:37 +09:30
parent f97630e38a
commit 6ee2a6e0a9
6 changed files with 17 additions and 16 deletions

View File

@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Divider
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.primarySurface
@ -20,6 +19,7 @@ import androidx.fragment.app.Fragment
import dagger.hilt.android.AndroidEntryPoint
import network.loki.messenger.R
import org.session.libsession.utilities.TextSecurePreferences
import org.thoughtcrime.securesms.ui.Divider
import org.thoughtcrime.securesms.ui.ItemButton
import org.thoughtcrime.securesms.ui.LocalDimensions
import org.thoughtcrime.securesms.ui.classicDarkColors

View File

@ -19,7 +19,6 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.layout.width
import androidx.compose.material.Divider
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
@ -94,6 +93,7 @@ import org.thoughtcrime.securesms.permissions.Permissions
import org.thoughtcrime.securesms.preferences.SettingsActivity
import org.thoughtcrime.securesms.showMuteDialog
import org.thoughtcrime.securesms.showSessionDialog
import org.thoughtcrime.securesms.ui.Divider
import org.thoughtcrime.securesms.ui.LocalColors
import org.thoughtcrime.securesms.ui.LocalDimensions
import org.thoughtcrime.securesms.ui.PreviewTheme
@ -444,10 +444,8 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
)
}
Divider(
modifier = Modifier.padding(vertical = LocalDimensions.current.marginExtraSmall),
color = LocalColors.current.borders
)
Divider(modifier = Modifier.padding(vertical = LocalDimensions.current.marginExtraSmall))
Text(
stringResource(R.string.conversationsNone),
style = MaterialTheme.typography.h8,

View File

@ -169,7 +169,7 @@ fun NotificationRadioButton(
tag?.let { Text(stringResource(it), color = LocalColors.current.primary, style = MaterialTheme.typography.h9) }
}
}
RadioButton(selected = selected, modifier = Modifier.align(Alignment.CenterVertically), onClick = onClick)
RadioButton(selected = selected, modifier = Modifier.align(Alignment.CenterVertically), onClick = onClick, colors = LocalColors.current.radioButtonColors())
}
}

View File

@ -321,10 +321,11 @@ fun Modifier.fadingEdges(
)
@Composable
fun Divider() {
fun Divider(modifier: Modifier = Modifier, startIndent: Dp = 0.dp) {
androidx.compose.material.Divider(
modifier = Modifier.padding(horizontal = 16.dp),
color = LocalColors.current.divider
modifier = modifier.padding(horizontal = LocalDimensions.current.marginExtraSmall),
color = LocalColors.current.divider,
startIndent = startIndent
)
}

View File

@ -37,7 +37,6 @@ import org.session.libsession.utilities.AppTextSecurePreferences
import org.thoughtcrime.securesms.util.ThemeState
import org.thoughtcrime.securesms.util.themeState
val LocalLightCell = staticCompositionLocalOf { Color.Black }
val LocalOnLightCell = staticCompositionLocalOf { Color.Black }
val LocalDimensions = staticCompositionLocalOf { Dimensions() }
@ -72,6 +71,8 @@ data class SessionColors(
val backgroundBubbleReceived: Color = Color.Unspecified,
val textBubbleReceived: Color = Color.Unspecified,
) {
val backgroundLight get() = if (isLight) backgroundSecondary else Color.White
val onBackgroundLight get() = if (isLight) text else background
val button get() = if (isLight) text else primary
val divider get() = text.copy(alpha = TabRowDefaults.DividerOpacity)
val backgroundBubbleSent get() = primary

View File

@ -33,7 +33,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import network.loki.messenger.R
import org.thoughtcrime.securesms.ui.LocalColors
import org.thoughtcrime.securesms.ui.LocalLightCell
import org.thoughtcrime.securesms.ui.LocalOnLightCell
import org.thoughtcrime.securesms.util.QRCodeUtilities
@ -47,23 +46,25 @@ fun QrImage(
mutableStateOf(null)
}
val dark = LocalColors.current.onBackgroundLight.value.toInt()
val scope = rememberCoroutineScope()
LaunchedEffect(string) {
scope.launch(Dispatchers.IO) {
bitmap = (300..500 step 100).firstNotNullOf {
runCatching { QRCodeUtilities.encode(string, it) }.getOrNull()
runCatching { QRCodeUtilities.encode(string, it, dark = dark) }.getOrNull()
}
}
}
if (LocalColors.current.isLight) {
Content(bitmap, icon, modifier = modifier, backgroundColor = MaterialTheme.colors.surface)
Content(bitmap, icon, modifier = modifier, backgroundColor = LocalColors.current.backgroundSecondary)
} else {
Card(
backgroundColor = LocalLightCell.current,
backgroundColor = Color.White,
elevation = 0.dp,
modifier = modifier
) { Content(bitmap, icon, modifier = Modifier.padding(16.dp), backgroundColor = LocalLightCell.current) }
) { Content(bitmap, icon, modifier = Modifier.padding(16.dp), backgroundColor = Color.White) }
}
}