Merge pull request #5950 from element-hq/feature/fga/iterate_permissions_screen
Changes : iterate again on permissions
This commit is contained in:
commit
76bc487f28
36 changed files with 243 additions and 151 deletions
|
|
@ -85,7 +85,7 @@ sealed interface ListItemContent {
|
|||
data class Text(val text: String) : ListItemContent
|
||||
|
||||
/** Displays any custom content. */
|
||||
data class Custom(val content: @Composable () -> Unit) : ListItemContent
|
||||
data class Custom(val content: @Composable (enabled: Boolean) -> Unit) : ListItemContent
|
||||
|
||||
/** Displays a badge. */
|
||||
data object Badge : ListItemContent
|
||||
|
|
@ -131,7 +131,7 @@ sealed interface ListItemContent {
|
|||
is Counter -> {
|
||||
CounterAtom(count = count)
|
||||
}
|
||||
is Custom -> content()
|
||||
is Custom -> content(isItemEnabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ fun PreferenceCheckbox(
|
|||
leadingContent = preferenceIcon(
|
||||
icon = icon,
|
||||
iconResourceId = iconResourceId,
|
||||
enabled = enabled,
|
||||
showIconAreaIfNoIcon = showIconAreaIfNoIcon,
|
||||
),
|
||||
headlineContent = {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ import io.element.android.libraries.designsystem.theme.components.DropdownMenuIt
|
|||
import io.element.android.libraries.designsystem.theme.components.Icon
|
||||
import io.element.android.libraries.designsystem.theme.components.ListItem
|
||||
import io.element.android.libraries.designsystem.theme.components.Text
|
||||
import io.element.android.libraries.designsystem.toEnabledColor
|
||||
import io.element.android.libraries.designsystem.toIconSecondaryEnabledColor
|
||||
import io.element.android.libraries.designsystem.toSecondaryEnabledColor
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
|
@ -64,7 +64,6 @@ fun <T : DropdownOption> PreferenceDropdown(
|
|||
leadingContent = preferenceIcon(
|
||||
icon = icon,
|
||||
iconResourceId = iconResourceId,
|
||||
enabled = enabled,
|
||||
showIconAreaIfNoIcon = showIconAreaIfNoIcon,
|
||||
),
|
||||
headlineContent = {
|
||||
|
|
@ -72,7 +71,6 @@ fun <T : DropdownOption> PreferenceDropdown(
|
|||
style = ElementTheme.typography.fontBodyLgRegular,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = title,
|
||||
color = enabled.toEnabledColor(),
|
||||
)
|
||||
},
|
||||
supportingContent = supportingText?.let {
|
||||
|
|
@ -80,22 +78,23 @@ fun <T : DropdownOption> PreferenceDropdown(
|
|||
Text(
|
||||
style = ElementTheme.typography.fontBodyMdRegular,
|
||||
text = it,
|
||||
color = enabled.toSecondaryEnabledColor(),
|
||||
)
|
||||
}
|
||||
},
|
||||
trailingContent = ListItemContent.Custom(
|
||||
content = {
|
||||
content = { enabled ->
|
||||
DropdownTrailingContent(
|
||||
selectedOption = selectedOption,
|
||||
options = options,
|
||||
onSelectOption = onSelectOption,
|
||||
expanded = isDropdownExpanded,
|
||||
onExpandedChange = { isDropdownExpanded = it },
|
||||
enabled = enabled,
|
||||
modifier = Modifier.fillMaxSize(0.3f)
|
||||
)
|
||||
}
|
||||
),
|
||||
enabled = enabled,
|
||||
onClick = { isDropdownExpanded = true }.takeIf { !isDropdownExpanded },
|
||||
)
|
||||
}
|
||||
|
|
@ -118,6 +117,7 @@ private fun <T : DropdownOption> DropdownTrailingContent(
|
|||
expanded: Boolean,
|
||||
onExpandedChange: (Boolean) -> Unit,
|
||||
onSelectOption: (T) -> Unit,
|
||||
enabled: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Row(
|
||||
|
|
@ -129,7 +129,7 @@ private fun <T : DropdownOption> DropdownTrailingContent(
|
|||
text = selectedOption?.getText().orEmpty(),
|
||||
maxLines = 1,
|
||||
style = ElementTheme.typography.fontBodyMdRegular,
|
||||
color = ElementTheme.colors.textSecondary,
|
||||
color = enabled.toSecondaryEnabledColor(),
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
textAlign = TextAlign.End,
|
||||
modifier = Modifier.weight(1f),
|
||||
|
|
@ -137,7 +137,7 @@ private fun <T : DropdownOption> DropdownTrailingContent(
|
|||
Icon(
|
||||
imageVector = CompoundIcons.ChevronDown(),
|
||||
contentDescription = null,
|
||||
tint = ElementTheme.colors.iconSecondary,
|
||||
tint = enabled.toIconSecondaryEnabledColor(),
|
||||
)
|
||||
DropdownMenu(
|
||||
expanded = expanded,
|
||||
|
|
@ -146,6 +146,7 @@ private fun <T : DropdownOption> DropdownTrailingContent(
|
|||
) {
|
||||
options.forEach { option ->
|
||||
DropdownMenuItem(
|
||||
enabled = enabled,
|
||||
text = {
|
||||
Text(
|
||||
text = option.getText(),
|
||||
|
|
@ -206,5 +207,14 @@ internal fun PreferenceDropdownPreview() = ElementThemedPreview {
|
|||
options = options,
|
||||
onSelectOption = {},
|
||||
)
|
||||
PreferenceDropdown(
|
||||
title = "Dropdown",
|
||||
supportingText = "Options for dropdown",
|
||||
icon = CompoundIcons.Threads(),
|
||||
selectedOption = options.first(),
|
||||
options = options,
|
||||
onSelectOption = {},
|
||||
enabled = false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ fun PreferenceSlide(
|
|||
leadingContent = preferenceIcon(
|
||||
icon = icon,
|
||||
iconResourceId = iconResourceId,
|
||||
enabled = enabled,
|
||||
showIconAreaIfNoIcon = showIconAreaIfNoIcon,
|
||||
),
|
||||
headlineContent = {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ fun PreferenceSwitch(
|
|||
leadingContent = preferenceIcon(
|
||||
icon = icon,
|
||||
iconResourceId = iconResourceId,
|
||||
enabled = enabled,
|
||||
showIconAreaIfNoIcon = showIconAreaIfNoIcon,
|
||||
),
|
||||
headlineContent = {
|
||||
|
|
|
|||
|
|
@ -34,11 +34,10 @@ fun preferenceIcon(
|
|||
@DrawableRes iconResourceId: Int? = null,
|
||||
showIconBadge: Boolean = false,
|
||||
tintColor: Color? = null,
|
||||
enabled: Boolean = true,
|
||||
showIconAreaIfNoIcon: Boolean = false,
|
||||
): ListItemContent.Custom? {
|
||||
return if (icon != null || iconResourceId != null || showIconAreaIfNoIcon) {
|
||||
ListItemContent.Custom {
|
||||
ListItemContent.Custom { enabled ->
|
||||
PreferenceIcon(
|
||||
icon = icon,
|
||||
iconResourceId = iconResourceId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue