Skip to content

Commit 83e84c4

Browse files
committed
Hide FAB if fully scrolled to bottom
1 parent 1278ba9 commit 83e84c4

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package entry
2+
3+
import androidx.fragment.app.testing.launchFragmentInContainer
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
import co.appreactor.news.R
6+
import entries.EntriesFragmentDirections
7+
import org.junit.Test
8+
import org.junit.runner.RunWith
9+
10+
@RunWith(AndroidJUnit4::class)
11+
class EntryFragmentTest {
12+
13+
@Test
14+
fun resumesWithoutCrashes() {
15+
val directions =
16+
EntriesFragmentDirections.actionEntriesFragmentToEntryFragment("")
17+
18+
launchFragmentInContainer<EntryFragment>(
19+
themeResId = R.style.Theme_Material3_DynamicColors_DayNight,
20+
fragmentArgs = directions.arguments,
21+
)
22+
}
23+
}

app/src/main/kotlin/entry/EntryFragment.kt

+8
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ class EntryFragment : AppFragment() {
6666

6767
model.state.collectLatest { setState(it ?: return@collectLatest) }
6868
}
69+
70+
scrollView.setOnScrollChangeListener { _, _, _, _, _ ->
71+
if (scrollView.canScrollVertically(1)) {
72+
fab.show()
73+
} else {
74+
fab.hide()
75+
}
76+
}
6977
}
7078
}
7179

0 commit comments

Comments
 (0)