From 7bc5165ad1f7943f0160d3682e3b840a431976ed Mon Sep 17 00:00:00 2001 From: Yasan Glass Date: Wed, 18 Oct 2023 23:41:27 +0200 Subject: [PATCH] Create Spacer components --- .../yasan/stillbirth/component/Spacer.kt | 20 ++++++++++ .../stillbirth/component/SpacerHorizontal.kt | 15 +++++++ .../stillbirth/component/SpacerVertical.kt | 15 +++++++ .../component/extension/DividerExtensions.kt | 10 +++++ .../component/extension/SpacerExtensions.kt | 39 +++++++++++++++++++ 5 files changed, 99 insertions(+) create mode 100644 stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/Spacer.kt create mode 100644 stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/SpacerHorizontal.kt create mode 100644 stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/SpacerVertical.kt create mode 100644 stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/extension/DividerExtensions.kt create mode 100644 stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/extension/SpacerExtensions.kt diff --git a/stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/Spacer.kt b/stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/Spacer.kt new file mode 100644 index 0000000..b136632 --- /dev/null +++ b/stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/Spacer.kt @@ -0,0 +1,20 @@ +package glass.yasan.stillbirth.component + +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.width +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.Dp + +@Composable +public fun Spacer( + width: Dp, + height: Dp, +) { + Spacer( + modifier = Modifier + .width(width) + .height(height), + ) +} diff --git a/stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/SpacerHorizontal.kt b/stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/SpacerHorizontal.kt new file mode 100644 index 0000000..11c8006 --- /dev/null +++ b/stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/SpacerHorizontal.kt @@ -0,0 +1,15 @@ +package glass.yasan.stillbirth.component + +import androidx.compose.runtime.Composable +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp + +@Composable +public fun SpacerHorizontal( + width: Dp, +) { + Spacer( + width = width, + height = 0.dp, + ) +} \ No newline at end of file diff --git a/stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/SpacerVertical.kt b/stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/SpacerVertical.kt new file mode 100644 index 0000000..4c58041 --- /dev/null +++ b/stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/SpacerVertical.kt @@ -0,0 +1,15 @@ +package glass.yasan.stillbirth.component + +import androidx.compose.runtime.Composable +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp + +@Composable +public fun SpacerVertical( + height: Dp, +) { + Spacer( + width = 0.dp, + height = height, + ) +} diff --git a/stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/extension/DividerExtensions.kt b/stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/extension/DividerExtensions.kt new file mode 100644 index 0000000..5a84743 --- /dev/null +++ b/stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/extension/DividerExtensions.kt @@ -0,0 +1,10 @@ +package glass.yasan.stillbirth.component.extension + +import androidx.compose.foundation.lazy.LazyListScope +import glass.yasan.stillbirth.component.Divider + +public fun LazyListScope.divider() { + item { + Divider() + } +} \ No newline at end of file diff --git a/stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/extension/SpacerExtensions.kt b/stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/extension/SpacerExtensions.kt new file mode 100644 index 0000000..fc2d44a --- /dev/null +++ b/stillbirth/src/main/kotlin/glass/yasan/stillbirth/component/extension/SpacerExtensions.kt @@ -0,0 +1,39 @@ +package glass.yasan.stillbirth.component.extension + +import androidx.compose.foundation.lazy.LazyListScope +import androidx.compose.ui.unit.Dp +import glass.yasan.stillbirth.component.Spacer +import glass.yasan.stillbirth.component.SpacerHorizontal +import glass.yasan.stillbirth.component.SpacerVertical + +public fun LazyListScope.spacer( + width: Dp, + height: Dp, +) { + item { + Spacer( + width = width, + height = height, + ) + } +} + +public fun LazyListScope.spacerHorizontal( + width: Dp, +) { + item { + SpacerHorizontal( + width = width, + ) + } +} + +public fun LazyListScope.spacerVertical( + height: Dp, +) { + item { + SpacerVertical( + height = height, + ) + } +} \ No newline at end of file