-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add : width를 nullable로 하는 버전 생성 * add : fillMaxWidth인 divider와 너비를 지정할 수 있는 Divider분리 * chore : 프리뷰수정 * chore : 리뷰 반영
- Loading branch information
1 parent
e342649
commit e39245a
Showing
6 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
app/src/main/kotlin/com/yourssu/handy/demo/DividerPreview.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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.DividerThickness | ||
import com.yourssu.handy.compose.HandyTheme | ||
import com.yourssu.handy.compose.Text | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun DividerExample() { | ||
Column { | ||
Text("Section 1") | ||
Divider( | ||
dividerThickness = DividerThickness.TWO, | ||
width = 100.dp, | ||
color = HandyTheme.colors.bgBasicBlack | ||
) | ||
Text("Section 2") | ||
Divider( | ||
dividerThickness = DividerThickness.FOUR, | ||
width = 200.dp, | ||
color = HandyTheme.colors.bgBasicBlack | ||
) | ||
Text("Section 3") | ||
Divider(dividerThickness = DividerThickness.EIGHT, color = HandyTheme.colors.bgBasicBlack) | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
compose/src/main/kotlin/com/yourssu/handy/compose/Divider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
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 | ||
|
||
/** | ||
* Divider의 두께를 정의하는 enum class | ||
*/ | ||
enum class DividerThickness( | ||
val size: Dp | ||
) { | ||
ONE(1.dp), | ||
TWO(2.dp), | ||
FOUR(4.dp), | ||
EIGHT(8.dp), | ||
} | ||
|
||
/** | ||
* width를 지정할 수 있는 Divider | ||
* @param width Divider의 너비 | ||
* @param color Divider의 색상 | ||
* @param dividerThickness Divider의 두께 | ||
*/ | ||
@Composable | ||
fun Divider( | ||
dividerThickness: DividerThickness, | ||
modifier: Modifier = Modifier, | ||
width: Dp = 0.dp, | ||
color: Color = HandyTheme.colors.bgBasicStrong, | ||
) { | ||
Box( | ||
modifier = modifier | ||
.width(width) | ||
.height(dividerThickness.size) | ||
.background(color) | ||
) | ||
} | ||
|
||
/** | ||
* width를 지정할 수 없는 Divider | ||
* 기본적으로 fillMaxWidth를 사용 | ||
* @param color Divider의 색상 | ||
* @param dividerThickness Divider의 두께 | ||
*/ | ||
@Composable | ||
fun Divider( | ||
dividerThickness: DividerThickness, | ||
modifier: Modifier = Modifier, | ||
color: Color = HandyTheme.colors.bgBasicStrong, | ||
) { | ||
Box( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.height(dividerThickness.size) | ||
.background(color) | ||
) | ||
} |