Skip to content

Commit 4c414ae

Browse files
committed
[chore]: GroupSearchScreen 주석 및 필터 수정 (#47)
1 parent 45e9898 commit 4c414ae

3 files changed

Lines changed: 60 additions & 13 deletions

File tree

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/texthip/thip/ui/group/myroom/screen/GroupSearchScreen.kt

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,21 @@ fun GroupSearchScreen(
4646
var searchText by rememberSaveable { mutableStateOf("") }
4747
var isSearched by rememberSaveable { mutableStateOf(false) }
4848
var selectedGenreIndex by rememberSaveable { mutableIntStateOf(-1) }
49-
var selectedSortOption by rememberSaveable { mutableStateOf("마감임박순") }
49+
var selectedSortOptionIndex by rememberSaveable { mutableIntStateOf(0) }
5050
val focusRequester = remember { FocusRequester() }
5151
val focusManager = LocalFocusManager.current
5252

53-
val genres = listOf("문학", "과학·IT", "사회과학", "인문학", "예술")
54-
val sortOptions = listOf("마감임박순", "최신순", "참여많은순")
53+
val genres = listOf(
54+
stringResource(R.string.literature),
55+
stringResource(R.string.science_it),
56+
stringResource(R.string.social_science),
57+
stringResource(R.string.humanities),
58+
stringResource(R.string.art)
59+
)
60+
val sortOptions = listOf(
61+
stringResource(R.string.group_filter_deadline),
62+
stringResource(R.string.group_filter_popular)
63+
)
5564

5665
val liveFilteredRoomList by remember(searchText) {
5766
derivedStateOf {
@@ -62,18 +71,22 @@ fun GroupSearchScreen(
6271
}
6372
}
6473

65-
val filteredRoomList by remember(searchText, selectedGenreIndex, selectedSortOption, isSearched) {
74+
val filteredRoomList by remember(
75+
searchText,
76+
selectedGenreIndex,
77+
selectedSortOptionIndex,
78+
isSearched
79+
) {
6680
derivedStateOf {
6781
if (!isSearched) emptyList()
6882
else {
6983
val filtered = roomList.filter { room ->
7084
(searchText.isBlank() || room.title.contains(searchText, ignoreCase = true)) &&
7185
(selectedGenreIndex == -1 || room.genreIndex == selectedGenreIndex)
7286
}
73-
when (selectedSortOption) {
74-
"마감임박순" -> filtered.sortedBy { it.endDate }
75-
"최신순" -> filtered // TODO: 생성일 기준 정렬 필요
76-
"참여많은순" -> filtered.sortedByDescending { it.participants }
87+
when (selectedSortOptionIndex) {
88+
0 -> filtered.sortedBy { it.endDate } // 마감임박순
89+
1 -> filtered.sortedByDescending { it.participants } // 인기순
7790
else -> filtered
7891
}
7992
}
@@ -131,6 +144,7 @@ fun GroupSearchScreen(
131144
onRemove = {}
132145
)
133146
}
147+
134148
searchText.isBlank() && !isSearched && recentSearches.isNotEmpty() -> {
135149
GroupRecentSearch(
136150
recentSearches = recentSearches,
@@ -143,6 +157,7 @@ fun GroupSearchScreen(
143157
}
144158
)
145159
}
160+
146161
searchText.isNotBlank() && !isSearched -> {
147162
if (liveFilteredRoomList.isEmpty()) {
148163
GroupEmptyResult(
@@ -155,6 +170,7 @@ fun GroupSearchScreen(
155170
)
156171
}
157172
}
173+
158174
isSearched -> {
159175
GroupFilteredSearchResult(
160176
genres = genres,
@@ -173,9 +189,11 @@ fun GroupSearchScreen(
173189
modifier = Modifier
174190
.align(Alignment.TopEnd)
175191
.padding(top = 176.dp, end = 20.dp),
176-
selectedOption = selectedSortOption,
192+
selectedOption = sortOptions[selectedSortOptionIndex],
177193
options = sortOptions,
178-
onOptionSelected = { selectedSortOption = it }
194+
onOptionSelected = { selected ->
195+
selectedSortOptionIndex = sortOptions.indexOf(selected)
196+
}
179197
)
180198
}
181199
}
@@ -190,8 +208,26 @@ fun PreviewGroupSearchScreen() {
190208
roomList = listOf(
191209
GroupCardItemRoomData("aaa", 22, 30, true, 3, R.drawable.bookcover_sample, 0),
192210
GroupCardItemRoomData("abc", 15, 20, true, 7, R.drawable.bookcover_sample, 1, true),
193-
GroupCardItemRoomData("abcd", 10, 15, true, 5, R.drawable.bookcover_sample, 2, true),
194-
GroupCardItemRoomData("abcde", 8, 12, false, 2, R.drawable.bookcover_sample, 3, true),
211+
GroupCardItemRoomData(
212+
"abcd",
213+
10,
214+
15,
215+
true,
216+
5,
217+
R.drawable.bookcover_sample,
218+
2,
219+
true
220+
),
221+
GroupCardItemRoomData(
222+
"abcde",
223+
8,
224+
12,
225+
false,
226+
2,
227+
R.drawable.bookcover_sample,
228+
3,
229+
true
230+
),
195231
GroupCardItemRoomData("abcdef", 18, 25, true, 4, R.drawable.bookcover_sample, 4),
196232
GroupCardItemRoomData("abcdefg", 12, 20, true, 1, R.drawable.bookcover_sample, 0),
197233
GroupCardItemRoomData("abcdefgh", 10, 14, true, 6, R.drawable.bookcover_sample, 1)

app/src/main/res/values/strings.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,5 +264,16 @@
264264
<string name="book_search_date">%1$s. 기준</string>
265265
<string name="book_no_most_search_result_comment_1">아직 순위가 집계되지 않았어요.</string>
266266
<string name="book_no_most_search_result_comment_2">조금만 기다려주세요!</string>
267+
<string name="search_recruiting_group_count">모집중인 모임방 %1$d개</string>
268+
<string name="search_write_feed_comment">피드에 글 쓰기</string>
269+
<string name="search_watch_feed">피드 글 둘러보기</string>
270+
<string name="search_no_feed_comment_1">이 책으로 작성된 피드가 없어요.</string>
271+
<string name="search_no_feed_comment_2">첫번째 피드를 작성해보세요!</string>
272+
<string name="search_filter_popular">인기순</string>
273+
<string name="search_filter_latest">최신순</string>
274+
<string name="search_book_comment">소개</string>
275+
<string name="search_book_author">%1$s 저 · %2$s</string>
276+
<string name="group_filter_popular">인기순</string>
277+
<string name="group_filter_deadline">마감임박순</string>
267278

268279
</resources>

0 commit comments

Comments
 (0)