4 Commits

Author SHA1 Message Date
Jeff Verkoeyen
e49a786767 [Badges] Rewrite badge appearance using Appearance objects.
This change consists of two related portions:

1. Extraction of badge and dot badge appearance-related APIs into corresponding Appearance objects and updating the MDC examples to reflect this new API format.
2. Updated bottom navigation to make use of the new appearance APIs.

Also added an example of using the appearance's "system tint" default behavior for nil, which is aligned with how UIKit handles similar APIs.

PiperOrigin-RevId: 417902876
2021-12-22 16:15:08 -08:00
Jeff Verkoeyen
583bfe143b [Badges] Add support for dot badges.
This was added as a separate API in order to avoid a duality of behavior in MDCBadgeView, and to provide a more explicit API that governs the behavior of dot badges, which are label-less.

PiperOrigin-RevId: 416367867
2021-12-14 12:35:33 -08:00
Jeff Verkoeyen
fae0808b93 [Badges] Add support for borders.
Borders are expected to be drawn outside the badge, but CALayer's border behavior drawers the borders inside of the view. Additionally, the border color is a CGColorRef meaning it won't react automatically to trait collection changes.

This change introduces two new APIs to support outer borders:

1. borderWidth
2. borderColor

`borderWidth` is a proxy for `self.layer.borderWidth`; the only difference between setting `self.borderWidth` and `self.layer.borderWidth` is that `self.borderWidth`'s setter will invalidate the layout and intrinsic content size. This is documented accordingly in API docs.

`borderColor` is a `UIColor`, which is stored adjacent to `self.layer.borderColor`. `self.layer.borderColor` can still technically be set directly, but the value will be reset to whatever `self.borderColor` is any time the trait collection changes.

PiperOrigin-RevId: 416155619
2021-12-13 16:00:54 -08:00
Jeff Verkoeyen
1cb5b29360 Badges] Extract BottomNavigation's badge out to its own component.
This is a verbatim copy. The only thing that has changed is the class name.

Also added a typical use basic example, which required implementing intrinsicContentSize.

PiperOrigin-RevId: 416131346
2021-12-13 14:14:49 -08:00