Skip to content

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

Merged
merged 12 commits into from
May 27, 2024
Merged

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented May 27, 2024

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

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

  • Navigate to the various preference screen and check that there is no issues.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@bmarty bmarty added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label May 27, 2024
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label May 27, 2024
Copy link
Contributor

github-actions bot commented May 27, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/JLWBdw

Let PreferenceCheckbox use ListItem and add missing previews.
Let PreferenceCategory use ListSectionHeader
Let PreferenceSlide use ListItem
Let PreferenceRow use ListItem
Let PreferenceText use ListItem
@bmarty bmarty force-pushed the feature/bma/iterateOnPreferenceDesign2 branch from 9f07601 to 34f7819 Compare May 27, 2024 10:19
@bmarty bmarty added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label May 27, 2024
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label May 27, 2024
ElementBot and others added 2 commits May 27, 2024 10:29
Also improve height of View to let the test see the View.
Copy link

codecov bot commented May 27, 2024

Codecov Report

Attention: Patch coverage is 78.68852% with 26 lines in your changes are missing coverage. Please review.

Project coverage is 75.15%. Comparing base (8f6190e) to head (414e2bb).
Report is 33 commits behind head on develop.

Files Patch % Lines
...omponents/preferences/components/PreferenceIcon.kt 55.55% 5 Missing and 3 partials ⚠️
...ignsystem/components/preferences/PreferenceText.kt 88.57% 0 Missing and 4 partials ⚠️
...references/impl/developer/DeveloperSettingsView.kt 57.14% 0 Missing and 3 partials ⚠️
...droid/features/roomdetails/impl/RoomDetailsView.kt 60.00% 0 Missing and 2 partials ⚠️
...signsystem/components/preferences/PreferenceRow.kt 71.42% 0 Missing and 2 partials ⚠️
...gnsystem/components/preferences/PreferenceSlide.kt 89.47% 0 Missing and 2 partials ⚠️
...lockscreen/impl/settings/LockScreenSettingsView.kt 0.00% 0 Missing and 1 partial ⚠️
...ystem/components/preferences/PreferenceCategory.kt 83.33% 0 Missing and 1 partial ⚠️
...ystem/components/preferences/PreferenceCheckbox.kt 88.88% 0 Missing and 1 partial ⚠️
...system/components/preferences/PreferenceDivider.kt 0.00% 0 Missing and 1 partial ⚠️
... and 1 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2922      +/-   ##
===========================================
- Coverage    75.23%   75.15%   -0.09%     
===========================================
  Files         1550     1549       -1     
  Lines        36954    36927      -27     
  Branches      7152     7170      +18     
===========================================
- Hits         27803    27752      -51     
- Misses        5415     5421       +6     
- Partials      3736     3754      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 27, 2024
@bmarty bmarty marked this pull request as ready for review May 27, 2024 12:38
@bmarty bmarty requested a review from a team as a code owner May 27, 2024 12:38
@bmarty bmarty requested review from jmartinesp and removed request for a team May 27, 2024 12:38
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 27, 2024
Copy link
Member

@jmartinesp jmartinesp left a 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),) {
Copy link
Member

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,
Copy link
Member

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 = {
Copy link
Member

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.

Copy link
Member Author

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 = {
Copy link
Member

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 {
Copy link
Member

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 {
Copy link
Member

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.

Copy link
Member Author

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.

@jmartinesp
Copy link
Member

I'm also quite confused about the coverage drop, the amount of covered lines should be pretty much the same 🫤 .

@bmarty bmarty added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label May 27, 2024
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label May 27, 2024
@bmarty
Copy link
Member Author

bmarty commented May 27, 2024

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...

@bmarty
Copy link
Member Author

bmarty commented May 27, 2024

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.

Having Preference* Composable helps to have compact code, but yes, maybe one day we could get ride of them, and directly use ListItem. I consider those changes as a step to this direction.

Copy link
Member

@jmartinesp jmartinesp left a 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!

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 27, 2024
@bmarty bmarty enabled auto-merge May 27, 2024 22:15
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 27, 2024
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@bmarty bmarty merged commit d0b2233 into develop May 27, 2024
24 of 25 checks passed
@bmarty bmarty deleted the feature/bma/iterateOnPreferenceDesign2 branch May 27, 2024 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants