Create ExtendedColors to define more colors.
This commit is contained in:
parent
7b0ae0014a
commit
3ecce4e24f
4 changed files with 59 additions and 29 deletions
|
|
@ -30,13 +30,7 @@ import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Shape
|
import androidx.compose.ui.graphics.Shape
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import io.element.android.features.messages.timeline.model.MessagesItemGroupPosition
|
import io.element.android.features.messages.timeline.model.MessagesItemGroupPosition
|
||||||
import io.element.android.libraries.designsystem.LocalIsDarkTheme
|
import io.element.android.libraries.designsystem.LocalExtendedColors
|
||||||
import io.element.android.libraries.designsystem.MessageHighlightDark
|
|
||||||
import io.element.android.libraries.designsystem.MessageHighlightLight
|
|
||||||
import io.element.android.libraries.designsystem.SystemGrey5Dark
|
|
||||||
import io.element.android.libraries.designsystem.SystemGrey5Light
|
|
||||||
import io.element.android.libraries.designsystem.SystemGrey6Dark
|
|
||||||
import io.element.android.libraries.designsystem.SystemGrey6Light
|
|
||||||
|
|
||||||
private val BUBBLE_RADIUS = 16.dp
|
private val BUBBLE_RADIUS = 16.dp
|
||||||
|
|
||||||
|
|
@ -88,24 +82,12 @@ fun MessageEventBubble(
|
||||||
}
|
}
|
||||||
|
|
||||||
val backgroundBubbleColor = if (isHighlighted) {
|
val backgroundBubbleColor = if (isHighlighted) {
|
||||||
if (LocalIsDarkTheme.current) {
|
LocalExtendedColors.current.messageHighlightedBackground
|
||||||
MessageHighlightDark
|
|
||||||
} else {
|
|
||||||
MessageHighlightLight
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (isMine) {
|
if (isMine) {
|
||||||
if (LocalIsDarkTheme.current) {
|
LocalExtendedColors.current.messageFromMeBackground
|
||||||
SystemGrey5Dark
|
|
||||||
} else {
|
|
||||||
SystemGrey5Light
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (LocalIsDarkTheme.current) {
|
LocalExtendedColors.current.messageFromOtherBackground
|
||||||
SystemGrey6Dark
|
|
||||||
} else {
|
|
||||||
SystemGrey6Light
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val bubbleShape = bubbleShape()
|
val bubbleShape = bubbleShape()
|
||||||
|
|
|
||||||
|
|
@ -52,10 +52,4 @@ val ElementGreen = Color(0xFF0DBD8B)
|
||||||
val ElementOrange = Color(0xFFD9B072)
|
val ElementOrange = Color(0xFFD9B072)
|
||||||
val Vermilion = Color(0xFFFF5B55)
|
val Vermilion = Color(0xFFFF5B55)
|
||||||
|
|
||||||
// TODO Update color
|
|
||||||
val MessageHighlightLight = Azure
|
|
||||||
|
|
||||||
// TODO Update color
|
|
||||||
val MessageHighlightDark = Azure
|
|
||||||
|
|
||||||
val LinkColor = Color(0xFF054F6E)
|
val LinkColor = Color(0xFF054F6E)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.libraries.designsystem
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Immutable
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
||||||
|
@Immutable
|
||||||
|
data class ExtendedColors(
|
||||||
|
val messageFromMeBackground: Color,
|
||||||
|
val messageFromOtherBackground: Color,
|
||||||
|
val messageHighlightedBackground: Color,
|
||||||
|
)
|
||||||
|
|
||||||
|
internal val extendedColorsLight = ExtendedColors(
|
||||||
|
messageFromMeBackground = SystemGrey5Light,
|
||||||
|
messageFromOtherBackground = SystemGrey6Light,
|
||||||
|
messageHighlightedBackground = Azure,
|
||||||
|
)
|
||||||
|
|
||||||
|
internal val extendedColorsDark = ExtendedColors(
|
||||||
|
messageFromMeBackground = SystemGrey5Dark,
|
||||||
|
messageFromOtherBackground = SystemGrey6Dark,
|
||||||
|
messageHighlightedBackground = Azure,
|
||||||
|
)
|
||||||
|
|
@ -27,6 +27,7 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.runtime.SideEffect
|
import androidx.compose.runtime.SideEffect
|
||||||
import androidx.compose.runtime.compositionLocalOf
|
import androidx.compose.runtime.compositionLocalOf
|
||||||
|
import androidx.compose.runtime.staticCompositionLocalOf
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||||
|
|
@ -64,9 +65,18 @@ private val LightColorScheme = lightColorScheme(
|
||||||
onSurface = Color(0xFF1C1B1F),
|
onSurface = Color(0xFF1C1B1F),
|
||||||
*/
|
*/
|
||||||
)
|
)
|
||||||
|
|
||||||
@Suppress("CompositionLocalAllowlist")
|
@Suppress("CompositionLocalAllowlist")
|
||||||
val LocalIsDarkTheme = compositionLocalOf<Boolean> { error("Not defined") }
|
val LocalIsDarkTheme = compositionLocalOf<Boolean> { error("Not defined") }
|
||||||
|
|
||||||
|
val LocalExtendedColors = staticCompositionLocalOf {
|
||||||
|
ExtendedColors(
|
||||||
|
messageFromMeBackground = Color.Unspecified,
|
||||||
|
messageFromOtherBackground = Color.Unspecified,
|
||||||
|
messageHighlightedBackground = Color.Unspecified,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ElementXTheme(
|
fun ElementXTheme(
|
||||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||||
|
|
@ -95,7 +105,12 @@ fun ElementXTheme(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
CompositionLocalProvider(LocalIsDarkTheme provides darkTheme) {
|
val extendedColors = if (darkTheme) extendedColorsDark else extendedColorsLight
|
||||||
|
|
||||||
|
CompositionLocalProvider(
|
||||||
|
LocalIsDarkTheme provides darkTheme,
|
||||||
|
LocalExtendedColors provides extendedColors,
|
||||||
|
) {
|
||||||
MaterialTheme(
|
MaterialTheme(
|
||||||
colorScheme = colorScheme,
|
colorScheme = colorScheme,
|
||||||
typography = Typography,
|
typography = Typography,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue