Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add missing parameters from MaterialTheme #75

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions material-kolor/api/android/material-kolor.api
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ public final class com/materialkolor/DynamicColorSchemeKt {
}

public final class com/materialkolor/DynamicMaterialThemeKt {
public static final fun AnimatedDynamicMaterialTheme-ZPw9REg (JZLcom/materialkolor/PaletteStyle;DLandroidx/compose/animation/core/AnimationSpec;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V
public static final fun DynamicMaterialTheme-yWKOrZg (JZLcom/materialkolor/PaletteStyle;DLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V
public static final fun AnimatedDynamicMaterialTheme-pzZJ40c (JZLcom/materialkolor/PaletteStyle;DLandroidx/compose/animation/core/AnimationSpec;Landroidx/compose/material3/Shapes;Landroidx/compose/material3/Typography;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V
public static final fun DynamicMaterialTheme-Pd0R-II (JZLcom/materialkolor/PaletteStyle;DLandroidx/compose/material3/Shapes;Landroidx/compose/material3/Typography;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V
}

public final class com/materialkolor/LocalDynamicMaterialThemeSeedKt {
Expand All @@ -22,6 +22,7 @@ public final class com/materialkolor/PaletteStyle : java/lang/Enum {
public static final field Rainbow Lcom/materialkolor/PaletteStyle;
public static final field TonalSpot Lcom/materialkolor/PaletteStyle;
public static final field Vibrant Lcom/materialkolor/PaletteStyle;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lcom/materialkolor/PaletteStyle;
public static fun values ()[Lcom/materialkolor/PaletteStyle;
}
Expand Down
5 changes: 3 additions & 2 deletions material-kolor/api/jvm/material-kolor.api
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ public final class com/materialkolor/DynamicColorSchemeKt {
}

public final class com/materialkolor/DynamicMaterialThemeKt {
public static final fun AnimatedDynamicMaterialTheme-ZPw9REg (JZLcom/materialkolor/PaletteStyle;DLandroidx/compose/animation/core/AnimationSpec;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V
public static final fun DynamicMaterialTheme-yWKOrZg (JZLcom/materialkolor/PaletteStyle;DLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V
public static final fun AnimatedDynamicMaterialTheme-pzZJ40c (JZLcom/materialkolor/PaletteStyle;DLandroidx/compose/animation/core/AnimationSpec;Landroidx/compose/material3/Shapes;Landroidx/compose/material3/Typography;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V
public static final fun DynamicMaterialTheme-Pd0R-II (JZLcom/materialkolor/PaletteStyle;DLandroidx/compose/material3/Shapes;Landroidx/compose/material3/Typography;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V
}

public final class com/materialkolor/LocalDynamicMaterialThemeSeedKt {
Expand All @@ -22,6 +22,7 @@ public final class com/materialkolor/PaletteStyle : java/lang/Enum {
public static final field Rainbow Lcom/materialkolor/PaletteStyle;
public static final field TonalSpot Lcom/materialkolor/PaletteStyle;
public static final field Vibrant Lcom/materialkolor/PaletteStyle;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lcom/materialkolor/PaletteStyle;
public static fun values ()[Lcom/materialkolor/PaletteStyle;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import androidx.compose.animation.core.spring
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Shapes
import androidx.compose.material3.Typography
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.derivedStateOf
Expand All @@ -20,6 +22,8 @@ public fun DynamicMaterialTheme(
useDarkTheme: Boolean = isSystemInDarkTheme(),
style: PaletteStyle = PaletteStyle.TonalSpot,
contrastLevel: Double = 0.0,
shapes: Shapes = MaterialTheme.shapes,
typography: Typography = MaterialTheme.typography,
content: @Composable () -> Unit,
) {
val colorScheme: ColorScheme by remember(seedColor, useDarkTheme, style, contrastLevel) {
Expand All @@ -34,7 +38,12 @@ public fun DynamicMaterialTheme(
}

CompositionLocalProvider(LocalDynamicMaterialThemeSeed provides seedColor) {
MaterialTheme(colorScheme = colorScheme, content = content)
MaterialTheme(
colorScheme = colorScheme,
shapes = shapes,
typography = typography,
content = content,
)
}
}

Expand All @@ -45,6 +54,8 @@ public fun AnimatedDynamicMaterialTheme(
style: PaletteStyle = PaletteStyle.TonalSpot,
contrastLevel: Double = 0.0,
animationSpec: AnimationSpec<Color> = spring(stiffness = Spring.StiffnessLow),
shapes: Shapes = MaterialTheme.shapes,
typography: Typography = MaterialTheme.typography,
content: @Composable () -> Unit,
) {
val colors: ColorScheme by remember(seedColor, useDarkTheme, style, contrastLevel) {
Expand Down Expand Up @@ -77,6 +88,11 @@ public fun AnimatedDynamicMaterialTheme(
)

CompositionLocalProvider(LocalDynamicMaterialThemeSeed provides seedColor) {
MaterialTheme(colorScheme = animatedColorScheme, content = content)
MaterialTheme(
colorScheme = animatedColorScheme,
shapes = shapes,
typography = typography,
content = content,
)
}
}