[TIMOB-27859] Android: Add "badge" support to TabGroup
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-11-25T15:11:23.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.3.0 |
Components | Android |
Labels | TabGroup, android, badge, parity, tab |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2020-04-21T17:29:12.000+0000 |
Updated | 2020-11-25T15:11:23.000+0000 |
Description
*Summary:*
We currently only support displaying badges in
TabGroup
tabs on iOS. We should add support to Android for parity.
https://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Tab-property-badge
https://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Tab-property-badgeColor
*To-Do:*
For the top tab style, we can use the "material" TabLayout.Tab
class' getOrCreateBadge()
and removeBadge()
APIs.
https://developer.android.com/reference/com/google/android/material/tabs/TabLayout.Tab
For the bottom tab style, we can use the "material" BottomNavigationView
class' getOrCreateBadge()
and removeBadge()
APIs.
https://developer.android.com/reference/com/google/android/material/bottomnavigation/BottomNavigationView
Both of the above tab classes use the "material" BadgeDrawable
class which provides APIs such as setNumber()
, setBackgroundColor()
, etc.
https://developer.android.com/reference/com/google/android/material/badge/BadgeDrawable
[~michael], will the badges not render correctly without the material theme? Is it a layout issue? Color issue? _*Side Note:*_ _Switching Titanium to use the material theme by default seemed like a breaking-change. So, we've punted on it for the moment. We'll probably look into it again for Titanium 10.0.0._
the app will crash with:
I've added the missing
badgeColor
Hmm... perhaps a good interim solution is to change Titanium's default theme from...
Theme.AppCompat
...to Google's material "bridge" themes... https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md#bridge-themes-bridge-themes https://material.io/develop/android/docs/getting-started/#bridge-themes I'll have to experiment with this on my end.[~michael], I'm working on switching Titanium's default theme from
"Theme.AppCompat"
to"Theme.MaterialComponents.Bridge"
for 9.3.0 now. Google's Bridge theme derives from AppCompat and so far looks to be completely backward compatible... and it preserves the current color scheme which avoids breaking-changes. It's looking pretty positive so far. The only problem is app developers can replace the default app theme with their own. Most people usually make their own custom theme which derives from"Theme.AppCompat"
, which will cause a crash with any AndroidX widget that requires the material theme. Not sure what we can do other than to let it crash and tell people to change the parent theme.FR Passed, Waiting on Jenkins build.
*Closing ticket*. Improvement verified in SDK version
9.3.0.v20201125050632
. Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/11659