Skip to content

Commit

Permalink
Introduce Paddings
Browse files Browse the repository at this point in the history
  • Loading branch information
boswelja committed Jan 3, 2024
1 parent 80a3297 commit c9d8319
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -33,6 +39,7 @@ fun AnimiteTheme(content: @Composable () -> Unit) {
) {
CompositionLocalProvider(
LocalRippleTheme provides AnimiteRippleTheme,
LocalPaddings provides paddings,
content = content
)
}
Expand Down
35 changes: 35 additions & 0 deletions core/src/main/kotlin/com/imashnake/animite/core/ui/Paddings.kt
Original file line number Diff line number Diff line change
@@ -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<Paddings> { 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)
)
}

0 comments on commit c9d8319

Please sign in to comment.