Centralize gradient color definitions
This commit is contained in:
parent
e8a3720c2a
commit
99bfde7eec
4 changed files with 53 additions and 18 deletions
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.designsystem.colors
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.ReadOnlyComposable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
|
||||
@Composable
|
||||
@ReadOnlyComposable
|
||||
fun gradientActionColors(): List<Color> = listOf(
|
||||
ElementTheme.colors.gradientActionStop1,
|
||||
ElementTheme.colors.gradientActionStop2,
|
||||
ElementTheme.colors.gradientActionStop3,
|
||||
ElementTheme.colors.gradientActionStop4,
|
||||
)
|
||||
|
||||
@Composable
|
||||
@ReadOnlyComposable
|
||||
fun gradientSubtleColors(): List<Color> = listOf(
|
||||
ElementTheme.colors.gradientSubtleStop1,
|
||||
ElementTheme.colors.gradientSubtleStop2,
|
||||
ElementTheme.colors.gradientSubtleStop3,
|
||||
ElementTheme.colors.gradientSubtleStop4,
|
||||
ElementTheme.colors.gradientSubtleStop5,
|
||||
ElementTheme.colors.gradientSubtleStop6,
|
||||
)
|
||||
|
||||
@Composable
|
||||
@ReadOnlyComposable
|
||||
fun gradientInfoColors(): List<Color> = listOf(
|
||||
ElementTheme.colors.gradientInfoStop1,
|
||||
ElementTheme.colors.gradientInfoStop2,
|
||||
ElementTheme.colors.gradientInfoStop3,
|
||||
ElementTheme.colors.gradientInfoStop4,
|
||||
ElementTheme.colors.gradientInfoStop5,
|
||||
ElementTheme.colors.gradientInfoStop6,
|
||||
)
|
||||
|
|
@ -37,6 +37,7 @@ import androidx.compose.ui.graphics.Shape
|
|||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.unit.dp
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.libraries.designsystem.colors.gradientActionColors
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.theme.LocalBuildMeta
|
||||
|
|
@ -68,12 +69,7 @@ fun SuperButton(
|
|||
ElementTheme.colors.textActionAccent,
|
||||
)
|
||||
} else {
|
||||
listOf(
|
||||
ElementTheme.colors.gradientActionStop1,
|
||||
ElementTheme.colors.gradientActionStop2,
|
||||
ElementTheme.colors.gradientActionStop3,
|
||||
ElementTheme.colors.gradientActionStop4,
|
||||
)
|
||||
gradientActionColors()
|
||||
}
|
||||
|
||||
val shaderBrush = remember(colors) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import androidx.compose.ui.graphics.Brush
|
|||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.libraries.designsystem.colors.gradientSubtleColors
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.theme.LocalBuildMeta
|
||||
|
|
@ -51,12 +52,10 @@ fun subtleColorStops(
|
|||
add(0.75f to ElementTheme.colors.bgCanvasDefault)
|
||||
add(1f to Color.Transparent)
|
||||
} else {
|
||||
add(0f to ElementTheme.colors.gradientSubtleStop1)
|
||||
add(1 / 5f to ElementTheme.colors.gradientSubtleStop2)
|
||||
add(2 / 5f to ElementTheme.colors.gradientSubtleStop3)
|
||||
add(3 / 5f to ElementTheme.colors.gradientSubtleStop4)
|
||||
add(4 / 5f to ElementTheme.colors.gradientSubtleStop5)
|
||||
add(1f to ElementTheme.colors.gradientSubtleStop6)
|
||||
val colors = gradientSubtleColors()
|
||||
colors.forEachIndexed { index, color ->
|
||||
add(index.toFloat() / (colors.size - 1) to color)
|
||||
}
|
||||
}
|
||||
}.toTypedArray()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import androidx.compose.ui.graphics.ShaderBrush
|
|||
import androidx.compose.ui.unit.dp
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.compound.tokens.generated.CompoundIcons
|
||||
import io.element.android.libraries.designsystem.colors.gradientActionColors
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.theme.components.Icon
|
||||
|
|
@ -89,12 +90,7 @@ private fun Modifier.buttonBackgroundModifier(
|
|||
canSendMessage: Boolean,
|
||||
) = then(
|
||||
if (canSendMessage) {
|
||||
val colors = listOf(
|
||||
ElementTheme.colors.gradientActionStop1,
|
||||
ElementTheme.colors.gradientActionStop2,
|
||||
ElementTheme.colors.gradientActionStop3,
|
||||
ElementTheme.colors.gradientActionStop4,
|
||||
)
|
||||
val colors = gradientActionColors()
|
||||
Modifier.drawWithCache {
|
||||
val verticalGradientBrush = ShaderBrush(
|
||||
LinearGradientShader(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue