change (preferences) : some more final tweaks after review.
This commit is contained in:
@@ -96,7 +96,9 @@ class JoinRoomPresenter @AssistedInject constructor(
|
||||
val forgetRoomAction: MutableState<AsyncAction<Unit>> = remember { mutableStateOf(AsyncAction.Uninitialized) }
|
||||
var knockMessage by rememberSaveable { mutableStateOf("") }
|
||||
var isDismissingContent by remember { mutableStateOf(false) }
|
||||
val shouldHideAvatars by appPreferencesStore.getHideInviteAvatarsFlow().collectAsState(initial = false)
|
||||
val hideInviteAvatars by remember {
|
||||
appPreferencesStore.getHideInviteAvatarsFlow()
|
||||
}.collectAsState(initial = false)
|
||||
val contentState by produceState<ContentState>(
|
||||
initialValue = ContentState.Loading,
|
||||
key1 = roomInfo,
|
||||
@@ -205,7 +207,7 @@ class JoinRoomPresenter @AssistedInject constructor(
|
||||
cancelKnockAction = cancelKnockAction.value,
|
||||
applicationName = buildMeta.applicationName,
|
||||
knockMessage = knockMessage,
|
||||
shouldHideAvatars = shouldHideAvatars,
|
||||
hideInviteAvatars = hideInviteAvatars,
|
||||
eventSink = ::handleEvents
|
||||
)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ data class JoinRoomState(
|
||||
val cancelKnockAction: AsyncAction<Unit>,
|
||||
private val applicationName: String,
|
||||
val knockMessage: String,
|
||||
val shouldHideAvatars: Boolean,
|
||||
val hideInviteAvatars: Boolean,
|
||||
val eventSink: (JoinRoomEvents) -> Unit
|
||||
) {
|
||||
val isJoinActionUnauthorized = joinAction is AsyncAction.Failure && joinAction.error is JoinRoomFailures.UnauthorizedJoin
|
||||
@@ -58,6 +58,8 @@ data class JoinRoomState(
|
||||
}
|
||||
else -> JoinAuthorisationStatus.None
|
||||
}
|
||||
|
||||
val hideAvatarsImages = hideInviteAvatars && joinAuthorisationStatus is JoinAuthorisationStatus.IsInvited
|
||||
}
|
||||
|
||||
@Immutable
|
||||
|
||||
@@ -171,7 +171,7 @@ fun aJoinRoomState(
|
||||
forgetAction: AsyncAction<Unit> = AsyncAction.Uninitialized,
|
||||
cancelKnockAction: AsyncAction<Unit> = AsyncAction.Uninitialized,
|
||||
knockMessage: String = "",
|
||||
shouldHideAvatars: Boolean = false,
|
||||
hideInviteAvatars: Boolean = false,
|
||||
eventSink: (JoinRoomEvents) -> Unit = {}
|
||||
) = JoinRoomState(
|
||||
roomIdOrAlias = roomIdOrAlias,
|
||||
@@ -183,7 +183,7 @@ fun aJoinRoomState(
|
||||
forgetAction = forgetAction,
|
||||
applicationName = "AppName",
|
||||
knockMessage = knockMessage,
|
||||
shouldHideAvatars = shouldHideAvatars,
|
||||
hideInviteAvatars = hideInviteAvatars,
|
||||
eventSink = eventSink
|
||||
)
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ fun JoinRoomView(
|
||||
roomIdOrAlias = state.roomIdOrAlias,
|
||||
contentState = state.contentState,
|
||||
knockMessage = state.knockMessage,
|
||||
shouldHideAvatars = state.shouldHideAvatars,
|
||||
hideAvatarsImages = state.hideAvatarsImages,
|
||||
onKnockMessageUpdate = { state.eventSink(JoinRoomEvents.UpdateKnockMessage(it)) },
|
||||
)
|
||||
},
|
||||
@@ -372,7 +372,7 @@ private fun JoinRoomContent(
|
||||
roomIdOrAlias: RoomIdOrAlias,
|
||||
contentState: ContentState,
|
||||
knockMessage: String,
|
||||
shouldHideAvatars: Boolean,
|
||||
hideAvatarsImages: Boolean,
|
||||
onKnockMessageUpdate: (String) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
@@ -387,14 +387,14 @@ private fun JoinRoomContent(
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
val inviteSender = (contentState.joinAuthorisationStatus as? JoinAuthorisationStatus.IsInvited)?.inviteSender
|
||||
if (inviteSender != null) {
|
||||
InviteSenderView(inviteSender = inviteSender, hideAvatarImage = shouldHideAvatars)
|
||||
InviteSenderView(inviteSender = inviteSender, hideAvatarImage = hideAvatarsImages)
|
||||
Spacer(modifier = Modifier.height(32.dp))
|
||||
}
|
||||
DefaultLoadedContent(
|
||||
modifier = Modifier.verticalScroll(rememberScrollState()),
|
||||
contentState = contentState,
|
||||
knockMessage = knockMessage,
|
||||
shouldHideAvatars = shouldHideAvatars,
|
||||
hideAvatarImage = hideAvatarsImages,
|
||||
onKnockMessageUpdate = onKnockMessageUpdate
|
||||
)
|
||||
}
|
||||
@@ -477,14 +477,14 @@ private fun IsKnockedLoadedContent(modifier: Modifier = Modifier) {
|
||||
private fun DefaultLoadedContent(
|
||||
contentState: ContentState.Loaded,
|
||||
knockMessage: String,
|
||||
shouldHideAvatars: Boolean,
|
||||
hideAvatarImage: Boolean,
|
||||
onKnockMessageUpdate: (String) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
RoomPreviewOrganism(
|
||||
modifier = modifier,
|
||||
avatar = {
|
||||
Avatar(contentState.avatarData(AvatarSize.RoomHeader), hideImage = shouldHideAvatars)
|
||||
Avatar(contentState.avatarData(AvatarSize.RoomHeader), hideImage = hideAvatarImage)
|
||||
},
|
||||
title = {
|
||||
if (contentState.name != null) {
|
||||
|
||||
@@ -15,14 +15,16 @@ import im.vector.app.features.analytics.plan.Interaction
|
||||
import io.element.android.compound.theme.Theme
|
||||
import io.element.android.compound.theme.themes
|
||||
import io.element.android.features.preferences.impl.R
|
||||
import io.element.android.libraries.architecture.coverage.ExcludeFromCoverage
|
||||
import io.element.android.libraries.designsystem.components.dialogs.ListOption
|
||||
import io.element.android.libraries.designsystem.components.dialogs.SingleSelectionDialog
|
||||
import io.element.android.libraries.designsystem.components.list.ListItemContent
|
||||
import io.element.android.libraries.designsystem.components.preferences.PreferenceCategory
|
||||
import io.element.android.libraries.designsystem.components.preferences.PreferencePage
|
||||
import io.element.android.libraries.designsystem.components.preferences.PreferenceSwitch
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
|
||||
import io.element.android.libraries.designsystem.preview.PreviewWithLargeHeight
|
||||
import io.element.android.libraries.designsystem.theme.components.ListItem
|
||||
import io.element.android.libraries.designsystem.theme.components.ListSectionHeader
|
||||
import io.element.android.libraries.designsystem.theme.components.ListSupportingText
|
||||
@@ -192,9 +194,21 @@ private fun Theme.toHumanReadable(): String {
|
||||
)
|
||||
}
|
||||
|
||||
@PreviewsDayNight
|
||||
@PreviewWithLargeHeight
|
||||
@Composable
|
||||
internal fun AdvancedSettingsViewPreview(@PreviewParameter(AdvancedSettingsStateProvider::class) state: AdvancedSettingsState) =
|
||||
ElementPreview {
|
||||
AdvancedSettingsView(state = state, onBackClick = { })
|
||||
}
|
||||
internal fun AdvancedSettingsViewLightPreview(@PreviewParameter(AdvancedSettingsStateProvider::class) state: AdvancedSettingsState) =
|
||||
ElementPreviewLight { ContentToPreview(state) }
|
||||
|
||||
@PreviewWithLargeHeight
|
||||
@Composable
|
||||
internal fun AdvancedSettingsViewDarkPreview(@PreviewParameter(AdvancedSettingsStateProvider::class) state: AdvancedSettingsState) =
|
||||
ElementPreviewDark { ContentToPreview(state) }
|
||||
|
||||
@ExcludeFromCoverage
|
||||
@Composable
|
||||
private fun ContentToPreview(state: AdvancedSettingsState) {
|
||||
AdvancedSettingsView(
|
||||
state = state,
|
||||
onBackClick = { }
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user