Skip to content

Commit

Permalink
Merge pull request #491 from arkivanov/fixed-pages-fast-swipe
Browse files Browse the repository at this point in the history
Fixed Pages not calling onPageSelected when swiping fast
  • Loading branch information
arkivanov authored Sep 27, 2023
2 parents 22820f4 + e19b42e commit d9c4500
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ fun <T : Any> Pages(
}
}

DisposableEffect(state.settledPage) {
onPageSelected(state.settledPage)
DisposableEffect(state.currentPage) {
onPageSelected(state.currentPage)
onDispose {}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ import kotlinx.coroutines.runBlocking
import org.junit.Rule
import kotlin.test.Test

@Suppress("TestFunctionName")
class PagesTest {

@get:Rule
val composeRule = createComposeRule()

@OptIn(ExperimentalDecomposeApi::class)
@Test
fun GIVEN_pages_dislpayed_WHEN_page_state_changed_THEN_pageCount_updated() {
fun GIVEN_pages_displayed_WHEN_page_state_changed_THEN_pageCount_updated() {
runBlocking(Dispatchers.Main) {
val state = mutableStateOf(
ChildPages<Config, Config>(
Expand Down Expand Up @@ -55,7 +56,7 @@ class PagesTest {

@OptIn(ExperimentalDecomposeApi::class)
@Test
fun GIVEN_page0_dislpayed_WHEN_switching_pages_THEN_current_page_updated() {
fun GIVEN_page0_displayed_WHEN_switching_pages_THEN_current_page_updated() {
runBlocking(Dispatchers.Main) {
val state = mutableStateOf(
ChildPages(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ import org.junit.Rule
import org.junit.Test
import java.io.Serializable

@Suppress("TestFunctionName")
class PagesTest {

@get:Rule
val composeRule = createComposeRule()

@OptIn(ExperimentalDecomposeApi::class)
@Test
fun GIVEN_pages_dislpayed_WHEN_page_state_changed_THEN_pageCount_updated() {
fun GIVEN_pages_displayed_WHEN_page_state_changed_THEN_pageCount_updated() {
val state = mutableStateOf(
ChildPages<Config, Config>(
items = listOf(
Expand Down Expand Up @@ -52,7 +53,7 @@ class PagesTest {

@OptIn(ExperimentalDecomposeApi::class)
@Test
fun GIVEN_page0_dislpayed_WHEN_switching_pages_THEN_current_page_updated() {
fun GIVEN_page0_displayed_WHEN_switching_pages_THEN_current_page_updated() {
val state = mutableStateOf(
ChildPages(
items = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ fun <T : Any> Pages(
}
}

DisposableEffect(state.settledPage) {
onPageSelected(state.settledPage)
DisposableEffect(state.currentPage) {
onPageSelected(state.currentPage)
onDispose {}
}

Expand Down

0 comments on commit d9c4500

Please sign in to comment.