1
1
package daily.dayo.presentation.screen.search
2
2
3
3
import androidx.compose.foundation.BorderStroke
4
+ import androidx.compose.foundation.Image
4
5
import androidx.compose.foundation.background
5
6
import androidx.compose.foundation.interaction.MutableInteractionSource
7
+ import androidx.compose.foundation.layout.Arrangement
6
8
import androidx.compose.foundation.layout.Box
7
9
import androidx.compose.foundation.layout.Column
8
10
import androidx.compose.foundation.layout.IntrinsicSize
@@ -37,9 +39,11 @@ import androidx.compose.ui.Alignment
37
39
import androidx.compose.ui.Modifier
38
40
import androidx.compose.ui.draw.alpha
39
41
import androidx.compose.ui.graphics.Color
42
+ import androidx.compose.ui.graphics.vector.ImageVector
40
43
import androidx.compose.ui.res.colorResource
41
44
import androidx.compose.ui.res.painterResource
42
45
import androidx.compose.ui.res.stringResource
46
+ import androidx.compose.ui.res.vectorResource
43
47
import androidx.compose.ui.text.TextStyle
44
48
import androidx.compose.ui.text.font.Font
45
49
import androidx.compose.ui.text.font.FontFamily
@@ -58,6 +62,8 @@ import daily.dayo.presentation.R
58
62
import daily.dayo.presentation.common.extension.clickableSingle
59
63
import daily.dayo.presentation.common.toSp
60
64
import daily.dayo.presentation.theme.DayoTheme
65
+ import daily.dayo.presentation.theme.Gray3_9FA5AE
66
+ import daily.dayo.presentation.theme.Gray4_C5CAD2
61
67
import daily.dayo.presentation.view.NoRippleIconButton
62
68
import daily.dayo.presentation.viewmodel.SearchViewModel
63
69
import kotlinx.coroutines.launch
@@ -118,14 +124,12 @@ fun SearchScreen(
118
124
onBackClick = onBackClick,
119
125
onSearchClick = onSearchClick
120
126
)
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
+ )
129
133
}
130
134
}
131
135
}
@@ -299,19 +303,59 @@ private fun SetSearchHistoryLayout(
299
303
item {
300
304
SearchHistoryGuideLayout ()
301
305
}
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
+ }
311
329
}
312
330
}
313
331
}
314
332
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
+
315
359
@Composable
316
360
private fun SearchHistoryLayout (
317
361
onKeywordClick : (String ) -> Unit ,
@@ -352,7 +396,7 @@ private fun SearchHistoryLayout(
352
396
@Preview
353
397
private fun PreviewSearchHistoryLayout () {
354
398
SearchHistoryLayout (
355
- onKeywordClick = { _, -> },
399
+ onKeywordClick = { _ -> },
356
400
onKeywordDeleteClick = { _, _ -> },
357
401
searchHistoryDetail = SearchHistoryDetail (
358
402
history = " 검색어" ,
0 commit comments