소스 검색

Merge pull request #161 from wix/modal_support

Fixes to Modal and top buttons
Guy Carmeli 8 년 전
부모
커밋
9ea0c34917

+ 20
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/Modal.java 파일 보기

@@ -10,12 +10,32 @@ import com.reactnativenavigation.layouts.Layout;
10 10
 import com.reactnativenavigation.layouts.ScreenStackContainer;
11 11
 import com.reactnativenavigation.layouts.SingleScreenLayout;
12 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 18
 public class Modal extends Dialog implements DialogInterface.OnDismissListener, ScreenStackContainer {
15 19
 
16 20
     private final AppCompatActivity activity;
17 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 39
     public interface OnModalDismissedListener {
20 40
         void onModalDismissed(Modal modal);
21 41
     }

+ 26
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/ModalController.java 파일 보기

@@ -4,7 +4,10 @@ import android.support.v7.app.AppCompatActivity;
4 4
 
5 5
 import com.reactnativenavigation.layouts.ScreenStackContainer;
6 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 11
 import java.util.Stack;
9 12
 
10 13
 public class ModalController implements ScreenStackContainer, Modal.OnModalDismissedListener {
@@ -70,4 +73,27 @@ public class ModalController implements ScreenStackContainer, Modal.OnModalDismi
70 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 파일 보기

@@ -119,31 +119,47 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
119 119
     }
120 120
 
121 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 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 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 145
     void setTopBarVisible(String screenInstanceId, boolean hidden, boolean animated) {
134 146
         layout.setTopBarVisible(screenInstanceId, hidden, animated);
147
+        modalController.setTopBarVisible(screenInstanceId, hidden, animated);
135 148
     }
136 149
 
137 150
     void setTitleBarTitle(String screenInstanceId, String title) {
138 151
         layout.setTitleBarTitle(screenInstanceId, title);
152
+        modalController.setTitleBarTitle(screenInstanceId, title);
139 153
     }
140 154
 
141 155
     public void setTitleBarButtons(String screenInstanceId, String navigatorEventId, List<TitleBarButtonParams> titleBarButtons) {
142 156
         layout.setTitleBarRightButtons(screenInstanceId, navigatorEventId, titleBarButtons);
157
+        modalController.setTitleBarRightButtons(screenInstanceId, navigatorEventId, titleBarButtons);
143 158
     }
144 159
 
145 160
     public void setTitleBarLeftButton(String screenInstanceId, String navigatorEventId, TitleBarLeftButtonParams titleBarLeftButton) {
146 161
         layout.setTitleBarLeftButton(screenInstanceId, navigatorEventId, titleBarLeftButton);
162
+        modalController.setTitleBarLeftButton(screenInstanceId, navigatorEventId, titleBarLeftButton);
147 163
     }
148 164
 
149 165
     void showModal(ScreenParams screenParams) {

+ 1
- 0
src/deprecated/platformSpecificDeprecated.android.js 파일 보기

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