Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with animations running on main thread #5142

Merged
merged 1 commit into from Jun 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.produceState
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
Expand All @@ -41,6 +42,7 @@ import androidx.compose.ui.unit.dp
import com.stripe.android.ui.core.R
import com.stripe.android.ui.core.paymentsColors
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

/**
* This is focused on converting an [TextFieldController] into what is displayed in a section
Expand Down Expand Up @@ -216,11 +218,15 @@ fun AnimatedIcons(
) {
if (icons.isEmpty()) return

val composableScope = rememberCoroutineScope()

val target by produceState(initialValue = icons.first()) {
while (true) {
icons.forEach {
delay(1000)
value = it
composableScope.launch {
while (true) {
icons.forEach {
delay(1000)
value = it
}
}
}
}
Expand Down