-
Notifications
You must be signed in to change notification settings - Fork 238
Iterate on preference design #2922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
Let PreferenceCheckbox use ListItem and add missing previews. Let PreferenceCategory use ListSectionHeader Let PreferenceSlide use ListItem Let PreferenceRow use ListItem Let PreferenceText use ListItem
9f07601
to
34f7819
Compare
Also improve height of View to let the test see the View.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work on this. To be honest I was going in the opposite direction, slowly replacing Preference*
components with plain ListItem
ones since that's what Compound gives us, so maybe we should first discuss which approach to take.
I'm not opposed to having EXA only wrappers but maybe they're not really needed in some cases, I'm not sure if this is one of them.
Besides that, I found a few things that could be improved since I think they'll affect paddings and internal margins.
@@ -83,7 +86,7 @@ fun EditDefaultNotificationSettingView( | |||
} | |||
} | |||
if (state.roomsWithUserDefinedMode.isNotEmpty()) { | |||
PreferenceCategory(title = stringResource(id = R.string.screen_notification_settings_edit_custom_settings_section_title)) { | |||
PreferenceCategory(title = stringResource(id = R.string.screen_notification_settings_edit_custom_settings_section_title),) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: unneeded comma here.
|
||
@Composable | ||
fun PreferenceCategory( | ||
modifier: Modifier = Modifier, | ||
title: String? = null, | ||
showDivider: Boolean = true, | ||
showTopDivider: Boolean = true, | ||
showBottomDivider: Boolean = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
showBottomDivider
is never true, should we remove it? The ListSectionHeader
component was built to always use only the top one ( which I admit is a bit awkward) so it shouldn't be needed.
) | ||
}, | ||
supportingContent = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be supportingContent = subtitle?.let { ... }
, I think otherwise the preference will add some spacing that's not really needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, having an empty Composable does not seems to have an impact, but let's do what you're suggesting to be sure.
Text( | ||
style = ElementTheme.typography.fontBodyLgRegular, | ||
text = title, | ||
color = tintColor ?: enabled.toEnabledColor(), | ||
) | ||
}, | ||
supportingContent = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here about the spacing, maybe inline the if
here and add composable blocks to each branch, and null
for the else
.
} | ||
} | ||
}, | ||
trailingContent = ListItemContent.Custom { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same about nullability here. If there's nothing to display it should be null
, not an empty row.
showIconAreaIfNoIcon: Boolean = false, | ||
): ListItemContent.Custom? { | ||
return if (icon != null || iconResourceId != null || showIconAreaIfNoIcon) { | ||
ListItemContent.Custom { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't wrong, but maybe it'd be better to use the exiting ListItemContent.Icon
when possible, maybe adding the badge option if needed, or a nullable version for the empty space. I'm not sure though, since that may complicate its usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there is room for improvement. "adding the badge option if needed" to ListItemContent.Icon
should be my choice but I prefer to work on this later.
I'm also quite confused about the coverage drop, the amount of covered lines should be pretty much the same 🫤 . |
Yes, let's ignore this for now... |
Having |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes, LGTM!
|
Type of change
Content
Let Preference Composable use ListItem under the hood.
Motivation and context
Let the application globally follow the design.
(And preparatory work for #2912)
Screenshots / GIFs
See recorded once.
Tests
Tested devices
Checklist