10 Commits

Author SHA1 Message Date
Frank Wang
ae3d2df04b [MDCBottomNavigationBar] Add checks for nil when a new appearance is set and provide defaults. Based on failures observed in testing when removing deprecated badge properties, these values are nil by neglect and not nil by intent. Hence we will provide default values for badge appearance properties when they are nil and set on the nav bar.
PiperOrigin-RevId: 719333484
2025-01-24 09:35:22 -08:00
Frank Wang
c4743a1951 [Badges] Remove the const keyword from size that fits dot badge calculation.
PiperOrigin-RevId: 694127922
2024-11-07 08:29:30 -08:00
Frank Wang
8eb898db4d [MDCBadge] Allow MDCBadgeView to take on a dot badge style.
PiperOrigin-RevId: 692247823
2024-11-01 11:54:28 -07:00
Nobody
b09e2076ad objc_direct symbols have hidden visibility. This prevents them from being usable across framework boundaries, which breaks common usage patterns.
PiperOrigin-RevId: 480998683
2022-10-13 15:32:07 -07:00
Wenyu Zhang
a127cc06cd [Badge] Remove boldFont property from MDCBadgeAppearance for simplicity.
PiperOrigin-RevId: 468827878
2022-08-19 18:55:08 -07:00
Jeff Verkoeyen
14f315acf0 [BottomNavigation] Replace null_resettable with nonnull.
null_resettable is imported to Swift as an optional type, which requires awkward nil checks when working with the appearance properties, even though the return value is guaranteed to be non-nil.

Instead, appearance properties are now all specified as nonnull. This allows Swift source to use the appearance APIs in a much simpler fashion.

To achieve the same "null_resettable" behavior as before, simply assign an empty instance of an appearance object.

PiperOrigin-RevId: 418678212
2021-12-28 14:23:01 -08:00
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