@ -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,6 +82,61 @@ fun PreferencesRootView(
@@ -81,6 +82,61 @@ fun PreferencesRootView(
} ,
user = state . myUser ,
)
// '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 = 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 _screen _lock ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Lock ( ) ) ) ,
onClick = onOpenLockScreenSettings ,
)
}
if ( state . showSecureBackup ) {
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . common _chat _backup ) ) } ,
@ -88,31 +144,36 @@ fun PreferencesRootView(
@@ -88,31 +144,36 @@ fun PreferencesRootView(
trailingContent = ListItemContent . Badge . takeIf { state . showSecureBackupBadge } ,
onClick = onSecureBackupClicked ,
)
}
if ( state . showNotificationSettings || state . showLockScreenSettings || state . showSecureBackup ) {
HorizontalDivider ( )
}
if ( state . accountManagementUrl != null ) {
}
@Composable
private fun ColumnScope . ManageAccountSection (
state : PreferencesRootState ,
onManageAccountClicked : ( url : String ) -> Unit ,
onOpenBlockedUsers : ( ) -> Unit ,
) {
state . accountManagementUrl ?. let { url ->
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 ,
onClick = { onManageAccountClicked ( url ) } ,
)
}
if ( state . showNotificationSettings ) {
state . devicesManagementUrl ?. let { url ->
ListItem (
headlineContent = { Text ( stringResource ( id = R . string . screen _notification _settings _title ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Notifications ( ) ) ) ,
onClick = onOpenNotificationSettings ,
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 ) ) } ,
@ -120,32 +181,38 @@ fun PreferencesRootView(
@@ -120,32 +181,38 @@ fun PreferencesRootView(
onClick = onOpenBlockedUsers ,
)
}
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . common _report _a _problem ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . ChatProblem ( ) ) ) ,
onClick = onOpenRageShake
)
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 ,
)
if ( state . showLockScreenSettings ) {
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . common _screen _lock ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Lock ( ) ) ) ,
onClick = onOpenLockScreenSettings ,
headlineContent = { Text ( stringResource ( id = CommonStrings . common _report _a _problem ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . ChatProblem ( ) ) ) ,
onClick = onOpenRageShake
)
}
HorizontalDivider ( )
if ( state . devicesManagementUrl != null ) {
if ( state . showAnalyticsSettings ) {
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 ) } ,
headlineContent = { Text ( stringResource ( id = CommonStrings . common _analytics ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . Chart ( ) ) ) ,
onClick = onOpenAnalytics ,
)
HorizontalDivider ( )
}
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . common _advanced _settings ) ) } ,
@ -155,18 +222,12 @@ fun PreferencesRootView(
@@ -155,18 +222,12 @@ fun PreferencesRootView(
if ( state . showDeveloperSettings ) {
DeveloperPreferencesView ( onOpenDeveloperSettings )
}
HorizontalDivider ( )
ListItem (
headlineContent = { Text ( stringResource ( id = CommonStrings . action _signout ) ) } ,
leadingContent = ListItemContent . Icon ( IconSource . Vector ( CompoundIcons . SignOut ( ) ) ) ,
style = ListItemStyle . Destructive ,
onClick = onSignOutClicked ,
)
Footer (
version = state . version ,
deviceId = state . deviceId ,
)
}
}
@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 ,