Guy Carmeli преди 7 години
родител
ревизия
d97046c210
No account linked to committer's email address

+ 2
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/BottomTabOptions.java Целия файл

13
             throw new RuntimeException("BottomTab must have an icon");
13
             throw new RuntimeException("BottomTab must have an icon");
14
         }
14
         }
15
         options.icon = TextParser.parse(json.optJSONObject("icon"), "uri");
15
         options.icon = TextParser.parse(json.optJSONObject("icon"), "uri");
16
+        options.testId = TextParser.parse(json, "testID");
16
         return options;
17
         return options;
17
     }
18
     }
18
 
19
 
19
     public Text title = new NullText();
20
     public Text title = new NullText();
20
     public Text icon = new NullText();
21
     public Text icon = new NullText();
22
+    public Text testId = new NullText();
21
 
23
 
22
     void mergeWith(final BottomTabOptions other) {
24
     void mergeWith(final BottomTabOptions other) {
23
         if (other.title.hasValue()) {
25
         if (other.title.hasValue()) {

+ 3
- 2
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/BottomTabsController.java Целия файл

76
 		this.tabs = tabs;
76
 		this.tabs = tabs;
77
 		getView();
77
 		getView();
78
 		for (int i = 0; i < tabs.size(); i++) {
78
 		for (int i = 0; i < tabs.size(); i++) {
79
-			createTab(tabs.get(i), tabs.get(i).options.bottomTabOptions, tabs.get(i).options.bottomTabsOptions);
79
+			createTab(i, tabs.get(i), tabs.get(i).options.bottomTabOptions, tabs.get(i).options.bottomTabsOptions);
80
 		}
80
 		}
81
 		selectTabAtIndex(0);
81
 		selectTabAtIndex(0);
82
 	}
82
 	}
83
 
83
 
84
-	private void createTab(ViewController tab, final BottomTabOptions tabOptions, final BottomTabsOptions bottomTabsOptions) {
84
+	private void createTab(int index, ViewController tab, final BottomTabOptions tabOptions, final BottomTabsOptions bottomTabsOptions) {
85
 	    if (!tabOptions.icon.hasValue()) {
85
 	    if (!tabOptions.icon.hasValue()) {
86
             throw new RuntimeException("BottomTab must have an icon");
86
             throw new RuntimeException("BottomTab must have an icon");
87
         }
87
         }
91
                 setIconColor(drawable, bottomTabsOptions);
91
                 setIconColor(drawable, bottomTabsOptions);
92
                 AHBottomNavigationItem item = new AHBottomNavigationItem(tabOptions.title.get(""), drawable);
92
                 AHBottomNavigationItem item = new AHBottomNavigationItem(tabOptions.title.get(""), drawable);
93
                 bottomTabs.addItem(item);
93
                 bottomTabs.addItem(item);
94
+                bottomTabs.post(() -> bottomTabs.setTabTag(index, tabOptions.testId));
94
             }
95
             }
95
 
96
 
96
             @Override
97
             @Override

+ 6
- 0
lib/android/app/src/main/java/com/reactnativenavigation/views/BottomTabs.java Целия файл

19
     private void setTestId(Text testId) {
19
     private void setTestId(Text testId) {
20
         if (testId.hasValue()) setTag(testId.get());
20
         if (testId.hasValue()) setTag(testId.get());
21
     }
21
     }
22
+
23
+    public void setTabTag(int index, Text testId) {
24
+        if (!testId.hasValue()) return;
25
+        if (testId.hasValue()) getViewAtPosition(index).setTag(testId.get());
26
+        if (testId.hasValue()) getViewAtPosition(index).setContentDescription(testId.get());
27
+    }
22
 }
28
 }