feat: add LocalInSurface in Surface

This commit is contained in:
2023-12-02 10:30:55 +08:00
parent 78619a0f6b
commit 5fff6801bf

View File

@@ -32,6 +32,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Immutable import androidx.compose.runtime.Immutable
import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.composed import androidx.compose.ui.composed
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
@@ -54,6 +55,7 @@ fun Surface(
content: @Composable BoxScope.() -> Unit content: @Composable BoxScope.() -> Unit
) { ) {
CompositionLocalProvider( CompositionLocalProvider(
LocalInSurface provides true,
LocalColors provides LocalColors.current.copy( LocalColors provides LocalColors.current.copy(
backgroundPrimary = colors.backgroundColor, backgroundPrimary = colors.backgroundColor,
textPrimary = colors.contentColor textPrimary = colors.contentColor
@@ -90,6 +92,8 @@ object Surface {
get() = defaultSurfacePadding() get() = defaultSurfacePadding()
} }
internal val LocalInSurface = compositionLocalOf { false }
@Composable @Composable
@ReadOnlyComposable @ReadOnlyComposable
private fun defaultSurfaceColors() = SurfaceColors( private fun defaultSurfaceColors() = SurfaceColors(