Browse Source

rename navigationOptions

Daniel Zlotin 6 years ago
parent
commit
8445e92eec

+ 6
- 6
lib/android/app/src/main/java/com/reactnativenavigation/parse/LayoutFactory.java View File

@@ -96,12 +96,12 @@ public class LayoutFactory {
96 96
 	private ViewController createComponent(LayoutNode node) {
97 97
 		String id = node.id;
98 98
 		String name = node.data.optString("name");
99
-		NavigationOptions navigationOptions = NavigationOptions.parse(typefaceManager, node.data.optJSONObject("navigationOptions"), defaultOptions);
99
+		NavigationOptions options = NavigationOptions.parse(typefaceManager, node.data.optJSONObject("options"), defaultOptions);
100 100
 		return new ComponentViewController(activity,
101 101
                 id,
102 102
                 name,
103 103
                 new ComponentViewCreator(reactInstanceManager),
104
-                navigationOptions
104
+                options
105 105
         );
106 106
 	}
107 107
 
@@ -137,19 +137,19 @@ public class LayoutFactory {
137 137
             tabController.setTabIndex(i);
138 138
             tabs.add(tabController);
139 139
         }
140
-        NavigationOptions navigationOptions = NavigationOptions.parse(typefaceManager, node.getNavigationOptions(), defaultOptions);
141
-        return new TopTabsController(activity, node.id, tabs, new TopTabsLayoutCreator(activity, tabs), navigationOptions);
140
+        NavigationOptions options = NavigationOptions.parse(typefaceManager, node.getNavigationOptions(), defaultOptions);
141
+        return new TopTabsController(activity, node.id, tabs, new TopTabsLayoutCreator(activity, tabs), options);
142 142
     }
143 143
 
144 144
     private ViewController createTopTab(LayoutNode node) {
145 145
         String id = node.id;
146 146
         String name = node.data.optString("name");
147
-        NavigationOptions navigationOptions = NavigationOptions.parse(typefaceManager, node.getNavigationOptions(), defaultOptions);
147
+        NavigationOptions options = NavigationOptions.parse(typefaceManager, node.getNavigationOptions(), defaultOptions);
148 148
         return new TopTabController(activity,
149 149
                 id,
150 150
                 name,
151 151
                 new ReactComponentViewCreator(reactInstanceManager),
152
-                navigationOptions
152
+                options
153 153
         );
154 154
     }
155 155
 }

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/parse/LayoutNode.java View File

@@ -35,6 +35,6 @@ public class LayoutNode {
35 35
 	}
36 36
 
37 37
     JSONObject getNavigationOptions() {
38
-	    return data.optJSONObject("navigationOptions");
38
+	    return data.optJSONObject("options");
39 39
     }
40 40
 }

+ 3
- 5
lib/android/app/src/main/java/com/reactnativenavigation/parse/NavigationOptions.java View File

@@ -1,12 +1,10 @@
1 1
 package com.reactnativenavigation.parse;
2 2
 
3
-import android.support.annotation.NonNull;
3
+import android.support.annotation.*;
4 4
 
5
-import com.reactnativenavigation.utils.TypefaceLoader;
5
+import com.reactnativenavigation.utils.*;
6 6
 
7
-import org.json.JSONObject;
8
-
9
-import java.util.ArrayList;
7
+import org.json.*;
10 8
 
11 9
 public class NavigationOptions implements DEFAULT_VALUES {
12 10
 

+ 7
- 7
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ComponentViewController.java View File

@@ -35,7 +35,7 @@ public class ComponentViewController extends ViewController implements Navigatio
35 35
 	private final String componentName;
36 36
 
37 37
 	private final ReactViewCreator viewCreator;
38
-	private NavigationOptions navigationOptions;
38
+	private NavigationOptions options;
39 39
 	private ReactComponent component;
40 40
 
41 41
 	public ComponentViewController(final Activity activity,
@@ -46,7 +46,7 @@ public class ComponentViewController extends ViewController implements Navigatio
46 46
 		super(activity, id);
47 47
 		this.componentName = componentName;
48 48
 		this.viewCreator = viewCreator;
49
-		this.navigationOptions = initialNavigationOptions;
49
+		this.options = initialNavigationOptions;
50 50
 	}
51 51
 
52 52
     @RestrictTo(RestrictTo.Scope.TESTS)
@@ -65,7 +65,7 @@ public class ComponentViewController extends ViewController implements Navigatio
65 65
 	public void onViewAppeared() {
66 66
 		super.onViewAppeared();
67 67
 		ensureViewIsCreated();
68
-		component.applyOptions(navigationOptions);
68
+		component.applyOptions(options);
69 69
 		component.sendComponentStart();
70 70
 	}
71 71
 
@@ -89,11 +89,11 @@ public class ComponentViewController extends ViewController implements Navigatio
89 89
 
90 90
 	@Override
91 91
 	public void mergeNavigationOptions(NavigationOptions options) {
92
-		navigationOptions.mergeWith(options);
93
-        component.applyOptions(navigationOptions);
92
+		this.options.mergeWith(options);
93
+        component.applyOptions(options);
94 94
 	}
95 95
 
96
-	NavigationOptions getNavigationOptions() {
97
-		return navigationOptions;
96
+	NavigationOptions getOptions() {
97
+		return options;
98 98
 	}
99 99
 }

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

@@ -63,7 +63,7 @@ public class ModalStack {
63 63
 
64 64
 	@Nullable
65 65
     ViewController findControllerById(String id) {
66
-        Modal modal = findModalByContainerId(id);
66
+        Modal modal = findModalByComponentId(id);
67 67
         return modal != null ? modal.viewController : null;
68 68
     }
69 69
 

+ 4
- 4
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabsController.java View File

@@ -20,12 +20,12 @@ public class TopTabsController extends ParentController implements NavigationOpt
20 20
     private List<TopTabController> tabs;
21 21
     private TopTabsLayout topTabsLayout;
22 22
     private TopTabsLayoutCreator viewCreator;
23
-    private NavigationOptions navigationOptions;
23
+    private NavigationOptions options;
24 24
 
25
-    public TopTabsController(Activity activity, String id, List<TopTabController> tabs, TopTabsLayoutCreator viewCreator, NavigationOptions navigationOptions) {
25
+    public TopTabsController(Activity activity, String id, List<TopTabController> tabs, TopTabsLayoutCreator viewCreator, NavigationOptions options) {
26 26
         super(activity, id);
27 27
         this.viewCreator = viewCreator;
28
-        this.navigationOptions = navigationOptions;
28
+        this.options = options;
29 29
         this.tabs = tabs;
30 30
         for (ViewController tab : tabs) {
31 31
             tab.setParentController(this);
@@ -47,7 +47,7 @@ public class TopTabsController extends ParentController implements NavigationOpt
47 47
 
48 48
     @Override
49 49
     public void onViewAppeared() {
50
-        applyOptions(navigationOptions);
50
+        applyOptions(options);
51 51
         performOnCurrentTab(TopTabController::onViewAppeared);
52 52
     }
53 53
 

+ 2
- 2
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigatorTest.java View File

@@ -197,13 +197,13 @@ public class NavigatorTest extends BaseTest {
197 197
 	public void setOptions_CallsApplyNavigationOptions() {
198 198
 		ComponentViewController componentVc = new SimpleComponentViewController(activity, "theId");
199 199
 		uut.setRoot(componentVc);
200
-		assertThat(componentVc.getNavigationOptions().topBarOptions.title).isEmpty();
200
+		assertThat(componentVc.getOptions().topBarOptions.title).isEmpty();
201 201
 
202 202
 		NavigationOptions options = new NavigationOptions();
203 203
 		options.topBarOptions.title = "new title";
204 204
 
205 205
 		uut.setOptions("theId", options);
206
-		assertThat(componentVc.getNavigationOptions().topBarOptions.title).isEqualTo("new title");
206
+		assertThat(componentVc.getOptions().topBarOptions.title).isEqualTo("new title");
207 207
 	}
208 208
 
209 209
 	@Test

+ 7
- 7
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java View File

@@ -44,7 +44,7 @@ public class OptionsApplyingTest extends BaseTest {
44 44
 
45 45
 	@Test
46 46
 	public void initialOptionsAppliedOnAppear() throws Exception {
47
-		assertThat(uut.getNavigationOptions()).isSameAs(initialNavigationOptions);
47
+		assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
48 48
 		initialNavigationOptions.topBarOptions.title = "the title";
49 49
 		StackController stackController = new StackController(activity, "stackId");
50 50
 		stackController.push(uut);
@@ -56,12 +56,12 @@ public class OptionsApplyingTest extends BaseTest {
56 56
 
57 57
 	@Test
58 58
 	public void mergeNavigationOptionsUpdatesCurrentOptions() throws Exception {
59
-		assertThat(uut.getNavigationOptions().topBarOptions.title).isEmpty();
59
+		assertThat(uut.getOptions().topBarOptions.title).isEmpty();
60 60
 		NavigationOptions options = new NavigationOptions();
61 61
 		options.topBarOptions.title = "new title";
62 62
 		uut.mergeNavigationOptions(options);
63
-		assertThat(uut.getNavigationOptions().topBarOptions.title).isEqualTo("new title");
64
-		assertThat(uut.getNavigationOptions()).isSameAs(initialNavigationOptions);
63
+		assertThat(uut.getOptions().topBarOptions.title).isEqualTo("new title");
64
+		assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
65 65
 	}
66 66
 
67 67
 	@Test
@@ -91,7 +91,7 @@ public class OptionsApplyingTest extends BaseTest {
91 91
 
92 92
 	@Test
93 93
 	public void appliesTopBarTextColor() throws Exception {
94
-		assertThat(uut.getNavigationOptions()).isSameAs(initialNavigationOptions);
94
+		assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
95 95
 		initialNavigationOptions.topBarOptions.title = "the title";
96 96
 		uut.onViewAppeared();
97 97
 		assertThat(uut.getTopBar().getTitleTextView().getCurrentTextColor()).isNotEqualTo(Color.RED);
@@ -107,7 +107,7 @@ public class OptionsApplyingTest extends BaseTest {
107 107
 
108 108
 	@Test
109 109
 	public void appliesTopBarTextSize() throws Exception {
110
-		assertThat(uut.getNavigationOptions()).isSameAs(initialNavigationOptions);
110
+		assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
111 111
 		initialNavigationOptions.topBarOptions.title = "the title";
112 112
 		uut.onViewAppeared();
113 113
 		assertThat(uut.getTopBar().getTitleTextView().getTextSize()).isNotEqualTo(18);
@@ -123,7 +123,7 @@ public class OptionsApplyingTest extends BaseTest {
123 123
 
124 124
 	@Test
125 125
 	public void appliesTopBarHidden() throws Exception {
126
-		assertThat(uut.getNavigationOptions()).isSameAs(initialNavigationOptions);
126
+		assertThat(uut.getOptions()).isSameAs(initialNavigationOptions);
127 127
 		initialNavigationOptions.topBarOptions.title = "the title";
128 128
 		uut.onViewAppeared();
129 129
 		assertThat(uut.getTopBar().getVisibility()).isNotEqualTo(View.GONE);

+ 4
- 4
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopTabsViewControllerTest.java View File

@@ -31,7 +31,7 @@ public class TopTabsViewControllerTest extends BaseTest {
31 31
     private List<TopTabLayoutMock> tabs = new ArrayList<>(SIZE);
32 32
     private List<TopTabController> tabControllers = new ArrayList<>(SIZE);
33 33
     private List<NavigationOptions> tabOptions = new ArrayList<>(SIZE);
34
-    private NavigationOptions navigationOptions;
34
+    private NavigationOptions options;
35 35
     private TopTabsLayout topTabsLayout;
36 36
 
37 37
     @Override
@@ -41,12 +41,12 @@ public class TopTabsViewControllerTest extends BaseTest {
41 41
         tabs.clear();
42 42
         Activity activity = newActivity();
43 43
         createTabs(activity);
44
-        navigationOptions = new NavigationOptions();
44
+        options = new NavigationOptions();
45 45
         topTabsLayout = spy(new TopTabsLayout(activity, tabControllers, new TopTabsAdapter(tabControllers)));
46 46
 
47 47
         TopTabsLayoutCreator layoutCreator = Mockito.mock(TopTabsLayoutCreator.class);
48 48
         Mockito.when(layoutCreator.create()).thenReturn(topTabsLayout);
49
-        uut = new TopTabsController(activity, "componentId", tabControllers, layoutCreator, navigationOptions);
49
+        uut = new TopTabsController(activity, "componentId", tabControllers, layoutCreator, options);
50 50
     }
51 51
 
52 52
     private void createTabs(Activity activity) {
@@ -130,7 +130,7 @@ public class TopTabsViewControllerTest extends BaseTest {
130 130
     public void appliesOptionsOnLayoutWhenVisible() throws Exception {
131 131
         uut.ensureViewIsCreated();
132 132
         uut.onViewAppeared();
133
-        verify(topTabsLayout, times(1)).applyOptions(navigationOptions);
133
+        verify(topTabsLayout, times(1)).applyOptions(options);
134 134
     }
135 135
 
136 136
     private IReactView tab(TopTabsLayout topTabs, final int index) {