@ -17,6 +17,7 @@
@@ -17,6 +17,7 @@
package io.element.android.features.preferences.impl.root
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
@ -81,92 +82,152 @@ fun PreferencesRootView(
@@ -81,92 +82,152 @@ fun PreferencesRootView(
} ,
user = state . myUser ,
)
if ( state . showSecureBackup ) {
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . common _chat _backup ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . KeySolid ( ) ) ) ,
trailingContent = ListItemContent . Badge . takeIf { state . showSecureBackupBadge } ,
onClick = onSecureBackupClicked ,
)
HorizontalDivider ( )
}
if ( state . accountManagementUrl != null ) {
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . action _manage _account ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . UserProfile ( ) ) ) ,
trailingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . PopOut ( ) ) ) ,
onClick = { onManageAccountClicked ( state . accountManagementUrl ) } ,
)
HorizontalDivider ( )
}
if ( state . showAnalyticsSettings ) {
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . common _analytics ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Chart ( ) ) ) ,
onClick = onOpenAnalytics ,
)
}
if ( state . showNotificationSettings ) {
ListItem (
headlineContent = { Text ( stringResource ( id = R . string . screen _notification _settings _title ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Notifications ( ) ) ) ,
onClick = onOpenNotificationSettings ,
)
}
if ( state . showBlockedUsersItem ) {
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . common _blocked _users ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Block ( ) ) ) ,
onClick = onOpenBlockedUsers ,
)
}
// 'Manage my app' section
ManageAppSection (
state = state ,
onOpenNotificationSettings = onOpenNotificationSettings ,
onOpenLockScreenSettings = onOpenLockScreenSettings ,
onSecureBackupClicked = onSecureBackupClicked ,
)
// 'Account' section
ManageAccountSection (
state = state ,
onManageAccountClicked = onManageAccountClicked ,
onOpenBlockedUsers = onOpenBlockedUsers
)
// General section
GeneralSection (
state = state ,
onOpenAbout = onOpenAbout ,
onOpenAnalytics = onOpenAnalytics ,
onOpenRageShake = onOpenRageShake ,
onOpenAdvancedSettings = onOpenAdvancedSettings ,
onOpenDeveloperSettings = onOpenDeveloperSettings ,
onSignOutClicked = onSignOutClicked ,
)
Footer (
version = state . version ,
deviceId = state . deviceId ,
)
}
}
@Composable
private fun ColumnScope . ManageAppSection (
state : PreferencesRootState ,
onOpenNotificationSettings : ( ) -> Unit ,
onOpenLockScreenSettings : ( ) -> Unit ,
onSecureBackupClicked : ( ) -> Unit ,
) {
if ( state . showNotificationSettings ) {
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . common _report _a _problem ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . ChatProblem ( ) ) ) ,
onClick = onOpenRageShake
headlineContent = { Text ( stringResource ( id = R . string . screen _notification _settings _title ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Notifications ( ) ) ) ,
onClick = onOpenNotificationSettings ,
)
}
if ( state . showLockScreenSettings ) {
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . common _about ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Info ( ) ) ) ,
onClick = onOpenAbout ,
headlineContent = { Text ( stringResource ( id = CommonStrings . common _screen _lock ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Lock ( ) ) ) ,
onClick = onOpenLockScreenSettings ,
)
if ( state . showLockScreenSettings ) {
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . common _screen _lock ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Lock ( ) ) ) ,
onClick = onOpenLockScreenSettings ,
)
}
HorizontalDivider ( )
if ( state . devicesManagementUrl != null ) {
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . action _manage _devices ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Devices ( ) ) ) ,
trailingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . PopOut ( ) ) ) ,
onClick = { onManageAccountClicked ( state . devicesManagementUrl ) } ,
)
HorizontalDivider ( )
}
}
if ( state . showSecureBackup ) {
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . common _advanced _settings ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Settings ( ) ) ) ,
onClick = onOpenAdvancedSettings ,
headlineContent = { Text ( stringResource ( id = CommonStrings . common _chat _backup ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . KeySolid ( ) ) ) ,
trailingContent = ListItemContent . Badge . takeIf { state . showSecureBackupBadge } ,
onClick = onSecureBackupClicked ,
)
if ( state . showDeveloperSettings ) {
DeveloperPreferencesView ( onOpenDeveloperSettings )
}
}
if ( state . showNotificationSettings || state . showLockScreenSettings || state . showSecureBackup ) {
HorizontalDivider ( )
}
}
@Composable
private fun ColumnScope . ManageAccountSection (
state : PreferencesRootState ,
onManageAccountClicked : ( url : String ) -> Unit ,
onOpenBlockedUsers : ( ) -> Unit ,
) {
state . accountManagementUrl ?. let { url ->
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . action _signout ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . SignOut ( ) ) ) ,
style = ListItemStyle . Destructive ,
onClick = onSignOutClicked ,
headlineContent = { Text ( stringResource ( id = CommonStrings . action _manage _accoun t ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . UserProfile ( ) ) ) ,
trailingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . PopOut ( ) ) ) ,
onClick = { onManageAccountClicked ( url ) } ,
)
Footer (
version = state . version ,
deviceId = state . deviceId ,
}
state . devicesManagementUrl ?. let { url ->
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . action _manage _devices ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Devices ( ) ) ) ,
trailingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . PopOut ( ) ) ) ,
onClick = { onManageAccountClicked ( url ) } ,
)
}
if ( state . showBlockedUsersItem ) {
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . common _blocked _users ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Block ( ) ) ) ,
onClick = onOpenBlockedUsers ,
)
}
if ( state . accountManagementUrl != null || state . devicesManagementUrl != null || state . showBlockedUsersItem ) {
HorizontalDivider ( )
}
}
@Composable
private fun ColumnScope . GeneralSection (
state : PreferencesRootState ,
onOpenAbout : ( ) -> Unit ,
onOpenAnalytics : ( ) -> Unit ,
onOpenRageShake : ( ) -> Unit ,
onOpenAdvancedSettings : ( ) -> Unit ,
onOpenDeveloperSettings : ( ) -> Unit ,
onSignOutClicked : ( ) -> Unit ,
) {
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . common _about ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Info ( ) ) ) ,
onClick = onOpenAbout ,
)
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . common _report _a _problem ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . ChatProblem ( ) ) ) ,
onClick = onOpenRageShake
)
if ( state . showAnalyticsSettings ) {
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . common _analytics ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Chart ( ) ) ) ,
onClick = onOpenAnalytics ,
)
}
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . common _advanced _settings ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Settings ( ) ) ) ,
onClick = onOpenAdvancedSettings ,
)
if ( state . showDeveloperSettings ) {
DeveloperPreferencesView ( onOpenDeveloperSettings )
}
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . action _signout ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . SignOut ( ) ) ) ,
style = ListItemStyle . Destructive ,
onClick = onSignOutClicked ,
)
}
@Composable
@ -186,7 +247,7 @@ private fun Footer(
@@ -186,7 +247,7 @@ private fun Footer(
Text (
modifier = Modifier
. fillMaxWidth ( )
. padding ( top = 40. dp , bottom = 24. dp ) ,
. padding ( start = 16. dp , end = 16. dp , top = 40. dp , bottom = 24. dp ) ,
textAlign = TextAlign . Center ,
text = text ,
style = ElementTheme . typography . fontBodySmRegular ,