Skip to content

Commit

Permalink
Hide FAB if fully scrolled to bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
bubelov committed Jan 30, 2022
1 parent 1278ba9 commit 83e84c4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/src/androidTest/kotlin/entry/EntryFragmentTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package entry

import androidx.fragment.app.testing.launchFragmentInContainer
import androidx.test.ext.junit.runners.AndroidJUnit4
import co.appreactor.news.R
import entries.EntriesFragmentDirections
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class EntryFragmentTest {

@Test
fun resumesWithoutCrashes() {
val directions =
EntriesFragmentDirections.actionEntriesFragmentToEntryFragment("")

launchFragmentInContainer<EntryFragment>(
themeResId = R.style.Theme_Material3_DynamicColors_DayNight,
fragmentArgs = directions.arguments,
)
}
}
8 changes: 8 additions & 0 deletions app/src/main/kotlin/entry/EntryFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ class EntryFragment : AppFragment() {

model.state.collectLatest { setState(it ?: return@collectLatest) }
}

scrollView.setOnScrollChangeListener { _, _, _, _, _ ->
if (scrollView.canScrollVertically(1)) {
fab.show()
} else {
fab.hide()
}
}
}
}

Expand Down

0 comments on commit 83e84c4

Please sign in to comment.