Fixed: Toolbar title was not appearing when closing the SearchView.

This commit is contained in:
MohitMaliFtechiz 2025-04-14 15:03:18 +05:30
parent ad9d43b455
commit 79e0ec72c1
6 changed files with 11 additions and 8 deletions

View File

@ -182,6 +182,7 @@ abstract class PageFragment : OnItemClickListener, BaseFragment(), FragmentActiv
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Log.e("ON_VIEW_CREATED", "onViewCreated: $screenTitle")
pageScreenState.value = pageScreenState.value.copy(
searchQueryHint = searchQueryHint,
searchText = "",
@ -242,7 +243,6 @@ abstract class PageFragment : OnItemClickListener, BaseFragment(), FragmentActiv
}
private fun onSwitchCheckedChanged(isChecked: Boolean): () -> Unit = {
Log.e("PAGE_FRAGMENT", "onSwitchCheckedChanged: $isChecked")
pageScreenState.value = pageScreenState.value.copy(switchIsChecked = isChecked)
pageViewModel.actions.offer(Action.UserClickedShowAllToggle(isChecked))
}

View File

@ -96,8 +96,8 @@ fun PageScreen(
@Composable
private fun searchBarIfActive(
state: PageFragmentScreenState
): (@Composable () -> Unit)? = {
if (state.isSearchActive) {
): (@Composable () -> Unit)? = if (state.isSearchActive) {
{
KiwixSearchView(
placeholder = state.searchQueryHint,
value = state.searchText,
@ -105,9 +105,9 @@ private fun searchBarIfActive(
onValueChange = { state.searchValueChangedListener(it) },
onClearClick = { state.clearSearchButtonClickListener.invoke() }
)
} else {
null
}
} else {
null
}
@Composable

View File

@ -16,7 +16,7 @@ class BookmarksFragment : PageFragment() {
PageAdapter(PageItemDelegate(this))
}
override val screenTitle: Int by lazy { R.string.bookmarks }
override val screenTitle: Int = R.string.bookmarks
override val noItemsString: String by lazy { getString(R.string.no_bookmarks) }
override val switchString: String by lazy { getString(R.string.bookmarks_from_current_book) }
override val deleteIconTitle: Int by lazy {

View File

@ -21,7 +21,7 @@ class HistoryFragment : PageFragment() {
override val noItemsString: String by lazy { getString(R.string.no_history) }
override val switchString: String by lazy { getString(R.string.history_from_current_book) }
override val screenTitle: Int by lazy { R.string.history }
override val screenTitle: Int = R.string.history
override val deleteIconTitle: Int by lazy {
R.string.pref_clear_all_history_title
}

View File

@ -30,7 +30,7 @@ import org.kiwix.kiwixmobile.core.page.notes.viewmodel.NotesViewModel
class NotesFragment : PageFragment() {
override val pageViewModel by lazy { viewModel<NotesViewModel>(viewModelFactory) }
override val screenTitle: Int get() = R.string.pref_notes
override val screenTitle: Int = R.string.pref_notes
override val pageAdapter: PageAdapter by lazy {
PageAdapter(PageDelegate.PageItemDelegate(this))

View File

@ -18,6 +18,7 @@
package org.kiwix.kiwixmobile.core.ui.components
import android.util.Log
import androidx.annotation.StringRes
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
@ -97,6 +98,7 @@ private fun AppBarTitleSection(
@StringRes titleId: Int,
searchBar: (@Composable () -> Unit)? = null
) {
Log.e("ON_VIEW_CREATED", "AppBarTitleSection: $titleId , and searchBar = $searchBar")
Box(
modifier = Modifier
.fillMaxSize()
@ -106,6 +108,7 @@ private fun AppBarTitleSection(
searchBar?.let {
it()
} ?: run {
Log.e("ON_VIEW_CREATED", "AppBarTitle: $titleId")
AppBarTitle(titleId)
}
}