From c0b855e7c7aca814e57180dfd51be5acf71b638b Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 14 Jan 2022 12:18:06 +0000 Subject: [PATCH] adding non light mode carousel background which uses a vertical gradient --- .../res/drawable/bg_carousel_page_dark.xml | 7 +++ .../ftueauth/SplashCarouselStateFactory.kt | 59 +++++++++++-------- 2 files changed, 40 insertions(+), 26 deletions(-) create mode 100644 library/ui-styles/src/main/res/drawable/bg_carousel_page_dark.xml diff --git a/library/ui-styles/src/main/res/drawable/bg_carousel_page_dark.xml b/library/ui-styles/src/main/res/drawable/bg_carousel_page_dark.xml new file mode 100644 index 0000000000..f229c51d1b --- /dev/null +++ b/library/ui-styles/src/main/res/drawable/bg_carousel_page_dark.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/SplashCarouselStateFactory.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/SplashCarouselStateFactory.kt index ffad3d15bc..0f420b5b5a 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/SplashCarouselStateFactory.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/SplashCarouselStateFactory.kt @@ -18,12 +18,14 @@ package im.vector.app.features.onboarding.ftueauth import android.content.Context import androidx.annotation.AttrRes +import androidx.annotation.DrawableRes import im.vector.app.R import im.vector.app.core.epoxy.charsequence.EpoxyCharSequence import im.vector.app.core.epoxy.charsequence.toEpoxyCharSequence import im.vector.app.core.resources.LocaleProvider import im.vector.app.core.resources.StringProvider import im.vector.app.core.resources.isEnglishSpeaking +import im.vector.app.features.themes.ThemeProvider import im.vector.app.features.themes.ThemeUtils import me.gujun.android.span.span import javax.inject.Inject @@ -32,34 +34,39 @@ class SplashCarouselStateFactory @Inject constructor( private val context: Context, private val stringProvider: StringProvider, private val localeProvider: LocaleProvider, + private val themeProvider: ThemeProvider, ) { - fun create() = SplashCarouselState(listOf( - SplashCarouselState.Item( - R.string.ftue_auth_carousel_1_title.colorTerminatingFullStop(R.attr.colorAccent), - R.string.ftue_auth_carousel_body_secure, - R.drawable.ic_splash_conversations, - R.drawable.bg_carousel_page_1 - ), - SplashCarouselState.Item( - R.string.ftue_auth_carousel_2_title.colorTerminatingFullStop(R.attr.colorAccent), - R.string.ftue_auth_carousel_body_control, - R.drawable.ic_splash_control, - R.drawable.bg_carousel_page_2 - ), - SplashCarouselState.Item( - R.string.ftue_auth_carousel_3_title.colorTerminatingFullStop(R.attr.colorAccent), - R.string.ftue_auth_carousel_body_encrypted, - R.drawable.ic_splash_secure, - R.drawable.bg_carousel_page_3 - ), - SplashCarouselState.Item( - collaborationTitle().colorTerminatingFullStop(R.attr.colorAccent), - R.string.ftue_auth_carousel_body_workplace, - R.drawable.ic_splash_collaboration, - R.drawable.bg_carousel_page_4 - ) - )) + fun create(): SplashCarouselState { + val lightTheme = themeProvider.isLightTheme() + fun background(@DrawableRes lightDrawable: Int) = if (lightTheme) lightDrawable else R.drawable.bg_carousel_page_dark + return SplashCarouselState(listOf( + SplashCarouselState.Item( + R.string.ftue_auth_carousel_1_title.colorTerminatingFullStop(R.attr.colorAccent), + R.string.ftue_auth_carousel_body_secure, + R.drawable.ic_splash_conversations, + background(R.drawable.bg_carousel_page_1) + ), + SplashCarouselState.Item( + R.string.ftue_auth_carousel_2_title.colorTerminatingFullStop(R.attr.colorAccent), + R.string.ftue_auth_carousel_body_control, + R.drawable.ic_splash_control, + background(R.drawable.bg_carousel_page_2) + ), + SplashCarouselState.Item( + R.string.ftue_auth_carousel_3_title.colorTerminatingFullStop(R.attr.colorAccent), + R.string.ftue_auth_carousel_body_encrypted, + R.drawable.ic_splash_secure, + background(R.drawable.bg_carousel_page_3) + ), + SplashCarouselState.Item( + collaborationTitle().colorTerminatingFullStop(R.attr.colorAccent), + R.string.ftue_auth_carousel_body_workplace, + R.drawable.ic_splash_collaboration, + background(R.drawable.bg_carousel_page_4) + ) + )) + } private fun collaborationTitle(): Int { return when {