From 26a96d91165180e6cd7b6edad1c038d6102ff409 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Thu, 28 Oct 2021 22:14:44 +0530 Subject: [PATCH] common: add `CompositionLocal` support to `LobstersTheme` --- .../dev/msfjarvis/claw/common/theme/Theme.kt | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/common/src/commonMain/kotlin/dev/msfjarvis/claw/common/theme/Theme.kt b/common/src/commonMain/kotlin/dev/msfjarvis/claw/common/theme/Theme.kt index fc6b9309..685a3a0a 100644 --- a/common/src/commonMain/kotlin/dev/msfjarvis/claw/common/theme/Theme.kt +++ b/common/src/commonMain/kotlin/dev/msfjarvis/claw/common/theme/Theme.kt @@ -5,6 +5,8 @@ import androidx.compose.material.Typography import androidx.compose.material.darkColors import androidx.compose.material.lightColors import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.ProvidedValue import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.font.FontFamily @@ -37,13 +39,19 @@ val darkColors = ) @Composable -fun LobstersTheme(darkTheme: Boolean, children: @Composable () -> Unit) { - MaterialTheme( - colors = if (darkTheme) darkColors else lightColors, - typography = - Typography( - defaultFontFamily = manropeFontFamily, - ), - content = children, - ) +fun LobstersTheme( + darkTheme: Boolean, + providedValues: Array> = emptyArray(), + children: @Composable () -> Unit +) { + CompositionLocalProvider(*providedValues) { + MaterialTheme( + colors = if (darkTheme) darkColors else lightColors, + typography = + Typography( + defaultFontFamily = manropeFontFamily, + ), + content = children, + ) + } }