Merge pull request #4226 from element-hq/feature/bma/themeOverride
Theme override
This commit is contained in:
commit
98f793b02e
111 changed files with 293 additions and 275 deletions
|
|
@ -7,24 +7,24 @@
|
|||
|
||||
package io.element.android.libraries.designsystem
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
|
||||
@Composable
|
||||
fun Boolean.toEnabledColor(): Color {
|
||||
return if (this) {
|
||||
MaterialTheme.colorScheme.primary
|
||||
ElementTheme.colors.textPrimary
|
||||
} else {
|
||||
MaterialTheme.colorScheme.primary.copy(alpha = 0.40f)
|
||||
ElementTheme.colors.textDisabled
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Boolean.toSecondaryEnabledColor(): Color {
|
||||
return if (this) {
|
||||
MaterialTheme.colorScheme.secondary
|
||||
ElementTheme.colors.textSecondary
|
||||
} else {
|
||||
MaterialTheme.colorScheme.secondary.copy(alpha = 0.40f)
|
||||
ElementTheme.colors.textDisabled
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ fun RedIndicatorAtom(
|
|||
Box(
|
||||
modifier = modifier
|
||||
.size(size)
|
||||
.border(borderSize, ElementTheme.materialColors.background, CircleShape)
|
||||
.border(borderSize, ElementTheme.colors.bgCanvasDefault, CircleShape)
|
||||
.padding(borderSize / 2)
|
||||
.clip(CircleShape)
|
||||
.background(color)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import androidx.compose.foundation.layout.size
|
|||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Home
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
|
|
@ -45,7 +44,7 @@ fun RoundedIconAtom(
|
|||
size: RoundedIconAtomSize = RoundedIconAtomSize.Big,
|
||||
resourceId: Int? = null,
|
||||
imageVector: ImageVector? = null,
|
||||
tint: Color = MaterialTheme.colorScheme.secondary,
|
||||
tint: Color = ElementTheme.colors.iconSecondary,
|
||||
backgroundTint: Color = ElementTheme.colors.temporaryColorBgSpecial,
|
||||
) {
|
||||
Box(
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ fun ComposerAlertMolecule(
|
|||
)
|
||||
val startColor = if (isCritical) ElementTheme.colors.bgCriticalSubtle else ElementTheme.colors.bgInfoSubtle
|
||||
val brush = Brush.verticalGradient(
|
||||
listOf(startColor, ElementTheme.materialColors.background),
|
||||
listOf(startColor, ElementTheme.colors.bgCanvasDefault),
|
||||
)
|
||||
Box(
|
||||
modifier = Modifier
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import androidx.compose.foundation.layout.Column
|
|||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
|
|
@ -51,7 +50,7 @@ fun IconTitleSubtitleMolecule(
|
|||
.fillMaxWidth(),
|
||||
textAlign = TextAlign.Center,
|
||||
style = ElementTheme.typography.fontHeadingMdBold,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
color = ElementTheme.colors.textPrimary,
|
||||
)
|
||||
if (subTitle != null) {
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
|
@ -60,7 +59,7 @@ fun IconTitleSubtitleMolecule(
|
|||
modifier = Modifier.fillMaxWidth(),
|
||||
textAlign = TextAlign.Center,
|
||||
style = ElementTheme.typography.fontBodyMdRegular,
|
||||
color = MaterialTheme.colorScheme.secondary,
|
||||
color = ElementTheme.colors.textSecondary,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|||
import androidx.compose.foundation.layout.imePadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.movableContentOf
|
||||
import androidx.compose.runtime.remember
|
||||
|
|
@ -46,7 +45,7 @@ import io.element.android.libraries.designsystem.theme.components.Text
|
|||
fun HeaderFooterPage(
|
||||
modifier: Modifier = Modifier,
|
||||
paddingValues: PaddingValues = PaddingValues(20.dp),
|
||||
containerColor: Color = MaterialTheme.colorScheme.background,
|
||||
containerColor: Color = ElementTheme.colors.bgCanvasDefault,
|
||||
isScrollable: Boolean = false,
|
||||
background: @Composable () -> Unit = {},
|
||||
topBar: @Composable () -> Unit = {},
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ package io.element.android.libraries.designsystem.background
|
|||
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.center
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.RadialGradientShader
|
||||
import androidx.compose.ui.graphics.ShaderBrush
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
|||
@Composable
|
||||
fun LightGradientBackground(
|
||||
modifier: Modifier = Modifier,
|
||||
backgroundColor: Color = MaterialTheme.colorScheme.background,
|
||||
backgroundColor: Color = ElementTheme.colors.bgCanvasDefault,
|
||||
firstColor: Color = Color(0x1E0DBD8B),
|
||||
secondColor: Color = Color(0x001273EB),
|
||||
ratio: Float = 642 / 775f,
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@ internal fun BloomPreview() {
|
|||
}
|
||||
.bloom(
|
||||
hash = blurhash,
|
||||
background = ElementTheme.materialColors.background,
|
||||
background = ElementTheme.colors.bgCanvasDefault,
|
||||
blurSize = DpSize(430.dp, 430.dp),
|
||||
offset = DpOffset(24.dp, 24.dp),
|
||||
clipToSize = if (topAppBarHeight > 0) DpSize(430.dp, topAppBarHeight.toDp()) else DpSize.Zero,
|
||||
|
|
@ -554,9 +554,9 @@ internal fun BloomInitialsPreview(@PreviewParameter(InitialsColorIntProvider::cl
|
|||
// Workaround to display a very subtle bloom for avatars with very soft colors
|
||||
Color(0xFFF9F9F9)
|
||||
} else {
|
||||
ElementTheme.materialColors.background
|
||||
ElementTheme.colors.bgCanvasDefault
|
||||
},
|
||||
bottomSoftEdgeColor = ElementTheme.materialColors.background,
|
||||
bottomSoftEdgeColor = ElementTheme.colors.bgCanvasDefault,
|
||||
blurSize = DpSize(256.dp, 256.dp),
|
||||
),
|
||||
contentAlignment = Alignment.Center
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ package io.element.android.libraries.designsystem.components
|
|||
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewGroup
|
||||
import io.element.android.libraries.designsystem.theme.components.Checkbox
|
||||
|
|
@ -38,7 +38,7 @@ fun LabelledCheckbox(
|
|||
)
|
||||
Text(
|
||||
text = text,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
color = ElementTheme.colors.textPrimary,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewGroup
|
||||
|
|
@ -64,13 +65,13 @@ fun ProgressDialog(
|
|||
when (type) {
|
||||
is ProgressDialogType.Indeterminate -> {
|
||||
CircularProgressIndicator(
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
color = ElementTheme.colors.iconPrimary
|
||||
)
|
||||
}
|
||||
is ProgressDialogType.Determinate -> {
|
||||
CircularProgressIndicator(
|
||||
progress = { type.progress },
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
color = ElementTheme.colors.iconPrimary
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -93,7 +94,7 @@ private fun ProgressDialogContent(
|
|||
onCancelClick: () -> Unit = {},
|
||||
progressIndicator: @Composable () -> Unit = {
|
||||
CircularProgressIndicator(
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
color = ElementTheme.colors.iconPrimary
|
||||
)
|
||||
}
|
||||
) {
|
||||
|
|
@ -114,7 +115,7 @@ private fun ProgressDialogContent(
|
|||
Spacer(modifier = Modifier.height(22.dp))
|
||||
Text(
|
||||
text = text,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
color = ElementTheme.colors.textPrimary,
|
||||
)
|
||||
}
|
||||
if (showCancelButton) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import androidx.compose.foundation.layout.height
|
|||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ripple
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
|
|
@ -58,17 +57,16 @@ fun MainActionButton(
|
|||
.widthIn(min = 76.dp, max = 96.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
val tintColor = if (enabled) LocalContentColor.current else MaterialTheme.colorScheme.secondary
|
||||
Icon(
|
||||
imageVector = imageVector,
|
||||
contentDescription = contentDescription,
|
||||
tint = tintColor,
|
||||
tint = if (enabled) LocalContentColor.current else ElementTheme.colors.iconDisabled,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(14.dp))
|
||||
Text(
|
||||
title,
|
||||
style = ElementTheme.typography.fontBodyMdMedium.copy(hyphens = Hyphens.Auto),
|
||||
color = tintColor,
|
||||
color = if (enabled) LocalContentColor.current else ElementTheme.colors.textDisabled,
|
||||
overflow = TextOverflow.Visible,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
package io.element.android.libraries.designsystem.theme
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import io.element.android.compound.annotations.CoreColorToken
|
||||
|
|
@ -24,13 +23,13 @@ import kotlinx.collections.immutable.persistentMapOf
|
|||
* Room list.
|
||||
*/
|
||||
@Composable
|
||||
fun MaterialTheme.roomListRoomName() = colorScheme.primary
|
||||
fun ElementTheme.roomListRoomName() = colors.textPrimary
|
||||
|
||||
@Composable
|
||||
fun MaterialTheme.roomListRoomMessage() = colorScheme.secondary
|
||||
fun ElementTheme.roomListRoomMessage() = colors.textSecondary
|
||||
|
||||
@Composable
|
||||
fun MaterialTheme.roomListRoomMessageDate() = colorScheme.secondary
|
||||
fun ElementTheme.roomListRoomMessageDate() = colors.textSecondary
|
||||
|
||||
val SemanticColors.unreadIndicator
|
||||
get() = iconAccentTertiary
|
||||
|
|
@ -181,9 +180,9 @@ internal fun ColorAliasesPreview() = ElementPreview {
|
|||
backgroundColor = Color.Black,
|
||||
foregroundColor = Color.White,
|
||||
colors = persistentMapOf(
|
||||
"roomListRoomName" to MaterialTheme.roomListRoomName(),
|
||||
"roomListRoomMessage" to MaterialTheme.roomListRoomMessage(),
|
||||
"roomListRoomMessageDate" to MaterialTheme.roomListRoomMessageDate(),
|
||||
"roomListRoomName" to ElementTheme.roomListRoomName(),
|
||||
"roomListRoomMessage" to ElementTheme.roomListRoomMessage(),
|
||||
"roomListRoomMessageDate" to ElementTheme.roomListRoomMessageDate(),
|
||||
"unreadIndicator" to ElementTheme.colors.unreadIndicator,
|
||||
"placeholderBackground" to ElementTheme.colors.placeholderBackground,
|
||||
"messageFromMeBackground" to ElementTheme.colors.messageFromMeBackground,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import io.element.android.compound.theme.ElementTheme
|
|||
import io.element.android.compound.theme.Theme
|
||||
import io.element.android.compound.theme.isDark
|
||||
import io.element.android.compound.theme.mapToTheme
|
||||
import io.element.android.features.enterprise.api.EnterpriseService
|
||||
import io.element.android.libraries.preferences.api.store.AppPreferencesStore
|
||||
|
||||
/**
|
||||
|
|
@ -29,6 +30,7 @@ import io.element.android.libraries.preferences.api.store.AppPreferencesStore
|
|||
@Composable
|
||||
fun ElementThemeApp(
|
||||
appPreferencesStore: AppPreferencesStore,
|
||||
enterpriseService: EnterpriseService,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
val theme by remember {
|
||||
|
|
@ -44,8 +46,12 @@ fun ElementThemeApp(
|
|||
}
|
||||
)
|
||||
}
|
||||
val compoundLight = remember { enterpriseService.semanticColorsLight() }
|
||||
val compoundDark = remember { enterpriseService.semanticColorsDark() }
|
||||
ElementTheme(
|
||||
darkTheme = theme.isDark(),
|
||||
content = content,
|
||||
compoundLight = compoundLight,
|
||||
compoundDark = compoundDark,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ internal fun SimpleAlertDialogContent(
|
|||
// most cases, TextButtons should be used for dismiss and confirm buttons.
|
||||
// TextButtons will not consume this provided content color value, and will used their
|
||||
// own defined or default colors.
|
||||
buttonContentColor = MaterialTheme.colorScheme.primary,
|
||||
buttonContentColor = ElementTheme.colors.textPrimary,
|
||||
applyPaddingToContents = applyPaddingToContents,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ internal enum class ButtonStyle {
|
|||
contentColor = if (destructive) {
|
||||
ElementTheme.colors.textCriticalPrimary
|
||||
} else {
|
||||
if (LocalContentColor.current.isSpecified) LocalContentColor.current else ElementTheme.materialColors.primary
|
||||
if (LocalContentColor.current.isSpecified) LocalContentColor.current else ElementTheme.colors.textPrimary
|
||||
},
|
||||
disabledContainerColor = Color.Transparent,
|
||||
disabledContentColor = getDisabledContentColor(destructive),
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ fun <T> SearchBar(
|
|||
Icon(
|
||||
imageVector = CompoundIcons.Search(),
|
||||
contentDescription = stringResource(CommonStrings.action_search),
|
||||
tint = ElementTheme.materialColors.tertiary,
|
||||
tint = ElementTheme.colors.iconTertiary,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ fun <T> SearchBar(
|
|||
Text(
|
||||
text = stringResource(CommonStrings.common_no_results),
|
||||
textAlign = TextAlign.Center,
|
||||
color = ElementTheme.materialColors.tertiary,
|
||||
color = ElementTheme.colors.textSecondary,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ package io.element.android.libraries.designsystem.theme.components.previews
|
|||
import androidx.compose.material3.AlertDialogDefaults
|
||||
import androidx.compose.material3.DatePicker
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.rememberDatePickerState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.libraries.architecture.coverage.ExcludeFromCoverage
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
|
||||
|
|
@ -48,7 +48,7 @@ private fun ContentToPreview() {
|
|||
shape = AlertDialogDefaults.shape,
|
||||
containerColor = AlertDialogDefaults.containerColor,
|
||||
tonalElevation = AlertDialogDefaults.TonalElevation,
|
||||
buttonContentColor = MaterialTheme.colorScheme.primary,
|
||||
buttonContentColor = ElementTheme.colors.textPrimary,
|
||||
iconContentColor = AlertDialogDefaults.iconContentColor,
|
||||
titleContentColor = AlertDialogDefaults.titleContentColor,
|
||||
textContentColor = AlertDialogDefaults.textContentColor,
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ package io.element.android.libraries.designsystem.theme.components.previews
|
|||
|
||||
import androidx.compose.material3.AlertDialogDefaults
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.TimePicker
|
||||
import androidx.compose.material3.TimePickerLayoutType
|
||||
import androidx.compose.material3.rememberTimePickerState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
|
||||
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
|
||||
|
|
@ -35,7 +35,7 @@ internal fun TimePickerHorizontalPreview() {
|
|||
shape = AlertDialogDefaults.shape,
|
||||
containerColor = AlertDialogDefaults.containerColor,
|
||||
tonalElevation = AlertDialogDefaults.TonalElevation,
|
||||
buttonContentColor = MaterialTheme.colorScheme.primary,
|
||||
buttonContentColor = ElementTheme.colors.textPrimary,
|
||||
iconContentColor = AlertDialogDefaults.iconContentColor,
|
||||
titleContentColor = AlertDialogDefaults.titleContentColor,
|
||||
textContentColor = AlertDialogDefaults.textContentColor,
|
||||
|
|
@ -57,7 +57,7 @@ internal fun TimePickerVerticalLightPreview() {
|
|||
shape = AlertDialogDefaults.shape,
|
||||
containerColor = AlertDialogDefaults.containerColor,
|
||||
tonalElevation = AlertDialogDefaults.TonalElevation,
|
||||
buttonContentColor = MaterialTheme.colorScheme.primary,
|
||||
buttonContentColor = ElementTheme.colors.textPrimary,
|
||||
iconContentColor = AlertDialogDefaults.iconContentColor,
|
||||
titleContentColor = AlertDialogDefaults.titleContentColor,
|
||||
textContentColor = AlertDialogDefaults.textContentColor,
|
||||
|
|
@ -83,7 +83,7 @@ internal fun TimePickerVerticalDarkPreview() {
|
|||
shape = AlertDialogDefaults.shape,
|
||||
containerColor = AlertDialogDefaults.containerColor,
|
||||
tonalElevation = AlertDialogDefaults.TonalElevation,
|
||||
buttonContentColor = MaterialTheme.colorScheme.primary,
|
||||
buttonContentColor = ElementTheme.colors.textPrimary,
|
||||
iconContentColor = AlertDialogDefaults.iconContentColor,
|
||||
titleContentColor = AlertDialogDefaults.titleContentColor,
|
||||
textContentColor = AlertDialogDefaults.textContentColor,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue