Skip to content

Commit

Permalink
Merge pull request #4140 from element-hq/feature/fga/compound_design_…
Browse files Browse the repository at this point in the history
…announcement

change(design) : New component Announcement
  • Loading branch information
ganfra authored Jan 15, 2025
2 parents 6b43255 + 24a1b31 commit 46119ae
Show file tree
Hide file tree
Showing 33 changed files with 339 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package io.element.android.features.preferences.impl.notifications

import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.progressSemantics
import androidx.compose.runtime.Composable
Expand All @@ -20,7 +21,8 @@ import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.features.preferences.impl.R
import io.element.android.libraries.androidutils.system.startNotificationSettingsIntent
import io.element.android.libraries.architecture.AsyncData
import io.element.android.libraries.designsystem.atomic.molecules.DialogLikeBannerMolecule
import io.element.android.libraries.designsystem.components.Announcement
import io.element.android.libraries.designsystem.components.AnnouncementType
import io.element.android.libraries.designsystem.components.async.AsyncActionView
import io.element.android.libraries.designsystem.components.dialogs.ErrorDialog
import io.element.android.libraries.designsystem.components.dialogs.ListOption
Expand Down Expand Up @@ -132,7 +134,7 @@ private fun NotificationSettingsContentView(
PreferenceText(
icon = CompoundIcons.VoiceCall(),
title = stringResource(id = R.string.full_screen_intent_banner_title),
subtitle = stringResource(R.string.full_screen_intent_banner_message,),
subtitle = stringResource(R.string.full_screen_intent_banner_message),
onClick = {
state.fullScreenIntentPermissionsState.openFullScreenIntentSettings()
}
Expand Down Expand Up @@ -247,12 +249,17 @@ private fun InvalidNotificationSettingsView(
showError: Boolean,
onContinueClick: () -> Unit,
onDismissError: () -> Unit,
modifier: Modifier = Modifier,
) {
DialogLikeBannerMolecule(
Announcement(
title = stringResource(R.string.screen_notification_settings_configuration_mismatch),
content = stringResource(R.string.screen_notification_settings_configuration_mismatch_description),
onSubmitClick = onContinueClick,
onDismissClick = null,
description = stringResource(R.string.screen_notification_settings_configuration_mismatch_description),
type = AnnouncementType.Actionable(
onActionClick = onContinueClick,
actionText = stringResource(CommonStrings.action_continue),
onDismissClick = null,
),
modifier = modifier.padding(horizontal = 16.dp, vertical = 8.dp),
)

if (showError) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright 2025 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/

package io.element.android.features.roomlist.impl.components

import androidx.compose.foundation.layout.padding
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

/**
* Common padding for RoomList banners.
*/
internal fun Modifier.roomListBannerPadding() = padding(horizontal = 16.dp, vertical = 8.dp)
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,27 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import io.element.android.features.roomlist.impl.R
import io.element.android.libraries.designsystem.atomic.molecules.DialogLikeBannerMolecule
import io.element.android.libraries.designsystem.components.Announcement
import io.element.android.libraries.designsystem.components.AnnouncementType
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import io.element.android.libraries.ui.strings.CommonStrings

@Composable
internal fun ConfirmRecoveryKeyBanner(
onContinueClick: () -> Unit,
onDismissClick: () -> Unit,
modifier: Modifier = Modifier,
) {
DialogLikeBannerMolecule(
modifier = modifier,
Announcement(
modifier = modifier.roomListBannerPadding(),
title = stringResource(R.string.confirm_recovery_key_banner_title),
content = stringResource(R.string.confirm_recovery_key_banner_message),
onSubmitClick = onContinueClick,
onDismissClick = onDismissClick,
description = stringResource(R.string.confirm_recovery_key_banner_message),
type = AnnouncementType.Actionable(
actionText = stringResource(CommonStrings.action_continue),
onActionClick = onContinueClick,
onDismissClick = onDismissClick,
),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,31 @@
package io.element.android.features.roomlist.impl.components

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import io.element.android.features.roomlist.impl.R
import io.element.android.libraries.designsystem.atomic.molecules.DialogLikeBannerMolecule
import io.element.android.libraries.designsystem.components.Announcement
import io.element.android.libraries.designsystem.components.AnnouncementType
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import io.element.android.libraries.fullscreenintent.api.FullScreenIntentPermissionsState
import io.element.android.libraries.fullscreenintent.api.aFullScreenIntentPermissionsState
import io.element.android.libraries.ui.strings.CommonStrings

@Composable
fun FullScreenIntentPermissionBanner(state: FullScreenIntentPermissionsState) {
DialogLikeBannerMolecule(
fun FullScreenIntentPermissionBanner(
state: FullScreenIntentPermissionsState,
modifier: Modifier = Modifier
) {
Announcement(
title = stringResource(R.string.full_screen_intent_banner_title),
content = stringResource(R.string.full_screen_intent_banner_message),
onDismissClick = state.dismissFullScreenIntentBanner,
onSubmitClick = state.openFullScreenIntentSettings,
description = stringResource(R.string.full_screen_intent_banner_message),
type = AnnouncementType.Actionable(
actionText = stringResource(CommonStrings.action_continue),
onDismissClick = state.dismissFullScreenIntentBanner,
onActionClick = state.openFullScreenIntentSettings,
),
modifier = modifier.roomListBannerPadding(),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import io.element.android.features.roomlist.impl.R
import io.element.android.libraries.designsystem.atomic.molecules.DialogLikeBannerMolecule
import io.element.android.libraries.designsystem.components.Announcement
import io.element.android.libraries.designsystem.components.AnnouncementType
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight

Expand All @@ -21,13 +22,15 @@ internal fun NativeSlidingSyncMigrationBanner(
onDismissClick: () -> Unit,
modifier: Modifier = Modifier,
) {
DialogLikeBannerMolecule(
modifier = modifier,
Announcement(
modifier = modifier.roomListBannerPadding(),
title = stringResource(R.string.banner_migrate_to_native_sliding_sync_title),
content = stringResource(R.string.banner_migrate_to_native_sliding_sync_description),
actionText = stringResource(R.string.banner_migrate_to_native_sliding_sync_action),
onSubmitClick = onContinueClick,
onDismissClick = onDismissClick,
description = stringResource(R.string.banner_migrate_to_native_sliding_sync_description),
type = AnnouncementType.Actionable(
actionText = stringResource(R.string.banner_migrate_to_native_sliding_sync_action),
onActionClick = onContinueClick,
onDismissClick = onDismissClick,
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ private fun EmptyView(
SecurityBannerState.SetUpRecovery -> {
SetUpRecoveryKeyBanner(
onContinueClick = onSetUpRecoveryClick,
onDismissClick = { eventSink(RoomListEvents.DismissBanner) }
onDismissClick = { eventSink(RoomListEvents.DismissBanner) },
)
}
SecurityBannerState.RecoveryKeyConfirmation -> {
ConfirmRecoveryKeyBanner(
onContinueClick = onConfirmRecoveryKeyClick,
onDismissClick = { eventSink(RoomListEvents.DismissBanner) }
onDismissClick = { eventSink(RoomListEvents.DismissBanner) },
)
}
else -> Unit
Expand Down Expand Up @@ -217,23 +217,23 @@ private fun RoomsViewList(
item {
SetUpRecoveryKeyBanner(
onContinueClick = onSetUpRecoveryClick,
onDismissClick = { updatedEventSink(RoomListEvents.DismissBanner) }
onDismissClick = { updatedEventSink(RoomListEvents.DismissBanner) },
)
}
}
SecurityBannerState.RecoveryKeyConfirmation -> {
item {
ConfirmRecoveryKeyBanner(
onContinueClick = onConfirmRecoveryKeyClick,
onDismissClick = { updatedEventSink(RoomListEvents.DismissBanner) }
onDismissClick = { updatedEventSink(RoomListEvents.DismissBanner) },
)
}
}
SecurityBannerState.NeedsNativeSlidingSyncMigration -> {
item {
NativeSlidingSyncMigrationBanner(
onContinueClick = onMigrateToNativeSlidingSyncClick,
onDismissClick = { updatedEventSink(RoomListEvents.DismissBanner) }
onDismissClick = { updatedEventSink(RoomListEvents.DismissBanner) },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import io.element.android.features.roomlist.impl.R
import io.element.android.libraries.designsystem.atomic.molecules.DialogLikeBannerMolecule
import io.element.android.libraries.designsystem.components.Announcement
import io.element.android.libraries.designsystem.components.AnnouncementType
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight

Expand All @@ -21,13 +22,15 @@ internal fun SetUpRecoveryKeyBanner(
onDismissClick: () -> Unit,
modifier: Modifier = Modifier,
) {
DialogLikeBannerMolecule(
modifier = modifier,
Announcement(
modifier = modifier.roomListBannerPadding(),
title = stringResource(R.string.banner_set_up_recovery_title),
content = stringResource(R.string.banner_set_up_recovery_content),
actionText = stringResource(R.string.banner_set_up_recovery_submit),
onSubmitClick = onContinueClick,
onDismissClick = onDismissClick,
description = stringResource(R.string.banner_set_up_recovery_content),
type = AnnouncementType.Actionable(
actionText = stringResource(R.string.banner_set_up_recovery_submit),
onActionClick = onContinueClick,
onDismissClick = onDismissClick,
),
)
}

Expand Down

This file was deleted.

Loading

0 comments on commit 46119ae

Please sign in to comment.