@@ -76,7 +76,8 @@ public class TabGroupProxy extends TiWindowProxy implements TiActivityWindow
76
76
private Object selectedTab ; // NOTE: Can be TabProxy or Number
77
77
private String tabGroupTitle = null ;
78
78
private boolean autoTabTitle = false ;
79
- private boolean tabEnabled = true ;
79
+ private boolean isTabBarVisible = true ;
80
+ private boolean isTabGroupEnabled = true ;
80
81
81
82
public TabGroupProxy ()
82
83
{
@@ -94,24 +95,49 @@ public int getTabIndex(TabProxy tabProxy)
94
95
@ Kroll .method
95
96
public void disableTabNavigation (Object params )
96
97
{
98
+ String message
99
+ = "Ti.UI.TabGroup.disableTabNavigation() has been deprecated in 12.7.0 in favor of"
100
+ + " Ti.UI.TabGroup.tabBarVisible and Ti.UI.TabGroup.enabled properties."
101
+ + " Ti.UI.TabGroup.disableTabNavigation() will be removed in 13.0.0." ;
102
+ Log .w (TAG , message );
103
+
97
104
if (params instanceof Boolean ) {
98
- TiUIAbstractTabGroup tabGroup = (TiUIAbstractTabGroup ) view ;
99
- if (tabGroup != null ) {
100
- tabGroup .disableTabNavigation (TiConvert .toBoolean (params , false ));
101
- }
102
- } else if (params instanceof HashMap <?, ?>) {
105
+ boolean isEnabled = !TiConvert .toBoolean (params , false );
106
+ setEnabled (isEnabled );
107
+ setTabBarVisible (isEnabled );
108
+ return ;
109
+ }
110
+
111
+ if (params instanceof HashMap <?, ?>) {
103
112
KrollDict options = new KrollDict ((HashMap <String , Object >) params );
104
- TiUIAbstractTabGroup tabGroup = (TiUIAbstractTabGroup ) view ;
105
- if (tabGroup != null ) {
106
- if (options .getBoolean (TiC .PROPERTY_ANIMATED )) {
107
- setTabBarVisible (options .getBoolean (TiC .PROPERTY_ENABLED ));
108
- } else {
109
- tabGroup .disableTabNavigation (options .getBoolean (TiC .PROPERTY_ENABLED ));
110
- }
113
+
114
+ boolean isEnabled = !options .optBoolean (TiC .PROPERTY_ENABLED , false );
115
+ boolean isAnimated = options .optBoolean (TiC .PROPERTY_ANIMATED , false );
116
+ setEnabled (isEnabled );
117
+
118
+ if (isAnimated ) {
119
+ showHideTabBar (isEnabled );
120
+ } else {
121
+ setTabBarVisible (isEnabled );
111
122
}
112
123
}
113
124
}
114
125
126
+ @ Kroll .setProperty
127
+ public void setEnabled (boolean enabled )
128
+ {
129
+ isTabGroupEnabled = enabled ;
130
+ if (view != null ) {
131
+ ((TiUIAbstractTabGroup ) view ).disableTabNavigation (!isTabGroupEnabled );
132
+ }
133
+ }
134
+
135
+ @ Kroll .getProperty
136
+ public boolean getEnabled ()
137
+ {
138
+ return isTabGroupEnabled ;
139
+ }
140
+
115
141
@ Kroll .method
116
142
public void addTab (TabProxy tab )
117
143
{
@@ -134,10 +160,37 @@ public void addTab(TabProxy tab)
134
160
@ Kroll .setProperty
135
161
public void setTabBarVisible (boolean visible )
136
162
{
137
- TiUIBottomNavigationTabGroup tabGroup = ( TiUIBottomNavigationTabGroup ) view ;
163
+ isTabBarVisible = visible ;
138
164
139
- if (tabGroup != null ) {
140
- tabGroup .setTabBarVisible (visible );
165
+ if (view instanceof TiUIBottomNavigationTabGroup bottomTabGroup ) {
166
+ bottomTabGroup .setTabGroupVisibility (visible );
167
+ } else if (view instanceof TiUITabLayoutTabGroup tabGroupDefault ) {
168
+ tabGroupDefault .setTabGroupVisibility (visible );
169
+ } else if (view instanceof TiUIBottomNavigation bottomNavigation ) {
170
+ bottomNavigation .setTabGroupVisibility (visible );
171
+ }
172
+ }
173
+
174
+ @ Kroll .method
175
+ public void showTabBar ()
176
+ {
177
+ showHideTabBar (true );
178
+ }
179
+
180
+ @ Kroll .method
181
+ public void hideTabBar ()
182
+ {
183
+ showHideTabBar (false );
184
+ }
185
+
186
+ private void showHideTabBar (boolean visible )
187
+ {
188
+ if (view instanceof TiUIBottomNavigationTabGroup bottomTabGroup ) {
189
+ bottomTabGroup .showHideTabBar (visible );
190
+ } else if (view instanceof TiUITabLayoutTabGroup tabGroupDefault ) {
191
+ tabGroupDefault .showHideTabBar (visible );
192
+ } else if (view instanceof TiUIBottomNavigation bottomNavigation ) {
193
+ bottomNavigation .showHideTabBar (visible );
141
194
}
142
195
}
143
196
@@ -197,22 +250,6 @@ public void setActiveTab(Object tabOrIndex)
197
250
}
198
251
}
199
252
200
- @ Kroll .setProperty
201
- public void setEnabled (Boolean enabled )
202
- {
203
- tabEnabled = enabled ;
204
- TiUIAbstractTabGroup tabGroup = (TiUIAbstractTabGroup ) view ;
205
- if (tabGroup != null ) {
206
- tabGroup .setEnabled (enabled );
207
- }
208
- }
209
-
210
- @ Kroll .getProperty
211
- public Boolean getEnabled ()
212
- {
213
- return tabEnabled ;
214
- }
215
-
216
253
private TabProxy getActiveTabProxy ()
217
254
{
218
255
Object activeTab = getActiveTab ();
@@ -244,8 +281,7 @@ public void setTabs(Object obj)
244
281
}
245
282
tabs .clear ();
246
283
247
- if (obj instanceof Object []) {
248
- Object [] objArray = (Object []) obj ;
284
+ if (obj instanceof Object [] objArray ) {
249
285
for (Object tabProxy : objArray ) {
250
286
if (tabProxy instanceof TabProxy ) {
251
287
addTab ((TabProxy ) tabProxy );
@@ -303,8 +339,11 @@ public void handleCreationDict(KrollDict options)
303
339
if (options .containsKeyAndNotNull (TiC .PROPERTY_ACTIVE_TAB )) {
304
340
setActiveTab (options .get (TiC .PROPERTY_ACTIVE_TAB ));
305
341
}
342
+ if (options .containsKeyAndNotNull (TiC .PROPERTY_TAB_BAR_VISIBLE )) {
343
+ isTabBarVisible = options .optBoolean (TiC .PROPERTY_TAB_BAR_VISIBLE , isTabBarVisible );
344
+ }
306
345
if (options .containsKeyAndNotNull (TiC .PROPERTY_ENABLED )) {
307
- setEnabled ( options .getBoolean (TiC .PROPERTY_ENABLED ) );
346
+ isTabGroupEnabled = options .optBoolean (TiC .PROPERTY_ENABLED , isTabGroupEnabled );
308
347
}
309
348
}
310
349
@@ -523,6 +562,12 @@ protected void handlePostOpen()
523
562
// Prevent any duplicate events from firing by marking
524
563
// this group has having focus.
525
564
isFocused = true ;
565
+
566
+ // Update UI if these properties are set before the native view is created.
567
+ tabGroup .onViewSizeAvailable (() -> {
568
+ setEnabled (isTabGroupEnabled );
569
+ setTabBarVisible (isTabBarVisible );
570
+ });
526
571
}
527
572
528
573
@ Override
0 commit comments