Skip to content

Commit d48cc4d

Browse files
committed
Add Search history empty view
1 parent 149374b commit d48cc4d

File tree

2 files changed

+64
-18
lines changed

2 files changed

+64
-18
lines changed

presentation/src/main/java/daily/dayo/presentation/screen/search/SearchScreen.kt

Lines changed: 62 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package daily.dayo.presentation.screen.search
22

33
import androidx.compose.foundation.BorderStroke
4+
import androidx.compose.foundation.Image
45
import androidx.compose.foundation.background
56
import androidx.compose.foundation.interaction.MutableInteractionSource
7+
import androidx.compose.foundation.layout.Arrangement
68
import androidx.compose.foundation.layout.Box
79
import androidx.compose.foundation.layout.Column
810
import androidx.compose.foundation.layout.IntrinsicSize
@@ -37,9 +39,11 @@ import androidx.compose.ui.Alignment
3739
import androidx.compose.ui.Modifier
3840
import androidx.compose.ui.draw.alpha
3941
import androidx.compose.ui.graphics.Color
42+
import androidx.compose.ui.graphics.vector.ImageVector
4043
import androidx.compose.ui.res.colorResource
4144
import androidx.compose.ui.res.painterResource
4245
import androidx.compose.ui.res.stringResource
46+
import androidx.compose.ui.res.vectorResource
4347
import androidx.compose.ui.text.TextStyle
4448
import androidx.compose.ui.text.font.Font
4549
import androidx.compose.ui.text.font.FontFamily
@@ -58,6 +62,8 @@ import daily.dayo.presentation.R
5862
import daily.dayo.presentation.common.extension.clickableSingle
5963
import daily.dayo.presentation.common.toSp
6064
import daily.dayo.presentation.theme.DayoTheme
65+
import daily.dayo.presentation.theme.Gray3_9FA5AE
66+
import daily.dayo.presentation.theme.Gray4_C5CAD2
6167
import daily.dayo.presentation.view.NoRippleIconButton
6268
import daily.dayo.presentation.viewmodel.SearchViewModel
6369
import kotlinx.coroutines.launch
@@ -118,14 +124,12 @@ fun SearchScreen(
118124
onBackClick = onBackClick,
119125
onSearchClick = onSearchClick
120126
)
121-
searchHistory.let {
122-
SetSearchHistoryLayout(
123-
onKeywordClick = onSearchClick,
124-
onKeywordDeleteClick = onKeywordDeleteClick,
125-
onHistoryClearClick = onHistoryClearClick,
126-
searchHistory = it
127-
)
128-
}
127+
SetSearchHistoryLayout(
128+
onKeywordClick = onSearchClick,
129+
onKeywordDeleteClick = onKeywordDeleteClick,
130+
onHistoryClearClick = onHistoryClearClick,
131+
searchHistory = searchHistory
132+
)
129133
}
130134
}
131135
}
@@ -299,19 +303,59 @@ private fun SetSearchHistoryLayout(
299303
item {
300304
SearchHistoryGuideLayout()
301305
}
302-
items(searchHistory.data) {
303-
SearchHistoryLayout(
304-
onKeywordClick = onKeywordClick,
305-
onKeywordDeleteClick = onKeywordDeleteClick,
306-
searchHistoryDetail = it
307-
)
308-
}
309-
item {
310-
SetClearSearchHistoryLayout(onHistoryClearClick = onHistoryClearClick)
306+
307+
if (searchHistory.data.isNotEmpty()) {
308+
items(searchHistory.data) {
309+
SearchHistoryLayout(
310+
onKeywordClick = onKeywordClick,
311+
onKeywordDeleteClick = onKeywordDeleteClick,
312+
searchHistoryDetail = it
313+
)
314+
}
315+
item {
316+
SetClearSearchHistoryLayout(onHistoryClearClick = onHistoryClearClick)
317+
}
318+
} else {
319+
item {
320+
Box(
321+
modifier = Modifier
322+
.fillParentMaxHeight()
323+
.fillMaxWidth(),
324+
contentAlignment = Alignment.Center
325+
) {
326+
SearchHistoryEmpty()
327+
}
328+
}
311329
}
312330
}
313331
}
314332

333+
@Composable
334+
@Preview
335+
fun SearchHistoryEmpty() {
336+
Column(
337+
modifier = Modifier.fillMaxSize(),
338+
verticalArrangement = Arrangement.Center,
339+
horizontalAlignment = Alignment.CenterHorizontally
340+
) {
341+
Image(
342+
imageVector = ImageVector.vectorResource(id = R.drawable.ic_search_empty),
343+
contentDescription = "search history empty"
344+
)
345+
Text(
346+
text = stringResource(R.string.search_history_empty_title),
347+
style = DayoTheme.typography.b3,
348+
color = Gray3_9FA5AE,
349+
)
350+
Text(
351+
modifier = Modifier.padding(vertical = 2.dp),
352+
text = stringResource(id = R.string.search_history_empty_description),
353+
style = DayoTheme.typography.caption2,
354+
color = Gray4_C5CAD2,
355+
)
356+
}
357+
}
358+
315359
@Composable
316360
private fun SearchHistoryLayout(
317361
onKeywordClick: (String) -> Unit,
@@ -352,7 +396,7 @@ private fun SearchHistoryLayout(
352396
@Preview
353397
private fun PreviewSearchHistoryLayout() {
354398
SearchHistoryLayout(
355-
onKeywordClick = { _, -> },
399+
onKeywordClick = { _ -> },
356400
onKeywordDeleteClick = { _, _ -> },
357401
searchHistoryDetail = SearchHistoryDetail(
358402
history = "검색어",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@
370370
<string name="search_result_empty_title">앗! 찾으시는 검색 결과가 없어요.</string>
371371
<string name="search_result_empty_description">다른 검색어를 입력해보세요</string>
372372
<string name="search_history_clear">검색 기록 지우기</string>
373+
<string name="search_history_empty_title">최근 검색 결과가 없어요.</string>
374+
<string name="search_history_empty_description">관심있는 키워드 또는 사용자를 찾아보세요</string>
373375

374376
<!-- Certificate-->
375377
<string name="get_certificate_code">인증번호 받기</string>

0 commit comments

Comments
 (0)