Browse Source

Merge pull request #161 from wix/modal_support

Fixes to Modal and top buttons
Guy Carmeli 8 years ago
parent
commit
9ea0c34917

+ 20
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/Modal.java View File

10
 import com.reactnativenavigation.layouts.ScreenStackContainer;
10
 import com.reactnativenavigation.layouts.ScreenStackContainer;
11
 import com.reactnativenavigation.layouts.SingleScreenLayout;
11
 import com.reactnativenavigation.layouts.SingleScreenLayout;
12
 import com.reactnativenavigation.params.ScreenParams;
12
 import com.reactnativenavigation.params.ScreenParams;
13
+import com.reactnativenavigation.params.TitleBarButtonParams;
14
+import com.reactnativenavigation.params.TitleBarLeftButtonParams;
15
+
16
+import java.util.List;
13
 
17
 
14
 public class Modal extends Dialog implements DialogInterface.OnDismissListener, ScreenStackContainer {
18
 public class Modal extends Dialog implements DialogInterface.OnDismissListener, ScreenStackContainer {
15
 
19
 
16
     private final AppCompatActivity activity;
20
     private final AppCompatActivity activity;
17
     private final OnModalDismissedListener onModalDismissedListener;
21
     private final OnModalDismissedListener onModalDismissedListener;
18
 
22
 
23
+    public void setTopBarVisible(String screenInstanceId, boolean hidden, boolean animated) {
24
+        layout.setTopBarVisible(screenInstanceId, hidden, animated);
25
+    }
26
+
27
+    public void setTitleBarTitle(String screenInstanceId, String title) {
28
+        layout.setTitleBarTitle(screenInstanceId, title);
29
+    }
30
+
31
+    public void setTitleBarRightButtons(String screenInstanceId, String navigatorEventId, List<TitleBarButtonParams> titleBarButtons) {
32
+        layout.setTitleBarRightButtons(screenInstanceId, navigatorEventId, titleBarButtons);
33
+    }
34
+
35
+    public void setTitleBarLeftButton(String screenInstanceId, String navigatorEventId, TitleBarLeftButtonParams titleBarLeftButton) {
36
+        layout.setTitleBarLeftButton(screenInstanceId, navigatorEventId, titleBarLeftButton);
37
+    }
38
+
19
     public interface OnModalDismissedListener {
39
     public interface OnModalDismissedListener {
20
         void onModalDismissed(Modal modal);
40
         void onModalDismissed(Modal modal);
21
     }
41
     }

+ 26
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/ModalController.java View File

4
 
4
 
5
 import com.reactnativenavigation.layouts.ScreenStackContainer;
5
 import com.reactnativenavigation.layouts.ScreenStackContainer;
6
 import com.reactnativenavigation.params.ScreenParams;
6
 import com.reactnativenavigation.params.ScreenParams;
7
+import com.reactnativenavigation.params.TitleBarButtonParams;
8
+import com.reactnativenavigation.params.TitleBarLeftButtonParams;
7
 
9
 
10
+import java.util.List;
8
 import java.util.Stack;
11
 import java.util.Stack;
9
 
12
 
10
 public class ModalController implements ScreenStackContainer, Modal.OnModalDismissedListener {
13
 public class ModalController implements ScreenStackContainer, Modal.OnModalDismissedListener {
70
         stack.remove(modal);
73
         stack.remove(modal);
71
     }
74
     }
72
 
75
 
76
+    public void setTopBarVisible(String screenInstanceId, boolean hidden, boolean animated) {
77
+        for (Modal modal : stack) {
78
+            modal.setTopBarVisible(screenInstanceId, hidden, animated);
79
+        }
80
+    }
81
+
82
+    public void setTitleBarTitle(String screenInstanceId, String title) {
83
+        for (Modal modal : stack) {
84
+            modal.setTitleBarTitle(screenInstanceId, title);
85
+        }
86
+    }
87
+
88
+    public void setTitleBarRightButtons(String screenInstanceId, String navigatorEventId, List<TitleBarButtonParams> titleBarButtons) {
89
+        for (Modal modal : stack) {
90
+            modal.setTitleBarRightButtons(screenInstanceId, navigatorEventId, titleBarButtons);
91
+        }
92
+    }
93
+
94
+    public void setTitleBarLeftButton(String screenInstanceId, String navigatorEventId, TitleBarLeftButtonParams titleBarLeftButton) {
95
+        for (Modal modal : stack) {
96
+            modal.setTitleBarLeftButton(screenInstanceId, navigatorEventId, titleBarLeftButton);
97
+        }
98
+    }
73
 }
99
 }

+ 19
- 3
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java View File

119
     }
119
     }
120
 
120
 
121
     void pop(ScreenParams params) {
121
     void pop(ScreenParams params) {
122
-        layout.pop(params);
122
+        if (modalController.isShowing()) {
123
+            modalController.pop(params);
124
+        } else {
125
+            layout.pop(params);
126
+        }
123
     }
127
     }
124
 
128
 
125
     void popToRoot(ScreenParams params) {
129
     void popToRoot(ScreenParams params) {
126
-        layout.popToRoot(params);
130
+        if (modalController.isShowing()) {
131
+            modalController.popToRoot(params);
132
+        } else {
133
+            layout.popToRoot(params);
134
+        }
127
     }
135
     }
128
 
136
 
129
     void newStack(ScreenParams params) {
137
     void newStack(ScreenParams params) {
130
-        layout.newStack(params);
138
+        if (modalController.isShowing()) {
139
+            modalController.newStack(params);
140
+        } else {
141
+            layout.newStack(params);
142
+        }
131
     }
143
     }
132
 
144
 
133
     void setTopBarVisible(String screenInstanceId, boolean hidden, boolean animated) {
145
     void setTopBarVisible(String screenInstanceId, boolean hidden, boolean animated) {
134
         layout.setTopBarVisible(screenInstanceId, hidden, animated);
146
         layout.setTopBarVisible(screenInstanceId, hidden, animated);
147
+        modalController.setTopBarVisible(screenInstanceId, hidden, animated);
135
     }
148
     }
136
 
149
 
137
     void setTitleBarTitle(String screenInstanceId, String title) {
150
     void setTitleBarTitle(String screenInstanceId, String title) {
138
         layout.setTitleBarTitle(screenInstanceId, title);
151
         layout.setTitleBarTitle(screenInstanceId, title);
152
+        modalController.setTitleBarTitle(screenInstanceId, title);
139
     }
153
     }
140
 
154
 
141
     public void setTitleBarButtons(String screenInstanceId, String navigatorEventId, List<TitleBarButtonParams> titleBarButtons) {
155
     public void setTitleBarButtons(String screenInstanceId, String navigatorEventId, List<TitleBarButtonParams> titleBarButtons) {
142
         layout.setTitleBarRightButtons(screenInstanceId, navigatorEventId, titleBarButtons);
156
         layout.setTitleBarRightButtons(screenInstanceId, navigatorEventId, titleBarButtons);
157
+        modalController.setTitleBarRightButtons(screenInstanceId, navigatorEventId, titleBarButtons);
143
     }
158
     }
144
 
159
 
145
     public void setTitleBarLeftButton(String screenInstanceId, String navigatorEventId, TitleBarLeftButtonParams titleBarLeftButton) {
160
     public void setTitleBarLeftButton(String screenInstanceId, String navigatorEventId, TitleBarLeftButtonParams titleBarLeftButton) {
146
         layout.setTitleBarLeftButton(screenInstanceId, navigatorEventId, titleBarLeftButton);
161
         layout.setTitleBarLeftButton(screenInstanceId, navigatorEventId, titleBarLeftButton);
162
+        modalController.setTitleBarLeftButton(screenInstanceId, navigatorEventId, titleBarLeftButton);
147
     }
163
     }
148
 
164
 
149
     void showModal(ScreenParams screenParams) {
165
     void showModal(ScreenParams screenParams) {

+ 1
- 0
src/deprecated/platformSpecificDeprecated.android.js View File

266
   const rightButtons = getRightButtons(screen);
266
   const rightButtons = getRightButtons(screen);
267
   if (rightButtons) {
267
   if (rightButtons) {
268
     rightButtons.forEach(function(button) {
268
     rightButtons.forEach(function(button) {
269
+      button.enabled = !button.disabled;
269
       if (button.icon) {
270
       if (button.icon) {
270
         const icon = resolveAssetSource(button.icon);
271
         const icon = resolveAssetSource(button.icon);
271
         if (icon) {
272
         if (icon) {