ComposePreference icon indicating copy to clipboard operation
ComposePreference copied to clipboard

Suggestion: Create switch bar preference

Open WSTxda opened this issue 1 year ago • 3 comments

Just like in settingslib / AOSP settings and other apps, the switch bar is used as a master control for a list of preferences.

This is useful when you need to determine a high priority preference in list, on which the others depend on it.

I think it could be an interesting addition.

Screenshot_2024-09-11-02-56-36-031_app.revanced.android.gms.jpg

Screenshot_2024-09-11-02-56-41-065_app.revanced.android.gms.jpg

WSTxda avatar Sep 11 '24 06:09 WSTxda

I did consider this one, the major issue I saw was that there's no good UX spec for the font, color and spacing etc so I didn't add it.

zhanghai avatar Sep 12 '24 02:09 zhanghai

I did consider this one, the major issue I saw was that there's no good UX spec for the font, color and spacing etc so I didn't add it.

Are you referring to attributes? I don't know how it is in compose, but a cardview or drawable shape can be used for this with primaryContainer in background color. For text can be usel use textAppearanceTitleLarge with 20sp for text size. For the paddings need to adjust according to the background for visual harmony.

Screenshot_2024-09-12-01-37-35-764_app.revanced.android.gms-edit.jpg

Noting that there must be a limit on the margin that visually respects the corners of the background.

WSTxda avatar Sep 12 '24 04:09 WSTxda

It's not as simple as that, because this has a lot of custom design tokens that aren't shared with other preferences so if we add it we'll have to expose all those as separate entries in PreferenceTheme as well. For instance the title font and the rounded corner size, and the different paddings. You may look at https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchPreference.java to implement one for yourself without supporting theming though, and that will be much simpler.

zhanghai avatar Sep 17 '24 00:09 zhanghai