fix : display security banner for room list empty state
This commit is contained in:
parent
1012272a08
commit
9e744690eb
4 changed files with 51 additions and 17 deletions
|
|
@ -21,6 +21,7 @@ open class RoomListContentStateProvider : PreviewParameterProvider<RoomListConte
|
||||||
aRoomsContentState(summaries = persistentListOf()),
|
aRoomsContentState(summaries = persistentListOf()),
|
||||||
aSkeletonContentState(),
|
aSkeletonContentState(),
|
||||||
anEmptyContentState(),
|
anEmptyContentState(),
|
||||||
|
anEmptyContentState(securityBannerState = SecurityBannerState.SetUpRecovery),
|
||||||
aRoomsContentState(securityBannerState = SecurityBannerState.NeedsNativeSlidingSyncMigration),
|
aRoomsContentState(securityBannerState = SecurityBannerState.NeedsNativeSlidingSyncMigration),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -37,4 +38,8 @@ internal fun aRoomsContentState(
|
||||||
|
|
||||||
internal fun aSkeletonContentState() = RoomListContentState.Skeleton(16)
|
internal fun aSkeletonContentState() = RoomListContentState.Skeleton(16)
|
||||||
|
|
||||||
internal fun anEmptyContentState() = RoomListContentState.Empty
|
internal fun anEmptyContentState(
|
||||||
|
securityBannerState: SecurityBannerState = SecurityBannerState.None,
|
||||||
|
) = RoomListContentState.Empty(
|
||||||
|
securityBannerState = securityBannerState,
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -236,11 +236,11 @@ class RoomListPresenter @Inject constructor(
|
||||||
client.isNativeSlidingSyncSupported() && !client.isUsingNativeSlidingSync()
|
client.isNativeSlidingSyncSupported() && !client.isUsingNativeSlidingSync()
|
||||||
}.getOrNull().orFalse()
|
}.getOrNull().orFalse()
|
||||||
}
|
}
|
||||||
|
val securityBannerState by rememberSecurityBannerState(securityBannerDismissed, needsSlidingSyncMigration)
|
||||||
return when {
|
return when {
|
||||||
showEmpty -> RoomListContentState.Empty
|
showEmpty -> RoomListContentState.Empty(securityBannerState = securityBannerState)
|
||||||
showSkeleton -> RoomListContentState.Skeleton(count = 16)
|
showSkeleton -> RoomListContentState.Skeleton(count = 16)
|
||||||
else -> {
|
else -> {
|
||||||
val securityBannerState by rememberSecurityBannerState(securityBannerDismissed, needsSlidingSyncMigration)
|
|
||||||
RoomListContentState.Rooms(
|
RoomListContentState.Rooms(
|
||||||
securityBannerState = securityBannerState,
|
securityBannerState = securityBannerState,
|
||||||
fullScreenIntentPermissionsState = fullScreenIntentPermissionsPresenter.present(),
|
fullScreenIntentPermissionsState = fullScreenIntentPermissionsPresenter.present(),
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,9 @@ enum class SecurityBannerState {
|
||||||
@Immutable
|
@Immutable
|
||||||
sealed interface RoomListContentState {
|
sealed interface RoomListContentState {
|
||||||
data class Skeleton(val count: Int) : RoomListContentState
|
data class Skeleton(val count: Int) : RoomListContentState
|
||||||
data object Empty : RoomListContentState
|
data class Empty(
|
||||||
|
val securityBannerState: SecurityBannerState,
|
||||||
|
) : RoomListContentState
|
||||||
data class Rooms(
|
data class Rooms(
|
||||||
val securityBannerState: SecurityBannerState,
|
val securityBannerState: SecurityBannerState,
|
||||||
val fullScreenIntentPermissionsState: FullScreenIntentPermissionsState,
|
val fullScreenIntentPermissionsState: FullScreenIntentPermissionsState,
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,10 @@ fun RoomListContentView(
|
||||||
}
|
}
|
||||||
is RoomListContentState.Empty -> {
|
is RoomListContentState.Empty -> {
|
||||||
EmptyView(
|
EmptyView(
|
||||||
|
state = contentState,
|
||||||
|
eventSink = eventSink,
|
||||||
|
onSetUpRecoveryClick = onSetUpRecoveryClick,
|
||||||
|
onConfirmRecoveryKeyClick = onConfirmRecoveryKeyClick,
|
||||||
onCreateRoomClick = onCreateRoomClick,
|
onCreateRoomClick = onCreateRoomClick,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -110,21 +114,44 @@ private fun SkeletonView(count: Int, modifier: Modifier = Modifier) {
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun EmptyView(
|
private fun EmptyView(
|
||||||
|
state: RoomListContentState.Empty,
|
||||||
|
eventSink: (RoomListEvents) -> Unit,
|
||||||
|
onSetUpRecoveryClick: () -> Unit,
|
||||||
|
onConfirmRecoveryKeyClick: () -> Unit,
|
||||||
onCreateRoomClick: () -> Unit,
|
onCreateRoomClick: () -> Unit,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
EmptyScaffold(
|
Box(modifier.fillMaxSize()) {
|
||||||
title = R.string.screen_roomlist_empty_title,
|
EmptyScaffold(
|
||||||
subtitle = R.string.screen_roomlist_empty_message,
|
title = R.string.screen_roomlist_empty_title,
|
||||||
action = {
|
subtitle = R.string.screen_roomlist_empty_message,
|
||||||
Button(
|
action = {
|
||||||
text = stringResource(CommonStrings.action_start_chat),
|
Button(
|
||||||
leadingIcon = IconSource.Vector(CompoundIcons.Compose()),
|
text = stringResource(CommonStrings.action_start_chat),
|
||||||
onClick = onCreateRoomClick,
|
leadingIcon = IconSource.Vector(CompoundIcons.Compose()),
|
||||||
)
|
onClick = onCreateRoomClick,
|
||||||
},
|
)
|
||||||
modifier = modifier.fillMaxSize(),
|
},
|
||||||
)
|
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
|
@Composable
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue