From 261510a42cbc2ca898d8edc25b215d8ba5521c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Rychnovsk=C3=BD?= Date: Mon, 11 Nov 2024 12:24:43 +0100 Subject: [PATCH] Fix WelcomeAnimation in testing (#1668) - These changes also improve the UX of the app launch, as it only waits for the animation duration. --- ui-lib/src/main/java/co/electriccoin/zcash/ui/MainActivity.kt | 2 +- .../zcash/ui/screen/authentication/view/AuthenticationView.kt | 4 +++- .../zcash/ui/screen/authentication/view/WelcomeAnimation.kt | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/MainActivity.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/MainActivity.kt index 482369bb..e687d1e9 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/MainActivity.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/MainActivity.kt @@ -259,7 +259,7 @@ class MainActivity : FragmentActivity() { onSuccess = { lifecycleScope.launch { // Wait until the welcome animation finishes, then mark it as presented to the user - delay((AnimationConstants.together()).milliseconds) + delay((AnimationConstants.durationOnly()).milliseconds) authenticationViewModel.appAccessAuthentication.value = AuthenticationUIState.Successful } }, diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/authentication/view/AuthenticationView.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/authentication/view/AuthenticationView.kt index 91b72717..f49c5914 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/authentication/view/AuthenticationView.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/authentication/view/AuthenticationView.kt @@ -8,6 +8,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.tooling.preview.Preview @@ -16,6 +17,7 @@ import co.electriccoin.zcash.ui.common.viewmodel.AuthenticationResult import co.electriccoin.zcash.ui.design.component.AppAlertDialog import co.electriccoin.zcash.ui.design.component.BlankSurface import co.electriccoin.zcash.ui.design.theme.ZcashTheme +import co.electriccoin.zcash.ui.screen.authentication.view.AnimationConstants.WELCOME_ANIM_TEST_TAG @Preview("App Access Authentication") @Composable @@ -72,7 +74,7 @@ fun AppAccessAuthentication( animationState = welcomeAnimVisibility, onRetry = onRetry, showAuthLogo = showAuthLogo, - modifier = modifier, + modifier = modifier.testTag(WELCOME_ANIM_TEST_TAG), ) } diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/authentication/view/WelcomeAnimation.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/authentication/view/WelcomeAnimation.kt index 37b1b82b..f89a8c4d 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/authentication/view/WelcomeAnimation.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/authentication/view/WelcomeAnimation.kt @@ -57,6 +57,8 @@ object AnimationConstants { const val WELCOME_ANIM_TEST_TAG = "WELCOME_ANIM_TEST_TAG" fun together() = (ANIMATION_DURATION + INITIAL_DELAY).toLong() + + fun durationOnly() = (ANIMATION_DURATION).toLong() } // TODO [#1002]: Welcome screen animation masking