Merge pull request #4378 from element-hq/feature/bma/customSuperButton
Be able to correctly render the UI with other colors.
This commit is contained in:
commit
44b837a6bd
20 changed files with 131 additions and 37 deletions
|
|
@ -27,6 +27,7 @@ import androidx.compose.ui.draw.drawBehind
|
|||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Size
|
||||
import androidx.compose.ui.geometry.center
|
||||
import androidx.compose.ui.graphics.BlendMode
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.LinearGradientShader
|
||||
import androidx.compose.ui.graphics.RadialGradientShader
|
||||
|
|
@ -36,10 +37,12 @@ import androidx.compose.ui.graphics.Shape
|
|||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.unit.dp
|
||||
import io.element.android.compound.annotations.CoreColorToken
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.compound.tokens.generated.CompoundIcons
|
||||
import io.element.android.compound.tokens.generated.internal.LightColorTokens
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.theme.LocalBuildMeta
|
||||
import io.element.android.libraries.designsystem.theme.components.Icon
|
||||
|
||||
@OptIn(CoreColorToken::class)
|
||||
|
|
@ -50,6 +53,16 @@ fun GradientFloatingActionButton(
|
|||
shape: Shape = RoundedCornerShape(25),
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
val color1 = if (LocalBuildMeta.current.isEnterpriseBuild) {
|
||||
ElementTheme.colors.textActionAccent
|
||||
} else {
|
||||
LightColorTokens.colorGreen700
|
||||
}
|
||||
val color2 = if (LocalBuildMeta.current.isEnterpriseBuild) {
|
||||
ElementTheme.colors.textActionAccent
|
||||
} else {
|
||||
LightColorTokens.colorBlue900
|
||||
}
|
||||
val linearShaderBrush = remember {
|
||||
object : ShaderBrush() {
|
||||
override fun createShader(size: Size): Shader {
|
||||
|
|
@ -57,8 +70,8 @@ fun GradientFloatingActionButton(
|
|||
from = Offset(size.width, size.height),
|
||||
to = Offset(size.width, 0f),
|
||||
colors = listOf(
|
||||
LightColorTokens.colorBlue900,
|
||||
LightColorTokens.colorGreen700,
|
||||
color2,
|
||||
color1,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -71,8 +84,8 @@ fun GradientFloatingActionButton(
|
|||
center = size.center,
|
||||
radius = size.width / 2,
|
||||
colors = listOf(
|
||||
LightColorTokens.colorGreen700,
|
||||
LightColorTokens.colorBlue900,
|
||||
color1,
|
||||
color2,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
@ -85,8 +98,8 @@ fun GradientFloatingActionButton(
|
|||
.graphicsLayer(shape = shape, clip = false)
|
||||
.clip(shape)
|
||||
.drawBehind {
|
||||
drawRect(brush = radialShaderBrush, alpha = 0.4f)
|
||||
drawRect(brush = linearShaderBrush)
|
||||
drawRect(brush = radialShaderBrush, alpha = 0.4f, blendMode = BlendMode.Overlay)
|
||||
}
|
||||
.clickable(
|
||||
enabled = true,
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import io.element.android.compound.tokens.generated.internal.DarkColorTokens
|
|||
import io.element.android.compound.tokens.generated.internal.LightColorTokens
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.theme.LocalBuildMeta
|
||||
import io.element.android.libraries.designsystem.theme.components.ButtonSize
|
||||
import io.element.android.libraries.designsystem.theme.components.HorizontalDivider
|
||||
import io.element.android.libraries.designsystem.theme.components.lowHorizontalPaddingValue
|
||||
|
|
@ -66,17 +67,24 @@ fun SuperButton(
|
|||
}
|
||||
}
|
||||
val isLightTheme = ElementTheme.isLightTheme
|
||||
val colors = remember(isLightTheme) {
|
||||
if (isLightTheme) {
|
||||
listOf(
|
||||
LightColorTokens.colorBlue900,
|
||||
LightColorTokens.colorGreen1100,
|
||||
)
|
||||
} else {
|
||||
listOf(
|
||||
DarkColorTokens.colorBlue900,
|
||||
DarkColorTokens.colorGreen1100,
|
||||
)
|
||||
val colors = if (LocalBuildMeta.current.isEnterpriseBuild) {
|
||||
listOf(
|
||||
ElementTheme.colors.textActionAccent,
|
||||
ElementTheme.colors.textActionAccent,
|
||||
)
|
||||
} else {
|
||||
remember(isLightTheme) {
|
||||
if (isLightTheme) {
|
||||
listOf(
|
||||
LightColorTokens.colorBlue900,
|
||||
LightColorTokens.colorGreen1100,
|
||||
)
|
||||
} else {
|
||||
listOf(
|
||||
DarkColorTokens.colorBlue900,
|
||||
DarkColorTokens.colorGreen1100,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,17 +9,40 @@ package io.element.android.libraries.designsystem.theme
|
|||
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
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.core.meta.BuildMeta
|
||||
import io.element.android.libraries.core.meta.BuildType
|
||||
import io.element.android.libraries.preferences.api.store.AppPreferencesStore
|
||||
|
||||
val LocalBuildMeta = staticCompositionLocalOf {
|
||||
BuildMeta(
|
||||
isDebuggable = true,
|
||||
buildType = BuildType.DEBUG,
|
||||
applicationName = "MyApp",
|
||||
productionApplicationName = "MyAppProd",
|
||||
desktopApplicationName = "MyAppDesktop",
|
||||
applicationId = "AppId",
|
||||
isEnterpriseBuild = false,
|
||||
lowPrivacyLoggingEnabled = false,
|
||||
versionName = "aVersion",
|
||||
versionCode = 123,
|
||||
gitRevision = "aRevision",
|
||||
gitBranchName = "aBranch",
|
||||
flavorDescription = "aFlavor",
|
||||
flavorShortDescription = "aFlavorShort",
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme to use for all the regular screens of the application.
|
||||
* Will manage the light / dark theme based on the user preference.
|
||||
|
|
@ -31,6 +54,7 @@ import io.element.android.libraries.preferences.api.store.AppPreferencesStore
|
|||
fun ElementThemeApp(
|
||||
appPreferencesStore: AppPreferencesStore,
|
||||
enterpriseService: EnterpriseService,
|
||||
buildMeta: BuildMeta,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
val theme by remember {
|
||||
|
|
@ -48,10 +72,14 @@ fun ElementThemeApp(
|
|||
}
|
||||
val compoundLight = remember { enterpriseService.semanticColorsLight() }
|
||||
val compoundDark = remember { enterpriseService.semanticColorsDark() }
|
||||
ElementTheme(
|
||||
darkTheme = theme.isDark(),
|
||||
content = content,
|
||||
compoundLight = compoundLight,
|
||||
compoundDark = compoundDark,
|
||||
)
|
||||
CompositionLocalProvider(
|
||||
LocalBuildMeta provides buildMeta,
|
||||
) {
|
||||
ElementTheme(
|
||||
darkTheme = theme.isDark(),
|
||||
content = content,
|
||||
compoundLight = compoundLight,
|
||||
compoundDark = compoundDark,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue