Skip to content

Commit

Permalink
Merge pull request #843 from nishimy432/fix/no-search-results-screen-…
Browse files Browse the repository at this point in the history
…no-input

Modify to change the display message based on whether the search text is empty or not
  • Loading branch information
takahirom authored Sep 2, 2024
2 parents a462654 + 3060217 commit 4eeb9c3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<string name="language_title">対応言語</string>
<string name="category_title">カテゴリ</string>
<string name="empty_search_result">「%1$s」と一致する検索結果がありません</string>
<string name="empty_search_result_no_input">一致する検索結果がありません</string>
<string name="filter_chip_day">開催日</string>
<string name="filter_chip_category">カテゴリ</string>
<string name="filter_chip_session_type">セッション種別</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<string name="language_title">Supported Languages</string>
<string name="category_title">Category</string>
<string name="empty_search_result">Nothing matched your search criteria "%1$s"</string>
<string name="empty_search_result_no_input">Nothing matched your search criteria</string>
<string name="filter_chip_day">Day</string>
<string name="filter_chip_category">Category</string>
<string name="filter_chip_session_type">Session type</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ fun searchScreenPresenter(
val sessions by rememberUpdatedState(sessionsRepository.timetable())

var searchWord by rememberRetained { mutableStateOf("") }
var hasSearched by rememberRetained { mutableStateOf(false) }
val selectedDays = rememberRetained { mutableStateListOf<DroidKaigi2024Day>() }
val selectedSessionTypes = rememberRetained { mutableStateListOf<TimetableSessionType>() }
val selectedCategories = rememberRetained { mutableStateListOf<TimetableCategory>() }
Expand Down Expand Up @@ -109,6 +110,7 @@ fun searchScreenPresenter(

is UpdateSearchWord -> {
searchWord = event.word
hasSearched = true
}

is ClearSearchWord -> {
Expand Down Expand Up @@ -150,7 +152,7 @@ fun searchScreenPresenter(
}

when {
filters.isNotEmpty() && filteredSessions.isEmpty() -> {
(filters.isNotEmpty() || hasSearched) && filteredSessions.isEmpty() -> {
SearchScreenUiState.Empty(
searchWord = searchWord,
searchFilterDayUiState = searchFilterDayUiState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import conference_app_2024.feature.sessions.generated.resources.Res
import conference_app_2024.feature.sessions.generated.resources.empty_search_result
import conference_app_2024.feature.sessions.generated.resources.empty_search_result_no_input
import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource
Expand All @@ -24,6 +25,12 @@ fun EmptySearchResultBody(
searchWord: String,
modifier: Modifier = Modifier,
) {
val message = if (searchWord.isEmpty()) {
stringResource(Res.string.empty_search_result_no_input)
} else {
stringResource(Res.string.empty_search_result, searchWord)
}

Column(
modifier = modifier
.fillMaxSize()
Expand All @@ -36,7 +43,7 @@ fun EmptySearchResultBody(
contentDescription = null,
)
Text(
text = stringResource(Res.string.empty_search_result, searchWord),
text = message,
style = MaterialTheme.typography.titleMedium,
textAlign = TextAlign.Center,
)
Expand Down

0 comments on commit 4eeb9c3

Please sign in to comment.