From c603b780cf594a29f5a38b19da2834e3753de989 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 29 Jun 2022 17:47:28 +0100 Subject: [PATCH] extracting common breaker background selection to ftue extensions --- ...email_verification.xml => bg_gradient_ftue_breaker.xml} | 0 .../ftueauth/FtueAuthResetPasswordBreakerFragment.kt | 7 +------ .../onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt | 7 +------ .../app/features/onboarding/ftueauth/FtueExtensions.kt | 7 +++++++ .../res/layout/fragment_ftue_reset_password_breaker.xml | 2 +- .../layout/fragment_ftue_wait_for_email_verification.xml | 2 +- 6 files changed, 11 insertions(+), 14 deletions(-) rename library/ui-styles/src/main/res/drawable/{bg_waiting_for_email_verification.xml => bg_gradient_ftue_breaker.xml} (100%) diff --git a/library/ui-styles/src/main/res/drawable/bg_waiting_for_email_verification.xml b/library/ui-styles/src/main/res/drawable/bg_gradient_ftue_breaker.xml similarity index 100% rename from library/ui-styles/src/main/res/drawable/bg_waiting_for_email_verification.xml rename to library/ui-styles/src/main/res/drawable/bg_gradient_ftue_breaker.xml diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthResetPasswordBreakerFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthResetPasswordBreakerFragment.kt index 31f934b356..41e24e96c2 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthResetPasswordBreakerFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthResetPasswordBreakerFragment.kt @@ -54,12 +54,7 @@ class FtueAuthResetPasswordBreakerFragment : AbstractFtueAuthFragment R.drawable.bg_waiting_for_email_verification - false -> R.drawable.bg_color_background - } - ) + views.resetPasswordBreakerGradientContainer.setBackgroundResource(themeProvider.ftueBreakerBackground()) views.resetPasswordBreakerTitle.text = getString(R.string.ftue_auth_reset_password_breaker_title) .colorTerminatingFullStop(ThemeUtils.getColor(requireContext(), R.attr.colorSecondary)) views.resetPasswordBreakerSubtitle.text = getString(R.string.ftue_auth_email_verification_subtitle, params.email) diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt index 75090f2a55..4649c7c799 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthWaitForEmailFragment.kt @@ -58,12 +58,7 @@ class FtueAuthWaitForEmailFragment @Inject constructor( } private fun setupUi() { - views.emailVerificationGradientContainer.setBackgroundResource( - when (themeProvider.isLightTheme()) { - true -> R.drawable.bg_waiting_for_email_verification - false -> R.drawable.bg_color_background - } - ) + views.emailVerificationGradientContainer.setBackgroundResource(themeProvider.ftueBreakerBackground()) views.emailVerificationTitle.text = getString(R.string.ftue_auth_email_verification_title) .colorTerminatingFullStop(ThemeUtils.getColor(requireContext(), R.attr.colorSecondary)) views.emailVerificationSubtitle.text = getString(R.string.ftue_auth_email_verification_subtitle, params.email) diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueExtensions.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueExtensions.kt index 8d63fbf547..8deb10b7b8 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueExtensions.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueExtensions.kt @@ -18,9 +18,11 @@ package im.vector.app.features.onboarding.ftueauth import android.widget.Button import com.google.android.material.textfield.TextInputLayout +import im.vector.app.R import im.vector.app.core.extensions.hasContentFlow import im.vector.app.features.login.SignMode import im.vector.app.features.onboarding.OnboardingAction +import im.vector.app.features.themes.ThemeProvider import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.onEach @@ -49,3 +51,8 @@ fun observeContentChangesAndResetErrors(username: TextInputLayout, password: Tex submit.isEnabled = it } } + +fun ThemeProvider.ftueBreakerBackground() = when (isLightTheme()) { + true -> R.drawable.bg_gradient_ftue_breaker + false -> R.drawable.bg_color_background +} diff --git a/vector/src/main/res/layout/fragment_ftue_reset_password_breaker.xml b/vector/src/main/res/layout/fragment_ftue_reset_password_breaker.xml index e395f67b4a..240a0a9980 100644 --- a/vector/src/main/res/layout/fragment_ftue_reset_password_breaker.xml +++ b/vector/src/main/res/layout/fragment_ftue_reset_password_breaker.xml @@ -25,7 +25,7 @@ android:layout_height="0dp" app:layout_constraintHeight_percent="0.60" app:layout_constraintTop_toTopOf="parent" - tools:background="@drawable/bg_waiting_for_email_verification" /> + tools:background="@drawable/bg_gradient_ftue_breaker" /> + tools:background="@drawable/bg_gradient_ftue_breaker" />