Skip to content

Commit

Permalink
feat(android): add tabMode to TabGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga committed Jun 28, 2023
1 parent 0d27497 commit 596dc5c
Show file tree
Hide file tree
Showing 8 changed files with 355 additions and 1 deletion.
8 changes: 8 additions & 0 deletions android/modules/design/res/values-land/values-land.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Widget.Design.TabLayout" parent="Base.Widget.Design.TabLayout">
<item name="tabMaxWidth">0dp</item>
<item name="tabGravity">fill</item>
<item name="tabMode">scrollable</item>
</style>
</resources>
302 changes: 302 additions & 0 deletions android/modules/design/res/values/values.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ public void windowCreated(TiBaseActivity activity, Bundle savedInstanceState)
if (getProperty(TiC.PROPERTY_STYLE) == null
|| ((Integer) getProperty(TiC.PROPERTY_STYLE)) == AndroidModule.TABS_STYLE_DEFAULT) {
view = new TiUITabLayoutTabGroup(this, activity);

if (getProperty(TiC.PROPERTY_TAB_MODE) != null) {
((TiUITabLayoutTabGroup) view).setTabMode((Integer) getProperty(TiC.PROPERTY_TAB_MODE));
}
} else {
view = new TiUIBottomNavigationTabGroup(this, activity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ public class AndroidModule extends KrollModule
@Kroll.constant
public static final int TABS_STYLE_BOTTOM_NAVIGATION = 1;

@Kroll.constant
public static final int TAB_MODE_FIXED = 1;
@Kroll.constant
public static final int TAB_MODE_SCROLLABLE = 0;

@Kroll.constant
public static final int TRANSITION_NONE = TiUIView.TRANSITION_NONE;
@Kroll.constant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ public void onTabReselected(TabLayout.Tab tab)
{
}

public void setTabMode(int value)
{
this.mTabLayout.setTabMode(value);
}

private LinearLayout getTabLinearLayoutForIndex(int index)
{
LinearLayout stripLayout = ((LinearLayout) this.mTabLayout.getChildAt(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,7 @@ public class TiC
public static final String PROPERTY_TAB_OPEN = "tabOpen";
public static final String PROPERTY_TABS_BACKGROUND_COLOR = "tabsBackgroundColor";
public static final String PROPERTY_TABS_BACKGROUND_SELECTED_COLOR = "tabsBackgroundSelectedColor";
public static final String PROPERTY_TAB_MODE = "tabMode";
public static final String PROPERTY_TAG = "tag";
public static final String PROPERTY_TEMPLATE = "template";
public static final String PROPERTY_TEMPLATES = "templates";
Expand Down
16 changes: 15 additions & 1 deletion apidoc/Titanium/UI/Android/Android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,20 @@ properties:
platforms: [android]
since: "8.0.0"

- name: TAB_MODE_FIXED
summary: Set the TabGroup tab mode to fixed (default).
type: Number
availability: creation
platforms: [android]
since: "12.2.0"

- name: TAB_MODE_SCROLLABLE
summary: Set the TabGroup tab mode to scrollable.
type: Number
availability: creation
platforms: [android]
since: "12.2.0"

- name: SCROLL_FLAG_ENTER_ALWAYS
summary: When entering (scrolling on screen) the view will scroll on any downwards scroll event, regardless of whether the scrolling view is also scrolling. This is commonly referred to as the 'quick return' pattern.
type: Number
Expand Down Expand Up @@ -937,7 +951,7 @@ properties:
since: "12.1.0"

- name: SCROLL_FLAG_SNAP_MARGINS
summary: An additional flag to be used with 'snap'. If set, the view will be snapped to its top and bottom margins, as opposed to the edges of the view itself.
summary: An additional flag to be used with 'snap'. If set, the view will be snapped to its top and bottom margins, as opposed to the edges of the view itself.
type: Number
permission: read-only
platforms: [android]
Expand Down
15 changes: 15 additions & 0 deletions apidoc/Titanium/UI/TabGroup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,21 @@ properties:
since: {android: "3.0.0", iphone: "3.0.0", ipad: "3.0.0"}
platforms: [android, iphone, ipad, macos]

- name: tabMode
summary: Property defining which tabMode is used for the TabGroup.
description: |
Sets the style of the TabGroup tabs.
[TAB_MODE_SCROLLABLE](Titanium.UI.Android.TAB_MODE_SCROLLABLE) is the best style for showing long tab titles and
enables horizontal scrolling (default).
[TAB_MODE_FIXED](Titanium.UI.Android.TAB_MODE_FIXED) will show all tabs at once.
availability: creation
constants: Titanium.UI.Android.TAB_MODE_*
since: "10.2.0"
type: Number
platforms: [android]

- name: tabsTintColor
summary: The tintColor to apply to the tabs.
description: |
Expand Down

0 comments on commit 596dc5c

Please sign in to comment.