Skip to content
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

Implement Material 3 "pill" component #5765

Merged
merged 13 commits into from
Oct 18, 2023
Merged

Conversation

seadowg
Copy link
Member

@seadowg seadowg commented Oct 4, 2023

Blocked by #5760

The "pill" component appears to exist in several places in Material 3's own spec (this table for instance), but doesn't seem to have been explicitly called out or implemented. It also appears in Google Maps.

This PR provides an implementation of the component that should adapt appropriately to shape, typography and color theming.

What has been done to verify that this works as intended?

Verified manually.

Why is this the best possible solution? Were any other approaches considered?

For code reviewers: the shape theming was the most complex here and involved some reverse engineering of the implementation of several Material components. In short, I ended up building a ShapeAppearanceModel with the theme's shapeAppearanceCornerSmall attribute and then used that to create a MaterialShapeDrawable that I could change the color on and set as the component's background. I'm not 100% sure this is correct™️, so it'd be worth doing some quick research to see if you agree with me. There are some docs on this (here), but they seemed to be more aimed at customising the shapes at a theme level and I didn't personally get much from them.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

This is just a visual change to the "complete" and "incomplete" pill on drafts, so verifying that they look correct is all that's needed really.

Before submitting this PR, please make sure you have:

  • run ./gradlew checkAll and confirmed all checks still pass OR confirm CircleCI build passes and run ./gradlew connectedDebugAndroidTest locally.
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

@seadowg seadowg changed the base branch from master to v2023.3.x October 4, 2023 16:50
@alyblenkin
Copy link
Collaborator

image

@seadowg - looking good! I think the spacing is working well - it doesn't feel too squished. I think it will be easier to scan when we remove the form icon, but that can come later.

A few design tweaks:

"Complete" pill

  • Let's use the light blue. In figma, I'm using the same blue as the banner because it’s still a neutral colour.
  • And try using the simple check icon
  • Use our black text instead of white

"Incomplete" Pill

  • We should use a light grey. We don't want it to be alarming if they have a list of red incomplete forms.
  • I'm using the M3 Neutral 90 (#E6E1E5), but if we have another similar grey already, we could use that.
  • Rule icon
  • Use our black text instead of white

@seadowg
Copy link
Member Author

seadowg commented Oct 5, 2023

@alyblenkin this is good for another look! The colors had to be hacked in as this release isn't using Material 3 yet so I we should revise this again when we merge into v2023.4.

@alyblenkin
Copy link
Collaborator

Looks great! The blue I'm using in figma must be darker because the grey pill really stands out here. Let's make the grey lighter so the contrast isn't so stark between the two. Could we try #ECECEC or the grey we use for the main menu buttons?

@seadowg
Copy link
Member Author

seadowg commented Oct 6, 2023

@alyblenkin I don't why I didn't just use that color to begin with actually! I've updated it.

@seadowg seadowg changed the title Implemenet Material 3 "pill" component Implement Material 3 "pill" component Oct 6, 2023
@seadowg seadowg added the blocked label Oct 6, 2023
@seadowg seadowg removed the blocked label Oct 9, 2023
@seadowg seadowg marked this pull request as ready for review October 9, 2023 19:13
material/src/main/res/layout/pill.xml Outdated Show resolved Hide resolved
collect_app/src/main/res/drawable/baseline_check_24.xml Outdated Show resolved Hide resolved
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the tint color is black it doesn't make sense to use white here right it's confusing. It should be black in both places.

Copy link
Member Author

@seadowg seadowg Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually something I realise I'm really unclear on. Given we might have an icon appear in multiple places where it needs different tints, should we have multiple vector assets with different tints or just have one that's a default black (or probably ?colorOnSurface)? It seems from this and the other comments you'd lean towards the former?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if it's used in only one place like here we can directly set the only color that's used in the XML file and don't think about it but generally yeah I think the first option is what I prefer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I think I always need to set it programmatically anyway as otherwise I can't have a default tint in pill.xml as it'll always override the one in the drawable. For now, I'll keep the setIconTint calls and make the icons use ?colorOnSurface as their default (which makes more sense than hardcoding black I think). Let me know if that doesn't sound right to you!

collect_app/src/main/res/drawable/baseline_rule_24.xml Outdated Show resolved Hide resolved
collect_app/src/main/res/drawable/baseline_rule_24.xml Outdated Show resolved Hide resolved
collect_app/src/main/res/drawable/baseline_check_24.xml Outdated Show resolved Hide resolved
@dbemke
Copy link

dbemke commented Oct 18, 2023

I started testing and there was a crash after tapping "Finalize all forms" in a form with pull data. Is PR #5775 included in CircleCi apk?

@seadowg
Copy link
Member Author

seadowg commented Oct 18, 2023

@dbemke I've rebased so the latest changes from v2023.3.x are included

@dbemke
Copy link

dbemke commented Oct 18, 2023

It seems that something changed in the dark mode. In the end screen "You will not be able to make edits..." has the light mode background although in the app the dark mode. I checked if it's connected with opposite modes device vs app but this doesn't seem to be the case (device dark mode, app dark mode- the issue occurs). I also checked the store version and I wasn't able to reproduce it there.
Steps to reproduce:

  1. In Settings set dark theme of the app.
  2. Open any form and go to the end screen.
    endscreenDarkmode
    It also occurs in the banner about editing finalized forms.
    banner

@seadowg
Copy link
Member Author

seadowg commented Oct 18, 2023

@dbemke that's fixed!

@dbemke
Copy link

dbemke commented Oct 18, 2023

In the form map geopoints saved as drafts are points not pins. Finalized and sent geopoints are pins as expected. I haven't checked Google maps and Mapbox because of the CircleCi apk. The issue doesn't occur in the store version.
formmap

@seadowg
Copy link
Member Author

seadowg commented Oct 18, 2023

@dbemke does it occur on v2023.3.x? I haven't touched any maps code here.

@dbemke
Copy link

dbemke commented Oct 18, 2023

I checked 2023.3.x 07d4688 and it occurs there too. So I'll file a separate issue.

@dbemke
Copy link

dbemke commented Oct 18, 2023

Tested with Success!

Verified on device with Android 10

Verified cases:

  • the new pill in Drafts
  • "Finalize all forms” for different forms
  • filtering drafts
  • dark and light mode
  • quick checks in the app and widgets

@srujner
Copy link

srujner commented Oct 18, 2023

Tested with Success!

Verified on device with Android 13

@grzesiek2010 grzesiek2010 merged commit 93e14fc into getodk:v2023.3.x Oct 18, 2023
6 checks passed
@seadowg seadowg deleted the pill branch October 18, 2023 13:52
seadowg pushed a commit to seadowg/collect that referenced this pull request Oct 24, 2023
Implement Material 3 "pill" component
seadowg pushed a commit to seadowg/collect that referenced this pull request Oct 30, 2023
Implement Material 3 "pill" component
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants