From 7715686af4bf2bd02633b890bbfbf06087c3f591 Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 19 Nov 2024 11:07:50 +0100 Subject: [PATCH 1/2] fix : display security banner for room list empty state --- .../impl/RoomListContentStateProvider.kt | 7 ++- .../roomlist/impl/RoomListPresenter.kt | 4 +- .../features/roomlist/impl/RoomListState.kt | 4 +- .../impl/components/RoomListContentView.kt | 53 ++++++++++++++----- 4 files changed, 51 insertions(+), 17 deletions(-) diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListContentStateProvider.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListContentStateProvider.kt index 8b216f3854..4c9e7e0595 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListContentStateProvider.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListContentStateProvider.kt @@ -21,6 +21,7 @@ open class RoomListContentStateProvider : PreviewParameterProvider RoomListContentState.Empty + showEmpty -> RoomListContentState.Empty(securityBannerState = securityBannerState) showSkeleton -> RoomListContentState.Skeleton(count = 16) else -> { - val securityBannerState by rememberSecurityBannerState(securityBannerDismissed, needsSlidingSyncMigration) RoomListContentState.Rooms( securityBannerState = securityBannerState, fullScreenIntentPermissionsState = fullScreenIntentPermissionsPresenter.present(), diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListState.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListState.kt index 642c7d879b..a6b9673b54 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListState.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListState.kt @@ -61,7 +61,9 @@ enum class SecurityBannerState { @Immutable sealed interface RoomListContentState { data class Skeleton(val count: Int) : RoomListContentState - data object Empty : RoomListContentState + data class Empty( + val securityBannerState: SecurityBannerState, + ) : RoomListContentState data class Rooms( val securityBannerState: SecurityBannerState, val fullScreenIntentPermissionsState: FullScreenIntentPermissionsState, diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListContentView.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListContentView.kt index d4af5a3fe5..503b00f348 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListContentView.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomListContentView.kt @@ -76,6 +76,10 @@ fun RoomListContentView( } is RoomListContentState.Empty -> { EmptyView( + state = contentState, + eventSink = eventSink, + onSetUpRecoveryClick = onSetUpRecoveryClick, + onConfirmRecoveryKeyClick = onConfirmRecoveryKeyClick, onCreateRoomClick = onCreateRoomClick, ) } @@ -110,21 +114,44 @@ private fun SkeletonView(count: Int, modifier: Modifier = Modifier) { @Composable private fun EmptyView( + state: RoomListContentState.Empty, + eventSink: (RoomListEvents) -> Unit, + onSetUpRecoveryClick: () -> Unit, + onConfirmRecoveryKeyClick: () -> Unit, onCreateRoomClick: () -> Unit, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, ) { - EmptyScaffold( - title = R.string.screen_roomlist_empty_title, - subtitle = R.string.screen_roomlist_empty_message, - action = { - Button( - text = stringResource(CommonStrings.action_start_chat), - leadingIcon = IconSource.Vector(CompoundIcons.Compose()), - onClick = onCreateRoomClick, - ) - }, - modifier = modifier.fillMaxSize(), - ) + Box(modifier.fillMaxSize()) { + EmptyScaffold( + title = R.string.screen_roomlist_empty_title, + subtitle = R.string.screen_roomlist_empty_message, + action = { + Button( + text = stringResource(CommonStrings.action_start_chat), + leadingIcon = IconSource.Vector(CompoundIcons.Compose()), + onClick = onCreateRoomClick, + ) + }, + modifier = Modifier.align(Alignment.Center), + ) + Box { + when (state.securityBannerState) { + SecurityBannerState.SetUpRecovery -> { + SetUpRecoveryKeyBanner( + onContinueClick = onSetUpRecoveryClick, + onDismissClick = { eventSink(RoomListEvents.DismissBanner) } + ) + } + SecurityBannerState.RecoveryKeyConfirmation -> { + ConfirmRecoveryKeyBanner( + onContinueClick = onConfirmRecoveryKeyClick, + onDismissClick = { eventSink(RoomListEvents.DismissBanner) } + ) + } + else -> Unit + } + } + } } @Composable From 71e65cd1a0d5126ca0ae27e347fb2a687f7fc578 Mon Sep 17 00:00:00 2001 From: ElementBot Date: Tue, 19 Nov 2024 10:19:01 +0000 Subject: [PATCH 2/2] Update screenshots --- ....roomlist.impl.components_RoomListContentView_Day_4_en.png | 4 ++-- ....roomlist.impl.components_RoomListContentView_Day_5_en.png | 3 +++ ...oomlist.impl.components_RoomListContentView_Night_4_en.png | 4 ++-- ...oomlist.impl.components_RoomListContentView_Night_5_en.png | 3 +++ 4 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Day_5_en.png create mode 100644 tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Night_5_en.png diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Day_4_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Day_4_en.png index 8952f01b7f..a465700eef 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Day_4_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Day_4_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a78abedec8a3aad14bf6368bf73d46621feaf8e6fd6e019d381077ef05856259 -size 72236 +oid sha256:f07e339529fa15809163745520ccd2d187d858f88148a37e59ec9df1d9559cdd +size 46528 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Day_5_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Day_5_en.png new file mode 100644 index 0000000000..8952f01b7f --- /dev/null +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Day_5_en.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a78abedec8a3aad14bf6368bf73d46621feaf8e6fd6e019d381077ef05856259 +size 72236 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Night_4_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Night_4_en.png index 1e6d6d626d..ef72333797 100644 --- a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Night_4_en.png +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Night_4_en.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f60d07c4be6d75142e753dec5071f7a6d5dd15519d87a2eb491b708fa7aeea4b -size 70917 +oid sha256:44b0af23c318bc8c4e881bca9ad61127d821d4d82f43de2d9e785860bbda2fcf +size 45038 diff --git a/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Night_5_en.png b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Night_5_en.png new file mode 100644 index 0000000000..1e6d6d626d --- /dev/null +++ b/tests/uitests/src/test/snapshots/images/features.roomlist.impl.components_RoomListContentView_Night_5_en.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f60d07c4be6d75142e753dec5071f7a6d5dd15519d87a2eb491b708fa7aeea4b +size 70917