Add text selection colors

This commit is contained in:
Andrew 2024-03-14 14:28:56 +10:30
parent c72f37a9ac
commit eb98ce961c
2 changed files with 10 additions and 3 deletions

View File

@ -80,7 +80,7 @@ fun destructiveButtonColors() = ButtonDefaults.buttonColors(backgroundColor = Co
@Preview
@Composable
fun Context.PreviewMessageDetails(
fun PreviewMessageDetails(
@PreviewParameter(ThemeResPreviewParameterProvider::class) themeResId: Int
) {
PreviewTheme(themeResId) {
@ -127,6 +127,5 @@ fun outlinedTextFieldColors(
textColor = if (isError) colorDestructive else LocalContentColor.current.copy(LocalContentAlpha.current),
focusedBorderColor = Color(classicDark3),
unfocusedBorderColor = Color(classicDark3),
cursorColor = LocalContentColor.current,
placeholderColor = if (isError) colorDestructive else MaterialTheme.colors.onSurface.copy(ContentAlpha.medium)
)

View File

@ -5,6 +5,8 @@ import androidx.annotation.AttrRes
import androidx.appcompat.view.ContextThemeWrapper
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.text.selection.LocalTextSelectionColors
import androidx.compose.foundation.text.selection.TextSelectionColors
import androidx.compose.material.LocalContentColor
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Shapes
@ -55,9 +57,15 @@ fun AppTheme(
val surface = context.getColorFromTheme(R.attr.colorSettingsBackground)
CompositionLocalProvider(LocalExtraColors provides extraColors) {
AppCompatTheme(surface = surface) {
content()
CompositionLocalProvider(LocalTextSelectionColors provides TextSelectionColors(
handleColor = MaterialTheme.colors.secondary,
backgroundColor = MaterialTheme.colors.secondary.copy(alpha = 0.5f)
)) {
content()
}
}
}
}