mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 14:08:26 +00:00
Moving color files
This commit is contained in:
parent
84b1fb6527
commit
d4e3c58dd7
@ -22,7 +22,7 @@ import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.NoOpCallbacks
|
||||
import org.thoughtcrime.securesms.ui.OptionsCard
|
||||
import org.thoughtcrime.securesms.ui.RadioOption
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.components.SlimOutlineButton
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
import org.thoughtcrime.securesms.ui.extraSmall
|
||||
|
@ -11,7 +11,7 @@ import network.loki.messenger.libsession_util.util.ExpiryMode
|
||||
import org.thoughtcrime.securesms.conversation.disappearingmessages.ExpiryType
|
||||
import org.thoughtcrime.securesms.conversation.disappearingmessages.State
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.color.Colors
|
||||
import org.thoughtcrime.securesms.ui.ThemeColors
|
||||
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||
|
||||
@Preview(widthDp = 450, heightDp = 700)
|
||||
@ -51,7 +51,7 @@ class StatePreviewParameterProvider : PreviewParameterProvider<State> {
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewThemes(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: ThemeColors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
DisappearingMessages(
|
||||
|
@ -24,8 +24,8 @@ import org.thoughtcrime.securesms.ui.ItemButton
|
||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||
import org.thoughtcrime.securesms.ui.color.Colors
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.ThemeColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.components.AppBar
|
||||
import org.thoughtcrime.securesms.ui.components.QrImage
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
@ -97,7 +97,7 @@ internal fun StartConversationScreen(
|
||||
@Preview
|
||||
@Composable
|
||||
private fun PreviewStartConversationScreen(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: ThemeColors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
StartConversationScreen(
|
||||
|
@ -18,7 +18,7 @@ import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.base
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.components.AppBar
|
||||
import org.thoughtcrime.securesms.ui.components.SlimOutlineButton
|
||||
import org.thoughtcrime.securesms.ui.components.SlimOutlineCopyButton
|
||||
|
@ -27,8 +27,8 @@ import org.thoughtcrime.securesms.ui.LoadingArcOr
|
||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||
import org.thoughtcrime.securesms.ui.color.Colors
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.ThemeColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.components.AppBar
|
||||
import org.thoughtcrime.securesms.ui.components.BorderlessButtonWithIcon
|
||||
import org.thoughtcrime.securesms.ui.components.MaybeScanQrCode
|
||||
@ -127,7 +127,7 @@ private fun EnterAccountId(
|
||||
@Preview
|
||||
@Composable
|
||||
private fun PreviewNewMessage(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: ThemeColors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
NewMessage(State("z"))
|
||||
|
@ -63,7 +63,6 @@ import org.thoughtcrime.securesms.ui.CellWithPaddingAndMargin
|
||||
import org.thoughtcrime.securesms.ui.Divider
|
||||
import org.thoughtcrime.securesms.ui.GetString
|
||||
import org.thoughtcrime.securesms.ui.HorizontalPagerIndicator
|
||||
import org.thoughtcrime.securesms.ui.ItemButton
|
||||
import org.thoughtcrime.securesms.ui.LargeItemButton
|
||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
@ -72,10 +71,10 @@ import org.thoughtcrime.securesms.ui.TitledText
|
||||
import org.thoughtcrime.securesms.ui.base
|
||||
import org.thoughtcrime.securesms.ui.baseBold
|
||||
import org.thoughtcrime.securesms.ui.baseMonospace
|
||||
import org.thoughtcrime.securesms.ui.color.Colors
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.color.blackAlpha40
|
||||
import org.thoughtcrime.securesms.ui.color.destructiveButtonColors
|
||||
import org.thoughtcrime.securesms.ui.ThemeColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.blackAlpha40
|
||||
import org.thoughtcrime.securesms.ui.destructiveButtonColors
|
||||
import org.thoughtcrime.securesms.ui.setComposeContent
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -313,7 +312,7 @@ fun ExpandButton(modifier: Modifier = Modifier, onClick: () -> Unit) {
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewMessageDetails(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: ThemeColors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
MessageDetails(
|
||||
|
@ -20,8 +20,8 @@ import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||
import org.thoughtcrime.securesms.ui.base
|
||||
import org.thoughtcrime.securesms.ui.color.Colors
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.ThemeColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.h4
|
||||
import org.thoughtcrime.securesms.ui.h8
|
||||
import org.thoughtcrime.securesms.ui.small
|
||||
@ -72,7 +72,7 @@ internal fun EmptyView(newAccount: Boolean) {
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewEmptyView(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: ThemeColors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
EmptyView(newAccount = false)
|
||||
@ -82,7 +82,7 @@ fun PreviewEmptyView(
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewEmptyViewNew(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: ThemeColors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
EmptyView(newAccount = true)
|
||||
|
@ -22,8 +22,8 @@ import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||
import org.thoughtcrime.securesms.ui.SessionShieldIcon
|
||||
import org.thoughtcrime.securesms.ui.color.Colors
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.ThemeColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.components.SlimPrimaryOutlineButton
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
import org.thoughtcrime.securesms.ui.h8
|
||||
@ -76,7 +76,7 @@ internal fun SeedReminder(startRecoveryPasswordActivity: () -> Unit) {
|
||||
@Preview
|
||||
@Composable
|
||||
private fun PreviewSeedReminder(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: ThemeColors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
SeedReminder {}
|
||||
|
@ -6,7 +6,7 @@ import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.ui.AlertDialog
|
||||
import org.thoughtcrime.securesms.ui.DialogButtonModel
|
||||
import org.thoughtcrime.securesms.ui.GetString
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
|
||||
@Composable
|
||||
fun OnboardingBackPressAlertDialog(
|
||||
|
@ -16,7 +16,6 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.Card
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
@ -43,8 +42,8 @@ import org.thoughtcrime.securesms.ui.GetString
|
||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||
import org.thoughtcrime.securesms.ui.color.Colors
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.ThemeColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.components.BorderlessHtmlButton
|
||||
import org.thoughtcrime.securesms.ui.components.PrimaryFillButton
|
||||
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton
|
||||
@ -56,7 +55,7 @@ import kotlin.time.Duration.Companion.milliseconds
|
||||
@Preview
|
||||
@Composable
|
||||
private fun PreviewLandingScreen(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: ThemeColors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
LandingScreen({}, {}, {}, {})
|
||||
|
@ -22,15 +22,12 @@ import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.onboarding.OnboardingBackPressAlertDialog
|
||||
import org.thoughtcrime.securesms.onboarding.messagenotifications.MessageNotificationsViewModel.UiState
|
||||
import org.thoughtcrime.securesms.onboarding.ui.ContinuePrimaryOutlineButton
|
||||
import org.thoughtcrime.securesms.ui.AlertDialog
|
||||
import org.thoughtcrime.securesms.ui.DialogButtonModel
|
||||
import org.thoughtcrime.securesms.ui.GetString
|
||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||
import org.thoughtcrime.securesms.ui.base
|
||||
import org.thoughtcrime.securesms.ui.color.Colors
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.ThemeColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.components.CircularProgressIndicator
|
||||
import org.thoughtcrime.securesms.ui.components.RadioButton
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
@ -141,7 +138,7 @@ private fun NotificationRadioButton(
|
||||
@Preview
|
||||
@Composable
|
||||
private fun MessageNotificationsScreenPreview(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: ThemeColors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
MessageNotificationsScreen()
|
||||
|
@ -26,7 +26,7 @@ import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||
import org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2
|
||||
import org.thoughtcrime.securesms.database.threadDatabase
|
||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.components.MaybeScanQrCode
|
||||
import org.thoughtcrime.securesms.ui.components.QrImage
|
||||
import org.thoughtcrime.securesms.ui.components.SessionTabRow
|
||||
|
@ -79,7 +79,7 @@ import org.thoughtcrime.securesms.ui.Divider
|
||||
import org.thoughtcrime.securesms.ui.LargeItemButton
|
||||
import org.thoughtcrime.securesms.ui.LargeItemButtonWithDrawable
|
||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.color.destructiveButtonColors
|
||||
import org.thoughtcrime.securesms.ui.destructiveButtonColors
|
||||
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton
|
||||
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineCopyButton
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
|
@ -31,8 +31,8 @@ import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||
import org.thoughtcrime.securesms.ui.SessionShieldIcon
|
||||
import org.thoughtcrime.securesms.ui.base
|
||||
import org.thoughtcrime.securesms.ui.color.Colors
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.ThemeColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.components.QrImage
|
||||
import org.thoughtcrime.securesms.ui.components.SlimOutlineButton
|
||||
import org.thoughtcrime.securesms.ui.components.SlimOutlineCopyButton
|
||||
@ -180,7 +180,7 @@ private fun HideRecoveryPasswordCell(onHide: () -> Unit = {}) {
|
||||
@Preview
|
||||
@Composable
|
||||
private fun PreviewRecoveryPasswordScreen(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: ThemeColors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
RecoveryPasswordScreen(mnemonic = "voyage urban toyed maverick peculiar tuxedo penguin tree grass building listen speak withdraw terminal plane")
|
||||
|
@ -22,7 +22,6 @@ import androidx.compose.ui.graphics.takeOrElse
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
|
||||
class DialogButtonModel(
|
||||
val text: GetString,
|
||||
|
@ -37,7 +37,6 @@ import androidx.compose.ui.unit.IntOffset
|
||||
import androidx.compose.ui.unit.dp
|
||||
import kotlinx.coroutines.launch
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlin.math.sign
|
||||
|
||||
|
@ -1,6 +1,24 @@
|
||||
package org.thoughtcrime.securesms.ui.color
|
||||
package org.thoughtcrime.securesms.ui
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.text.selection.TextSelectionColors
|
||||
import androidx.compose.material.ButtonDefaults
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.RadioButtonDefaults
|
||||
import androidx.compose.material.TabRowDefaults
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.TextFieldDefaults
|
||||
import androidx.compose.material.primarySurface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.takeOrElse
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
|
||||
val classicDark0 = Color.Black
|
||||
val classicDark1 = Color(0xff1B1B1B)
|
@ -64,10 +64,6 @@ import org.session.libsession.utilities.recipients.Recipient
|
||||
import org.session.libsession.utilities.runIf
|
||||
import org.thoughtcrime.securesms.components.ProfilePictureView
|
||||
import org.thoughtcrime.securesms.conversation.disappearingmessages.ui.OptionsCard
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.color.divider
|
||||
import org.thoughtcrime.securesms.ui.color.radioButtonColors
|
||||
import org.thoughtcrime.securesms.ui.color.transparentButtonColors
|
||||
import org.thoughtcrime.securesms.ui.components.SmallCircularProgressIndicator
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.thoughtcrime.securesms.ui.color
|
||||
package org.thoughtcrime.securesms.ui
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
@ -13,19 +13,14 @@ import androidx.compose.material.Text
|
||||
import androidx.compose.material.TextFieldDefaults
|
||||
import androidx.compose.material.primarySurface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.takeOrElse
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||
import org.thoughtcrime.securesms.ui.base
|
||||
|
||||
val LocalColors = staticCompositionLocalOf<Colors> { ClassicDark() }
|
||||
|
||||
interface Colors {
|
||||
interface ThemeColors {
|
||||
// properties to override for each theme
|
||||
val isLight: Boolean
|
||||
val primary: Color
|
||||
val danger: Color
|
||||
@ -38,23 +33,57 @@ interface Colors {
|
||||
val textBubbleSent: Color
|
||||
val backgroundBubbleReceived: Color
|
||||
val textBubbleReceived: Color
|
||||
val backgroundBubbleSent: Color get() = primary
|
||||
val qrCodeContent: Color
|
||||
val qrCodeBackground: Color
|
||||
val primaryButtonFill: Color
|
||||
val primaryButtonFillText: Color
|
||||
}
|
||||
|
||||
fun Colors.text(isError: Boolean): Color = if (isError) danger else text
|
||||
fun Colors.textSecondary(isError: Boolean): Color = if (isError) danger else textSecondary
|
||||
fun Colors.borders(isError: Boolean): Color = if (isError) danger else borders
|
||||
|
||||
val Colors.textSelectionColors get() = TextSelectionColors(
|
||||
// extra functions and properties that work for all themes
|
||||
val ThemeColors.textSelectionColors get() = TextSelectionColors(
|
||||
handleColor = primary,
|
||||
backgroundColor = primary.copy(alpha = 0.5f)
|
||||
)
|
||||
|
||||
data class ClassicDark(override val primary: Color = primaryGreen): Colors {
|
||||
val ThemeColors.divider get() = text.copy(alpha = TabRowDefaults.DividerOpacity)
|
||||
|
||||
fun ThemeColors.text(isError: Boolean): Color = if (isError) danger else text
|
||||
fun ThemeColors.textSecondary(isError: Boolean): Color = if (isError) danger else textSecondary
|
||||
fun ThemeColors.borders(isError: Boolean): Color = if (isError) danger else borders
|
||||
|
||||
fun ThemeColors.toMaterialColors() = androidx.compose.material.Colors(
|
||||
primary = background,
|
||||
primaryVariant = backgroundSecondary,
|
||||
secondary = background,
|
||||
secondaryVariant = background,
|
||||
background = background,
|
||||
surface = background,
|
||||
error = danger,
|
||||
onPrimary = text,
|
||||
onSecondary = text,
|
||||
onBackground = text,
|
||||
onSurface = text,
|
||||
onError = text,
|
||||
isLight = isLight
|
||||
)
|
||||
|
||||
|
||||
@Composable
|
||||
fun ThemeColors.radioButtonColors() = RadioButtonDefaults.colors(
|
||||
selectedColor = primary,
|
||||
unselectedColor = text,
|
||||
disabledColor = disabled
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun transparentButtonColors() = ButtonDefaults.buttonColors(backgroundColor = Color.Transparent)
|
||||
|
||||
@Composable
|
||||
fun destructiveButtonColors() = ButtonDefaults.buttonColors(backgroundColor = Color.Transparent, contentColor = LocalColors.current.danger)
|
||||
|
||||
|
||||
// Our themes
|
||||
data class ClassicDark(override val primary: Color = primaryGreen): ThemeColors {
|
||||
override val isLight = false
|
||||
override val danger = dangerDark
|
||||
override val disabled = disabledDark
|
||||
@ -72,7 +101,7 @@ data class ClassicDark(override val primary: Color = primaryGreen): Colors {
|
||||
override val primaryButtonFillText = Color.Black
|
||||
}
|
||||
|
||||
data class ClassicLight(override val primary: Color = primaryGreen): Colors {
|
||||
data class ClassicLight(override val primary: Color = primaryGreen): ThemeColors {
|
||||
override val isLight = true
|
||||
override val danger = dangerLight
|
||||
override val disabled = disabledLight
|
||||
@ -90,7 +119,7 @@ data class ClassicLight(override val primary: Color = primaryGreen): Colors {
|
||||
override val primaryButtonFillText = Color.White
|
||||
}
|
||||
|
||||
data class OceanDark(override val primary: Color = primaryBlue): Colors {
|
||||
data class OceanDark(override val primary: Color = primaryBlue): ThemeColors {
|
||||
override val isLight = false
|
||||
override val danger = dangerDark
|
||||
override val disabled = disabledDark
|
||||
@ -108,7 +137,7 @@ data class OceanDark(override val primary: Color = primaryBlue): Colors {
|
||||
override val primaryButtonFillText = Color.Black
|
||||
}
|
||||
|
||||
data class OceanLight(override val primary: Color = primaryBlue): Colors {
|
||||
data class OceanLight(override val primary: Color = primaryBlue): ThemeColors {
|
||||
override val isLight = true
|
||||
override val danger = dangerLight
|
||||
override val disabled = disabledLight
|
||||
@ -126,21 +155,10 @@ data class OceanLight(override val primary: Color = primaryBlue): Colors {
|
||||
override val primaryButtonFillText = Color.White
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Colors(name: String, colors: List<Color>) {
|
||||
Column {
|
||||
colors.forEachIndexed { i, it ->
|
||||
Box(Modifier.background(it)) {
|
||||
Text("$name: $i")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewThemeColors(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: ThemeColors
|
||||
) {
|
||||
PreviewTheme(colors) { ThemeColors() }
|
||||
}
|
||||
@ -175,42 +193,16 @@ private fun ThemeColors() {
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Colors.outlinedTextFieldColors(
|
||||
isError: Boolean
|
||||
) = TextFieldDefaults.outlinedTextFieldColors(
|
||||
textColor = if (isError) danger else text,
|
||||
cursorColor = if (isError) danger else text,
|
||||
focusedBorderColor = borders,
|
||||
unfocusedBorderColor = borders,
|
||||
placeholderColor = if (isError) danger else textSecondary
|
||||
)
|
||||
|
||||
val Colors.divider get() = text.copy(alpha = TabRowDefaults.DividerOpacity)
|
||||
|
||||
@Composable
|
||||
fun Colors.radioButtonColors() = RadioButtonDefaults.colors(
|
||||
selectedColor = primary,
|
||||
unselectedColor = text,
|
||||
disabledColor = disabled
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun transparentButtonColors() = ButtonDefaults.buttonColors(backgroundColor = Color.Transparent)
|
||||
|
||||
@Composable
|
||||
fun destructiveButtonColors() = ButtonDefaults.buttonColors(backgroundColor = Color.Transparent, contentColor = LocalColors.current.danger)
|
||||
|
||||
|
||||
/**
|
||||
* This class holds two instances of [Colors], [light] representing the [Colors] to use when the system is in a
|
||||
* light theme, and [dark] representing the [Colors] to use when the system is in a dark theme.
|
||||
* This class holds two instances of [ThemeColors], [light] representing the [ThemeColors] to use when the system is in a
|
||||
* light theme, and [dark] representing the [ThemeColors] to use when the system is in a dark theme.
|
||||
*
|
||||
* If the user has [followSystemSettings] turned on then [light] should be equal to [dark].
|
||||
*/
|
||||
data class LightDarkColors(
|
||||
val light: Colors,
|
||||
val dark: Colors
|
||||
val light: ThemeColors,
|
||||
val dark: ThemeColors
|
||||
) {
|
||||
@Composable
|
||||
fun colors() = if (light == dark || isSystemInDarkTheme()) dark else light
|
||||
@ -230,4 +222,4 @@ fun LightDarkColors(isClassic: Boolean, isLight: Boolean, followSystemSettings:
|
||||
else -> if (isClassic) ClassicDark(primary) else OceanDark(primary)
|
||||
}
|
||||
return LightDarkColors(light, dark)
|
||||
}
|
||||
}
|
@ -10,19 +10,16 @@ import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Shapes
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import androidx.compose.ui.unit.dp
|
||||
import org.session.libsession.utilities.AppTextSecurePreferences
|
||||
import org.thoughtcrime.securesms.ui.color.ClassicDark
|
||||
import org.thoughtcrime.securesms.ui.color.ClassicLight
|
||||
import org.thoughtcrime.securesms.ui.color.Colors
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.color.OceanDark
|
||||
import org.thoughtcrime.securesms.ui.color.OceanLight
|
||||
import org.thoughtcrime.securesms.ui.color.colors
|
||||
import org.thoughtcrime.securesms.ui.color.textSelectionColors
|
||||
|
||||
// Globally accessible composition local objects
|
||||
val LocalColors = staticCompositionLocalOf<ThemeColors> { ClassicDark() }
|
||||
|
||||
/**
|
||||
* Apply a Material2 compose theme based on user selections in SharedPreferences.
|
||||
@ -35,11 +32,11 @@ fun SessionMaterialTheme(
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a given [Colors], and our typography and shapes as a Material 2 Compose Theme.
|
||||
* Apply a given [ThemeColors], and our typography and shapes as a Material 2 Compose Theme.
|
||||
**/
|
||||
@Composable
|
||||
fun SessionMaterialTheme(
|
||||
colors: Colors,
|
||||
colors: ThemeColors,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
MaterialTheme(
|
||||
@ -57,22 +54,6 @@ fun SessionMaterialTheme(
|
||||
}
|
||||
}
|
||||
|
||||
private fun Colors.toMaterialColors() = androidx.compose.material.Colors(
|
||||
primary = background,
|
||||
primaryVariant = backgroundSecondary,
|
||||
secondary = background,
|
||||
secondaryVariant = background,
|
||||
background = background,
|
||||
surface = background,
|
||||
error = danger,
|
||||
onPrimary = text,
|
||||
onSecondary = text,
|
||||
onBackground = text,
|
||||
onSurface = text,
|
||||
onError = text,
|
||||
isLight = isLight
|
||||
)
|
||||
|
||||
@Composable private fun Context.colors() = AppTextSecurePreferences(this).colors()
|
||||
|
||||
val pillShape = RoundedCornerShape(percent = 50)
|
||||
@ -88,7 +69,7 @@ val sessionShapes = Shapes(
|
||||
*/
|
||||
@Composable
|
||||
fun PreviewTheme(
|
||||
colors: Colors = LocalColors.current,
|
||||
colors: ThemeColors = LocalColors.current,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
SessionMaterialTheme(colors) {
|
||||
@ -98,6 +79,6 @@ fun PreviewTheme(
|
||||
}
|
||||
}
|
||||
|
||||
class SessionColorsParameterProvider : PreviewParameterProvider<Colors> {
|
||||
class SessionColorsParameterProvider : PreviewParameterProvider<ThemeColors> {
|
||||
override val values = sequenceOf(ClassicDark(), ClassicLight(), OceanDark(), OceanLight())
|
||||
}
|
||||
|
@ -13,22 +13,24 @@ import org.session.libsession.utilities.TextSecurePreferences.Companion.PINK_ACC
|
||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.PURPLE_ACCENT
|
||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.RED_ACCENT
|
||||
import org.session.libsession.utilities.TextSecurePreferences.Companion.YELLOW_ACCENT
|
||||
import org.thoughtcrime.securesms.ui.ThemeColors
|
||||
import org.thoughtcrime.securesms.ui.LightDarkColors
|
||||
|
||||
/**
|
||||
* Retrieve the current [Colors] from [TextSecurePreferences] and current system settings.
|
||||
* Retrieve the current [ThemeColors] from [TextSecurePreferences] and current system settings.
|
||||
*/
|
||||
@Composable
|
||||
fun TextSecurePreferences.colors(): Colors = lightDarkColors().colors()
|
||||
fun TextSecurePreferences.colors(): ThemeColors = lightDarkColors().colors()
|
||||
private fun TextSecurePreferences.lightDarkColors() = LightDarkColors(isClassic(), isLight(), getFollowSystemSettings(), primaryColor())
|
||||
private fun TextSecurePreferences.isLight(): Boolean = getThemeStyle() in setOf(CLASSIC_LIGHT, OCEAN_LIGHT)
|
||||
private fun TextSecurePreferences.isClassic(): Boolean = getThemeStyle() in setOf(CLASSIC_DARK, CLASSIC_LIGHT)
|
||||
private fun TextSecurePreferences.primaryColor(): Color = when(getSelectedAccentColor()) {
|
||||
GREEN_ACCENT -> primaryGreen
|
||||
BLUE_ACCENT -> primaryBlue
|
||||
PURPLE_ACCENT -> primaryPurple
|
||||
PINK_ACCENT -> primaryPink
|
||||
RED_ACCENT -> primaryRed
|
||||
ORANGE_ACCENT -> primaryOrange
|
||||
YELLOW_ACCENT -> primaryYellow
|
||||
GREEN_ACCENT -> org.thoughtcrime.securesms.ui.primaryGreen
|
||||
BLUE_ACCENT -> org.thoughtcrime.securesms.ui.primaryBlue
|
||||
PURPLE_ACCENT -> org.thoughtcrime.securesms.ui.primaryPurple
|
||||
PINK_ACCENT -> org.thoughtcrime.securesms.ui.primaryPink
|
||||
RED_ACCENT -> org.thoughtcrime.securesms.ui.primaryRed
|
||||
ORANGE_ACCENT -> org.thoughtcrime.securesms.ui.primaryOrange
|
||||
YELLOW_ACCENT -> org.thoughtcrime.securesms.ui.primaryYellow
|
||||
else -> Color.Unspecified
|
||||
}
|
||||
|
@ -18,13 +18,13 @@ import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||
import org.thoughtcrime.securesms.ui.color.Colors
|
||||
import org.thoughtcrime.securesms.ui.ThemeColors
|
||||
import org.thoughtcrime.securesms.ui.h4
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun AppBarPreview(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: ThemeColors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
AppBar(title = "Title", {}, {})
|
||||
|
@ -6,7 +6,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.SolidColor
|
||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
|
||||
@Composable
|
||||
fun Modifier.border() = this.border(
|
||||
|
@ -41,8 +41,8 @@ import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||
import org.thoughtcrime.securesms.ui.baseBold
|
||||
import org.thoughtcrime.securesms.ui.buttonShape
|
||||
import org.thoughtcrime.securesms.ui.color.Colors
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.ThemeColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
@ -292,7 +292,7 @@ val MutableInteractionSource.releases
|
||||
@Preview
|
||||
@Composable
|
||||
private fun VariousButtons(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: ThemeColors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
FlowRow(
|
||||
|
@ -8,7 +8,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
|
||||
private val disabledBorder @Composable get() = BorderStroke(
|
||||
width = LocalDimensions.current.borderStroke,
|
||||
|
@ -58,7 +58,7 @@ import network.loki.messenger.R
|
||||
import org.session.libsignal.utilities.Log
|
||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.base
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.xl
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
|
@ -33,7 +33,7 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.util.QRCodeUtilities
|
||||
|
||||
@Composable
|
||||
|
@ -18,7 +18,6 @@ import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.selection.selectable
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.TextButton
|
||||
import androidx.compose.material.ripple.rememberRipple
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
@ -27,8 +26,8 @@ import androidx.compose.ui.graphics.RectangleShape
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.unit.dp
|
||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.color.transparentButtonColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.transparentButtonColors
|
||||
|
||||
@Composable
|
||||
fun RadioButton(
|
||||
|
@ -20,11 +20,11 @@ import androidx.compose.ui.unit.dp
|
||||
import kotlinx.coroutines.launch
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.color.Colors
|
||||
import org.thoughtcrime.securesms.ui.ThemeColors
|
||||
import org.thoughtcrime.securesms.ui.SessionColorsParameterProvider
|
||||
import org.thoughtcrime.securesms.ui.color.divider
|
||||
import org.thoughtcrime.securesms.ui.divider
|
||||
import org.thoughtcrime.securesms.ui.h8
|
||||
|
||||
private val TITLES = listOf(R.string.sessionRecoveryPassword, R.string.qrScan)
|
||||
@ -69,7 +69,7 @@ fun SessionTabRow(pagerState: PagerState, titles: List<Int>) {
|
||||
@androidx.compose.ui.tooling.preview.Preview
|
||||
@Composable
|
||||
fun PreviewSessionTabRow(
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: Colors
|
||||
@PreviewParameter(SessionColorsParameterProvider::class) colors: ThemeColors
|
||||
) {
|
||||
PreviewTheme(colors) {
|
||||
val pagerState = rememberPagerState { TITLES.size }
|
||||
|
@ -41,10 +41,10 @@ import org.thoughtcrime.securesms.ui.LocalDimensions
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.base
|
||||
import org.thoughtcrime.securesms.ui.baseBold
|
||||
import org.thoughtcrime.securesms.ui.color.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.color.borders
|
||||
import org.thoughtcrime.securesms.ui.color.text
|
||||
import org.thoughtcrime.securesms.ui.color.textSecondary
|
||||
import org.thoughtcrime.securesms.ui.LocalColors
|
||||
import org.thoughtcrime.securesms.ui.borders
|
||||
import org.thoughtcrime.securesms.ui.text
|
||||
import org.thoughtcrime.securesms.ui.textSecondary
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
|
||||
@Preview
|
||||
|
Loading…
x
Reference in New Issue
Block a user