Browse Source

fixed FragmentScreen

Daniel Zlotin 8 years ago
parent
commit
0d1c709203

+ 4
- 0
CHANGELOG.md View File

@@ -5,3 +5,7 @@
5 5
 * **Breaking change:** in order to handle nav button press events, you now need to register your event handler explicitly. Until now, you've just had to have `onNavigatorEvent(event)` method on your screen component. From now on, explicitly register your handler with `navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));`. A good place to do this is in your screen's constructor. See the example for an example.
6 6
 * Simplified API significantly. You now don't need to have your screen components extend `Screen`. You can leave them extending React's traditional `Component`. When you register your screen, instead of using `Navigation.registerScreen` directly, you can now use `Navigation.registerComponent`. This wrapper will wrap your regular component with a `Screen` automatically and pass the navigator instance through props. The benefit of this change is that your screen components now have *zero(!)* references to react-native-navigation. All of the changes required by this package are now purely concentrated in one place - your app bootstrap.
7 7
 * Added redux example and optional redux support
8
+
9
+### 2.0.0
10
+
11
+* Android native code redesign

+ 4
- 4
android/app/src/main/java/com/reactnativenavigation/NavigationApplication.java View File

@@ -9,7 +9,7 @@ import com.facebook.react.shell.MainReactPackage;
9 9
 import com.reactnativenavigation.bridge.NavigationReactPackage;
10 10
 import com.reactnativenavigation.react.NavigationReactInstance;
11 11
 
12
-import java.util.Arrays;
12
+import java.util.ArrayList;
13 13
 import java.util.List;
14 14
 
15 15
 public abstract class NavigationApplication extends Application {
@@ -38,9 +38,9 @@ public abstract class NavigationApplication extends Application {
38 38
     }
39 39
 
40 40
     public final List<ReactPackage> createReactPackages() {
41
-        List<ReactPackage> list = Arrays.asList(
42
-                new MainReactPackage(),
43
-                new NavigationReactPackage());
41
+        List<ReactPackage> list = new ArrayList<>();
42
+        list.add(new MainReactPackage());
43
+        list.add(new NavigationReactPackage());
44 44
         addAdditionalReactPackagesIfNeeded(list);
45 45
         return list;
46 46
     }

+ 0
- 2
android/app/src/main/java/com/reactnativenavigation/screens/FragmentScreen.java View File

@@ -22,12 +22,10 @@ public class FragmentScreen extends Screen {
22 22
 
23 23
     private static final String CONTRACT_GET_FRAGMENT = "getFragment";
24 24
     private static final String CONTRACT_GET_SUPPORT_FRAGMENT = "getSupportFragment";
25
-    private final AppCompatActivity activity;
26 25
     private FrameLayout content;
27 26
 
28 27
     public FragmentScreen(AppCompatActivity activity, ScreenParams screenParams, TitleBarBackButtonListener titleBarBackButtonListener) {
29 28
         super(activity, screenParams, titleBarBackButtonListener);
30
-        this.activity = activity;
31 29
     }
32 30
 
33 31
     @Override

+ 5
- 3
android/app/src/main/java/com/reactnativenavigation/screens/Screen.java View File

@@ -2,9 +2,9 @@ package com.reactnativenavigation.screens;
2 2
 
3 3
 import android.annotation.TargetApi;
4 4
 import android.app.Activity;
5
-import android.content.Context;
6 5
 import android.graphics.Color;
7 6
 import android.os.Build;
7
+import android.support.v7.app.AppCompatActivity;
8 8
 import android.util.Log;
9 9
 import android.view.Window;
10 10
 import android.widget.RelativeLayout;
@@ -27,13 +27,15 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
27 27
 
28 28
 public abstract class Screen extends RelativeLayout implements ScrollDirectionListener.OnScrollChanged {
29 29
 
30
+    protected final AppCompatActivity activity;
30 31
     protected final ScreenParams screenParams;
31 32
     protected TopBar topBar;
32 33
     private final TitleBarBackButtonListener titleBarBackButtonListener;
33 34
     private VisibilityAnimator topBarVisibilityAnimator;
34 35
 
35
-    public Screen(Context context, ScreenParams screenParams, TitleBarBackButtonListener titleBarBackButtonListener) {
36
-        super(context);
36
+    public Screen(AppCompatActivity activity, ScreenParams screenParams, TitleBarBackButtonListener titleBarBackButtonListener) {
37
+        super(activity);
38
+        this.activity = activity;
37 39
         this.screenParams = screenParams;
38 40
         this.titleBarBackButtonListener = titleBarBackButtonListener;
39 41
 

+ 3
- 3
android/app/src/main/java/com/reactnativenavigation/screens/SingleScreen.java View File

@@ -1,7 +1,7 @@
1 1
 package com.reactnativenavigation.screens;
2 2
 
3
-import android.content.Context;
4 3
 import android.support.annotation.NonNull;
4
+import android.support.v7.app.AppCompatActivity;
5 5
 
6 6
 import com.reactnativenavigation.params.ScreenParams;
7 7
 import com.reactnativenavigation.views.ContentView;
@@ -13,9 +13,9 @@ public class SingleScreen extends Screen {
13 13
 
14 14
     private ContentView contentView;
15 15
 
16
-    public SingleScreen(Context context, ScreenParams screenParams,
16
+    public SingleScreen(AppCompatActivity activity, ScreenParams screenParams,
17 17
                         TitleBarBackButtonListener titleBarBarBackButtonListener) {
18
-        super(context, screenParams, titleBarBarBackButtonListener);
18
+        super(activity, screenParams, titleBarBarBackButtonListener);
19 19
     }
20 20
 
21 21
     @Override

+ 3
- 3
android/app/src/main/java/com/reactnativenavigation/screens/TabbedScreen.java View File

@@ -1,10 +1,10 @@
1 1
 package com.reactnativenavigation.screens;
2 2
 
3
-import android.content.Context;
4 3
 import android.support.annotation.NonNull;
5 4
 import android.support.design.widget.TabLayout;
6 5
 import android.support.v4.view.PagerAdapter;
7 6
 import android.support.v4.view.ViewPager;
7
+import android.support.v7.app.AppCompatActivity;
8 8
 import android.view.View;
9 9
 import android.view.ViewGroup;
10 10
 
@@ -24,8 +24,8 @@ public class TabbedScreen extends Screen {
24 24
     private ViewPager viewPager;
25 25
     private ContentViewPagerAdapter adapter;
26 26
 
27
-    public TabbedScreen(Context context, ScreenParams screenParams, TitleBarBackButtonListener backButtonListener) {
28
-        super(context, screenParams, backButtonListener);
27
+    public TabbedScreen(AppCompatActivity activity, ScreenParams screenParams, TitleBarBackButtonListener backButtonListener) {
28
+        super(activity, screenParams, backButtonListener);
29 29
     }
30 30
 
31 31
     @Override

+ 2
- 2
src/deprecated/platformSpecificDeprecated.android.js View File

@@ -277,7 +277,7 @@ function getLeftButton(screen) {
277 277
     return screen.navigatorButtons.leftButton;
278 278
   }
279 279
 
280
-  return screen.leftButton
280
+  return screen.leftButton;
281 281
 }
282 282
 
283 283
 function getRightButtons(screen) {
@@ -285,7 +285,7 @@ function getRightButtons(screen) {
285 285
     return screen.navigatorButtons.rightButtons;
286 286
   }
287 287
 
288
-  return screen.rightButtons
288
+  return screen.rightButtons;
289 289
 }
290 290
 
291 291
 function addNavigationStyleParams(screen) {