Updated showing / hiding filters

This commit is contained in:
Viktor De Pasquale 2019-11-21 17:35:29 +01:00
parent 67c50d7504
commit 550f6aff7e
2 changed files with 23 additions and 12 deletions

View File

@ -33,6 +33,13 @@ class HideFragment : CompatFragment<HideViewModel, FragmentHideMd2Binding>() {
override val layoutRes = R.layout.fragment_hide_md2
override val viewModel by viewModel<HideViewModel>()
private var isFilterVisible
get() = binding.hideFilter.isVisible
set(value) {
if (!value) hideKeyboard()
MotionRevealHelper.withViews(binding.hideFilter, binding.hideFilterToggle, value)
}
override fun consumeSystemWindowInsets(insets: Insets) = insets
override fun onAttach(context: Context) {
@ -45,11 +52,10 @@ class HideFragment : CompatFragment<HideViewModel, FragmentHideMd2Binding>() {
super.onViewCreated(view, savedInstanceState)
binding.hideFilterToggle.setOnClickListener {
MotionRevealHelper.withViews(binding.hideFilter, binding.hideFilterToggle, true)
isFilterVisible = true
}
binding.hideFilterInclude.hideFilterDone.setOnClickListener {
hideKeyboard()
MotionRevealHelper.withViews(binding.hideFilter, binding.hideFilterToggle, false)
isFilterVisible = false
}
binding.hideContent.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
@ -64,8 +70,8 @@ class HideFragment : CompatFragment<HideViewModel, FragmentHideMd2Binding>() {
override fun onPreBind(binding: FragmentHideMd2Binding) = Unit
override fun onBackPressed(): Boolean {
if (binding.hideFilter.isVisible) {
binding.hideFilterInclude.hideFilterDone.performClick()
if (isFilterVisible) {
isFilterVisible = false
return true
}
return super.onBackPressed()

View File

@ -29,6 +29,14 @@ class ModuleFragment : CompatFragment<ModuleViewModel, FragmentModuleMd2Binding>
private val listeners = hashSetOf<EndlessRecyclerScrollListener>()
private var isFilterVisible
get() = binding.moduleFilter.isVisible
set(value) {
if (!value) hideKeyboard()
(activity as? MainActivity)?.requestNavigationHidden(value)
MotionRevealHelper.withViews(binding.moduleFilter, binding.moduleFilterToggle, value)
}
override fun consumeSystemWindowInsets(insets: Insets) = insets
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
@ -48,13 +56,10 @@ class ModuleFragment : CompatFragment<ModuleViewModel, FragmentModuleMd2Binding>
setEndlessSearch()
binding.moduleFilterToggle.setOnClickListener {
(activity as? MainActivity)?.requestNavigationHidden()
MotionRevealHelper.withViews(binding.moduleFilter, binding.moduleFilterToggle, true)
isFilterVisible = true
}
binding.moduleFilterInclude.moduleFilterDone.setOnClickListener {
(activity as? MainActivity)?.requestNavigationHidden(false)
hideKeyboard()
MotionRevealHelper.withViews(binding.moduleFilter, binding.moduleFilterToggle, false)
isFilterVisible = false
}
binding.moduleFilterInclude.moduleFilterList.addOnScrollListener(object :
RecyclerView.OnScrollListener() {
@ -73,8 +78,8 @@ class ModuleFragment : CompatFragment<ModuleViewModel, FragmentModuleMd2Binding>
}
override fun onBackPressed(): Boolean {
if (binding.moduleFilter.isVisible) {
binding.moduleFilterInclude.moduleFilterDone.performClick()
if (isFilterVisible) {
isFilterVisible = false
return true
}
return super.onBackPressed()