-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed the predictive back gesture interrupted with the new animation API
- Loading branch information
Showing
5 changed files
with
497 additions
and
42 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
.../commonMain/kotlin/com/arkivanov/decompose/extensions/compose/experimental/stack/Utils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
package com.arkivanov.decompose.extensions.compose.experimental.stack | ||
|
||
import com.arkivanov.decompose.router.stack.ChildStack | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.coroutineScope | ||
import kotlinx.coroutines.joinAll | ||
import kotlinx.coroutines.launch | ||
|
||
internal fun <C : Any, T : Any> ChildStack<C, T>.dropLast(): ChildStack<C, T> = | ||
ChildStack(active = backStack.last(), backStack = backStack.dropLast(1)) | ||
|
||
internal val ChildStack<*, *>.size: Int get() = items.size | ||
|
||
internal suspend inline fun awaitAll(vararg jobs: suspend CoroutineScope.() -> Unit) { | ||
coroutineScope { | ||
jobs.map { launch(block = it) }.joinAll() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...l/src/jvmTest/kotlin/com/arkivanov/decompose/extensions/compose/experimental/TestUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.arkivanov.decompose.extensions.compose.experimental | ||
|
||
import androidx.compose.ui.semantics.SemanticsConfiguration | ||
import androidx.compose.ui.semantics.SemanticsNode | ||
import androidx.compose.ui.semantics.SemanticsProperties | ||
import androidx.compose.ui.semantics.getOrNull | ||
import androidx.compose.ui.test.SemanticsNodeInteraction | ||
import kotlin.test.fail | ||
|
||
internal fun SemanticsNodeInteraction.assertTestTagToRootExists(testTag: String) { | ||
val count = collectTestTagsToRoot().filter { it == testTag }.size | ||
if (count != 1) { | ||
fail("Expected to have one node with the specified test tag \"$testTag\", but was $count") | ||
} | ||
} | ||
|
||
internal fun SemanticsNodeInteraction.assertTestTagToRootDoesNotExist(matcher: (String) -> Boolean) { | ||
val count = collectTestTagsToRoot().filter(matcher).size | ||
if (count != 0) { | ||
fail("Expected not to have a node with a test tag matching the specified predicate, but was $count") | ||
} | ||
} | ||
|
||
private fun SemanticsNodeInteraction.collectTestTagsToRoot(): List<String> = | ||
collectSemanticsFromRoot() | ||
.mapNotNull { it.getOrNull(SemanticsProperties.TestTag) } | ||
|
||
private fun SemanticsNodeInteraction.collectSemanticsFromRoot(): List<SemanticsConfiguration> { | ||
val list = ArrayList<SemanticsConfiguration>() | ||
var node: SemanticsNode? = fetchSemanticsNode() | ||
while (node != null) { | ||
list += node.config | ||
node = node.parent | ||
} | ||
|
||
return list | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.