Skip to content

Commit 139b9ac

Browse files
committed
[NDGL-101] chore: NDGLSearchNavigationBar 추가
1 parent 0030134 commit 139b9ac

1 file changed

Lines changed: 137 additions & 0 deletions

File tree

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
package com.yapp.ndgl.core.ui.designsystem
2+
3+
import androidx.compose.foundation.background
4+
import androidx.compose.foundation.clickable
5+
import androidx.compose.foundation.layout.Arrangement
6+
import androidx.compose.foundation.layout.Box
7+
import androidx.compose.foundation.layout.Row
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.foundation.text.BasicTextField
14+
import androidx.compose.foundation.text.KeyboardActions
15+
import androidx.compose.foundation.text.KeyboardOptions
16+
import androidx.compose.material3.Icon
17+
import androidx.compose.material3.Text
18+
import androidx.compose.material3.ripple
19+
import androidx.compose.runtime.Composable
20+
import androidx.compose.ui.Alignment
21+
import androidx.compose.ui.Modifier
22+
import androidx.compose.ui.draw.clip
23+
import androidx.compose.ui.graphics.SolidColor
24+
import androidx.compose.ui.graphics.vector.ImageVector
25+
import androidx.compose.ui.res.vectorResource
26+
import androidx.compose.ui.text.input.ImeAction
27+
import androidx.compose.ui.tooling.preview.Preview
28+
import androidx.compose.ui.unit.dp
29+
import com.yapp.ndgl.core.ui.R
30+
import com.yapp.ndgl.core.ui.theme.NDGLTheme
31+
32+
@Composable
33+
fun NDGLSearchNavigationBar(
34+
searchKeyword: String,
35+
onSearchKeywordChange: (String) -> Unit,
36+
onSearch: (String) -> Unit,
37+
onBackClick: () -> Unit,
38+
modifier: Modifier = Modifier,
39+
placeholder: String? = null,
40+
) {
41+
Row(
42+
modifier = modifier
43+
.fillMaxWidth()
44+
.height(48.dp)
45+
.padding(horizontal = 24.dp, vertical = 2.dp),
46+
horizontalArrangement = Arrangement.spacedBy(8.dp),
47+
verticalAlignment = Alignment.CenterVertically,
48+
) {
49+
Icon(
50+
imageVector = ImageVector.vectorResource(R.drawable.ic_28_chevron_left),
51+
contentDescription = null,
52+
modifier = Modifier
53+
.clickable(
54+
onClick = onBackClick,
55+
interactionSource = null,
56+
indication = ripple(bounded = false),
57+
)
58+
.size(28.dp),
59+
tint = NDGLTheme.colors.black600,
60+
)
61+
62+
BasicTextField(
63+
value = searchKeyword,
64+
onValueChange = onSearchKeywordChange,
65+
modifier = Modifier.weight(1f),
66+
textStyle = NDGLTheme.typography.bodyLgRegular.copy(
67+
color = NDGLTheme.colors.black700,
68+
),
69+
singleLine = true,
70+
cursorBrush = SolidColor(NDGLTheme.colors.black400),
71+
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
72+
keyboardActions = KeyboardActions(onSearch = { onSearch(searchKeyword) }),
73+
decorationBox = { innerTextField ->
74+
Row(
75+
modifier = Modifier
76+
.fillMaxWidth()
77+
.clip(CircleShape)
78+
.background(NDGLTheme.colors.black100)
79+
.padding(horizontal = 16.dp, vertical = 8.dp),
80+
verticalAlignment = Alignment.CenterVertically,
81+
horizontalArrangement = Arrangement.spacedBy(2.dp),
82+
) {
83+
Box(modifier = Modifier.weight(1f)) {
84+
if (placeholder != null && searchKeyword.isEmpty()) {
85+
Text(
86+
text = placeholder,
87+
style = NDGLTheme.typography.bodyLgRegular,
88+
color = NDGLTheme.colors.black400,
89+
)
90+
}
91+
innerTextField()
92+
}
93+
Icon(
94+
imageVector = ImageVector.vectorResource(R.drawable.ic_28_search),
95+
contentDescription = null,
96+
modifier = Modifier
97+
.size(28.dp)
98+
.clickable(
99+
onClick = { onSearch(searchKeyword) },
100+
interactionSource = null,
101+
indication = ripple(bounded = false),
102+
),
103+
tint = NDGLTheme.colors.black600,
104+
)
105+
}
106+
},
107+
)
108+
}
109+
}
110+
111+
@Preview(showBackground = true)
112+
@Composable
113+
private fun NDGLSearchNavigationBarEmptyPreview() {
114+
NDGLTheme {
115+
NDGLSearchNavigationBar(
116+
searchKeyword = "",
117+
onSearchKeywordChange = {},
118+
placeholder = "여행 템플릿을 검색해 보세요",
119+
onSearch = {},
120+
onBackClick = {},
121+
)
122+
}
123+
}
124+
125+
@Preview(showBackground = true)
126+
@Composable
127+
private fun NDGLSearchNavigationBarFilledPreview() {
128+
NDGLTheme {
129+
NDGLSearchNavigationBar(
130+
searchKeyword = "제주도 3박 4일",
131+
onSearchKeywordChange = {},
132+
placeholder = "여행 템플릿을 검색해 보세요",
133+
onSearch = {},
134+
onBackClick = {},
135+
)
136+
}
137+
}

0 commit comments

Comments
 (0)