diff --git a/app/src/main/java/com/imashnake/animite/features/theme/Theme.kt b/app/src/main/java/com/imashnake/animite/features/theme/Theme.kt index ba10def8..14f744e4 100644 --- a/app/src/main/java/com/imashnake/animite/features/theme/Theme.kt +++ b/app/src/main/java/com/imashnake/animite/features/theme/Theme.kt @@ -12,10 +12,16 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.Immutable import androidx.compose.ui.platform.LocalContext +import com.imashnake.animite.core.ui.LocalPaddings +import com.imashnake.animite.core.ui.Paddings +import com.imashnake.animite.core.ui.rememberDefaultPaddings import com.imashnake.animite.dev.ext.pastelize @Composable -fun AnimiteTheme(content: @Composable () -> Unit) { +fun AnimiteTheme( + paddings: Paddings = rememberDefaultPaddings(), + content: @Composable () -> Unit +) { val dynamicColor = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S val darkTheme = isSystemInDarkTheme() val animiteColorScheme = when { @@ -33,6 +39,7 @@ fun AnimiteTheme(content: @Composable () -> Unit) { ) { CompositionLocalProvider( LocalRippleTheme provides AnimiteRippleTheme, + LocalPaddings provides paddings, content = content ) } diff --git a/core/src/main/kotlin/com/imashnake/animite/core/ui/Paddings.kt b/core/src/main/kotlin/com/imashnake/animite/core/ui/Paddings.kt new file mode 100644 index 00000000..14ab809b --- /dev/null +++ b/core/src/main/kotlin/com/imashnake/animite/core/ui/Paddings.kt @@ -0,0 +1,35 @@ +package com.imashnake.animite.core.ui + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.runtime.staticCompositionLocalOf +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.dimensionResource +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import com.imashnake.animite.core.R + +data class Paddings( + val ultraTiny: Dp, + val tiny: Dp, + val small: Dp, + val medium: Dp, + val large: Dp +) { + companion object { + val ZERO = 0.dp + } +} + +val LocalPaddings = staticCompositionLocalOf { error("Paddings must be set!") } + +@Composable +fun rememberDefaultPaddings(): Paddings { + return Paddings( + ultraTiny = dimensionResource(R.dimen.ultra_tiny_padding), + tiny = dimensionResource(R.dimen.tiny_padding), + small = dimensionResource(R.dimen.small_padding), + medium = dimensionResource(R.dimen.medium_padding), + large = dimensionResource(R.dimen.large_padding) + ) +}