Skip to content

Commit

Permalink
[MERGE] #140 -> develop
Browse files Browse the repository at this point in the history
[HOTFIX/140] 검색 ν‚€λ³΄λ“œ μ•„μ΄μ½˜ λ³€κ²½
  • Loading branch information
arinming authored Jul 18, 2024
2 parents 4f38a2b + d372b01 commit fe2ca9c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.terning.core.designsystem.component.textfield
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.text.input.ImeAction
import com.terning.core.designsystem.theme.Grey300
import com.terning.core.designsystem.theme.Grey400
Expand All @@ -18,8 +20,11 @@ fun SearchTextField(
leftIcon: Int,
enabled: Boolean = true,
readOnly: Boolean = false,
onDoneAction: (() -> Unit)? = null,
onSearchAction: () -> Unit? = {},
) {
val keyboardController = LocalSoftwareKeyboardController.current
val focusManager = LocalFocusManager.current

TerningBasicTextField(
value = text,
onValueChange = onValueChange,
Expand All @@ -33,14 +38,17 @@ fun SearchTextField(
hintColor = Grey300,
leftIcon = leftIcon,
leftIconColor = TerningMain,
imeAction = if (text.isNotBlank()) {
ImeAction.Search
} else {
ImeAction.Done
},
imeAction = ImeAction.Search,
enabled = enabled,
readOnly = readOnly,
onDoneAction = onDoneAction,
onSearchAction = {
if (text.isNotBlank()) {
keyboardController?.hide()
keyboardController?.hide()
focusManager.clearFocus()
onSearchAction()
}
},
helperColor = TerningMain
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.ImeAction
Expand All @@ -46,7 +44,7 @@ fun TerningBasicTextField(
strokeWidth: Float = 1f,
leftIcon: Int? = null,
leftIconColor: Color = TerningMain,
imeAction: ImeAction? = ImeAction.Done,
imeAction: ImeAction = ImeAction.Done,
maxTextLength: Int? = null,
showTextLength: Boolean = false,
hint: String = "",
Expand All @@ -55,30 +53,24 @@ fun TerningBasicTextField(
enabled: Boolean = true,
helperColor: Color,
readOnly: Boolean = false,
onDoneAction: (() -> Unit)? = null,
onDoneAction: () -> Unit? = {},
onSearchAction: () -> Unit? = {},
) {
val keyboardController = LocalSoftwareKeyboardController.current
val focusManager = LocalFocusManager.current
val isFocused: MutableState<Boolean> = remember { mutableStateOf(false) }

BasicTextField(
value = value,
onValueChange = onValueChange,
onValueChange = {
if (maxTextLength == null || it.length <= maxTextLength) {
onValueChange(it)
}
},
singleLine = true,
maxLines = 1,
keyboardOptions = KeyboardOptions(
imeAction = imeAction ?: ImeAction.Done
),
keyboardOptions = KeyboardOptions(imeAction = imeAction),
keyboardActions = KeyboardActions(
onDone = {
if (value.isNotBlank()) {
keyboardController?.hide()
focusManager.clearFocus()
if (onDoneAction != null) {
onDoneAction()
}
}
}
onDone = { onDoneAction() },
onSearch = { onSearchAction() },
),

modifier = modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fun SearchProcessScreen(
.padding(top = 8.dp)
.focusRequester(focusRequester)
.addFocusCleaner(focusManager),
onDoneAction = {
onSearchAction = {
viewModel.getSearchList(
keyword = state.text,
sortBy = SORT_BY,
Expand Down

0 comments on commit fe2ca9c

Please sign in to comment.