Skip to content

Commit

Permalink
Set compose view composition strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
ashiagr committed Feb 17, 2023
1 parent 8b37574 commit 139d617
Showing 1 changed file with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import androidx.appcompat.widget.SearchView
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
Expand Down Expand Up @@ -243,21 +244,24 @@ class SearchFragment : BaseFragment() {
recyclerView.itemAnimator = null
recyclerView.addOnScrollListener(onScrollListener)

binding.searchHistoryPanel.setContent {
AppTheme(theme.activeTheme) {
SearchHistoryPage(
viewModel = searchHistoryViewModel,
onClick = ::navigateFromSearchHistoryEntry,
onShowClearAllConfirmation = {
SearchHistoryClearAllConfirmationDialog(
context = this@SearchFragment.requireContext(),
onConfirm = { searchHistoryViewModel.clearAll() }
).show(parentFragmentManager, SEARCH_HISTORY_CLEAR_ALL_CONFIRMATION_DIALOG_TAG)
},
onScroll = { UiUtil.hideKeyboard(recyclerView) }
)
if (viewModel.isFragmentChangingConfigurations && viewModel.showSearchHistory) {
binding.searchHistoryPanel.show()
binding.searchHistoryPanel.apply {
ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed
setContent {
AppTheme(theme.activeTheme) {
SearchHistoryPage(
viewModel = searchHistoryViewModel,
onClick = ::navigateFromSearchHistoryEntry,
onShowClearAllConfirmation = {
SearchHistoryClearAllConfirmationDialog(
context = this@SearchFragment.requireContext(),
onConfirm = { searchHistoryViewModel.clearAll() }
).show(parentFragmentManager, SEARCH_HISTORY_CLEAR_ALL_CONFIRMATION_DIALOG_TAG)
},
onScroll = { UiUtil.hideKeyboard(recyclerView) }
)
if (viewModel.isFragmentChangingConfigurations && viewModel.showSearchHistory) {
binding.searchHistoryPanel.show()
}
}
}
}
Expand Down

0 comments on commit 139d617

Please sign in to comment.