From 2713c6e2ac27c24d1e7828277b300729313ca3ce Mon Sep 17 00:00:00 2001 From: kwak kun Date: Fri, 1 Nov 2024 01:23:41 +0900 Subject: [PATCH 1/3] =?UTF-8?q?add=20:=20width=EB=A5=BC=20nullable?= =?UTF-8?q?=EB=A1=9C=20=ED=95=98=EB=8A=94=20=EB=B2=84=EC=A0=84=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yourssu/handy/demo/DividerPreview.kt | 20 +++++++++++ .../com/yourssu/handy/compose/Divider.kt | 36 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 app/src/main/kotlin/com/yourssu/handy/demo/DividerPreview.kt create mode 100644 compose/src/main/kotlin/com/yourssu/handy/compose/Divider.kt diff --git a/app/src/main/kotlin/com/yourssu/handy/demo/DividerPreview.kt b/app/src/main/kotlin/com/yourssu/handy/demo/DividerPreview.kt new file mode 100644 index 0000000..c969965 --- /dev/null +++ b/app/src/main/kotlin/com/yourssu/handy/demo/DividerPreview.kt @@ -0,0 +1,20 @@ +package com.yourssu.handy.demo + +import androidx.compose.foundation.layout.Column +import androidx.compose.runtime.Composable +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import com.yourssu.handy.compose.Divider +import com.yourssu.handy.compose.DividerSize +import com.yourssu.handy.compose.Text + +@Preview +@Composable +fun DividerExample() { + Column { + Text("Section 1") + Divider(dividerSize = DividerSize.TWO, width = 100.dp) + Text("Section 2") + Divider(dividerSize = DividerSize.EIGHT) + } +} diff --git a/compose/src/main/kotlin/com/yourssu/handy/compose/Divider.kt b/compose/src/main/kotlin/com/yourssu/handy/compose/Divider.kt new file mode 100644 index 0000000..3c530d0 --- /dev/null +++ b/compose/src/main/kotlin/com/yourssu/handy/compose/Divider.kt @@ -0,0 +1,36 @@ +package com.yourssu.handy.compose + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxWidth +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.graphics.Color +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp + +enum class DividerSize( + val size: Dp +) { + ONE(1.dp), + TWO(2.dp), + FOUR(4.dp), + EIGHT(8.dp), +} + +@Composable +fun Divider( + dividerSize: DividerSize, + modifier: Modifier = Modifier, + width: Dp? = null, + color: Color = HandyTheme.colors.bgBasicStrong, +) { + Box( + modifier = modifier + .then(if (width != null) Modifier.width(width) else Modifier.fillMaxWidth()) + .height(dividerSize.size) + .background(color) + ) +} \ No newline at end of file From b0ae564c07b03f6741ab1e477ffafc228220132d Mon Sep 17 00:00:00 2001 From: Gael-Android Date: Fri, 15 Nov 2024 15:05:44 +0900 Subject: [PATCH 2/3] =?UTF-8?q?add=20:=20fillMaxWidth=EC=9D=B8=20divider?= =?UTF-8?q?=EC=99=80=20=EB=84=88=EB=B9=84=EB=A5=BC=20=EC=A7=80=EC=A0=95?= =?UTF-8?q?=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8A=94=20Divider=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yourssu/handy/demo/DividerPreview.kt | 4 ++- .../com/yourssu/handy/compose/Divider.kt | 33 +++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/yourssu/handy/demo/DividerPreview.kt b/app/src/main/kotlin/com/yourssu/handy/demo/DividerPreview.kt index c969965..d96cd2a 100644 --- a/app/src/main/kotlin/com/yourssu/handy/demo/DividerPreview.kt +++ b/app/src/main/kotlin/com/yourssu/handy/demo/DividerPreview.kt @@ -8,13 +8,15 @@ import com.yourssu.handy.compose.Divider import com.yourssu.handy.compose.DividerSize import com.yourssu.handy.compose.Text -@Preview +@Preview(showBackground = true) @Composable fun DividerExample() { Column { Text("Section 1") Divider(dividerSize = DividerSize.TWO, width = 100.dp) Text("Section 2") + Divider(dividerSize = DividerSize.FOUR, width = 200.dp) + Text("Section 3") Divider(dividerSize = DividerSize.EIGHT) } } diff --git a/compose/src/main/kotlin/com/yourssu/handy/compose/Divider.kt b/compose/src/main/kotlin/com/yourssu/handy/compose/Divider.kt index 3c530d0..f338e2c 100644 --- a/compose/src/main/kotlin/com/yourssu/handy/compose/Divider.kt +++ b/compose/src/main/kotlin/com/yourssu/handy/compose/Divider.kt @@ -11,6 +11,9 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +/** + * Divider의 두께를 정의하는 enum class + */ enum class DividerSize( val size: Dp ) { @@ -20,16 +23,42 @@ enum class DividerSize( EIGHT(8.dp), } +/** + * width를 지정할 수 있는 Divider + * @param width Divider의 너비 + * @param color Divider의 색상 + * @param dividerSize Divider의 두께 + */ @Composable fun Divider( dividerSize: DividerSize, modifier: Modifier = Modifier, - width: Dp? = null, + width: Dp = 0.dp, color: Color = HandyTheme.colors.bgBasicStrong, ) { Box( modifier = modifier - .then(if (width != null) Modifier.width(width) else Modifier.fillMaxWidth()) + .width(width) + .height(dividerSize.size) + .background(color) + ) +} + +/** + * width를 지정할 수 없는 Divider + * 기본적으로 fillMaxWidth를 사용 + * @param color Divider의 색상 + * @param dividerSize Divider의 두께 + */ +@Composable +fun Divider( + dividerSize: DividerSize, + modifier: Modifier = Modifier, + color: Color = HandyTheme.colors.bgBasicStrong, +) { + Box( + modifier = modifier + .fillMaxWidth() .height(dividerSize.size) .background(color) ) From d78be9d3563afe0a6b4cf599869ef40b9042b191 Mon Sep 17 00:00:00 2001 From: Gael-Android Date: Fri, 22 Nov 2024 14:30:31 +0900 Subject: [PATCH 3/3] =?UTF-8?q?chore=20:=20=ED=94=84=EB=A6=AC=EB=B7=B0?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/deploymentTargetSelector.xml | 6 ++++++ .idea/git_toolbox_blame.xml | 6 ++++++ .idea/gradle.xml | 1 + .idea/runConfigurations.xml | 13 +++++++++++++ .../com/yourssu/handy/demo/DividerPreview.kt | 15 ++++++++++++--- 5 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 .idea/git_toolbox_blame.xml create mode 100644 .idea/runConfigurations.xml diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml index b268ef3..5394540 100644 --- a/.idea/deploymentTargetSelector.xml +++ b/.idea/deploymentTargetSelector.xml @@ -5,6 +5,12 @@ + + + + \ No newline at end of file diff --git a/.idea/git_toolbox_blame.xml b/.idea/git_toolbox_blame.xml new file mode 100644 index 0000000..7dc1249 --- /dev/null +++ b/.idea/git_toolbox_blame.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index bb0078e..a425311 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,6 +4,7 @@