Skip to content

Commit

Permalink
[CHORE] #21 세부 사항 수정
Browse files Browse the repository at this point in the history
- 아래 문제점 수정
: "모아보기", "안읽음" 필터 클릭시 포킷 선택으로 bottomSheet가 호출되던 문제
: bottomSheet에서 저장하기 클릭시 필터가 전부 취소되어 있을 때 필터 버튼만 표시되던 문제
- 아래 기능 구현
: 키보드 엔터 클릭시 검색 결과 화면으로 이동
: 검색어 제거 클릭시 검색창 활성화
: 정렬 기준 변경 로직 추가
  • Loading branch information
l5x5l committed Jul 26, 2024
1 parent ad2eae0 commit 99ad97f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ fun SearchScreenContainer(
onClickFilterItem = viewModel::showFilterBottomSheetWithType,
hideBottomSheet = viewModel::hideFilterBottomSheet,
onClickFilterSave = viewModel::setFilter,
toggleSortOrder = viewModel::toggleSortOrder
)
}

Expand All @@ -64,7 +65,8 @@ fun SearchScreen(
onClickFilterSelect: () -> Unit = {},
onClickFilterItem: (FilterType) -> Unit = {},
hideBottomSheet: () -> Unit = {},
onClickFilterSave : (Filter) -> Unit = {}
onClickFilterSave : (Filter) -> Unit = {},
toggleSortOrder: () -> Unit = {},
) {
Column(
modifier = Modifier.fillMaxSize()
Expand All @@ -73,7 +75,8 @@ fun SearchScreen(
onClickBack = onClickBack,
inputSearchWord = inputSearchWord,
currentSearchWord = currentSearchWord,
onClickSearch = onClickSearch
onClickSearch = onClickSearch,
onClickRemove = remember {{ inputSearchWord("") }}
)

if (state.step == SearchScreenStep.INPUT) {
Expand Down Expand Up @@ -107,6 +110,8 @@ fun SearchScreen(
modifier = Modifier
.fillMaxWidth()
.weight(1f),
onToggleSort = toggleSortOrder,
useRecentOrder = state.sortRecent,
links = linkList
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,22 @@ class SearchViewModel : ViewModel() {
_state.update { state ->
state.copy(
showFilterBottomSheet = false,
filter = filter,
filter = if (filter == Filter.DefaultFilter) {
null
} else {
filter
},
)
}

_linkList.update {
emptyList()
// todo refresh 기능 구현
}

fun toggleSortOrder() {
_state.update { state ->
state.copy(sortRecent = !state.sortRecent)
}

// todo refresh 기능 구현
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fun FilterArea(
resourceId = coreDrawable.icon_24_arrow_down,
position = PokitButtonIconPosition.RIGHT
),
onClick = onClickPokitName,
onClick = onClickBookmark,
size = PokitButtonSize.SMALL,
shape = PokitButtonShape.ROUND,
style = PokitButtonStyle.STROKE
Expand All @@ -142,7 +142,7 @@ fun FilterArea(
resourceId = coreDrawable.icon_24_arrow_down,
position = PokitButtonIconPosition.RIGHT
),
onClick = onClickPokitName,
onClick = onClickBookmark,
size = PokitButtonSize.SMALL,
shape = PokitButtonShape.ROUND,
style = PokitButtonStyle.STROKE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
Expand All @@ -27,7 +31,10 @@ internal fun Toolbar(
inputSearchWord: (String) -> Unit = {},
currentSearchWord: String = "",
onClickSearch: () -> Unit = {},
onClickRemove: () -> Unit = {},
) {
val focusManager = LocalFocusManager.current
val focusRequester = remember { FocusRequester() }

Row(
modifier = Modifier
Expand All @@ -53,11 +60,24 @@ internal fun Toolbar(
hintText = stringResource(id = SearchString.placeholder_input_search_word),
onChangeText = inputSearchWord,
shape = PokitInputShape.ROUND,
icon = PokitInputIcon(
position = PokitInputIconPosition.RIGHT,
resourceId = coreDrawable.icon_24_search
),
onClickIcon = onClickSearch
icon = if (currentSearchWord.isNotEmpty())
PokitInputIcon(
position = PokitInputIconPosition.RIGHT,
resourceId = coreDrawable.icon_24_x
) else null,
onClickIcon = remember{
{
onClickRemove()
focusRequester.requestFocus()
}
},
keyboardActions = remember {
KeyboardActions {
onClickSearch()
focusManager.clearFocus()
}
},
focusRequester = focusRequester
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ data class Filter(
null
}
}

companion object {
val DefaultFilter = Filter()
}
}

enum class FilterType(val stringResourceId : Int, val index : Int) {
Expand Down

0 comments on commit 99ad97f

Please sign in to comment.