Browse Source

pass testID to BottomTabs (#2657)

Guy Carmeli 6 years ago
parent
commit
9ff1349bd3
No account linked to committer's email address

+ 2
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/BottomTabsOptions.java View File

17
 		options.currentTabIndex = json.optInt("currentTabIndex", NO_INT_VALUE);
17
 		options.currentTabIndex = json.optInt("currentTabIndex", NO_INT_VALUE);
18
 		options.visible = BooleanOptions.parse(json.optString("visible"));
18
 		options.visible = BooleanOptions.parse(json.optString("visible"));
19
 		options.animateHide = BooleanOptions.parse(json.optString("animateHide"));
19
 		options.animateHide = BooleanOptions.parse(json.optString("animateHide"));
20
+        options.testId = TextParser.parse(json, "testID");
20
 
21
 
21
 		return options;
22
 		return options;
22
 	}
23
 	}
27
 	BooleanOptions animateHide = BooleanOptions.False;
28
 	BooleanOptions animateHide = BooleanOptions.False;
28
 	public int currentTabIndex = NO_INT_VALUE;
29
 	public int currentTabIndex = NO_INT_VALUE;
29
 	public Text currentTabId = new NullText();
30
 	public Text currentTabId = new NullText();
31
+    public Text testId = new NullText();
30
 
32
 
31
 	void mergeWith(final BottomTabsOptions other) {
33
 	void mergeWith(final BottomTabsOptions other) {
32
 		if (other.currentTabId.hasValue()) {
34
 		if (other.currentTabId.hasValue()) {

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/BottomTabsController.java View File

44
 	@Override
44
 	@Override
45
 	protected ViewGroup createView() {
45
 	protected ViewGroup createView() {
46
 		RelativeLayout root = new RelativeLayout(getActivity());
46
 		RelativeLayout root = new RelativeLayout(getActivity());
47
-		bottomTabs = new BottomTabs(getActivity());
47
+		bottomTabs = new BottomTabs(getActivity(), options.bottomTabsOptions);
48
         bottomTabs.setOnTabSelectedListener(this);
48
         bottomTabs.setOnTabSelectedListener(this);
49
 		RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT);
49
 		RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT);
50
 		lp.addRule(ALIGN_PARENT_BOTTOM);
50
 		lp.addRule(ALIGN_PARENT_BOTTOM);

+ 5
- 1
lib/android/app/src/main/java/com/reactnativenavigation/views/BottomTabs.java View File

1
 package com.reactnativenavigation.views;
1
 package com.reactnativenavigation.views;
2
 
2
 
3
+import android.annotation.SuppressLint;
3
 import android.content.Context;
4
 import android.content.Context;
4
 
5
 
5
 import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
6
 import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
7
+import com.reactnativenavigation.parse.BottomTabsOptions;
6
 import com.reactnativenavigation.utils.CompatUtils;
8
 import com.reactnativenavigation.utils.CompatUtils;
7
 
9
 
10
+@SuppressLint("ViewConstructor")
8
 public class BottomTabs extends AHBottomNavigation {
11
 public class BottomTabs extends AHBottomNavigation {
9
-    public BottomTabs(Context context) {
12
+    public BottomTabs(Context context, BottomTabsOptions bottomTabsOptions) {
10
         super(context);
13
         super(context);
11
         setId(CompatUtils.generateViewId());
14
         setId(CompatUtils.generateViewId());
15
+        setTag(bottomTabsOptions.testId.get(""));
12
     }
16
     }
13
 }
17
 }