Browse Source

fixed FragmentScreen

Daniel Zlotin 8 years ago
parent
commit
0d1c709203

+ 4
- 0
CHANGELOG.md View File

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.
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
 * 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.
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
 * Added redux example and optional redux support
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
 import com.reactnativenavigation.bridge.NavigationReactPackage;
9
 import com.reactnativenavigation.bridge.NavigationReactPackage;
10
 import com.reactnativenavigation.react.NavigationReactInstance;
10
 import com.reactnativenavigation.react.NavigationReactInstance;
11
 
11
 
12
-import java.util.Arrays;
12
+import java.util.ArrayList;
13
 import java.util.List;
13
 import java.util.List;
14
 
14
 
15
 public abstract class NavigationApplication extends Application {
15
 public abstract class NavigationApplication extends Application {
38
     }
38
     }
39
 
39
 
40
     public final List<ReactPackage> createReactPackages() {
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
         addAdditionalReactPackagesIfNeeded(list);
44
         addAdditionalReactPackagesIfNeeded(list);
45
         return list;
45
         return list;
46
     }
46
     }

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

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

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

2
 
2
 
3
 import android.annotation.TargetApi;
3
 import android.annotation.TargetApi;
4
 import android.app.Activity;
4
 import android.app.Activity;
5
-import android.content.Context;
6
 import android.graphics.Color;
5
 import android.graphics.Color;
7
 import android.os.Build;
6
 import android.os.Build;
7
+import android.support.v7.app.AppCompatActivity;
8
 import android.util.Log;
8
 import android.util.Log;
9
 import android.view.Window;
9
 import android.view.Window;
10
 import android.widget.RelativeLayout;
10
 import android.widget.RelativeLayout;
27
 
27
 
28
 public abstract class Screen extends RelativeLayout implements ScrollDirectionListener.OnScrollChanged {
28
 public abstract class Screen extends RelativeLayout implements ScrollDirectionListener.OnScrollChanged {
29
 
29
 
30
+    protected final AppCompatActivity activity;
30
     protected final ScreenParams screenParams;
31
     protected final ScreenParams screenParams;
31
     protected TopBar topBar;
32
     protected TopBar topBar;
32
     private final TitleBarBackButtonListener titleBarBackButtonListener;
33
     private final TitleBarBackButtonListener titleBarBackButtonListener;
33
     private VisibilityAnimator topBarVisibilityAnimator;
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
         this.screenParams = screenParams;
39
         this.screenParams = screenParams;
38
         this.titleBarBackButtonListener = titleBarBackButtonListener;
40
         this.titleBarBackButtonListener = titleBarBackButtonListener;
39
 
41
 

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

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

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

1
 package com.reactnativenavigation.screens;
1
 package com.reactnativenavigation.screens;
2
 
2
 
3
-import android.content.Context;
4
 import android.support.annotation.NonNull;
3
 import android.support.annotation.NonNull;
5
 import android.support.design.widget.TabLayout;
4
 import android.support.design.widget.TabLayout;
6
 import android.support.v4.view.PagerAdapter;
5
 import android.support.v4.view.PagerAdapter;
7
 import android.support.v4.view.ViewPager;
6
 import android.support.v4.view.ViewPager;
7
+import android.support.v7.app.AppCompatActivity;
8
 import android.view.View;
8
 import android.view.View;
9
 import android.view.ViewGroup;
9
 import android.view.ViewGroup;
10
 
10
 
24
     private ViewPager viewPager;
24
     private ViewPager viewPager;
25
     private ContentViewPagerAdapter adapter;
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
     @Override
31
     @Override

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

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