From 8be6bad4658dfbdc6d0c516a4b062966dc73efd1 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 10 Oct 2023 20:59:58 +0200 Subject: [PATCH] SignedOutView: iterate on design. --- features/signedout/impl/build.gradle.kts | 1 + .../signedout/impl/SignedOutPresenter.kt | 3 ++ .../features/signedout/impl/SignedOutState.kt | 1 + .../signedout/impl/SignedOutStateProvider.kt | 3 +- .../features/signedout/impl/SignedOutView.kt | 45 ++++++++++--------- .../impl/src/main/res/drawable/ic_devices.xml | 29 ++++++++++++ .../main/res/drawable/ic_do_disturb_alt.xml | 29 ++++++++++++ .../src/main/res/drawable/ic_lock_outline.xml | 29 ++++++++++++ .../impl/src/main/res/values/localazy.xml | 2 +- 9 files changed, 118 insertions(+), 24 deletions(-) create mode 100644 features/signedout/impl/src/main/res/drawable/ic_devices.xml create mode 100644 features/signedout/impl/src/main/res/drawable/ic_do_disturb_alt.xml create mode 100644 features/signedout/impl/src/main/res/drawable/ic_lock_outline.xml diff --git a/features/signedout/impl/build.gradle.kts b/features/signedout/impl/build.gradle.kts index 399c95e254..0255ac3ca1 100644 --- a/features/signedout/impl/build.gradle.kts +++ b/features/signedout/impl/build.gradle.kts @@ -38,6 +38,7 @@ dependencies { implementation(projects.libraries.matrix.api) implementation(projects.libraries.matrixui) implementation(projects.libraries.designsystem) + implementation(projects.libraries.uiStrings) testImplementation(libs.test.junit) testImplementation(libs.coroutines.test) diff --git a/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutPresenter.kt b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutPresenter.kt index ee8cf2e63f..a93d22253d 100644 --- a/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutPresenter.kt +++ b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutPresenter.kt @@ -26,12 +26,14 @@ import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject import io.element.android.libraries.architecture.Presenter +import io.element.android.libraries.core.meta.BuildMeta import io.element.android.libraries.sessionstorage.api.SessionStore import kotlinx.coroutines.launch class SignedOutPresenter @AssistedInject constructor( @Assisted private val sessionId: String, /* Cannot inject SessionId */ private val sessionStore: SessionStore, + private val buildMeta: BuildMeta, ) : Presenter { @AssistedFactory @@ -56,6 +58,7 @@ class SignedOutPresenter @AssistedInject constructor( } return SignedOutState( + appName = buildMeta.applicationName, signedOutSession = signedOutSession, eventSink = ::handleEvents ) diff --git a/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutState.kt b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutState.kt index 2f7af29e40..eff0ab6d5b 100644 --- a/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutState.kt +++ b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutState.kt @@ -20,6 +20,7 @@ import io.element.android.libraries.sessionstorage.api.SessionData // Do not use default value, so no member get forgotten in the presenters. data class SignedOutState( + val appName: String, val signedOutSession: SessionData?, val eventSink: (SignedOutEvents) -> Unit, ) diff --git a/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutStateProvider.kt b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutStateProvider.kt index 1af0ef41de..0182e87cf3 100644 --- a/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutStateProvider.kt +++ b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutStateProvider.kt @@ -30,8 +30,9 @@ open class SignedOutStateProvider : PreviewParameterProvider { } fun aSignedOutState() = SignedOutState( + appName = "AppName", + signedOutSession = aSessionData(), eventSink = {}, - signedOutSession = aSessionData() ) fun aSessionData( diff --git a/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutView.kt b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutView.kt index 42c38224b6..63845ead90 100644 --- a/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutView.kt +++ b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutView.kt @@ -17,7 +17,7 @@ package io.element.android.features.signedout.impl import androidx.activity.compose.BackHandler -import androidx.compose.foundation.background +import androidx.annotation.DrawableRes import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth @@ -25,13 +25,12 @@ import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.systemBarsPadding -import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.AccountCircle -import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.BiasAlignment import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import io.element.android.libraries.designsystem.atomic.molecules.ButtonColumnMolecule @@ -44,8 +43,8 @@ import io.element.android.libraries.designsystem.preview.PreviewsDayNight import io.element.android.libraries.designsystem.theme.components.Button import io.element.android.libraries.designsystem.theme.components.Icon import io.element.android.libraries.designsystem.theme.temporaryColorBgSpecial -import io.element.android.libraries.designsystem.utils.CommonDrawables import io.element.android.libraries.theme.ElementTheme +import io.element.android.libraries.ui.strings.CommonStrings import kotlinx.collections.immutable.persistentListOf @Composable @@ -59,7 +58,7 @@ fun SignedOutView( .fillMaxSize() .systemBarsPadding() .imePadding(), - header = { SignedOutHeader() }, + header = { SignedOutHeader(state) }, content = { SignedOutContent() }, footer = { SignedOutFooter( @@ -70,12 +69,13 @@ fun SignedOutView( } @Composable -private fun SignedOutHeader() { +private fun SignedOutHeader(state: SignedOutState) { IconTitleSubtitleMolecule( modifier = Modifier.padding(top = 60.dp, bottom = 12.dp), - title = "You’re signed out", - subTitle = "It can be due to various reasons:", - iconImageVector = Icons.Filled.AccountCircle + title = stringResource(id = R.string.screen_signed_out_title), + subTitle = stringResource(id = R.string.screen_signed_out_subtitle, state.appName), + iconImageVector = Icons.Filled.AccountCircle, + iconTint = ElementTheme.colors.iconSecondary, ) } @@ -93,16 +93,16 @@ private fun SignedOutContent( InfoListOrganism( items = persistentListOf( InfoListItem( - message = "You’ve changed your password on another session.", - iconComposable = { CheckIcon() }, + message = stringResource(id = R.string.screen_signed_out_reason_1), + iconComposable = { Icon(R.drawable.ic_lock_outline) }, ), InfoListItem( - message = "You have deleted this session from another session.", - iconComposable = { CheckIcon() }, + message = stringResource(id = R.string.screen_signed_out_reason_2), + iconComposable = { Icon(R.drawable.ic_devices) }, ), InfoListItem( - message = "The administrator of your server has invalidated your access for security reason.", - iconComposable = { CheckIcon() }, + message = stringResource(id = R.string.screen_signed_out_reason_3), + iconComposable = { Icon(R.drawable.ic_do_disturb_alt) }, ), ), textStyle = ElementTheme.typography.fontBodyMdMedium, @@ -113,15 +113,16 @@ private fun SignedOutContent( } @Composable -private fun CheckIcon(modifier: Modifier = Modifier) { +private fun Icon( + @DrawableRes iconResourceId: Int, + modifier: Modifier = Modifier, +) { Icon( modifier = modifier - .size(20.dp) - .background(color = MaterialTheme.colorScheme.background, shape = CircleShape) - .padding(2.dp), - resourceId = CommonDrawables.ic_compound_check, + .size(20.dp), + resourceId = iconResourceId, contentDescription = null, - tint = ElementTheme.colors.textActionAccent, + tint = ElementTheme.colors.iconSecondary, ) } @@ -134,7 +135,7 @@ private fun SignedOutFooter( modifier = modifier, ) { Button( - text = "Sign in again", + text = stringResource(id = CommonStrings.action_sign_in_again), onClick = onSignInAgain, modifier = Modifier.fillMaxWidth(), ) diff --git a/features/signedout/impl/src/main/res/drawable/ic_devices.xml b/features/signedout/impl/src/main/res/drawable/ic_devices.xml new file mode 100644 index 0000000000..e01de99a1d --- /dev/null +++ b/features/signedout/impl/src/main/res/drawable/ic_devices.xml @@ -0,0 +1,29 @@ + + + + + + + + diff --git a/features/signedout/impl/src/main/res/drawable/ic_do_disturb_alt.xml b/features/signedout/impl/src/main/res/drawable/ic_do_disturb_alt.xml new file mode 100644 index 0000000000..2ac90bd377 --- /dev/null +++ b/features/signedout/impl/src/main/res/drawable/ic_do_disturb_alt.xml @@ -0,0 +1,29 @@ + + + + + + + + diff --git a/features/signedout/impl/src/main/res/drawable/ic_lock_outline.xml b/features/signedout/impl/src/main/res/drawable/ic_lock_outline.xml new file mode 100644 index 0000000000..51831bf3c1 --- /dev/null +++ b/features/signedout/impl/src/main/res/drawable/ic_lock_outline.xml @@ -0,0 +1,29 @@ + + + + + + + + diff --git a/features/signedout/impl/src/main/res/values/localazy.xml b/features/signedout/impl/src/main/res/values/localazy.xml index bfbad719c7..f70b0042d5 100644 --- a/features/signedout/impl/src/main/res/values/localazy.xml +++ b/features/signedout/impl/src/main/res/values/localazy.xml @@ -3,6 +3,6 @@ "You’ve changed your password on another session" "You have deleted the session from another session" "Your server’s administrator has invalidated your access" - "You might have been signed out for one of the reasons listed below. Please sign in again to continue using Element." + "You might have been signed out for one of the reasons listed below. Please sign in again to continue using %s." "You’re signed out"