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
[TIMOB-26354] Android: Refactor TabGroup and introduce new style #10358
Conversation
…s UI and replacing it with TabLayout. Introducing a new style.
Yey! Will try it out asap. |
Cool. I like where this is heading. 😄 I'm curious about the ripple effect you are adding. Does it work like the Google Play tabs? Where tapping a tab changes the background color of the whole tab bar with that circle scaling effect? Oh and the |
Remove the Lifecycle Interface implementation from TiUIAbstractTabGroup. Fix removing of Tabs before AND after opening the TabGroup. Add titleColor and activeTitleColor properties of Tab parity for Android. Add support for disabling shiftMode for BottomNavigationView (not yet exposed in the JS). Prevent double selection of items in the TabGroup controller.
Yes, ActionBar tabs had the ripple effect by default and since I am messing with the background drawables to support different colors for selected/unselected states I needed to add it manually.
|
Fix the smoothScrollOnTabClick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This yml update looks good to me.
Clean up listener for tab changes. Fix focus/blur and select/unselect events for TabGroup and Tabs.
Optimize the handling of tabs swiping. Fix disabling of tab navigation. Format code.
Guard agains API level. Guard for closing the group before drawing it. Cleanup a bit of code and imports. Lint unit tests and format code. Add docs.
Generated by 🚫 dangerJS |
Quick note: You could add even more parity by exposing the bottomNavigation.setNotification(notification, bottomNavigation.getItemsCount() - 1); |
@ypbnv , I see that |
@jquick-axway I did some testing and it seems that prior to the refactoring the image was still passed as a drawable with its raw dimensions. Here a two screenshots for the same project with the same resources. I have intentionally used images with different dimensions - one is 30x30 and other 60x60 pixels: I also thought that they were scaled according to the device, but I suppose the difference was more noticeable due to the new layout. That opens the question if we still want to scale them in the refactored code? |
@ypbnv, I'm sorry man. You are exactly right. The old tab group handling did not scale the tab icons. My bad. |
@lokeshchdhry, this PR is ready for you. |
Passing final FR (first was done earlier before CR) as all CR comments seems to be looked at & appropriate changes made. Studio Ver: 5.1.2.201810301430 |
hi, how to change icon color? |
@juliengatt , Titanium does not support tinting the tab icons on Android. So, the icon PNG you assign to the tab is displayed as-is. |
We could use <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_checked="true"
android:color="@color/colorPrimary" />
<item
android:state_checked="false"
android:color="@color/grey" />
</selector> Should be possible via XML. |
Yes, it is possible to do it natively on Android, but Titanium does not currently support it. |
But shouldn't it be possible with global styling. In any case, it's one of the last tabgroup parity issues effecting devs in real life use cases |
On Android, you would normally do this via a drawable in XML. In that drawable's XML, you can define the different states. I think our internal code will load a drawable as-is in this case (not assume it's a BitmapDrawable) when loading from a |
If already possible, an example would be greatly appreciated! |
You would need to create a "selector" in XML kind of like what is shown in the link below. This XML file would go under your project's And then you would assign the above to the tab's icon as follows... Ti.UI.createTab({
icon: "android.resource://" + Ti.App.id + "/drawable/my_tab_icon1",
}); Note that I haven't tested the above. But "something" like that should theoretically work. You'll have to figure it out from there. I've also written up a feature request ticket below. |
@jquick-axway I haven't been able to make it work. I tried the following:
my_tab_icon1.xml and selected.png & unselected.png in drawable folder
I have found out that whatever icon color I add to the folder, the selected icon color will always be the opposite. I don't think this should be the expected behavior. Please advise. |
@hansemannn did you make it work? |
I have seen the following ticket but not able to reproduce: |
Possible to use font awesome? |
@juliengatt try with a custom theme customTheme.xml
drawable/nav_item_color_state.xml
|
JIRA: https://jira.appcelerator.org/browse/TIMOB-26354
Description:
Refactor the implementation of TabGroup - remove deprecated ActioBar tabs UI and replace it with TabLayout. Introduce a new style for using BottomNavigationView. A more detailed description will be available once I am done with everything.
Currently still trying to fix the removal of tabs before opening the TabGroup by simplifying the relation between the tab proxies added and their TiUiAbstractTab counterparts.
Update:
How things work after the refactoring:
TiUIAbstractTabGroup
;TiUIAbstractTabGroup
provides an interface for communication with different "controllers";Note: The constants for style will be used from the same namespace for the
TabbedBar
component. I will change them in the PR for it once this gets the green light for merging.Tickets that should be resolved by this refactoring:
Test case:
app.js
Note: I haven't added a new example in the docs. I was thinking the test case from here should do, but maybe it is not in the best format to go there (too long?).