Skip to content

Commit 5fd393a

Browse files
committed
[NDGL-31] NDGLNavigationBar 추가
1 parent 3dae059 commit 5fd393a

1 file changed

Lines changed: 128 additions & 0 deletions

File tree

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
package com.yapp.ndgl.core.ui.designSystem
2+
3+
import androidx.annotation.DrawableRes
4+
import androidx.compose.foundation.clickable
5+
import androidx.compose.foundation.layout.Arrangement
6+
import androidx.compose.foundation.layout.Row
7+
import androidx.compose.foundation.layout.Spacer
8+
import androidx.compose.foundation.layout.fillMaxWidth
9+
import androidx.compose.foundation.layout.height
10+
import androidx.compose.foundation.layout.padding
11+
import androidx.compose.foundation.layout.size
12+
import androidx.compose.foundation.shape.CircleShape
13+
import androidx.compose.material3.Icon
14+
import androidx.compose.material3.Text
15+
import androidx.compose.runtime.Composable
16+
import androidx.compose.ui.Alignment
17+
import androidx.compose.ui.Modifier
18+
import androidx.compose.ui.draw.clip
19+
import androidx.compose.ui.graphics.vector.ImageVector
20+
import androidx.compose.ui.res.vectorResource
21+
import androidx.compose.ui.text.style.TextAlign
22+
import androidx.compose.ui.tooling.preview.Preview
23+
import androidx.compose.ui.unit.dp
24+
import com.yapp.ndgl.core.ui.R
25+
import com.yapp.ndgl.core.ui.theme.NDGLTheme
26+
import kotlinx.collections.immutable.ImmutableList
27+
import kotlinx.collections.immutable.persistentListOf
28+
29+
object NDGLNavigationBarAttr {
30+
enum class TextAlignType {
31+
START,
32+
CENTER,
33+
}
34+
}
35+
36+
@Composable
37+
fun NDGLNavigationBar(
38+
textAlignType: NDGLNavigationBarAttr.TextAlignType,
39+
modifier: Modifier = Modifier,
40+
headline: String? = null,
41+
@DrawableRes leadingIcon: Int? = null,
42+
onLeadingIconClick: () -> Unit = {},
43+
@DrawableRes trailingIcons: ImmutableList<Int>? = null,
44+
onTrailingIconClick: () -> Unit = {},
45+
) {
46+
Row(
47+
modifier = modifier
48+
.fillMaxWidth()
49+
.height(48.dp)
50+
.padding(horizontal = 24.dp, vertical = 12.dp),
51+
horizontalArrangement = Arrangement.spacedBy(8.dp),
52+
verticalAlignment = Alignment.CenterVertically,
53+
) {
54+
leadingIcon?.let { icon ->
55+
Icon(
56+
imageVector = ImageVector.vectorResource(icon),
57+
contentDescription = null,
58+
modifier = Modifier
59+
.size(28.dp)
60+
.clip(CircleShape)
61+
.clickable(onClick = onLeadingIconClick),
62+
tint = NDGLTheme.colors.black700,
63+
)
64+
}
65+
66+
headline?.let { text ->
67+
Text(
68+
text = text,
69+
modifier = Modifier.weight(1f),
70+
style = NDGLTheme.typography.bodyLgMedium,
71+
color = NDGLTheme.colors.black700,
72+
textAlign = when (textAlignType) {
73+
NDGLNavigationBarAttr.TextAlignType.START -> TextAlign.Start
74+
NDGLNavigationBarAttr.TextAlignType.CENTER -> TextAlign.Center
75+
},
76+
)
77+
} ?: Spacer(modifier = Modifier.weight(1f))
78+
79+
trailingIcons?.forEachIndexed { index, icon ->
80+
Icon(
81+
imageVector = ImageVector.vectorResource(icon),
82+
contentDescription = null,
83+
modifier = Modifier
84+
.size(28.dp)
85+
.clip(CircleShape)
86+
.clickable(onClick = onTrailingIconClick),
87+
tint = NDGLTheme.colors.black700,
88+
)
89+
}
90+
}
91+
}
92+
93+
@Preview(showBackground = true)
94+
@Composable
95+
private fun NDGLNavigationBarCenterPreview() {
96+
NDGLTheme {
97+
NDGLNavigationBar(
98+
textAlignType = NDGLNavigationBarAttr.TextAlignType.CENTER,
99+
headline = "미리보기",
100+
leadingIcon = R.drawable.ic_28_chevron_left,
101+
trailingIcons = persistentListOf(R.drawable.ic_28_search, R.drawable.ic_28_settings),
102+
)
103+
}
104+
}
105+
106+
@Preview(showBackground = true)
107+
@Composable
108+
private fun NDGLNavigationBarStartPreview() {
109+
NDGLTheme {
110+
NDGLNavigationBar(
111+
textAlignType = NDGLNavigationBarAttr.TextAlignType.START,
112+
headline = "미리보기",
113+
leadingIcon = R.drawable.ic_28_chevron_left,
114+
)
115+
}
116+
}
117+
118+
@Preview(showBackground = true)
119+
@Composable
120+
private fun NDGLNavigationBarNoHeadlinePreview() {
121+
NDGLTheme {
122+
NDGLNavigationBar(
123+
textAlignType = NDGLNavigationBarAttr.TextAlignType.START,
124+
leadingIcon = R.drawable.ic_28_menu,
125+
trailingIcons = persistentListOf(R.drawable.ic_28_search),
126+
)
127+
}
128+
}

0 commit comments

Comments
 (0)