Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify to change the display message based on whether the search text is empty or not #843

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,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 @@ -29,6 +29,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) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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
Loading