Skip to content

Commit

Permalink
add : SearchTopBar에 actions 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Gael-Android committed Feb 1, 2024
1 parent 321b3b9 commit d87ef44
Showing 1 changed file with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
Expand Down Expand Up @@ -36,22 +37,24 @@ fun SearchTopBar(
onSearch: () -> Unit,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
navigationIcon: @Composable () -> Unit = {},
actions: @Composable RowScope.() -> Unit = {},
) {
TopAppBar(
modifier = modifier
.fillMaxWidth()
.height(56.dp),
contentPadding = PaddingValues(start = 4.dp),
contentPadding = PaddingValues(0.dp)
) {
Box(
modifier = Modifier
.padding(start = 4.dp)
.fillMaxWidth(),
) {
Row(
modifier = Modifier.fillMaxWidth(),
) {
navigationIcon()
Box(modifier = Modifier.padding(start = 4.dp, end = 4.dp)) {
navigationIcon()
}
SearchTextField(
text = text,
placeHolderText = placeHolderText,
Expand All @@ -60,10 +63,12 @@ fun SearchTopBar(
onSearch = onSearch,
interactionSource = interactionSource,
modifier = Modifier
.padding(start = 4.dp, end = 16.dp)
.fillMaxWidth()
.weight(1f)
.align(alignment = CenterVertically),
)
Row(modifier = Modifier.padding(start = 4.dp, end = 4.dp)) {
actions()
}
}
}
}
Expand Down Expand Up @@ -92,19 +97,25 @@ private fun PreviewSearchTopBar() {
Toast.LENGTH_SHORT,
).show()
},
navigationIcon = {
// navigationIcon = {
// TopBarButton(
// icon = R.drawable.ic_arrow_left_line,
// isDisabled = false,
// onClick = {
// Toast.makeText(
// context,
// "navigationIcon Clicked!",
// Toast.LENGTH_SHORT,
// ).show()
// },
// )
// },
actions = {
TopBarButton(
icon = R.drawable.ic_arrow_left_line,
isDisabled = false,
onClick = {
Toast.makeText(
context,
"navigationIcon Clicked!",
Toast.LENGTH_SHORT,
).show()
},
text = "취소",
isDisabled = false
)
},
}
)
},
) {
Expand Down

0 comments on commit d87ef44

Please sign in to comment.