|
|
@ -63,10 +63,12 @@ import androidx.compose.ui.platform.testTag
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
import androidx.compose.ui.text.AnnotatedString
|
|
|
|
import androidx.compose.ui.text.AnnotatedString
|
|
|
|
import androidx.compose.ui.text.SpanStyle
|
|
|
|
import androidx.compose.ui.text.SpanStyle
|
|
|
|
|
|
|
|
import androidx.compose.ui.text.TextStyle
|
|
|
|
import androidx.compose.ui.text.buildAnnotatedString
|
|
|
|
import androidx.compose.ui.text.buildAnnotatedString
|
|
|
|
import androidx.compose.ui.text.font.FontFamily
|
|
|
|
import androidx.compose.ui.text.font.FontFamily
|
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
|
|
import androidx.compose.ui.text.input.ImeAction
|
|
|
|
import androidx.compose.ui.text.input.ImeAction
|
|
|
|
|
|
|
|
import androidx.compose.ui.text.style.TextAlign
|
|
|
|
import androidx.compose.ui.text.style.TextDecoration
|
|
|
|
import androidx.compose.ui.text.style.TextDecoration
|
|
|
|
import androidx.compose.ui.text.withStyle
|
|
|
|
import androidx.compose.ui.text.withStyle
|
|
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
|
@ -147,6 +149,7 @@ internal fun SearchScreen(
|
|
|
|
SearchResultUiState.Loading,
|
|
|
|
SearchResultUiState.Loading,
|
|
|
|
SearchResultUiState.LoadFailed,
|
|
|
|
SearchResultUiState.LoadFailed,
|
|
|
|
-> Unit
|
|
|
|
-> Unit
|
|
|
|
|
|
|
|
|
|
|
|
SearchResultUiState.EmptyQuery,
|
|
|
|
SearchResultUiState.EmptyQuery,
|
|
|
|
-> {
|
|
|
|
-> {
|
|
|
|
if (recentSearchesUiState is RecentSearchQueriesUiState.Success) {
|
|
|
|
if (recentSearchesUiState is RecentSearchQueriesUiState.Success) {
|
|
|
@ -167,6 +170,16 @@ internal fun SearchScreen(
|
|
|
|
onInterestsClick = onInterestsClick,
|
|
|
|
onInterestsClick = onInterestsClick,
|
|
|
|
searchQuery = searchQuery,
|
|
|
|
searchQuery = searchQuery,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
if (recentSearchesUiState is RecentSearchQueriesUiState.Success) {
|
|
|
|
|
|
|
|
RecentSearchesBody(
|
|
|
|
|
|
|
|
onClearRecentSearches = onClearRecentSearches,
|
|
|
|
|
|
|
|
onRecentSearchClicked = {
|
|
|
|
|
|
|
|
onSearchQueryChanged(it)
|
|
|
|
|
|
|
|
onSearchTriggered(it)
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
recentSearchQueries = recentSearchesUiState.recentQueries.map { it.query },
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
SearchResultBody(
|
|
|
|
SearchResultBody(
|
|
|
|
topics = searchResultUiState.topics,
|
|
|
|
topics = searchResultUiState.topics,
|
|
|
@ -189,7 +202,10 @@ fun EmptySearchResultBody(
|
|
|
|
onInterestsClick: () -> Unit,
|
|
|
|
onInterestsClick: () -> Unit,
|
|
|
|
searchQuery: String,
|
|
|
|
searchQuery: String,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
|
|
|
Column(
|
|
|
|
|
|
|
|
horizontalAlignment = Alignment.CenterHorizontally,
|
|
|
|
|
|
|
|
modifier = Modifier.padding(horizontal = 48.dp),
|
|
|
|
|
|
|
|
) {
|
|
|
|
val message = stringResource(id = searchR.string.search_result_not_found, searchQuery)
|
|
|
|
val message = stringResource(id = searchR.string.search_result_not_found, searchQuery)
|
|
|
|
val start = message.indexOf(searchQuery)
|
|
|
|
val start = message.indexOf(searchQuery)
|
|
|
|
Text(
|
|
|
|
Text(
|
|
|
@ -203,10 +219,13 @@ fun EmptySearchResultBody(
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
modifier = Modifier.padding(horizontal = 36.dp, vertical = 24.dp),
|
|
|
|
fontSize = 18.sp,
|
|
|
|
|
|
|
|
textAlign = TextAlign.Center,
|
|
|
|
|
|
|
|
modifier = Modifier.padding(vertical = 24.dp),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
val interests = stringResource(id = searchR.string.interests)
|
|
|
|
val interests = stringResource(id = searchR.string.interests)
|
|
|
|
val tryAnotherSearchString = buildAnnotatedString {
|
|
|
|
val tryAnotherSearchString = buildAnnotatedString {
|
|
|
|
|
|
|
|
withStyle(style = SpanStyle(fontSize = 18.sp)) {
|
|
|
|
append(stringResource(id = searchR.string.try_another_search))
|
|
|
|
append(stringResource(id = searchR.string.try_another_search))
|
|
|
|
append(" ")
|
|
|
|
append(" ")
|
|
|
|
withStyle(
|
|
|
|
withStyle(
|
|
|
@ -221,8 +240,13 @@ fun EmptySearchResultBody(
|
|
|
|
append(" ")
|
|
|
|
append(" ")
|
|
|
|
append(stringResource(id = searchR.string.to_browse_topics))
|
|
|
|
append(stringResource(id = searchR.string.to_browse_topics))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
ClickableText(
|
|
|
|
ClickableText(
|
|
|
|
text = tryAnotherSearchString,
|
|
|
|
text = tryAnotherSearchString,
|
|
|
|
|
|
|
|
style = TextStyle(
|
|
|
|
|
|
|
|
textAlign = TextAlign.Center,
|
|
|
|
|
|
|
|
lineHeight = 24.sp,
|
|
|
|
|
|
|
|
),
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier
|
|
|
|
.padding(start = 36.dp, end = 36.dp, bottom = 24.dp)
|
|
|
|
.padding(start = 36.dp, end = 36.dp, bottom = 24.dp)
|
|
|
|
.clickable {},
|
|
|
|
.clickable {},
|
|
|
@ -454,7 +478,8 @@ private fun SearchTextField(
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.testTag("searchTextField"),
|
|
|
|
}
|
|
|
|
|
|
|
|
.testTag("searchTextField"),
|
|
|
|
shape = RoundedCornerShape(32.dp),
|
|
|
|
shape = RoundedCornerShape(32.dp),
|
|
|
|
value = searchQuery,
|
|
|
|
value = searchQuery,
|
|
|
|
keyboardOptions = KeyboardOptions(
|
|
|
|
keyboardOptions = KeyboardOptions(
|
|
|
|