6
6
*/
7
7
package ti .modules .titanium .ui ;
8
8
9
+ import static ti .modules .titanium .android .AndroidModule .STATUS_BAR_LIGHT ;
10
+
9
11
import android .app .Activity ;
10
12
import android .content .Intent ;
13
+ import android .os .Build ;
11
14
import android .os .Bundle ;
12
15
import android .view .LayoutInflater ;
16
+ import android .view .View ;
13
17
14
18
import androidx .annotation .NonNull ;
15
19
import androidx .appcompat .app .ActionBar ;
29
33
import org .appcelerator .titanium .TiRootActivity ;
30
34
import org .appcelerator .titanium .proxy .ActivityProxy ;
31
35
import org .appcelerator .titanium .proxy .TiWindowProxy ;
36
+ import org .appcelerator .titanium .util .TiColorHelper ;
32
37
import org .appcelerator .titanium .util .TiConvert ;
33
38
import org .appcelerator .titanium .util .TiRHelper ;
34
39
import org .appcelerator .titanium .util .TiUIHelper ;
39
44
40
45
import ti .modules .titanium .ui .android .AndroidModule ;
41
46
import ti .modules .titanium .ui .widget .tabgroup .TiUIAbstractTabGroup ;
47
+ import ti .modules .titanium .ui .widget .tabgroup .TiUIBottomNavigation ;
42
48
import ti .modules .titanium .ui .widget .tabgroup .TiUIBottomNavigationTabGroup ;
43
49
import ti .modules .titanium .ui .widget .tabgroup .TiUITabLayoutTabGroup ;
44
50
49
55
TiC .PROPERTY_SWIPEABLE ,
50
56
TiC .PROPERTY_AUTO_TAB_TITLE ,
51
57
TiC .PROPERTY_EXIT_ON_CLOSE ,
52
- TiC .PROPERTY_SMOOTH_SCROLL_ON_TAB_CLICK
58
+ TiC .PROPERTY_SMOOTH_SCROLL_ON_TAB_CLICK ,
59
+ TiC .PROPERTY_INDICATOR_COLOR
53
60
})
54
61
public class TabGroupProxy extends TiWindowProxy implements TiActivityWindow
55
62
{
@@ -69,6 +76,7 @@ public class TabGroupProxy extends TiWindowProxy implements TiActivityWindow
69
76
private Object selectedTab ; // NOTE: Can be TabProxy or Number
70
77
private String tabGroupTitle = null ;
71
78
private boolean autoTabTitle = false ;
79
+ private boolean tabEnabled = true ;
72
80
73
81
public TabGroupProxy ()
74
82
{
@@ -189,6 +197,22 @@ public void setActiveTab(Object tabOrIndex)
189
197
}
190
198
}
191
199
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
+
192
216
private TabProxy getActiveTabProxy ()
193
217
{
194
218
Object activeTab = getActiveTab ();
@@ -279,6 +303,9 @@ public void handleCreationDict(KrollDict options)
279
303
if (options .containsKeyAndNotNull (TiC .PROPERTY_ACTIVE_TAB )) {
280
304
setActiveTab (options .get (TiC .PROPERTY_ACTIVE_TAB ));
281
305
}
306
+ if (options .containsKeyAndNotNull (TiC .PROPERTY_ENABLED )) {
307
+ setEnabled (options .getBoolean (TiC .PROPERTY_ENABLED ));
308
+ }
282
309
}
283
310
284
311
@ Kroll .getProperty
@@ -323,6 +350,21 @@ protected void handleOpen(KrollDict options)
323
350
if (topActivity == null || topActivity .isFinishing ()) {
324
351
return ;
325
352
}
353
+
354
+ // set theme for XML layout
355
+ if (hasProperty (TiC .PROPERTY_STYLE )
356
+ && ((Integer ) getProperty (TiC .PROPERTY_STYLE )) == AndroidModule .TABS_STYLE_BOTTOM_NAVIGATION
357
+ && getProperty (TiC .PROPERTY_THEME ) != null ) {
358
+ try {
359
+ String themeName = getProperty (TiC .PROPERTY_THEME ).toString ();
360
+ int theme = TiRHelper .getResource ("style."
361
+ + themeName .replaceAll ("[^A-Za-z0-9_]" , "_" ));
362
+ topActivity .setTheme (theme );
363
+ topActivity .getApplicationContext ().setTheme (theme );
364
+ } catch (Exception e ) {
365
+ }
366
+ }
367
+
326
368
Intent intent = new Intent (topActivity , TiActivity .class );
327
369
fillIntent (topActivity , intent );
328
370
@@ -367,7 +409,11 @@ public void windowCreated(TiBaseActivity activity, Bundle savedInstanceState)
367
409
((TiUITabLayoutTabGroup ) view ).setTabMode ((Integer ) getProperty (TiC .PROPERTY_TAB_MODE ));
368
410
}
369
411
} else {
370
- view = new TiUIBottomNavigationTabGroup (this , activity );
412
+ if (TiConvert .toBoolean (getProperty ("experimental" ), false )) {
413
+ view = new TiUIBottomNavigation (this , activity );
414
+ } else {
415
+ view = new TiUIBottomNavigationTabGroup (this , activity );
416
+ }
371
417
}
372
418
// If we have set a title before the creation of the native view, set it now.
373
419
if (this .tabGroupTitle != null ) {
@@ -405,6 +451,22 @@ public void windowCreated(TiBaseActivity activity, Bundle savedInstanceState)
405
451
406
452
// Need to handle the cached activity proxy properties in the JS side.
407
453
callPropertySync (PROPERTY_POST_TAB_GROUP_CREATED , null );
454
+
455
+ if (getActivity () != null ) {
456
+ if (hasPropertyAndNotNull (TiC .PROPERTY_FLAGS )) {
457
+ if (TiConvert .toInt (getProperty (TiC .PROPERTY_FLAGS )) == STATUS_BAR_LIGHT
458
+ && Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
459
+ getActivity ().getWindow ().getDecorView ()
460
+ .setSystemUiVisibility (View .SYSTEM_UI_FLAG_LIGHT_STATUS_BAR );
461
+ }
462
+ }
463
+ if (hasPropertyAndNotNull (TiC .PROPERTY_STATUS_BAR_COLOR )) {
464
+ int colorInt = TiColorHelper .parseColor (
465
+ TiConvert .toString (getProperty (TiC .PROPERTY_STATUS_BAR_COLOR )),
466
+ TiApplication .getAppRootOrCurrentActivity ());
467
+ getActivity ().getWindow ().setStatusBarColor (colorInt );
468
+ }
469
+ }
408
470
}
409
471
410
472
@ Override
0 commit comments