Skip to content

Commit

Permalink
[enhancement] Improve the UX of Manage folders screen: Hide Add Folde…
Browse files Browse the repository at this point in the history
…r button when reaching bottom item of the list.
  • Loading branch information
tuancoltech committed Oct 17, 2023
1 parent 4e96c0b commit 3c593e1
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import by.kirich1409.viewbindingdelegate.viewBinding
import dev.arkbuilders.navigator.R
import dev.arkbuilders.navigator.data.utils.LogTags.FOLDERS_SCREEN
Expand Down Expand Up @@ -97,6 +98,26 @@ class FoldersFragment : Fragment(R.layout.fragment_folders) {
binding.fabAddRoots.setOnClickListener {
openRootPickerDialog(null)
}

binding.rvRoots.addOnScrollListener(object: RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(
recyclerView: RecyclerView,
newState: Int
) {
super.onScrollStateChanged(recyclerView, newState)

//Reach the end of the list
if (!binding.rvRoots.canScrollVertically(1)) {
if (binding.fabAddRoots.visibility == View.VISIBLE) {
binding.fabAddRoots.visibility = View.GONE
}
} else {
if (binding.fabAddRoots.visibility == View.GONE) {
binding.fabAddRoots.visibility = View.VISIBLE
}
}
}
})
}

private fun render(state: FoldersState) = with(state) {
Expand Down

0 comments on commit 3c593e1

Please sign in to comment.