浏览代码

removed old code, reenabled unit tests

Daniel Zlotin 7 年前
父节点
当前提交
ea4a0e2cf7
共有 100 个文件被更改,包括 0 次插入6906 次删除
  1. 0
    106
      lib/android/app/deprecated/java/com/reactnativenavigation/NavigationApplication.java
  2. 0
    120
      lib/android/app/deprecated/java/com/reactnativenavigation/animation/VisibilityAnimator.java
  3. 0
    76
      lib/android/app/deprecated/java/com/reactnativenavigation/bridge/BundleConverter.java
  4. 0
    41
      lib/android/app/deprecated/java/com/reactnativenavigation/bridge/EventEmitter.java
  5. 0
    41
      lib/android/app/deprecated/java/com/reactnativenavigation/bridge/NavigationReactEventEmitter.java
  6. 0
    205
      lib/android/app/deprecated/java/com/reactnativenavigation/bridge/NavigationReactModule.java
  7. 0
    31
      lib/android/app/deprecated/java/com/reactnativenavigation/bridge/NavigationReactPackage.java
  8. 0
    35
      lib/android/app/deprecated/java/com/reactnativenavigation/controllers/ActivityCallbacks.java
  9. 0
    30
      lib/android/app/deprecated/java/com/reactnativenavigation/controllers/IntentDataHandler.java
  10. 0
    4
      lib/android/app/deprecated/java/com/reactnativenavigation/controllers/LandscapeNavigationActivity.java
  11. 0
    137
      lib/android/app/deprecated/java/com/reactnativenavigation/controllers/Modal.java
  12. 0
    146
      lib/android/app/deprecated/java/com/reactnativenavigation/controllers/ModalController.java
  13. 0
    339
      lib/android/app/deprecated/java/com/reactnativenavigation/controllers/NavigationActivity.java
  14. 0
    380
      lib/android/app/deprecated/java/com/reactnativenavigation/controllers/NavigationCommandsHandler.java
  15. 0
    4
      lib/android/app/deprecated/java/com/reactnativenavigation/controllers/PortraitNavigationActivity.java
  16. 0
    69
      lib/android/app/deprecated/java/com/reactnativenavigation/controllers/SplashActivity.java
  17. 0
    9
      lib/android/app/deprecated/java/com/reactnativenavigation/events/ContextualMenuHiddenEvent.java
  18. 0
    5
      lib/android/app/deprecated/java/com/reactnativenavigation/events/Event.java
  19. 0
    49
      lib/android/app/deprecated/java/com/reactnativenavigation/events/EventBus.java
  20. 0
    18
      lib/android/app/deprecated/java/com/reactnativenavigation/events/FabSetEvent.java
  21. 0
    11
      lib/android/app/deprecated/java/com/reactnativenavigation/events/JsDevReloadEvent.java
  22. 0
    10
      lib/android/app/deprecated/java/com/reactnativenavigation/events/ModalDismissedEvent.java
  23. 0
    18
      lib/android/app/deprecated/java/com/reactnativenavigation/events/ScreenChangedEvent.java
  24. 0
    5
      lib/android/app/deprecated/java/com/reactnativenavigation/events/Subscriber.java
  25. 0
    10
      lib/android/app/deprecated/java/com/reactnativenavigation/events/ViewPagerScreenChangedEvent.java
  26. 0
    9
      lib/android/app/deprecated/java/com/reactnativenavigation/events/ViewPagerScreenScrollStartEvent.java
  27. 0
    397
      lib/android/app/deprecated/java/com/reactnativenavigation/layouts/BottomTabsLayout.java
  28. 0
    48
      lib/android/app/deprecated/java/com/reactnativenavigation/layouts/Layout.java
  29. 0
    36
      lib/android/app/deprecated/java/com/reactnativenavigation/layouts/LayoutFactory.java
  30. 0
    21
      lib/android/app/deprecated/java/com/reactnativenavigation/layouts/ModalScreenLayout.java
  31. 0
    16
      lib/android/app/deprecated/java/com/reactnativenavigation/layouts/ScreenStackContainer.java
  32. 0
    257
      lib/android/app/deprecated/java/com/reactnativenavigation/layouts/SingleScreenLayout.java
  33. 0
    16
      lib/android/app/deprecated/java/com/reactnativenavigation/params/ActivityParams.java
  34. 0
    13
      lib/android/app/deprecated/java/com/reactnativenavigation/params/AppStyle.java
  35. 0
    45
      lib/android/app/deprecated/java/com/reactnativenavigation/params/BaseScreenParams.java
  36. 0
    33
      lib/android/app/deprecated/java/com/reactnativenavigation/params/BaseTitleBarButtonParams.java
  37. 0
    15
      lib/android/app/deprecated/java/com/reactnativenavigation/params/CollapsingTopBarParams.java
  38. 0
    5
      lib/android/app/deprecated/java/com/reactnativenavigation/params/ContextualMenuButtonParams.java
  39. 0
    16
      lib/android/app/deprecated/java/com/reactnativenavigation/params/ContextualMenuParams.java
  40. 0
    10
      lib/android/app/deprecated/java/com/reactnativenavigation/params/FabActionParams.java
  41. 0
    24
      lib/android/app/deprecated/java/com/reactnativenavigation/params/FabParams.java
  42. 0
    27
      lib/android/app/deprecated/java/com/reactnativenavigation/params/NavigationParams.java
  43. 0
    6
      lib/android/app/deprecated/java/com/reactnativenavigation/params/PageParams.java
  44. 0
    19
      lib/android/app/deprecated/java/com/reactnativenavigation/params/ScreenParams.java
  45. 0
    10
      lib/android/app/deprecated/java/com/reactnativenavigation/params/SideMenuParams.java
  46. 0
    9
      lib/android/app/deprecated/java/com/reactnativenavigation/params/SnackbarParams.java
  47. 0
    79
      lib/android/app/deprecated/java/com/reactnativenavigation/params/StyleParams.java
  48. 0
    22
      lib/android/app/deprecated/java/com/reactnativenavigation/params/TitleBarButtonParams.java
  49. 0
    23
      lib/android/app/deprecated/java/com/reactnativenavigation/params/TitleBarLeftButtonParams.java
  50. 0
    36
      lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/ActivityParamsParser.java
  51. 0
    45
      lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/ButtonParser.java
  52. 0
    51
      lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/CollapsingTopBarParamsParser.java
  53. 0
    32
      lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/ContextualMenuButtonParamsParser.java
  54. 0
    16
      lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/ContextualMenuParamsParser.java
  55. 0
    18
      lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/FabActionParamsParser.java
  56. 0
    35
      lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/FabParamsParser.java
  57. 0
    44
      lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/Parser.java
  58. 0
    88
      lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/ScreenParamsParser.java
  59. 0
    29
      lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/SideMenuParamsParser.java
  60. 0
    32
      lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/SnackbarParamsParser.java
  61. 0
    221
      lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/StyleParamsParser.java
  62. 0
    55
      lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/TitleBarButtonParamsParser.java
  63. 0
    29
      lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/TitleBarLeftButtonParamsParser.java
  64. 0
    38
      lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/TopTabParamsParser.java
  65. 0
    36
      lib/android/app/deprecated/java/com/reactnativenavigation/react/ImageLoader.java
  66. 0
    37
      lib/android/app/deprecated/java/com/reactnativenavigation/react/JsDevImageLoader.java
  67. 0
    48
      lib/android/app/deprecated/java/com/reactnativenavigation/react/JsDevReloadHandler.java
  68. 0
    69
      lib/android/app/deprecated/java/com/reactnativenavigation/react/JsDevReloadListenerReplacer.java
  69. 0
    183
      lib/android/app/deprecated/java/com/reactnativenavigation/react/NavigationReactGateway.java
  70. 0
    36
      lib/android/app/deprecated/java/com/reactnativenavigation/react/ReactDevPermission.java
  71. 0
    34
      lib/android/app/deprecated/java/com/reactnativenavigation/react/ReactGateway.java
  72. 0
    56
      lib/android/app/deprecated/java/com/reactnativenavigation/react/ResourceDrawableIdHelper.java
  73. 0
    87
      lib/android/app/deprecated/java/com/reactnativenavigation/screens/CollapsingSingleScreen.java
  74. 0
    112
      lib/android/app/deprecated/java/com/reactnativenavigation/screens/CollapsingViewPagerScreen.java
  75. 0
    75
      lib/android/app/deprecated/java/com/reactnativenavigation/screens/ContentViewPagerAdapter.java
  76. 0
    131
      lib/android/app/deprecated/java/com/reactnativenavigation/screens/FragmentScreen.java
  77. 0
    250
      lib/android/app/deprecated/java/com/reactnativenavigation/screens/Screen.java
  78. 0
    99
      lib/android/app/deprecated/java/com/reactnativenavigation/screens/ScreenAnimator.java
  79. 0
    26
      lib/android/app/deprecated/java/com/reactnativenavigation/screens/ScreenFactory.java
  80. 0
    301
      lib/android/app/deprecated/java/com/reactnativenavigation/screens/ScreenStack.java
  81. 0
    47
      lib/android/app/deprecated/java/com/reactnativenavigation/screens/SingleScreen.java
  82. 0
    108
      lib/android/app/deprecated/java/com/reactnativenavigation/screens/ViewPagerScreen.java
  83. 0
    79
      lib/android/app/deprecated/java/com/reactnativenavigation/utils/KeyboardVisibilityDetector.java
  84. 0
    46
      lib/android/app/deprecated/java/com/reactnativenavigation/utils/ReflectionUtils.java
  85. 0
    5
      lib/android/app/deprecated/java/com/reactnativenavigation/utils/Task.java
  86. 0
    138
      lib/android/app/deprecated/java/com/reactnativenavigation/utils/ViewUtils.java
  87. 0
    100
      lib/android/app/deprecated/java/com/reactnativenavigation/views/BottomTabs.java
  88. 0
    18
      lib/android/app/deprecated/java/com/reactnativenavigation/views/ButtonFactory.java
  89. 0
    83
      lib/android/app/deprecated/java/com/reactnativenavigation/views/CollapsingContentView.java
  90. 0
    78
      lib/android/app/deprecated/java/com/reactnativenavigation/views/ContentView.java
  91. 0
    83
      lib/android/app/deprecated/java/com/reactnativenavigation/views/ContextualMenu.java
  92. 0
    28
      lib/android/app/deprecated/java/com/reactnativenavigation/views/ContextualMenuButton.java
  93. 0
    120
      lib/android/app/deprecated/java/com/reactnativenavigation/views/FloatingActionButtonAnimator.java
  94. 0
    237
      lib/android/app/deprecated/java/com/reactnativenavigation/views/FloatingActionButtonCoordinator.java
  95. 0
    84
      lib/android/app/deprecated/java/com/reactnativenavigation/views/LeftButton.java
  96. 0
    7
      lib/android/app/deprecated/java/com/reactnativenavigation/views/LeftButtonOnClickListener.java
  97. 0
    61
      lib/android/app/deprecated/java/com/reactnativenavigation/views/Scrim.java
  98. 0
    53
      lib/android/app/deprecated/java/com/reactnativenavigation/views/ScrollDirectionListener.java
  99. 0
    127
      lib/android/app/deprecated/java/com/reactnativenavigation/views/SideMenu.java
  100. 0
    0
      lib/android/app/deprecated/java/com/reactnativenavigation/views/SnackbarAndFabContainer.java

+ 0
- 106
lib/android/app/deprecated/java/com/reactnativenavigation/NavigationApplication.java 查看文件

@@ -1,106 +0,0 @@
1
-package com.reactnativenavigation;
2
-
3
-import android.app.Application;
4
-import android.os.Handler;
5
-import android.support.annotation.Nullable;
6
-
7
-import com.facebook.react.ReactApplication;
8
-import com.facebook.react.ReactNativeHost;
9
-import com.facebook.react.ReactPackage;
10
-import com.facebook.react.bridge.ReactContext;
11
-import com.reactnativenavigation.bridge.EventEmitter;
12
-import com.reactnativenavigation.controllers.ActivityCallbacks;
13
-import com.reactnativenavigation.react.NavigationReactGateway;
14
-import com.reactnativenavigation.react.ReactGateway;
15
-
16
-import java.util.List;
17
-
18
-public abstract class NavigationApplication extends Application implements ReactApplication {
19
-
20
-    public static NavigationApplication instance;
21
-
22
-    private NavigationReactGateway reactGateway;
23
-    private EventEmitter eventEmitter;
24
-    private Handler handler;
25
-    private ActivityCallbacks activityCallbacks;
26
-
27
-    @Override
28
-    public void onCreate() {
29
-        super.onCreate();
30
-        instance = this;
31
-        handler = new Handler(getMainLooper());
32
-        reactGateway = new NavigationReactGateway();
33
-        eventEmitter = new EventEmitter(reactGateway);
34
-        activityCallbacks = new ActivityCallbacks();
35
-    }
36
-
37
-    public void startReactContextOnceInBackgroundAndExecuteJS() {
38
-        reactGateway.startReactContextOnceInBackgroundAndExecuteJS();
39
-    }
40
-
41
-    public void runOnMainThread(Runnable runnable) {
42
-        handler.post(runnable);
43
-    }
44
-
45
-    public void runOnMainThread(Runnable runnable, long delay) {
46
-        handler.postDelayed(runnable, delay);
47
-    }
48
-
49
-    public ReactGateway getReactGateway() {
50
-        return reactGateway;
51
-    }
52
-
53
-    public ActivityCallbacks getActivityCallbacks() {
54
-        return activityCallbacks;
55
-    }
56
-
57
-    protected void setActivityCallbacks(ActivityCallbacks activityLifecycleCallbacks) {
58
-        this.activityCallbacks = activityLifecycleCallbacks;
59
-    }
60
-
61
-    public boolean isReactContextInitialized() {
62
-        return reactGateway.isInitialized();
63
-    }
64
-
65
-    public void onReactInitialized(ReactContext reactContext) {
66
-        // nothing
67
-    }
68
-
69
-    @Override
70
-    public ReactNativeHost getReactNativeHost() {
71
-        return reactGateway.getReactNativeHost();
72
-    }
73
-
74
-    public EventEmitter getEventEmitter() {
75
-        return eventEmitter;
76
-    }
77
-
78
-    /**
79
-     * @see ReactNativeHost#getJSMainModuleName()
80
-     */
81
-    @Nullable
82
-    public String getJSMainModuleName() {
83
-        return null;
84
-    }
85
-
86
-    /**
87
-     * @see ReactNativeHost#getJSBundleFile()
88
-     */
89
-    @Nullable
90
-    public String getJSBundleFile() {
91
-        return null;
92
-    }
93
-
94
-    /**
95
-     * @see ReactNativeHost#getBundleAssetName()
96
-     */
97
-    @Nullable
98
-    public String getBundleAssetName() {
99
-        return null;
100
-    }
101
-
102
-    public abstract boolean isDebug();
103
-
104
-    @Nullable
105
-    public abstract List<ReactPackage> createAdditionalReactPackages();
106
-}

+ 0
- 120
lib/android/app/deprecated/java/com/reactnativenavigation/animation/VisibilityAnimator.java 查看文件

@@ -1,120 +0,0 @@
1
-package com.reactnativenavigation.animation;
2
-
3
-import android.animation.Animator;
4
-import android.animation.AnimatorListenerAdapter;
5
-import android.animation.ObjectAnimator;
6
-import android.support.v4.view.animation.LinearOutSlowInInterpolator;
7
-import android.view.View;
8
-
9
-import com.reactnativenavigation.views.ScrollDirectionListener;
10
-
11
-public class VisibilityAnimator {
12
-
13
-    public enum HideDirection {
14
-        Up, Down
15
-    }
16
-
17
-    private enum VisibilityState {
18
-        Hidden, AnimateHide, Shown, AnimateShow
19
-    }
20
-
21
-    private static final int SHOW_END_VALUE = 0;
22
-    private static final int DURATION = 300;
23
-
24
-    private final View view;
25
-    private final HideDirection hideDirection;
26
-    private final int hiddenEndValue;
27
-    private VisibilityState visibilityState = VisibilityState.Shown;
28
-
29
-    public VisibilityAnimator(View view, HideDirection hideDirection, int height) {
30
-        this.view = view;
31
-        this.hideDirection = hideDirection;
32
-        this.hiddenEndValue = hideDirection == HideDirection.Up ? -height : height;
33
-    }
34
-
35
-    public void onScrollChanged(ScrollDirectionListener.Direction scrollDirection) {
36
-        if (hideDirection == HideDirection.Down) {
37
-            handleDownHidingViews(scrollDirection);
38
-        } else {
39
-            handleUpHidingViews(scrollDirection);
40
-        }
41
-    }
42
-
43
-    public void setVisible(boolean visible, boolean animate) {
44
-        if (visible && isHiding()) {
45
-            show(animate);
46
-        } else if (!visible && isShowing()) {
47
-            hide(animate);
48
-        }
49
-    }
50
-
51
-    private void handleUpHidingViews(ScrollDirectionListener.Direction scrollDirection) {
52
-        if (scrollUp(scrollDirection) && !isShowing()) {
53
-            show(true);
54
-        } else if (scrollDown(scrollDirection) && !isHiding()) {
55
-            hide(true);
56
-        }
57
-    }
58
-
59
-    private void handleDownHidingViews(ScrollDirectionListener.Direction scrollDirection) {
60
-        if (scrollDown(scrollDirection) && !isHiding()) {
61
-            hide(true);
62
-        } else if (scrollUp(scrollDirection) && !isShowing()) {
63
-            show(true);
64
-        }
65
-    }
66
-
67
-    private void show(boolean animate) {
68
-        if (animate) {
69
-            ObjectAnimator animator = createAnimator(true);
70
-            animator.start();
71
-        } else {
72
-            visibilityState = VisibilityState.Shown;
73
-            view.setVisibility(View.VISIBLE);
74
-        }
75
-    }
76
-
77
-    private void hide(boolean animate) {
78
-        if (animate) {
79
-            ObjectAnimator animator = createAnimator(false);
80
-            animator.start();
81
-        } else {
82
-            visibilityState = VisibilityState.Hidden;
83
-            view.setVisibility(View.GONE);
84
-        }
85
-    }
86
-
87
-    private boolean scrollUp(ScrollDirectionListener.Direction scrollDirection) {
88
-        return scrollDirection == ScrollDirectionListener.Direction.Up;
89
-    }
90
-
91
-    private boolean scrollDown(ScrollDirectionListener.Direction scrollDirection) {
92
-        return scrollDirection == ScrollDirectionListener.Direction.Down;
93
-    }
94
-
95
-    private boolean isShowing() {
96
-        return visibilityState == VisibilityState.Shown || visibilityState == VisibilityState.AnimateShow;
97
-    }
98
-
99
-    private boolean isHiding() {
100
-        return visibilityState == VisibilityState.Hidden || visibilityState == VisibilityState.AnimateHide;
101
-    }
102
-
103
-    private ObjectAnimator createAnimator(final boolean show) {
104
-        ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, show ? SHOW_END_VALUE : hiddenEndValue);
105
-        animator.setDuration(DURATION);
106
-        animator.setInterpolator(new LinearOutSlowInInterpolator());
107
-        animator.addListener(new AnimatorListenerAdapter() {
108
-            @Override
109
-            public void onAnimationStart(Animator animation) {
110
-                visibilityState = show ? VisibilityState.AnimateShow : VisibilityState.AnimateHide;
111
-            }
112
-
113
-            @Override
114
-            public void onAnimationEnd(Animator animation) {
115
-                visibilityState = show ? VisibilityState.Shown : VisibilityState.Hidden;
116
-            }
117
-        });
118
-        return animator;
119
-    }
120
-}

+ 0
- 76
lib/android/app/deprecated/java/com/reactnativenavigation/bridge/BundleConverter.java 查看文件

@@ -1,76 +0,0 @@
1
-package com.reactnativenavigation.bridge;
2
-
3
-import android.os.Bundle;
4
-
5
-import com.facebook.react.bridge.ReadableArray;
6
-import com.facebook.react.bridge.ReadableMap;
7
-import com.facebook.react.bridge.ReadableMapKeySetIterator;
8
-
9
-public class BundleConverter {
10
-    public static Bundle toBundle(ReadableMap map) {
11
-        Bundle bundle = new Bundle();
12
-        ReadableMapKeySetIterator it = map.keySetIterator();
13
-        while (it.hasNextKey()) {
14
-            String key = it.nextKey();
15
-            switch (map.getType(key)) {
16
-                case Null:
17
-                    break;
18
-                case Boolean:
19
-                    bundle.putBoolean(key, map.getBoolean(key));
20
-                    break;
21
-                case Number:
22
-                    putNumber(bundle, map, key);
23
-                    break;
24
-                case String:
25
-                    bundle.putString(key, map.getString(key));
26
-                    break;
27
-                case Map:
28
-                    bundle.putBundle(key, toBundle(map.getMap(key)));
29
-                    break;
30
-                case Array:
31
-                    bundle.putBundle(key, toBundle(map.getArray(key)));
32
-                    break;
33
-                default:
34
-                    break;
35
-            }
36
-        }
37
-        return bundle;
38
-    }
39
-
40
-    private static void putNumber(Bundle bundle, ReadableMap map, String key) {
41
-        try {
42
-            bundle.putInt(key, map.getInt(key));
43
-        } catch (Exception e) {
44
-            bundle.putDouble(key, map.getDouble(key));
45
-        }
46
-    }
47
-
48
-    public static Bundle toBundle(ReadableArray array) {
49
-        Bundle bundle = new Bundle();
50
-        for (int i = 0; i < array.size(); i++) {
51
-            String key = String.valueOf(i);
52
-            switch (array.getType(i)) {
53
-                case Null:
54
-                    break;
55
-                case Boolean:
56
-                    bundle.putBoolean(key, array.getBoolean(i));
57
-                    break;
58
-                case Number:
59
-                    bundle.putDouble(key, array.getDouble(i));
60
-                    break;
61
-                case String:
62
-                    bundle.putString(key, array.getString(i));
63
-                    break;
64
-                case Map:
65
-                    bundle.putBundle(key, toBundle(array.getMap(i)));
66
-                    break;
67
-                case Array:
68
-                    bundle.putBundle(key, toBundle(array.getArray(i)));
69
-                    break;
70
-                default:
71
-                    break;
72
-            }
73
-        }
74
-        return bundle;
75
-    }
76
-}

+ 0
- 41
lib/android/app/deprecated/java/com/reactnativenavigation/bridge/EventEmitter.java 查看文件

@@ -1,41 +0,0 @@
1
-package com.reactnativenavigation.bridge;
2
-
3
-import com.facebook.react.bridge.WritableMap;
4
-import com.reactnativenavigation.NavigationApplication;
5
-import com.reactnativenavigation.react.ReactGateway;
6
-
7
-public class EventEmitter {
8
-    private ReactGateway reactGateway;
9
-
10
-    public EventEmitter(ReactGateway reactGateway) {
11
-        this.reactGateway = reactGateway;
12
-    }
13
-
14
-    public void sendNavigatorEvent(String eventId, String navigatorEventId) {
15
-        if (!NavigationApplication.instance.isReactContextInitialized()) {
16
-            return;
17
-        }
18
-        reactGateway.getReactEventEmitter().sendNavigatorEvent(eventId, navigatorEventId);
19
-    }
20
-
21
-    public void sendNavigatorEvent(String eventId, String navigatorEventId, WritableMap data) {
22
-        if (!NavigationApplication.instance.isReactContextInitialized()) {
23
-            return;
24
-        }
25
-        reactGateway.getReactEventEmitter().sendNavigatorEvent(eventId, navigatorEventId, data);
26
-    }
27
-
28
-    public void sendEvent(String eventId, String navigatorEventId) {
29
-        if (!NavigationApplication.instance.isReactContextInitialized()) {
30
-            return;
31
-        }
32
-        reactGateway.getReactEventEmitter().sendEvent(eventId, navigatorEventId);
33
-    }
34
-
35
-    public void sendNavigatorEvent(String eventId, WritableMap arguments) {
36
-        if (!NavigationApplication.instance.isReactContextInitialized()) {
37
-            return;
38
-        }
39
-        reactGateway.getReactEventEmitter().sendEvent(eventId, arguments);
40
-    }
41
-}

+ 0
- 41
lib/android/app/deprecated/java/com/reactnativenavigation/bridge/NavigationReactEventEmitter.java 查看文件

@@ -1,41 +0,0 @@
1
-package com.reactnativenavigation.bridge;
2
-
3
-import com.facebook.react.bridge.Arguments;
4
-import com.facebook.react.bridge.ReactContext;
5
-import com.facebook.react.bridge.WritableMap;
6
-import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
7
-
8
-public class NavigationReactEventEmitter {
9
-
10
-    private static final String KEY_EVENT_ID = "id";
11
-    private static final String KEY_EVENT_TYPE = "type";
12
-    private static final String KEY_NAVIGATOR_EVENT_ID = "navigatorEventID";
13
-    private static final String EVENT_TYPE = "NavBarButtonPress";
14
-    private RCTDeviceEventEmitter eventEmitter;
15
-
16
-    public NavigationReactEventEmitter(ReactContext reactContext) {
17
-        this.eventEmitter = reactContext.getJSModule(RCTDeviceEventEmitter.class);
18
-    }
19
-
20
-    public void sendNavigatorEvent(String eventId, String navigatorEventId) {
21
-        WritableMap data = Arguments.createMap();
22
-        data.putString(KEY_EVENT_TYPE, EVENT_TYPE);
23
-        data.putString(KEY_EVENT_ID, eventId);
24
-        data.putString(KEY_NAVIGATOR_EVENT_ID, navigatorEventId);
25
-        eventEmitter.emit(navigatorEventId, data);
26
-    }
27
-
28
-    public void sendNavigatorEvent(String eventId, String navigatorEventId, WritableMap data) {
29
-        data.putString(KEY_NAVIGATOR_EVENT_ID, navigatorEventId);
30
-        data.putString(KEY_EVENT_ID, eventId);
31
-        eventEmitter.emit(navigatorEventId, data);
32
-    }
33
-
34
-    public void sendEvent(String eventId, String data) {
35
-        eventEmitter.emit(eventId, data);
36
-    }
37
-
38
-    public void sendEvent(String eventId, WritableMap data) {
39
-        eventEmitter.emit(eventId, data);
40
-    }
41
-}

+ 0
- 205
lib/android/app/deprecated/java/com/reactnativenavigation/bridge/NavigationReactModule.java 查看文件

@@ -1,205 +0,0 @@
1
-package com.reactnativenavigation.bridge;
2
-
3
-import com.facebook.react.bridge.Callback;
4
-import com.facebook.react.bridge.ReactApplicationContext;
5
-import com.facebook.react.bridge.ReactContextBaseJavaModule;
6
-import com.facebook.react.bridge.ReactMethod;
7
-import com.facebook.react.bridge.ReadableArray;
8
-import com.facebook.react.bridge.ReadableMap;
9
-import com.reactnativenavigation.controllers.NavigationCommandsHandler;
10
-import com.reactnativenavigation.params.ContextualMenuParams;
11
-import com.reactnativenavigation.params.FabParams;
12
-import com.reactnativenavigation.params.SnackbarParams;
13
-import com.reactnativenavigation.params.TitleBarButtonParams;
14
-import com.reactnativenavigation.params.TitleBarLeftButtonParams;
15
-import com.reactnativenavigation.params.parsers.ContextualMenuParamsParser;
16
-import com.reactnativenavigation.params.parsers.FabParamsParser;
17
-import com.reactnativenavigation.params.parsers.SnackbarParamsParser;
18
-import com.reactnativenavigation.params.parsers.TitleBarButtonParamsParser;
19
-import com.reactnativenavigation.params.parsers.TitleBarLeftButtonParamsParser;
20
-import com.reactnativenavigation.views.SideMenu.Side;
21
-
22
-import java.util.List;
23
-
24
-/**
25
- * The basic abstract components we will expose:
26
- * BottomTabs (app) - boolean
27
- * TopBar (per screen)
28
- * - TitleBar
29
- * - - RightButtons
30
- * - - LeftButton
31
- * - TopTabs (segmented control / view pager tabs)
32
- * DeviceStatusBar (app) (colors are per screen)
33
- * AndroidNavigationBar (app) (colors are per screen)
34
- * SideMenu (app) - boolean, (menu icon is screen-based)
35
- */
36
-public class NavigationReactModule extends ReactContextBaseJavaModule {
37
-    public static final String NAME = "NavigationReactModule";
38
-
39
-    public NavigationReactModule(ReactApplicationContext reactContext) {
40
-        super(reactContext);
41
-    }
42
-
43
-    @Override
44
-    public String getName() {
45
-        return NAME;
46
-    }
47
-
48
-    @ReactMethod
49
-    public void startApp(final ReadableMap params) {
50
-        boolean portraitOnlyMode = false;
51
-        boolean landscapeOnlyMode = false;
52
-
53
-        if (params.hasKey("portraitOnlyMode")) {
54
-            portraitOnlyMode = params.getBoolean("portraitOnlyMode");
55
-        }
56
-
57
-        if (params.hasKey(("landscapeOnlyMode"))) {
58
-            landscapeOnlyMode = params.getBoolean("landscapeOnlyMode");
59
-        }
60
-
61
-        NavigationCommandsHandler.startApp(BundleConverter.toBundle(params), portraitOnlyMode, landscapeOnlyMode);
62
-    }
63
-
64
-    @ReactMethod
65
-    public void setScreenTitleBarTitle(String screenInstanceId, String title) {
66
-        NavigationCommandsHandler.setScreenTitleBarTitle(screenInstanceId, title);
67
-    }
68
-
69
-    @ReactMethod
70
-    public void setScreenTitleBarSubtitle(String screenInstanceId, String subtitle) {
71
-        NavigationCommandsHandler.setScreenTitleBarSubtitle(screenInstanceId, subtitle);
72
-    }
73
-
74
-    @ReactMethod
75
-    public void setScreenButtons(String screenInstanceId, String navigatorEventId,
76
-                                 ReadableArray rightButtonsParams, ReadableMap leftButtonParams, ReadableMap fab) {
77
-        if (rightButtonsParams != null) {
78
-            setScreenTitleBarRightButtons(screenInstanceId, navigatorEventId, rightButtonsParams);
79
-        }
80
-        if (leftButtonParams != null) {
81
-            setScreenTitleBarLeftButton(screenInstanceId, navigatorEventId, leftButtonParams);
82
-        }
83
-        if (fab != null) {
84
-            setScreenFab(screenInstanceId, navigatorEventId, fab);
85
-        }
86
-    }
87
-
88
-    private void setScreenTitleBarRightButtons(String screenInstanceId, String navigatorEventId, ReadableArray rightButtonsParams) {
89
-        List<TitleBarButtonParams> rightButtons = new TitleBarButtonParamsParser()
90
-                .parseButtons(BundleConverter.toBundle(rightButtonsParams));
91
-        NavigationCommandsHandler.setScreenTitleBarRightButtons(screenInstanceId, navigatorEventId, rightButtons);
92
-    }
93
-
94
-    private void setScreenTitleBarLeftButton(String screenInstanceId, String navigatorEventId, ReadableMap leftButtonParams) {
95
-        TitleBarLeftButtonParams leftButton = new TitleBarLeftButtonParamsParser()
96
-                .parseSingleButton(BundleConverter.toBundle(leftButtonParams));
97
-        NavigationCommandsHandler.setScreenTitleBarLeftButtons(screenInstanceId, navigatorEventId, leftButton);
98
-    }
99
-
100
-    private void setScreenFab(String screenInstanceId, String navigatorEventId, ReadableMap fab) {
101
-        FabParams fabParams = new FabParamsParser().parse(BundleConverter.toBundle(fab), navigatorEventId, screenInstanceId);
102
-        NavigationCommandsHandler.setScreenFab(screenInstanceId, navigatorEventId, fabParams);
103
-    }
104
-
105
-    @ReactMethod
106
-    public void setBottomTabBadgeByIndex(Integer index, String badge) {
107
-        NavigationCommandsHandler.setBottomTabBadgeByIndex(index, badge);
108
-    }
109
-
110
-    @ReactMethod
111
-    public void setBottomTabBadgeByNavigatorId(String navigatorId, String badge) {
112
-        NavigationCommandsHandler.setBottomTabBadgeByNavigatorId(navigatorId, badge);
113
-    }
114
-
115
-    @ReactMethod
116
-    public void selectBottomTabByTabIndex(Integer index) {
117
-        NavigationCommandsHandler.selectBottomTabByTabIndex(index);
118
-    }
119
-
120
-    @ReactMethod
121
-    public void selectBottomTabByNavigatorId(String navigatorId) {
122
-        NavigationCommandsHandler.selectBottomTabByNavigatorId(navigatorId);
123
-    }
124
-
125
-    @ReactMethod
126
-    public void toggleSideMenuVisible(boolean animated, String side) {
127
-        NavigationCommandsHandler.toggleSideMenuVisible(animated, Side.fromString(side));
128
-    }
129
-
130
-    @ReactMethod
131
-    public void setSideMenuVisible(boolean animated, boolean visible, String side) {
132
-        NavigationCommandsHandler.setSideMenuVisible(animated, visible, Side.fromString(side));
133
-    }
134
-
135
-    @ReactMethod
136
-    public void toggleTopBarVisible(final ReadableMap params) {
137
-    }
138
-
139
-    @ReactMethod
140
-    public void setTopBarVisible(String screenInstanceId, boolean hidden, boolean animated) {
141
-        NavigationCommandsHandler.setTopBarVisible(screenInstanceId, hidden, animated);
142
-    }
143
-
144
-    @ReactMethod
145
-    public void toggleBottomTabsVisible(final ReadableMap params) {
146
-    }
147
-
148
-    @ReactMethod
149
-    public void setBottomTabsVisible(boolean hidden, boolean animated) {
150
-        NavigationCommandsHandler.setBottomTabsVisible(hidden, animated);
151
-    }
152
-
153
-    @ReactMethod
154
-    public void push(final ReadableMap params) {
155
-        NavigationCommandsHandler.push(BundleConverter.toBundle(params));
156
-    }
157
-
158
-    @ReactMethod
159
-    public void pop(final ReadableMap params) {
160
-        NavigationCommandsHandler.pop(BundleConverter.toBundle(params));
161
-    }
162
-
163
-    @ReactMethod
164
-    public void popToRoot(final ReadableMap params) {
165
-        NavigationCommandsHandler.popToRoot(BundleConverter.toBundle(params));
166
-    }
167
-
168
-    @ReactMethod
169
-    public void newStack(final ReadableMap params) {
170
-        NavigationCommandsHandler.newStack(BundleConverter.toBundle(params));
171
-    }
172
-
173
-    @ReactMethod
174
-    public void showModal(final ReadableMap params) {
175
-        NavigationCommandsHandler.showModal(BundleConverter.toBundle(params));
176
-    }
177
-
178
-    @ReactMethod
179
-    public void dismissAllModals() {
180
-        NavigationCommandsHandler.dismissAllModals();
181
-    }
182
-
183
-    @ReactMethod
184
-    public void dismissTopModal() {
185
-        NavigationCommandsHandler.dismissTopModal();
186
-    }
187
-
188
-    @ReactMethod
189
-    public void showSnackbar(final ReadableMap params) {
190
-        SnackbarParams snackbarParams = new SnackbarParamsParser().parse(BundleConverter.toBundle(params));
191
-        NavigationCommandsHandler.showSnackbar(snackbarParams);
192
-    }
193
-
194
-    @ReactMethod
195
-    public void showContextualMenu(final String screenInstanceId, final ReadableMap params, final Callback onButtonClicked) {
196
-        ContextualMenuParams contextualMenuParams =
197
-                new ContextualMenuParamsParser().parse(BundleConverter.toBundle(params));
198
-        NavigationCommandsHandler.showContextualMenu(screenInstanceId, contextualMenuParams, onButtonClicked);
199
-    }
200
-
201
-    @ReactMethod
202
-    public void dismissContextualMenu(String screenInstanceId) {
203
-        NavigationCommandsHandler.dismissContextualMenu(screenInstanceId);
204
-    }
205
-}

+ 0
- 31
lib/android/app/deprecated/java/com/reactnativenavigation/bridge/NavigationReactPackage.java 查看文件

@@ -1,31 +0,0 @@
1
-package com.reactnativenavigation.bridge;
2
-
3
-import com.facebook.react.ReactPackage;
4
-import com.facebook.react.bridge.JavaScriptModule;
5
-import com.facebook.react.bridge.NativeModule;
6
-import com.facebook.react.bridge.ReactApplicationContext;
7
-import com.facebook.react.uimanager.ViewManager;
8
-
9
-import java.util.Arrays;
10
-import java.util.Collections;
11
-import java.util.List;
12
-
13
-public class NavigationReactPackage implements ReactPackage {
14
-
15
-    @Override
16
-    public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
17
-        return Arrays.<NativeModule>asList(
18
-                new NavigationReactModule(reactContext)
19
-        );
20
-    }
21
-
22
-    @Override
23
-    public List<Class<? extends JavaScriptModule>> createJSModules() {
24
-        return Collections.emptyList();
25
-    }
26
-
27
-    @Override
28
-    public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
29
-        return Collections.emptyList();
30
-    }
31
-}

+ 0
- 35
lib/android/app/deprecated/java/com/reactnativenavigation/controllers/ActivityCallbacks.java 查看文件

@@ -1,35 +0,0 @@
1
-package com.reactnativenavigation.controllers;
2
-
3
-import android.app.Activity;
4
-import android.content.Intent;
5
-import android.os.Bundle;
6
-
7
-public class ActivityCallbacks {
8
-    public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
9
-
10
-    }
11
-
12
-    public void onActivityStarted(Activity activity) {
13
-
14
-    }
15
-
16
-    public void onActivityResumed(Activity activity) {
17
-
18
-    }
19
-
20
-    public void onActivityPaused(Activity activity) {
21
-
22
-    }
23
-
24
-    public void onActivityStopped(Activity activity) {
25
-
26
-    }
27
-
28
-    public void onActivityResult(int requestCode, int resultCode, Intent data) {
29
-
30
-    }
31
-
32
-    public void onActivityDestroyed(Activity activity) {
33
-
34
-    }
35
-}

+ 0
- 30
lib/android/app/deprecated/java/com/reactnativenavigation/controllers/IntentDataHandler.java 查看文件

@@ -1,30 +0,0 @@
1
-package com.reactnativenavigation.controllers;
2
-
3
-import android.content.Intent;
4
-
5
-import static android.content.Intent.ACTION_VIEW;
6
-
7
-public class IntentDataHandler {
8
-    private static Intent intent;
9
-
10
-    static void saveIntentData(Intent intent) {
11
-        IntentDataHandler.intent = intent;
12
-    }
13
-
14
-    static boolean hasIntentData() {
15
-        return intent != null;
16
-    }
17
-
18
-    static void setIntentData(Intent intent) {
19
-        if (IntentDataHandler.intent != null) {
20
-            intent.setData(IntentDataHandler.intent.getData());
21
-            intent.putExtras(IntentDataHandler.intent);
22
-            intent.setAction(ACTION_VIEW);
23
-            clear();
24
-        }
25
-    }
26
-
27
-    private static void clear() {
28
-        intent = null;
29
-    }
30
-}

+ 0
- 4
lib/android/app/deprecated/java/com/reactnativenavigation/controllers/LandscapeNavigationActivity.java 查看文件

@@ -1,4 +0,0 @@
1
-package com.reactnativenavigation.controllers;
2
-
3
-public class LandscapeNavigationActivity extends NavigationActivity {
4
-}

+ 0
- 137
lib/android/app/deprecated/java/com/reactnativenavigation/controllers/Modal.java 查看文件

@@ -1,137 +0,0 @@
1
-package com.reactnativenavigation.controllers;
2
-
3
-import android.app.Dialog;
4
-import android.content.DialogInterface;
5
-import android.support.v7.app.AppCompatActivity;
6
-import android.view.Window;
7
-import android.view.WindowManager;
8
-
9
-import com.facebook.react.bridge.Callback;
10
-import com.reactnativenavigation.R;
11
-import com.reactnativenavigation.layouts.Layout;
12
-import com.reactnativenavigation.layouts.ModalScreenLayout;
13
-import com.reactnativenavigation.layouts.ScreenStackContainer;
14
-import com.reactnativenavigation.params.ContextualMenuParams;
15
-import com.reactnativenavigation.params.ScreenParams;
16
-import com.reactnativenavigation.params.TitleBarButtonParams;
17
-import com.reactnativenavigation.params.TitleBarLeftButtonParams;
18
-
19
-import java.util.List;
20
-
21
-public class Modal extends Dialog implements DialogInterface.OnDismissListener, ScreenStackContainer {
22
-
23
-    private final AppCompatActivity activity;
24
-    private final OnModalDismissedListener onModalDismissedListener;
25
-    private final ScreenParams screenParams;
26
-    private Layout layout;
27
-
28
-    public void setTopBarVisible(String screenInstanceId, boolean hidden, boolean animated) {
29
-        layout.setTopBarVisible(screenInstanceId, hidden, animated);
30
-    }
31
-
32
-    void setTitleBarTitle(String screenInstanceId, String title) {
33
-        layout.setTitleBarTitle(screenInstanceId, title);
34
-    }
35
-
36
-    void setTitleBarSubtitle(String screenInstanceId, String subtitle) {
37
-        layout.setTitleBarSubtitle(screenInstanceId, subtitle);
38
-    }
39
-
40
-    void setTitleBarRightButtons(String screenInstanceId, String navigatorEventId, List<TitleBarButtonParams> titleBarButtons) {
41
-        layout.setTitleBarRightButtons(screenInstanceId, navigatorEventId, titleBarButtons);
42
-    }
43
-
44
-    public void setTitleBarLeftButton(String screenInstanceId, String navigatorEventId, TitleBarLeftButtonParams titleBarLeftButton) {
45
-        layout.setTitleBarLeftButton(screenInstanceId, navigatorEventId, titleBarLeftButton);
46
-    }
47
-
48
-    public void showContextualMenu(String screenInstanceId, ContextualMenuParams params, Callback onButtonClicked) {
49
-        layout.showContextualMenu(screenInstanceId, params, onButtonClicked);
50
-    }
51
-
52
-    public void dismissContextualMenu(String screenInstanceId) {
53
-        layout.dismissContextualMenu(screenInstanceId);
54
-    }
55
-
56
-    @Override
57
-    public boolean onTitleBarBackButtonClick() {
58
-        if (!layout.onBackPressed()) {
59
-            onBackPressed();
60
-        }
61
-        return true;
62
-    }
63
-
64
-    public void onSideMenuButtonClick() {
65
-    }
66
-
67
-    interface OnModalDismissedListener {
68
-        void onModalDismissed(Modal modal);
69
-    }
70
-
71
-    public Modal(AppCompatActivity activity, OnModalDismissedListener onModalDismissedListener, ScreenParams screenParams) {
72
-        super(activity, R.style.Modal);
73
-        this.activity = activity;
74
-        this.onModalDismissedListener = onModalDismissedListener;
75
-        this.screenParams = screenParams;
76
-        createContent();
77
-    }
78
-
79
-    public AppCompatActivity getActivity() {
80
-        return activity;
81
-    }
82
-
83
-    private void createContent() {
84
-        setCancelable(true);
85
-        setOnDismissListener(this);
86
-        requestWindowFeature(Window.FEATURE_NO_TITLE);
87
-        layout = new ModalScreenLayout(getActivity(), screenParams, this);
88
-        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
89
-        setContentView(layout.asView());
90
-    }
91
-
92
-    @Override
93
-    public void push(ScreenParams params) {
94
-        layout.push(params);
95
-    }
96
-
97
-    @Override
98
-    public void pop(ScreenParams screenParams) {
99
-        layout.pop(screenParams);
100
-    }
101
-
102
-    @Override
103
-    public void popToRoot(ScreenParams params) {
104
-        layout.popToRoot(params);
105
-    }
106
-
107
-    @Override
108
-    public void newStack(ScreenParams params) {
109
-        layout.newStack(params);
110
-    }
111
-
112
-    public boolean containsNavigator(String navigatorId) {
113
-        return layout.containsNavigator(navigatorId);
114
-    }
115
-
116
-    @Override
117
-    public void destroy() {
118
-        layout.destroy();
119
-    }
120
-
121
-    @Override
122
-    public void onBackPressed() {
123
-        if (!layout.onBackPressed()) {
124
-            super.onBackPressed();
125
-        }
126
-    }
127
-
128
-    @Override
129
-    public void onDismiss(DialogInterface dialog) {
130
-        destroy();
131
-        onModalDismissedListener.onModalDismissed(this);
132
-    }
133
-
134
-    void onModalDismissed() {
135
-        layout.onModalDismissed();
136
-    }
137
-}

+ 0
- 146
lib/android/app/deprecated/java/com/reactnativenavigation/controllers/ModalController.java 查看文件

@@ -1,146 +0,0 @@
1
-package com.reactnativenavigation.controllers;
2
-
3
-import android.support.v7.app.AppCompatActivity;
4
-
5
-import com.facebook.react.bridge.Callback;
6
-import com.reactnativenavigation.events.EventBus;
7
-import com.reactnativenavigation.events.ModalDismissedEvent;
8
-import com.reactnativenavigation.layouts.ScreenStackContainer;
9
-import com.reactnativenavigation.params.ContextualMenuParams;
10
-import com.reactnativenavigation.params.ScreenParams;
11
-import com.reactnativenavigation.params.TitleBarButtonParams;
12
-import com.reactnativenavigation.params.TitleBarLeftButtonParams;
13
-
14
-import java.util.List;
15
-import java.util.Stack;
16
-
17
-public class ModalController implements ScreenStackContainer, Modal.OnModalDismissedListener {
18
-    private final AppCompatActivity activity;
19
-    private Stack<Modal> stack = new Stack<>();
20
-
21
-    public ModalController(AppCompatActivity activity) {
22
-        this.activity = activity;
23
-    }
24
-
25
-    public boolean containsNavigator(String navigatorId) {
26
-        for (Modal modal : stack) {
27
-            if (modal.containsNavigator(navigatorId)) {
28
-                return true;
29
-            }
30
-        }
31
-        return false;
32
-    }
33
-
34
-    public void showModal(ScreenParams screenParams) {
35
-        Modal modal = new Modal(activity, this, screenParams);
36
-        modal.show();
37
-        stack.add(modal);
38
-    }
39
-
40
-    public void dismissTopModal() {
41
-        if (isShowing()) {
42
-            stack.pop().dismiss();
43
-        }
44
-    }
45
-
46
-    public void dismissAllModals() {
47
-        for (Modal modal : stack) {
48
-            modal.dismiss();
49
-        }
50
-        stack.clear();
51
-    }
52
-
53
-    public boolean isShowing() {
54
-        return !stack.empty();
55
-    }
56
-
57
-    public void push(ScreenParams params) {
58
-        stack.peek().push(params);
59
-    }
60
-
61
-    @Override
62
-    public void pop(ScreenParams screenParams) {
63
-        stack.peek().pop(screenParams);
64
-    }
65
-
66
-    @Override
67
-    public void popToRoot(ScreenParams params) {
68
-        stack.peek().popToRoot(params);
69
-    }
70
-
71
-    @Override
72
-    public void newStack(ScreenParams params) {
73
-        stack.peek().newStack(params);
74
-    }
75
-
76
-    @Override
77
-    public void destroy() {
78
-        for (Modal modal : stack) {
79
-            modal.destroy();
80
-            modal.dismiss();
81
-        }
82
-        stack.clear();
83
-    }
84
-
85
-    @Override
86
-    public void onModalDismissed(Modal modal) {
87
-        stack.remove(modal);
88
-        if (isShowing()) {
89
-            stack.peek().onModalDismissed();
90
-        }
91
-        EventBus.instance.post(new ModalDismissedEvent());
92
-    }
93
-
94
-    public void setTopBarVisible(String screenInstanceId, boolean hidden, boolean animated) {
95
-        for (Modal modal : stack) {
96
-            modal.setTopBarVisible(screenInstanceId, hidden, animated);
97
-        }
98
-    }
99
-
100
-    public void setTitleBarTitle(String screenInstanceId, String title) {
101
-        for (Modal modal : stack) {
102
-            modal.setTitleBarTitle(screenInstanceId, title);
103
-        }
104
-    }
105
-
106
-    public void setTitleBarSubtitle(String screenInstanceId, String subtitle) {
107
-        for (Modal modal : stack) {
108
-            modal.setTitleBarSubtitle(screenInstanceId, subtitle);
109
-        }
110
-    }
111
-
112
-    public void setTitleBarRightButtons(String screenInstanceId, String navigatorEventId, List<TitleBarButtonParams> titleBarButtons) {
113
-        for (Modal modal : stack) {
114
-            modal.setTitleBarRightButtons(screenInstanceId, navigatorEventId, titleBarButtons);
115
-        }
116
-    }
117
-
118
-    public void setTitleBarLeftButton(String screenInstanceId, String navigatorEventId, TitleBarLeftButtonParams titleBarLeftButton) {
119
-        for (Modal modal : stack) {
120
-            modal.setTitleBarLeftButton(screenInstanceId, navigatorEventId, titleBarLeftButton);
121
-        }
122
-    }
123
-
124
-    public void showContextualMenu(String screenInstanceId, ContextualMenuParams params, Callback onButtonClicked) {
125
-        for (Modal modal : stack) {
126
-            modal.showContextualMenu(screenInstanceId, params, onButtonClicked);
127
-        }
128
-    }
129
-
130
-    public void dismissContextualMenu(String screenInstanceId) {
131
-        for (Modal modal : stack) {
132
-            modal.dismissContextualMenu(screenInstanceId);
133
-        }
134
-    }
135
-
136
-    @Override
137
-    public boolean onTitleBarBackButtonClick() {
138
-        // Do nothing and let the layout handle the back button click
139
-        return false;
140
-    }
141
-
142
-    @Override
143
-    public void onSideMenuButtonClick() {
144
-        // Do nothing and let the layout handle the click
145
-    }
146
-}

+ 0
- 339
lib/android/app/deprecated/java/com/reactnativenavigation/controllers/NavigationActivity.java 查看文件

@@ -1,339 +0,0 @@
1
-package com.reactnativenavigation.controllers;
2
-
3
-import android.annotation.TargetApi;
4
-import android.content.Intent;
5
-import android.os.Build;
6
-import android.os.Bundle;
7
-import android.support.annotation.Nullable;
8
-import android.support.v7.app.AppCompatActivity;
9
-import android.view.KeyEvent;
10
-
11
-import com.facebook.react.bridge.Callback;
12
-import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
13
-import com.facebook.react.modules.core.PermissionAwareActivity;
14
-import com.facebook.react.modules.core.PermissionListener;
15
-import com.reactnativenavigation.NavigationApplication;
16
-import com.reactnativenavigation.events.Event;
17
-import com.reactnativenavigation.events.EventBus;
18
-import com.reactnativenavigation.events.JsDevReloadEvent;
19
-import com.reactnativenavigation.events.ModalDismissedEvent;
20
-import com.reactnativenavigation.events.Subscriber;
21
-import com.reactnativenavigation.layouts.BottomTabsLayout;
22
-import com.reactnativenavigation.layouts.Layout;
23
-import com.reactnativenavigation.layouts.LayoutFactory;
24
-import com.reactnativenavigation.params.ActivityParams;
25
-import com.reactnativenavigation.params.AppStyle;
26
-import com.reactnativenavigation.params.ContextualMenuParams;
27
-import com.reactnativenavigation.params.FabParams;
28
-import com.reactnativenavigation.params.ScreenParams;
29
-import com.reactnativenavigation.params.SnackbarParams;
30
-import com.reactnativenavigation.params.TitleBarButtonParams;
31
-import com.reactnativenavigation.params.TitleBarLeftButtonParams;
32
-import com.reactnativenavigation.react.JsDevReloadHandler;
33
-import com.reactnativenavigation.views.SideMenu.Side;
34
-
35
-import java.util.List;
36
-
37
-public class NavigationActivity extends AppCompatActivity implements DefaultHardwareBackBtnHandler, Subscriber, PermissionAwareActivity {
38
-
39
-    /**
40
-     * Although we start multiple activities, we make sure to pass Intent.CLEAR_TASK | Intent.NEW_TASK
41
-     * So that we actually have only 1 instance of the activity running at one time.
42
-     * We hold the currentActivity (resume->pause) so we know when we need to destroy the javascript context
43
-     * (when currentActivity is null, ie pause and destroy was called without resume).
44
-     * This is somewhat weird, and in the future we better use a single activity with changing contentView similar to ReactNative impl.
45
-     * Along with that, we should handle commands from the bridge using onNewIntent
46
-     */
47
-    static NavigationActivity currentActivity;
48
-
49
-    private ActivityParams activityParams;
50
-    private ModalController modalController;
51
-    private Layout layout;
52
-    @Nullable private PermissionListener mPermissionListener;
53
-
54
-    @Override
55
-    protected void onCreate(Bundle savedInstanceState) {
56
-        super.onCreate(savedInstanceState);
57
-
58
-        if (!NavigationApplication.instance.isReactContextInitialized()) {
59
-            NavigationApplication.instance.startReactContextOnceInBackgroundAndExecuteJS();
60
-            return;
61
-        }
62
-
63
-        activityParams = NavigationCommandsHandler.parseActivityParams(getIntent());
64
-
65
-        disableActivityShowAnimationIfNeeded();
66
-        createLayout();
67
-        createModalController();
68
-        NavigationApplication.instance.getActivityCallbacks().onActivityCreated(this, savedInstanceState);
69
-    }
70
-
71
-    private void disableActivityShowAnimationIfNeeded() {
72
-        if (!activityParams.animateShow) {
73
-            overridePendingTransition(0, 0);
74
-        }
75
-    }
76
-
77
-    private void createModalController() {
78
-        modalController = new ModalController(this);
79
-    }
80
-
81
-    private void createLayout() {
82
-        layout = LayoutFactory.create(this, activityParams);
83
-        if (hasBackgroundColor()) {
84
-            layout.asView().setBackgroundColor(AppStyle.appStyle.screenBackgroundColor.getColor());
85
-        }
86
-        setContentView(layout.asView());
87
-    }
88
-
89
-    private boolean hasBackgroundColor() {
90
-        return AppStyle.appStyle.screenBackgroundColor != null &&
91
-               AppStyle.appStyle.screenBackgroundColor.hasColor();
92
-    }
93
-
94
-    @Override
95
-    protected void onStart() {
96
-        super.onStart();
97
-        NavigationApplication.instance.getActivityCallbacks().onActivityStarted(this);
98
-    }
99
-
100
-    @Override
101
-    protected void onResume() {
102
-        super.onResume();
103
-        if (isFinishing() || !NavigationApplication.instance.isReactContextInitialized()) {
104
-            return;
105
-        }
106
-
107
-        currentActivity = this;
108
-        setDeepLinkData();
109
-        NavigationApplication.instance.getReactGateway().onResumeActivity(this, this);
110
-        NavigationApplication.instance.getActivityCallbacks().onActivityResumed(this);
111
-        EventBus.instance.register(this);
112
-    }
113
-
114
-    private void setDeepLinkData() {
115
-        if (IntentDataHandler.hasIntentData()) {
116
-            IntentDataHandler.setIntentData(getIntent());
117
-        }
118
-    }
119
-
120
-    @Override
121
-    protected void onPause() {
122
-        super.onPause();
123
-        currentActivity = null;
124
-        NavigationApplication.instance.getReactGateway().onPauseActivity();
125
-        NavigationApplication.instance.getActivityCallbacks().onActivityPaused(this);
126
-        EventBus.instance.unregister(this);
127
-    }
128
-
129
-    @Override
130
-    protected void onStop() {
131
-        super.onStop();
132
-        NavigationApplication.instance.getActivityCallbacks().onActivityStopped(this);
133
-    }
134
-
135
-    @Override
136
-    protected void onDestroy() {
137
-        destroyLayouts();
138
-        destroyJsIfNeeded();
139
-        NavigationApplication.instance.getActivityCallbacks().onActivityDestroyed(this);
140
-        super.onDestroy();
141
-    }
142
-
143
-    private void destroyLayouts() {
144
-        if (modalController != null) {
145
-            modalController.destroy();
146
-        }
147
-        if (layout != null) {
148
-            layout.destroy();
149
-            layout = null;
150
-        }
151
-    }
152
-
153
-    private void destroyJsIfNeeded() {
154
-        if (currentActivity == null || currentActivity.isFinishing()) {
155
-            NavigationApplication.instance.getReactGateway().onDestroyApp();
156
-        }
157
-    }
158
-
159
-    @Override
160
-    public void invokeDefaultOnBackPressed() {
161
-        super.onBackPressed();
162
-    }
163
-
164
-    @Override
165
-    public void onBackPressed() {
166
-        if (layout != null && !layout.onBackPressed()) {
167
-            NavigationApplication.instance.getReactGateway().onBackPressed();
168
-        }
169
-    }
170
-
171
-    @Override
172
-    public void onActivityResult(int requestCode, int resultCode, Intent data) {
173
-        NavigationApplication.instance.getReactGateway().onActivityResult(requestCode, resultCode, data);
174
-        NavigationApplication.instance.getActivityCallbacks().onActivityResult(requestCode, resultCode, data);
175
-    }
176
-
177
-    @Override
178
-    public boolean onKeyUp(int keyCode, KeyEvent event) {
179
-        return JsDevReloadHandler.onKeyUp(getCurrentFocus(), keyCode) || super.onKeyUp(keyCode, event);
180
-    }
181
-
182
-    void push(ScreenParams params) {
183
-        if (modalController.containsNavigator(params.getNavigatorId())) {
184
-            modalController.push(params);
185
-        } else {
186
-            layout.push(params);
187
-        }
188
-    }
189
-
190
-    void pop(ScreenParams params) {
191
-        if (modalController.containsNavigator(params.getNavigatorId())) {
192
-            modalController.pop(params);
193
-        } else {
194
-            layout.pop(params);
195
-        }
196
-    }
197
-
198
-    void popToRoot(ScreenParams params) {
199
-        if (modalController.containsNavigator(params.getNavigatorId())) {
200
-            modalController.popToRoot(params);
201
-        } else {
202
-            layout.popToRoot(params);
203
-        }
204
-    }
205
-
206
-    void newStack(ScreenParams params) {
207
-        if (modalController.containsNavigator(params.getNavigatorId())) {
208
-            modalController.newStack(params);
209
-        } else {
210
-            layout.newStack(params);
211
-        }
212
-    }
213
-
214
-    void showModal(ScreenParams screenParams) {
215
-        modalController.showModal(screenParams);
216
-    }
217
-
218
-    void dismissTopModal() {
219
-        modalController.dismissTopModal();
220
-    }
221
-
222
-    void dismissAllModals() {
223
-        modalController.dismissAllModals();
224
-    }
225
-
226
-    //TODO all these setters should be combined to something like setStyle
227
-    void setTopBarVisible(String screenInstanceId, boolean hidden, boolean animated) {
228
-        layout.setTopBarVisible(screenInstanceId, hidden, animated);
229
-        modalController.setTopBarVisible(screenInstanceId, hidden, animated);
230
-    }
231
-
232
-    void setBottomTabsVisible(boolean hidden, boolean animated) {
233
-        if (layout instanceof BottomTabsLayout) {
234
-            ((BottomTabsLayout) layout).setBottomTabsVisible(hidden, animated);
235
-        }
236
-    }
237
-
238
-    void setTitleBarTitle(String screenInstanceId, String title) {
239
-        layout.setTitleBarTitle(screenInstanceId, title);
240
-        modalController.setTitleBarTitle(screenInstanceId, title);
241
-    }
242
-
243
-    public void setTitleBarSubtitle(String screenInstanceId, String subtitle) {
244
-        layout.setTitleBarSubtitle(screenInstanceId, subtitle);
245
-        modalController.setTitleBarSubtitle(screenInstanceId, subtitle);
246
-    }
247
-
248
-    void setTitleBarButtons(String screenInstanceId, String navigatorEventId, List<TitleBarButtonParams> titleBarButtons) {
249
-        layout.setTitleBarRightButtons(screenInstanceId, navigatorEventId, titleBarButtons);
250
-        modalController.setTitleBarRightButtons(screenInstanceId, navigatorEventId, titleBarButtons);
251
-    }
252
-
253
-    void setTitleBarLeftButton(String screenInstanceId, String navigatorEventId, TitleBarLeftButtonParams titleBarLeftButton) {
254
-        layout.setTitleBarLeftButton(screenInstanceId, navigatorEventId, titleBarLeftButton);
255
-        modalController.setTitleBarLeftButton(screenInstanceId, navigatorEventId, titleBarLeftButton);
256
-    }
257
-
258
-    void setScreenFab(String screenInstanceId, String navigatorEventId, FabParams fab) {
259
-        layout.setFab(screenInstanceId, navigatorEventId, fab);
260
-    }
261
-
262
-    public void toggleSideMenuVisible(boolean animated, Side side) {
263
-        layout.toggleSideMenuVisible(animated, side);
264
-    }
265
-
266
-    public void setSideMenuVisible(boolean animated, boolean visible, Side side) {
267
-        layout.setSideMenuVisible(animated, visible, side);
268
-    }
269
-
270
-    public void selectBottomTabByTabIndex(Integer index) {
271
-        if (layout instanceof BottomTabsLayout) {
272
-            ((BottomTabsLayout) layout).selectBottomTabByTabIndex(index);
273
-        }
274
-    }
275
-
276
-    public void selectBottomTabByNavigatorId(String navigatorId) {
277
-        if (layout instanceof BottomTabsLayout) {
278
-            ((BottomTabsLayout) layout).selectBottomTabByNavigatorId(navigatorId);
279
-        }
280
-    }
281
-
282
-    public void setBottomTabBadgeByIndex(Integer index, String badge) {
283
-        if (layout instanceof BottomTabsLayout) {
284
-            ((BottomTabsLayout) layout).setBottomTabBadgeByIndex(index, badge);
285
-        }
286
-    }
287
-
288
-    public void setBottomTabBadgeByNavigatorId(String navigatorId, String badge) {
289
-        if (layout instanceof BottomTabsLayout) {
290
-            ((BottomTabsLayout) layout).setBottomTabBadgeByNavigatorId(navigatorId, badge);
291
-        }
292
-    }
293
-
294
-    public void showSnackbar(SnackbarParams params) {
295
-        layout.showSnackbar(params);
296
-    }
297
-
298
-    public void showContextualMenu(String screenInstanceId, ContextualMenuParams params, Callback onButtonClicked) {
299
-        layout.showContextualMenu(screenInstanceId, params, onButtonClicked);
300
-        modalController.showContextualMenu(screenInstanceId, params, onButtonClicked);
301
-    }
302
-
303
-    public void dismissContextualMenu(String screenInstanceId) {
304
-        layout.dismissContextualMenu(screenInstanceId);
305
-        modalController.dismissContextualMenu(screenInstanceId);
306
-    }
307
-
308
-    @Override
309
-    public void onEvent(Event event) {
310
-        if (event.getType().equals(ModalDismissedEvent.TYPE)) {
311
-            handleModalDismissedEvent();
312
-        } else if (event.getType().equals(JsDevReloadEvent.TYPE)) {
313
-            handleJsDevReloadEvent();
314
-        }
315
-    }
316
-
317
-    private void handleModalDismissedEvent() {
318
-        if (!modalController.isShowing()) {
319
-            layout.onModalDismissed();
320
-        }
321
-    }
322
-
323
-    private void handleJsDevReloadEvent() {
324
-        modalController.destroy();
325
-        layout.destroy();
326
-    }
327
-
328
-    @TargetApi(Build.VERSION_CODES.M)
329
-    public void requestPermissions(String[] permissions, int requestCode, PermissionListener listener) {
330
-        mPermissionListener = listener;
331
-        requestPermissions(permissions, requestCode);
332
-    }
333
-
334
-    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
335
-        if (mPermissionListener != null && mPermissionListener.onRequestPermissionsResult(requestCode, permissions, grantResults)) {
336
-            mPermissionListener = null;
337
-        }
338
-    }
339
-}

+ 0
- 380
lib/android/app/deprecated/java/com/reactnativenavigation/controllers/NavigationCommandsHandler.java 查看文件

@@ -1,380 +0,0 @@
1
-package com.reactnativenavigation.controllers;
2
-
3
-import android.content.Intent;
4
-import android.os.Bundle;
5
-
6
-import com.facebook.react.bridge.Callback;
7
-import com.reactnativenavigation.NavigationApplication;
8
-import com.reactnativenavigation.params.ActivityParams;
9
-import com.reactnativenavigation.params.ContextualMenuParams;
10
-import com.reactnativenavigation.params.FabParams;
11
-import com.reactnativenavigation.params.ScreenParams;
12
-import com.reactnativenavigation.params.SnackbarParams;
13
-import com.reactnativenavigation.params.TitleBarButtonParams;
14
-import com.reactnativenavigation.params.TitleBarLeftButtonParams;
15
-import com.reactnativenavigation.params.parsers.ActivityParamsParser;
16
-import com.reactnativenavigation.params.parsers.ScreenParamsParser;
17
-import com.reactnativenavigation.views.SideMenu.Side;
18
-
19
-import java.util.List;
20
-
21
-public class NavigationCommandsHandler {
22
-
23
-    private static final String ACTIVITY_PARAMS_BUNDLE = "ACTIVITY_PARAMS_BUNDLE";
24
-
25
-    static ActivityParams parseActivityParams(Intent intent) {
26
-        return ActivityParamsParser.parse(intent.getBundleExtra(NavigationCommandsHandler.ACTIVITY_PARAMS_BUNDLE));
27
-    }
28
-
29
-    /**
30
-     * start a new activity with CLEAR_TASK | NEW_TASK
31
-     *
32
-     * @param params ActivityParams as bundle
33
-     */
34
-
35
-    public static void startApp(Bundle params, boolean portraitOnlyMode, boolean landscapeOnlyMode) {
36
-        Intent intent;
37
-        if (portraitOnlyMode) {
38
-            intent = new Intent(NavigationApplication.instance, PortraitNavigationActivity.class);
39
-        } else if (landscapeOnlyMode) {
40
-            intent = new Intent(NavigationApplication.instance, LandscapeNavigationActivity.class);
41
-        } else {
42
-            intent = new Intent(NavigationApplication.instance, NavigationActivity.class);
43
-        }
44
-        IntentDataHandler.setIntentData(intent);
45
-        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
46
-        intent.putExtra(ACTIVITY_PARAMS_BUNDLE, params);
47
-        NavigationApplication.instance.startActivity(intent);
48
-    }
49
-
50
-    public static void push(Bundle screenParams) {
51
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
52
-        if (currentActivity == null) {
53
-            return;
54
-        }
55
-
56
-        final ScreenParams params = ScreenParamsParser.parse(screenParams);
57
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
58
-            @Override
59
-            public void run() {
60
-                currentActivity.push(params);
61
-            }
62
-        });
63
-    }
64
-
65
-    public static void pop(Bundle screenParams) {
66
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
67
-        if (currentActivity == null) {
68
-            return;
69
-        }
70
-
71
-        final ScreenParams params = ScreenParamsParser.parse(screenParams);
72
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
73
-            @Override
74
-            public void run() {
75
-                currentActivity.pop(params);
76
-            }
77
-        });
78
-    }
79
-
80
-    public static void popToRoot(Bundle screenParams) {
81
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
82
-        if (currentActivity == null) {
83
-            return;
84
-        }
85
-
86
-        final ScreenParams params = ScreenParamsParser.parse(screenParams);
87
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
88
-            @Override
89
-            public void run() {
90
-                currentActivity.popToRoot(params);
91
-            }
92
-        });
93
-    }
94
-
95
-    public static void newStack(Bundle screenParams) {
96
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
97
-        if (currentActivity == null) {
98
-            return;
99
-        }
100
-
101
-        final ScreenParams params = ScreenParamsParser.parse(screenParams);
102
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
103
-            @Override
104
-            public void run() {
105
-                currentActivity.newStack(params);
106
-            }
107
-        });
108
-    }
109
-
110
-    public static void setTopBarVisible(final String screenInstanceID, final boolean hidden, final boolean animated) {
111
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
112
-        if (currentActivity == null) {
113
-            return;
114
-        }
115
-
116
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
117
-            @Override
118
-            public void run() {
119
-                currentActivity.setTopBarVisible(screenInstanceID, hidden, animated);
120
-            }
121
-        });
122
-    }
123
-
124
-    public static void setBottomTabsVisible(final boolean hidden, final boolean animated) {
125
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
126
-        if (currentActivity == null) {
127
-            return;
128
-        }
129
-
130
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
131
-            @Override
132
-            public void run() {
133
-                currentActivity.setBottomTabsVisible(hidden, animated);
134
-            }
135
-        });
136
-    }
137
-
138
-    public static void setScreenTitleBarTitle(final String screenInstanceId, final String title) {
139
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
140
-        if (currentActivity == null) {
141
-            return;
142
-        }
143
-
144
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
145
-            @Override
146
-            public void run() {
147
-                currentActivity.setTitleBarTitle(screenInstanceId, title);
148
-            }
149
-        });
150
-    }
151
-
152
-    public static void setScreenTitleBarSubtitle(final String screenInstanceId, final String subtitle) {
153
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
154
-        if (currentActivity == null) {
155
-            return;
156
-        }
157
-
158
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
159
-            @Override
160
-            public void run() {
161
-                currentActivity.setTitleBarSubtitle(screenInstanceId, subtitle);
162
-            }
163
-        });
164
-    }
165
-
166
-    public static void showModal(Bundle params) {
167
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
168
-        if (currentActivity == null) {
169
-            return;
170
-        }
171
-
172
-        final ScreenParams screenParams = ScreenParamsParser.parse(params);
173
-
174
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
175
-            @Override
176
-            public void run() {
177
-                currentActivity.showModal(screenParams);
178
-            }
179
-        });
180
-    }
181
-
182
-    public static void setScreenTitleBarRightButtons(final String screenInstanceId,
183
-                                                     final String navigatorEventId,
184
-                                                     final List<TitleBarButtonParams> titleBarButtons) {
185
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
186
-        if (currentActivity == null) {
187
-            return;
188
-        }
189
-
190
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
191
-            @Override
192
-            public void run() {
193
-                currentActivity.setTitleBarButtons(screenInstanceId, navigatorEventId, titleBarButtons);
194
-            }
195
-        });
196
-    }
197
-
198
-    public static void setScreenTitleBarLeftButtons(final String screenInstanceId,
199
-                                                    final String navigatorEventId,
200
-                                                    final TitleBarLeftButtonParams titleBarButtons) {
201
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
202
-        if (currentActivity == null) {
203
-            return;
204
-        }
205
-
206
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
207
-            @Override
208
-            public void run() {
209
-                currentActivity.setTitleBarLeftButton(screenInstanceId, navigatorEventId, titleBarButtons);
210
-            }
211
-        });
212
-    }
213
-
214
-    public static void setScreenFab(final String screenInstanceId, final String navigatorEventId, final FabParams fab) {
215
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
216
-        if (currentActivity == null) {
217
-            return;
218
-        }
219
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
220
-            @Override
221
-            public void run() {
222
-                currentActivity.setScreenFab(screenInstanceId, navigatorEventId, fab);
223
-            }
224
-        });
225
-    }
226
-
227
-    public static void dismissTopModal() {
228
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
229
-        if (currentActivity == null) {
230
-            return;
231
-        }
232
-
233
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
234
-            @Override
235
-            public void run() {
236
-                currentActivity.dismissTopModal();
237
-            }
238
-        });
239
-    }
240
-
241
-    public static void dismissAllModals() {
242
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
243
-        if (currentActivity == null) {
244
-            return;
245
-        }
246
-
247
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
248
-            @Override
249
-            public void run() {
250
-                currentActivity.dismissAllModals();
251
-            }
252
-        });
253
-    }
254
-
255
-    public static void toggleSideMenuVisible(final boolean animated, final Side side) {
256
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
257
-        if (currentActivity == null) {
258
-            return;
259
-        }
260
-
261
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
262
-            @Override
263
-            public void run() {
264
-                currentActivity.toggleSideMenuVisible(animated, side);
265
-            }
266
-        });
267
-    }
268
-
269
-    public static void setSideMenuVisible(final boolean animated, final boolean visible, final Side side) {
270
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
271
-        if (currentActivity == null) {
272
-            return;
273
-        }
274
-
275
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
276
-            @Override
277
-            public void run() {
278
-                currentActivity.setSideMenuVisible(animated, visible, side);
279
-            }
280
-        });
281
-    }
282
-
283
-    public static void selectBottomTabByTabIndex(final Integer index) {
284
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
285
-        if (currentActivity == null) {
286
-            return;
287
-        }
288
-
289
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
290
-            @Override
291
-            public void run() {
292
-                currentActivity.selectBottomTabByTabIndex(index);
293
-            }
294
-        });
295
-    }
296
-
297
-    public static void selectBottomTabByNavigatorId(final String navigatorId) {
298
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
299
-        if (currentActivity == null) {
300
-            return;
301
-        }
302
-
303
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
304
-            @Override
305
-            public void run() {
306
-                currentActivity.selectBottomTabByNavigatorId(navigatorId);
307
-            }
308
-        });
309
-    }
310
-
311
-    public static void setBottomTabBadgeByIndex(final Integer index, final String badge) {
312
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
313
-        if (currentActivity == null) {
314
-            return;
315
-        }
316
-
317
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
318
-            @Override
319
-            public void run() {
320
-                currentActivity.setBottomTabBadgeByIndex(index, badge);
321
-            }
322
-        });
323
-    }
324
-
325
-    public static void setBottomTabBadgeByNavigatorId(final String navigatorId, final String badge) {
326
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
327
-        if (currentActivity == null) {
328
-            return;
329
-        }
330
-
331
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
332
-            @Override
333
-            public void run() {
334
-                currentActivity.setBottomTabBadgeByNavigatorId(navigatorId, badge);
335
-            }
336
-        });
337
-    }
338
-
339
-    public static void showSnackbar(final SnackbarParams params) {
340
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
341
-        if (currentActivity == null) {
342
-            return;
343
-        }
344
-
345
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
346
-            @Override
347
-            public void run() {
348
-                currentActivity.showSnackbar(params);
349
-            }
350
-        });
351
-    }
352
-
353
-    public static void showContextualMenu(final String screenInstanceId, final ContextualMenuParams params, final Callback onButtonClicked) {
354
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
355
-        if (currentActivity == null) {
356
-            return;
357
-        }
358
-
359
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
360
-            @Override
361
-            public void run() {
362
-                currentActivity.showContextualMenu(screenInstanceId, params, onButtonClicked);
363
-            }
364
-        });
365
-    }
366
-
367
-    public static void dismissContextualMenu(final String screenInstanceId) {
368
-        final NavigationActivity currentActivity = NavigationActivity.currentActivity;
369
-        if (currentActivity == null) {
370
-            return;
371
-        }
372
-
373
-        NavigationApplication.instance.runOnMainThread(new Runnable() {
374
-            @Override
375
-            public void run() {
376
-                currentActivity.dismissContextualMenu(screenInstanceId);
377
-            }
378
-        });
379
-    }
380
-}

+ 0
- 4
lib/android/app/deprecated/java/com/reactnativenavigation/controllers/PortraitNavigationActivity.java 查看文件

@@ -1,4 +0,0 @@
1
-package com.reactnativenavigation.controllers;
2
-
3
-public class PortraitNavigationActivity extends NavigationActivity {
4
-}

+ 0
- 69
lib/android/app/deprecated/java/com/reactnativenavigation/controllers/SplashActivity.java 查看文件

@@ -1,69 +0,0 @@
1
-package com.reactnativenavigation.controllers;
2
-
3
-import android.graphics.Color;
4
-import android.os.Bundle;
5
-import android.support.annotation.LayoutRes;
6
-import android.support.annotation.Nullable;
7
-import android.support.v7.app.AppCompatActivity;
8
-import android.view.View;
9
-
10
-import com.reactnativenavigation.NavigationApplication;
11
-import com.reactnativenavigation.react.ReactDevPermission;
12
-
13
-public abstract class SplashActivity extends AppCompatActivity {
14
-
15
-    @Override
16
-    protected void onCreate(@Nullable Bundle savedInstanceState) {
17
-        super.onCreate(savedInstanceState);
18
-        setSplashLayout();
19
-        IntentDataHandler.saveIntentData(getIntent());
20
-    }
21
-
22
-    @Override
23
-    protected void onResume() {
24
-        super.onResume();
25
-
26
-        if (NavigationApplication.instance.getReactGateway().hasStartedCreatingContext()) {
27
-            finish();
28
-        }
29
-
30
-        if (ReactDevPermission.shouldAskPermission()) {
31
-            ReactDevPermission.askPermission(this);
32
-            return;
33
-        }
34
-
35
-        if (NavigationApplication.instance.isReactContextInitialized()) {
36
-            finish();
37
-            return;
38
-        }
39
-
40
-        // TODO I'm starting to think this entire flow is incorrect and should be done in Application
41
-        NavigationApplication.instance.startReactContextOnceInBackgroundAndExecuteJS();
42
-    }
43
-
44
-    private void setSplashLayout() {
45
-        final int splashLayout = getSplashLayout();
46
-        if (splashLayout > 0) {
47
-            setContentView(splashLayout);
48
-        } else {
49
-            setContentView(createSplashLayout());
50
-        }
51
-    }
52
-
53
-    /**
54
-     * @return xml layout res id
55
-     */
56
-    @LayoutRes
57
-    public int getSplashLayout() {
58
-        return 0;
59
-    }
60
-
61
-    /**
62
-     * @return the layout you would like to show while react's js context loads
63
-     */
64
-    public View createSplashLayout() {
65
-        View view = new View(this);
66
-        view.setBackgroundColor(Color.WHITE);
67
-        return view;
68
-    }
69
-}

+ 0
- 9
lib/android/app/deprecated/java/com/reactnativenavigation/events/ContextualMenuHiddenEvent.java 查看文件

@@ -1,9 +0,0 @@
1
-package com.reactnativenavigation.events;
2
-
3
-public class ContextualMenuHiddenEvent implements Event {
4
-    public static final String TYPE = "ContextualMenuDismissed";
5
-    @Override
6
-    public String getType() {
7
-        return TYPE;
8
-    }
9
-}

+ 0
- 5
lib/android/app/deprecated/java/com/reactnativenavigation/events/Event.java 查看文件

@@ -1,5 +0,0 @@
1
-package com.reactnativenavigation.events;
2
-
3
-public interface Event {
4
-    String getType();
5
-}

+ 0
- 49
lib/android/app/deprecated/java/com/reactnativenavigation/events/EventBus.java 查看文件

@@ -1,49 +0,0 @@
1
-package com.reactnativenavigation.events;
2
-
3
-import java.lang.ref.WeakReference;
4
-import java.util.ArrayList;
5
-import java.util.List;
6
-import java.util.ListIterator;
7
-
8
-public enum EventBus {
9
-    instance;
10
-
11
-    private final List<WeakReference<Subscriber>> subscribers = new ArrayList<>();
12
-
13
-    public void register(Subscriber subscriber) {
14
-        if (isSubscribed(subscriber)) return;
15
-        subscribers.add(new WeakReference<>(subscriber));
16
-    }
17
-
18
-    public void unregister(Subscriber subscriber) {
19
-        ListIterator<WeakReference<Subscriber>> iterator = subscribers.listIterator();
20
-        while (iterator.hasNext()) {
21
-            WeakReference<Subscriber> ref = iterator.next();
22
-            Subscriber registered = ref.get();
23
-            if (registered != null && registered == subscriber) {
24
-                iterator.remove();
25
-            }
26
-        }
27
-    }
28
-
29
-    public void post(Event event) {
30
-        ListIterator<WeakReference<Subscriber>> iterator = subscribers.listIterator();
31
-        while (iterator.hasNext()) {
32
-            WeakReference<Subscriber> ref = iterator.next();
33
-            Subscriber registered = ref.get();
34
-            if (registered != null) {
35
-                registered.onEvent(event);
36
-            }
37
-        }
38
-    }
39
-
40
-    public boolean isSubscribed(Subscriber subscriber) {
41
-        for (WeakReference<Subscriber> ref : subscribers) {
42
-            Subscriber registered = ref.get();
43
-            if (registered != null && registered.equals(subscriber)) {
44
-                return true;
45
-            }
46
-        }
47
-        return false;
48
-    }
49
-}

+ 0
- 18
lib/android/app/deprecated/java/com/reactnativenavigation/events/FabSetEvent.java 查看文件

@@ -1,18 +0,0 @@
1
-package com.reactnativenavigation.events;
2
-
3
-import com.reactnativenavigation.params.FabParams;
4
-
5
-public class FabSetEvent implements Event {
6
-    public static final String TYPE = "FabSetEvent";
7
-
8
-    public FabParams fabParams;
9
-
10
-    public FabSetEvent(FabParams fabParams) {
11
-        this.fabParams = fabParams;
12
-    }
13
-
14
-    @Override
15
-    public String getType() {
16
-        return TYPE;
17
-    }
18
-}

+ 0
- 11
lib/android/app/deprecated/java/com/reactnativenavigation/events/JsDevReloadEvent.java 查看文件

@@ -1,11 +0,0 @@
1
-package com.reactnativenavigation.events;
2
-
3
-public class JsDevReloadEvent implements Event {
4
-
5
-    public static final String TYPE = "JsDevReloadEvent";
6
-
7
-    @Override
8
-    public String getType() {
9
-        return TYPE;
10
-    }
11
-}

+ 0
- 10
lib/android/app/deprecated/java/com/reactnativenavigation/events/ModalDismissedEvent.java 查看文件

@@ -1,10 +0,0 @@
1
-package com.reactnativenavigation.events;
2
-
3
-public class ModalDismissedEvent implements Event {
4
-    public static final String TYPE = "ModalDismissedEvent";
5
-
6
-    @Override
7
-    public String getType() {
8
-        return TYPE;
9
-    }
10
-}

+ 0
- 18
lib/android/app/deprecated/java/com/reactnativenavigation/events/ScreenChangedEvent.java 查看文件

@@ -1,18 +0,0 @@
1
-package com.reactnativenavigation.events;
2
-
3
-import com.reactnativenavigation.params.BaseScreenParams;
4
-import com.reactnativenavigation.params.FabParams;
5
-
6
-public class ScreenChangedEvent implements Event {
7
-    public static final String TYPE = "ScreenChangedEvent";
8
-    public FabParams fabParams;
9
-
10
-    public ScreenChangedEvent(BaseScreenParams screenParams) {
11
-        this.fabParams = screenParams.getFab();
12
-    }
13
-
14
-    @Override
15
-    public String getType() {
16
-        return TYPE;
17
-    }
18
-}

+ 0
- 5
lib/android/app/deprecated/java/com/reactnativenavigation/events/Subscriber.java 查看文件

@@ -1,5 +0,0 @@
1
-package com.reactnativenavigation.events;
2
-
3
-public interface Subscriber {
4
-    void onEvent(Event event);
5
-}

+ 0
- 10
lib/android/app/deprecated/java/com/reactnativenavigation/events/ViewPagerScreenChangedEvent.java 查看文件

@@ -1,10 +0,0 @@
1
-package com.reactnativenavigation.events;
2
-
3
-public class ViewPagerScreenChangedEvent implements Event {
4
-    public static final String TYPE = "ViewPagerScreenChangedEvent";
5
-
6
-    @Override
7
-    public String getType() {
8
-        return TYPE;
9
-    }
10
-}

+ 0
- 9
lib/android/app/deprecated/java/com/reactnativenavigation/events/ViewPagerScreenScrollStartEvent.java 查看文件

@@ -1,9 +0,0 @@
1
-package com.reactnativenavigation.events;
2
-
3
-public class ViewPagerScreenScrollStartEvent implements Event {
4
-    public static final String TYPE = "ViewPagerScreenScrollStartEvent";
5
-    @Override
6
-    public String getType() {
7
-        return TYPE;
8
-    }
9
-}

+ 0
- 397
lib/android/app/deprecated/java/com/reactnativenavigation/layouts/BottomTabsLayout.java 查看文件

@@ -1,397 +0,0 @@
1
-package com.reactnativenavigation.layouts;
2
-
3
-import android.support.annotation.NonNull;
4
-import android.support.annotation.Nullable;
5
-import android.support.v7.app.AppCompatActivity;
6
-import android.view.View;
7
-import android.widget.RelativeLayout;
8
-
9
-import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
10
-import com.facebook.react.bridge.Arguments;
11
-import com.facebook.react.bridge.Callback;
12
-import com.facebook.react.bridge.WritableMap;
13
-import com.reactnativenavigation.NavigationApplication;
14
-import com.reactnativenavigation.events.EventBus;
15
-import com.reactnativenavigation.events.ScreenChangedEvent;
16
-import com.reactnativenavigation.params.ActivityParams;
17
-import com.reactnativenavigation.params.ContextualMenuParams;
18
-import com.reactnativenavigation.params.FabParams;
19
-import com.reactnativenavigation.params.ScreenParams;
20
-import com.reactnativenavigation.params.SideMenuParams;
21
-import com.reactnativenavigation.params.SnackbarParams;
22
-import com.reactnativenavigation.params.TitleBarButtonParams;
23
-import com.reactnativenavigation.params.TitleBarLeftButtonParams;
24
-import com.reactnativenavigation.screens.Screen;
25
-import com.reactnativenavigation.screens.ScreenStack;
26
-import com.reactnativenavigation.views.BottomTabs;
27
-import com.reactnativenavigation.views.SideMenu;
28
-import com.reactnativenavigation.views.SideMenu.Side;
29
-import com.reactnativenavigation.views.SnackbarAndFabContainer;
30
-
31
-import java.util.List;
32
-
33
-import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
34
-import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
35
-
36
-public class BottomTabsLayout extends RelativeLayout implements Layout, AHBottomNavigation.OnTabSelectedListener {
37
-
38
-    private final AppCompatActivity activity;
39
-    private ActivityParams params;
40
-    private SnackbarAndFabContainer snackbarAndFabContainer;
41
-    private BottomTabs bottomTabs;
42
-    private ScreenStack[] screenStacks;
43
-    private final SideMenuParams leftSideMenuParams;
44
-    private final SideMenuParams rightSideMenuParams;
45
-    private @Nullable SideMenu sideMenu;
46
-    private int currentStackIndex = 0;
47
-
48
-    public BottomTabsLayout(AppCompatActivity activity, ActivityParams params) {
49
-        super(activity);
50
-        this.activity = activity;
51
-        this.params = params;
52
-        leftSideMenuParams = params.leftSideMenuParams;
53
-        rightSideMenuParams = params.rightSideMenuParams;
54
-        screenStacks = new ScreenStack[params.tabParams.size()];
55
-        createLayout();
56
-    }
57
-
58
-    private void createLayout() {
59
-        createSideMenu();
60
-        createBottomTabs();
61
-        addBottomTabs();
62
-        addScreenStacks();
63
-        createSnackbarContainer();
64
-        showInitialScreenStack();
65
-    }
66
-
67
-    private void createSideMenu() {
68
-        if (leftSideMenuParams == null && rightSideMenuParams == null) {
69
-            return;
70
-        }
71
-        sideMenu = new SideMenu(getContext(), leftSideMenuParams, rightSideMenuParams);
72
-        RelativeLayout.LayoutParams lp = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
73
-        addView(sideMenu, lp);
74
-    }
75
-
76
-    private void addScreenStacks() {
77
-        for (int i = screenStacks.length - 1; i >= 0; i--) {
78
-            createAndAddScreens(i);
79
-        }
80
-    }
81
-
82
-    private void createAndAddScreens(int position) {
83
-        ScreenParams screenParams = params.tabParams.get(position);
84
-        ScreenStack newStack = new ScreenStack(activity, getScreenStackParent(), screenParams.getNavigatorId(), this);
85
-        newStack.pushInitialScreen(screenParams, createScreenLayoutParams(screenParams));
86
-        screenStacks[position] = newStack;
87
-    }
88
-
89
-    private RelativeLayout getScreenStackParent() {
90
-        return sideMenu == null ? this : sideMenu.getContentContainer();
91
-    }
92
-
93
-    @NonNull
94
-    private LayoutParams createScreenLayoutParams(ScreenParams params) {
95
-        LayoutParams lp = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
96
-        if (params.styleParams.drawScreenAboveBottomTabs) {
97
-            lp.addRule(RelativeLayout.ABOVE, bottomTabs.getId());
98
-        }
99
-        return lp;
100
-    }
101
-
102
-    private void createBottomTabs() {
103
-        bottomTabs = new BottomTabs(getContext());
104
-        bottomTabs.addTabs(params.tabParams, this);
105
-    }
106
-
107
-    private void addBottomTabs() {
108
-        LayoutParams lp = new LayoutParams(MATCH_PARENT, WRAP_CONTENT);
109
-        lp.addRule(ALIGN_PARENT_BOTTOM);
110
-        getScreenStackParent().addView(bottomTabs, lp);
111
-    }
112
-
113
-    private void createSnackbarContainer() {
114
-        snackbarAndFabContainer = new SnackbarAndFabContainer(getContext(), this);
115
-        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
116
-        lp.addRule(ABOVE, bottomTabs.getId());
117
-        getScreenStackParent().addView(snackbarAndFabContainer, lp);
118
-    }
119
-
120
-    private void showInitialScreenStack() {
121
-        showStackAndUpdateStyle(screenStacks[0]);
122
-        EventBus.instance.post(new ScreenChangedEvent(screenStacks[0].peek().getScreenParams()));
123
-    }
124
-
125
-    @Override
126
-    public View asView() {
127
-        return this;
128
-    }
129
-
130
-    @Override
131
-    public boolean onBackPressed() {
132
-        if (getCurrentScreenStack().handleBackPressInJs()) {
133
-            return true;
134
-        }
135
-
136
-        if (getCurrentScreenStack().canPop()) {
137
-            getCurrentScreenStack().pop(true);
138
-            setBottomTabsStyleFromCurrentScreen();
139
-            EventBus.instance.post(new ScreenChangedEvent(getCurrentScreenStack().peek().getScreenParams()));
140
-            return true;
141
-        } else {
142
-            return false;
143
-        }
144
-    }
145
-
146
-    @Override
147
-    public void setTopBarVisible(String screenInstanceId, boolean hidden, boolean animated) {
148
-        for (int i = 0; i < bottomTabs.getItemsCount(); i++) {
149
-            screenStacks[i].setScreenTopBarVisible(screenInstanceId, hidden, animated);
150
-        }
151
-    }
152
-
153
-    public void setBottomTabsVisible(boolean hidden, boolean animated) {
154
-        bottomTabs.setVisibility(hidden, animated);
155
-    }
156
-
157
-    @Override
158
-    public void setTitleBarTitle(String screenInstanceId, String title) {
159
-        for (int i = 0; i < bottomTabs.getItemsCount(); i++) {
160
-            screenStacks[i].setScreenTitleBarTitle(screenInstanceId, title);
161
-        }
162
-    }
163
-
164
-    @Override
165
-    public void setTitleBarSubtitle(String screenInstanceId, String subtitle) {
166
-        for (int i = 0; i < bottomTabs.getItemsCount(); i++) {
167
-            screenStacks[i].setScreenTitleBarSubtitle(screenInstanceId, subtitle);
168
-        }
169
-    }
170
-
171
-    @Override
172
-    public void setTitleBarRightButtons(String screenInstanceId, String navigatorEventId, List<TitleBarButtonParams> titleBarButtons) {
173
-        for (int i = 0; i < bottomTabs.getItemsCount(); i++) {
174
-            screenStacks[i].setScreenTitleBarRightButtons(screenInstanceId, navigatorEventId, titleBarButtons);
175
-        }
176
-    }
177
-
178
-    @Override
179
-    public void setTitleBarLeftButton(String screenInstanceId, String navigatorEventId, TitleBarLeftButtonParams titleBarLeftButtonParams) {
180
-        for (int i = 0; i < bottomTabs.getItemsCount(); i++) {
181
-            screenStacks[i].setScreenTitleBarLeftButton(screenInstanceId, navigatorEventId, titleBarLeftButtonParams);
182
-        }
183
-    }
184
-
185
-    @Override
186
-    public void setFab(String screenInstanceId, String navigatorEventId, FabParams fabParams) {
187
-        for (int i = 0; i < bottomTabs.getItemsCount(); i++) {
188
-            screenStacks[i].setFab(screenInstanceId, navigatorEventId, fabParams);
189
-        }
190
-    }
191
-
192
-    @Override
193
-    public void toggleSideMenuVisible(boolean animated, Side side) {
194
-        if (sideMenu != null) {
195
-            sideMenu.toggleVisible(animated, side);
196
-        }
197
-    }
198
-
199
-    @Override
200
-    public void setSideMenuVisible(boolean animated, boolean visible, Side side) {
201
-        if (sideMenu != null) {
202
-            sideMenu.setVisible(visible, animated, side);
203
-        }
204
-    }
205
-
206
-    @Override
207
-    public void showSnackbar(SnackbarParams params) {
208
-        final String eventId = getCurrentScreenStack().peek().getNavigatorEventId();
209
-        snackbarAndFabContainer.showSnackbar(eventId, params);
210
-    }
211
-
212
-    @Override
213
-    public void onModalDismissed() {
214
-        EventBus.instance.post(new ScreenChangedEvent(getCurrentScreenStack().peek().getScreenParams()));
215
-    }
216
-
217
-    @Override
218
-    public boolean containsNavigator(String navigatorId) {
219
-        // Unused
220
-        return false;
221
-    }
222
-
223
-    @Override
224
-    public void showContextualMenu(String screenInstanceId, ContextualMenuParams params, Callback onButtonClicked) {
225
-        getCurrentScreenStack().peek().showContextualMenu(params, onButtonClicked);
226
-    }
227
-
228
-    @Override
229
-    public void dismissContextualMenu(String screenInstanceId) {
230
-        getCurrentScreenStack().peek().dismissContextualMenu();
231
-    }
232
-
233
-    @Override
234
-    public Screen getCurrentScreen() {
235
-        return getCurrentScreenStack().peek();
236
-    }
237
-
238
-    public void selectBottomTabByTabIndex(Integer index) {
239
-        bottomTabs.setCurrentItem(index);
240
-    }
241
-
242
-    public void selectBottomTabByNavigatorId(String navigatorId) {
243
-        bottomTabs.setCurrentItem(getScreenStackIndex(navigatorId));
244
-    }
245
-
246
-    @Override
247
-    public void push(ScreenParams params) {
248
-        ScreenStack screenStack = getScreenStack(params.getNavigatorId());
249
-        screenStack.push(params, createScreenLayoutParams(params));
250
-        if (isCurrentStack(screenStack)) {
251
-            bottomTabs.setStyleFromScreen(params.styleParams);
252
-            EventBus.instance.post(new ScreenChangedEvent(params));
253
-        }
254
-    }
255
-
256
-    @Override
257
-    public void pop(ScreenParams params) {
258
-        getCurrentScreenStack().pop(params.animateScreenTransitions, new ScreenStack.OnScreenPop() {
259
-            @Override
260
-            public void onScreenPopAnimationEnd() {
261
-                setBottomTabsStyleFromCurrentScreen();
262
-            }
263
-        });
264
-        EventBus.instance.post(new ScreenChangedEvent(getCurrentScreenStack().peek().getScreenParams()));
265
-    }
266
-
267
-    @Override
268
-    public void popToRoot(ScreenParams params) {
269
-        getCurrentScreenStack().popToRoot(params.animateScreenTransitions);
270
-        setBottomTabsStyleFromCurrentScreen();
271
-        EventBus.instance.post(new ScreenChangedEvent(getCurrentScreenStack().peek().getScreenParams()));
272
-    }
273
-
274
-    @Override
275
-    public void newStack(ScreenParams params) {
276
-        ScreenStack currentScreenStack = getCurrentScreenStack();
277
-        removeView(currentScreenStack.peek());
278
-        currentScreenStack.destroy();
279
-
280
-        ScreenStack newStack = new ScreenStack(activity, getScreenStackParent(), params.getNavigatorId(), this);
281
-        LayoutParams lp = createScreenLayoutParams(params);
282
-        newStack.pushInitialScreenWithAnimation(params, lp);
283
-        screenStacks[currentStackIndex] = newStack;
284
-
285
-        bottomTabs.setStyleFromScreen(params.styleParams);
286
-        EventBus.instance.post(new ScreenChangedEvent(params));
287
-    }
288
-
289
-    @Override
290
-    public void destroy() {
291
-        snackbarAndFabContainer.destroy();
292
-        for (ScreenStack screenStack : screenStacks) {
293
-            screenStack.destroy();
294
-        }
295
-        if (sideMenu != null) {
296
-            sideMenu.destroy();
297
-        }
298
-    }
299
-
300
-    @Override
301
-    public boolean onTabSelected(int position, boolean wasSelected) {
302
-        if (wasSelected) {
303
-            return false;
304
-        }
305
-        
306
-        hideCurrentStack();
307
-        showNewStack(position);
308
-        EventBus.instance.post(new ScreenChangedEvent(getCurrentScreenStack().peek().getScreenParams()));
309
-        sendTabSelectedEventToJs();
310
-        return true;
311
-    }
312
-
313
-    private void sendTabSelectedEventToJs() {
314
-        WritableMap data = Arguments.createMap();
315
-        String navigatorEventId = getCurrentScreenStack().peek().getNavigatorEventId();
316
-        NavigationApplication.instance.getEventEmitter().sendNavigatorEvent("bottomTabSelected", navigatorEventId, data);
317
-    }
318
-
319
-    private void showNewStack(int position) {
320
-        showStackAndUpdateStyle(screenStacks[position]);
321
-        currentStackIndex = position;
322
-    }
323
-
324
-    private void showStackAndUpdateStyle(ScreenStack newStack) {
325
-        newStack.show();
326
-        bottomTabs.setStyleFromScreen(newStack.getCurrentScreenStyleParams());
327
-    }
328
-
329
-    private void hideCurrentStack() {
330
-        ScreenStack currentScreenStack = getCurrentScreenStack();
331
-        currentScreenStack.hide();
332
-    }
333
-
334
-    private ScreenStack getCurrentScreenStack() {
335
-        return screenStacks[currentStackIndex];
336
-    }
337
-
338
-    private @NonNull ScreenStack getScreenStack(String navigatorId) {
339
-        int index = getScreenStackIndex(navigatorId);
340
-        return screenStacks[index];
341
-    }
342
-
343
-    public void setBottomTabBadgeByIndex(Integer index, String badge) {
344
-        bottomTabs.setNotification(badge, index);
345
-    }
346
-
347
-    public void setBottomTabBadgeByNavigatorId(String navigatorId, String badge) {
348
-        bottomTabs.setNotification(badge, getScreenStackIndex(navigatorId));
349
-    }
350
-
351
-    private int getScreenStackIndex(String navigatorId) throws ScreenStackNotFoundException {
352
-        for (int i = 0; i < screenStacks.length; i++) {
353
-            if (screenStacks[i].getNavigatorId().equals(navigatorId)) {
354
-                return i;
355
-            }
356
-        }
357
-        throw new ScreenStackNotFoundException("Stack " + navigatorId + " not found");
358
-    }
359
-
360
-    private class ScreenStackNotFoundException extends RuntimeException {
361
-        ScreenStackNotFoundException(String navigatorId) {
362
-            super(navigatorId);
363
-        }
364
-    }
365
-
366
-    private boolean isCurrentStack(ScreenStack screenStack) {
367
-        return getCurrentScreenStack() == screenStack;
368
-    }
369
-
370
-    private void setBottomTabsStyleFromCurrentScreen() {
371
-        bottomTabs.setStyleFromScreen(getCurrentScreenStack().getCurrentScreenStyleParams());
372
-    }
373
-
374
-    @Override
375
-    public boolean onTitleBarBackButtonClick() {
376
-        if (getCurrentScreenStack().canPop()) {
377
-            getCurrentScreenStack().pop(true, new ScreenStack.OnScreenPop() {
378
-                @Override
379
-                public void onScreenPopAnimationEnd() {
380
-                    setBottomTabsStyleFromCurrentScreen();
381
-                    EventBus.instance.post(new ScreenChangedEvent(getCurrentScreenStack().peek().getScreenParams()));
382
-                }
383
-            });
384
-            return true;
385
-        }
386
-        return false;
387
-    }
388
-
389
-    @Override
390
-    public void onSideMenuButtonClick() {
391
-        final String navigatorEventId = getCurrentScreenStack().peek().getNavigatorEventId();
392
-        NavigationApplication.instance.getEventEmitter().sendNavigatorEvent("sideMenu", navigatorEventId);
393
-        if (sideMenu != null) {
394
-            sideMenu.openDrawer(Side.Left);
395
-        }
396
-    }
397
-}

+ 0
- 48
lib/android/app/deprecated/java/com/reactnativenavigation/layouts/Layout.java 查看文件

@@ -1,48 +0,0 @@
1
-package com.reactnativenavigation.layouts;
2
-
3
-import android.view.View;
4
-
5
-import com.facebook.react.bridge.Callback;
6
-import com.reactnativenavigation.params.ContextualMenuParams;
7
-import com.reactnativenavigation.params.FabParams;
8
-import com.reactnativenavigation.params.SnackbarParams;
9
-import com.reactnativenavigation.params.TitleBarButtonParams;
10
-import com.reactnativenavigation.params.TitleBarLeftButtonParams;
11
-import com.reactnativenavigation.screens.Screen;
12
-import com.reactnativenavigation.views.SideMenu.Side;
13
-
14
-import java.util.List;
15
-
16
-public interface Layout extends ScreenStackContainer {
17
-    View asView();
18
-
19
-    boolean onBackPressed();
20
-
21
-    void setTopBarVisible(String screenInstanceId, boolean hidden, boolean animated);
22
-
23
-    void setTitleBarTitle(String screenInstanceId, String title);
24
-
25
-    void setTitleBarSubtitle(String screenInstanceId, String subtitle);
26
-
27
-    void setTitleBarRightButtons(String screenInstanceId, String navigatorEventId, List<TitleBarButtonParams> titleBarButtons);
28
-
29
-    void setTitleBarLeftButton(String screenInstanceId, String navigatorEventId, TitleBarLeftButtonParams titleBarLeftButtonParams);
30
-
31
-    void setFab(String screenInstanceId, String navigatorEventId, FabParams fabParams);
32
-
33
-    void toggleSideMenuVisible(boolean animated, Side side);
34
-
35
-    void setSideMenuVisible(boolean animated, boolean visible, Side side);
36
-
37
-    void showSnackbar(SnackbarParams params);
38
-
39
-    void onModalDismissed();
40
-
41
-    boolean containsNavigator(String navigatorId);
42
-
43
-    void showContextualMenu(String screenInstanceId, ContextualMenuParams params, Callback onButtonClicked);
44
-
45
-    void dismissContextualMenu(String screenInstanceId);
46
-
47
-    Screen getCurrentScreen();
48
-}

+ 0
- 36
lib/android/app/deprecated/java/com/reactnativenavigation/layouts/LayoutFactory.java 查看文件

@@ -1,36 +0,0 @@
1
-package com.reactnativenavigation.layouts;
2
-
3
-import android.support.v7.app.AppCompatActivity;
4
-import android.util.Log;
5
-
6
-import com.reactnativenavigation.params.ActivityParams;
7
-
8
-public class LayoutFactory {
9
-    public static Layout create(AppCompatActivity activity, ActivityParams params) {
10
-        switch (params.type) {
11
-            case TabBased:
12
-                return createBottomTabsScreenLayout(activity, params);
13
-            case SingleScreen:
14
-            default:
15
-                return createSingleScreenLayout(activity, params);
16
-        }
17
-    }
18
-
19
-    private static Layout createSingleScreenLayout(AppCompatActivity activity, ActivityParams params) {
20
-        return new SingleScreenLayout(activity, params.leftSideMenuParams, params.rightSideMenuParams, params.screenParams);
21
-    }
22
-
23
-    private static Layout createBottomTabsScreenLayout(AppCompatActivity activity, ActivityParams params) {
24
-        if (params.tabParams.size() > 5) {
25
-            removeAllButTheFirst5Tabs(params);
26
-        }
27
-        return new BottomTabsLayout(activity, params);
28
-    }
29
-
30
-    private static void removeAllButTheFirst5Tabs(ActivityParams params) {
31
-        Log.e("Navigation", "LayoutFactory:createBottomTabsScreenLayout() does not support more than 5 tabs, currently");
32
-        while (params.tabParams.size() > 5) {
33
-            params.tabParams.remove(params.tabParams.size() - 1);
34
-        }
35
-    }
36
-}

+ 0
- 21
lib/android/app/deprecated/java/com/reactnativenavigation/layouts/ModalScreenLayout.java 查看文件

@@ -1,21 +0,0 @@
1
-package com.reactnativenavigation.layouts;
2
-
3
-import android.support.v7.app.AppCompatActivity;
4
-
5
-import com.reactnativenavigation.params.ScreenParams;
6
-import com.reactnativenavigation.views.LeftButtonOnClickListener;
7
-
8
-public class ModalScreenLayout extends SingleScreenLayout {
9
-
10
-    public ModalScreenLayout(AppCompatActivity activity,
11
-                             ScreenParams screenParams,
12
-                             LeftButtonOnClickListener leftButtonOnClickListener) {
13
-        super(activity, null, null, screenParams);
14
-        this.leftButtonOnClickListener = leftButtonOnClickListener;
15
-    }
16
-
17
-    @Override
18
-    protected void pushInitialScreen(LayoutParams lp) {
19
-        stack.pushInitialScreenWithAnimation(screenParams, lp);
20
-    }
21
-}

+ 0
- 16
lib/android/app/deprecated/java/com/reactnativenavigation/layouts/ScreenStackContainer.java 查看文件

@@ -1,16 +0,0 @@
1
-package com.reactnativenavigation.layouts;
2
-
3
-import com.reactnativenavigation.params.ScreenParams;
4
-import com.reactnativenavigation.views.LeftButtonOnClickListener;
5
-
6
-public interface ScreenStackContainer extends LeftButtonOnClickListener {
7
-    void push(ScreenParams screenParams);
8
-
9
-    void pop(ScreenParams screenParams);
10
-
11
-    void popToRoot(ScreenParams params);
12
-
13
-    void newStack(ScreenParams params);
14
-
15
-    void destroy();
16
-}

+ 0
- 257
lib/android/app/deprecated/java/com/reactnativenavigation/layouts/SingleScreenLayout.java 查看文件

@@ -1,257 +0,0 @@
1
-package com.reactnativenavigation.layouts;
2
-
3
-import android.support.annotation.Nullable;
4
-import android.support.v7.app.AppCompatActivity;
5
-import android.view.View;
6
-import android.widget.RelativeLayout;
7
-
8
-import com.facebook.react.bridge.Callback;
9
-import com.reactnativenavigation.NavigationApplication;
10
-import com.reactnativenavigation.events.EventBus;
11
-import com.reactnativenavigation.events.ScreenChangedEvent;
12
-import com.reactnativenavigation.params.ContextualMenuParams;
13
-import com.reactnativenavigation.params.FabParams;
14
-import com.reactnativenavigation.params.ScreenParams;
15
-import com.reactnativenavigation.params.SideMenuParams;
16
-import com.reactnativenavigation.params.SnackbarParams;
17
-import com.reactnativenavigation.params.TitleBarButtonParams;
18
-import com.reactnativenavigation.params.TitleBarLeftButtonParams;
19
-import com.reactnativenavigation.screens.Screen;
20
-import com.reactnativenavigation.screens.ScreenStack;
21
-import com.reactnativenavigation.views.LeftButtonOnClickListener;
22
-import com.reactnativenavigation.views.SideMenu;
23
-import com.reactnativenavigation.views.SideMenu.Side;
24
-import com.reactnativenavigation.views.SnackbarAndFabContainer;
25
-
26
-import java.util.List;
27
-
28
-import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
29
-
30
-public class SingleScreenLayout extends RelativeLayout implements Layout {
31
-
32
-    private final AppCompatActivity activity;
33
-    protected final ScreenParams screenParams;
34
-    private final SideMenuParams leftSideMenuParams;
35
-    private final SideMenuParams rightSideMenuParams;
36
-    protected ScreenStack stack;
37
-    private SnackbarAndFabContainer snackbarAndFabContainer;
38
-    protected LeftButtonOnClickListener leftButtonOnClickListener;
39
-    private @Nullable SideMenu sideMenu;
40
-
41
-    public SingleScreenLayout(AppCompatActivity activity, SideMenuParams leftSideMenuParams,
42
-                              SideMenuParams rightSideMenuParams, ScreenParams screenParams) {
43
-        super(activity);
44
-        this.activity = activity;
45
-        this.screenParams = screenParams;
46
-        this.leftSideMenuParams = leftSideMenuParams;
47
-        this.rightSideMenuParams = rightSideMenuParams;
48
-        createLayout();
49
-    }
50
-
51
-    private void createLayout() {
52
-        if (leftSideMenuParams == null && rightSideMenuParams == null) {
53
-            createStack(getScreenStackParent());
54
-        } else {
55
-            sideMenu = createSideMenu();
56
-            createStack(getScreenStackParent());
57
-        }
58
-        createFabAndSnackbarContainer();
59
-        sendScreenChangedEventAfterInitialPush();
60
-    }
61
-
62
-    private RelativeLayout getScreenStackParent() {
63
-        return sideMenu == null ? this : sideMenu.getContentContainer();
64
-    }
65
-
66
-    private SideMenu createSideMenu() {
67
-        SideMenu sideMenu = new SideMenu(getContext(), leftSideMenuParams, rightSideMenuParams);
68
-        RelativeLayout.LayoutParams lp = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
69
-        addView(sideMenu, lp);
70
-        return sideMenu;
71
-    }
72
-
73
-    private void createStack(RelativeLayout parent) {
74
-        if (stack != null) {
75
-            stack.destroy();
76
-        }
77
-        stack = new ScreenStack(activity, parent, screenParams.getNavigatorId(), this);
78
-        LayoutParams lp = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
79
-        pushInitialScreen(lp);
80
-    }
81
-
82
-    protected void pushInitialScreen(LayoutParams lp) {
83
-        stack.pushInitialScreen(screenParams, lp);
84
-        stack.show();
85
-    }
86
-
87
-    private void sendScreenChangedEventAfterInitialPush() {
88
-        if (screenParams.topTabParams != null) {
89
-            EventBus.instance.post(new ScreenChangedEvent(screenParams.topTabParams.get(0)));
90
-        } else {
91
-            EventBus.instance.post(new ScreenChangedEvent(screenParams));
92
-        }
93
-    }
94
-
95
-    private void createFabAndSnackbarContainer() {
96
-        snackbarAndFabContainer = new SnackbarAndFabContainer(getContext(), this);
97
-        RelativeLayout.LayoutParams lp = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
98
-        lp.addRule(ALIGN_PARENT_BOTTOM);
99
-        snackbarAndFabContainer.setLayoutParams(lp);
100
-        getScreenStackParent().addView(snackbarAndFabContainer);
101
-    }
102
-
103
-    @Override
104
-    public boolean onBackPressed() {
105
-        if (stack.handleBackPressInJs()) {
106
-            return true;
107
-        }
108
-
109
-        if (stack.canPop()) {
110
-            stack.pop(true);
111
-            EventBus.instance.post(new ScreenChangedEvent(stack.peek().getScreenParams()));
112
-            return true;
113
-        } else {
114
-            return false;
115
-        }
116
-    }
117
-
118
-    @Override
119
-    public void destroy() {
120
-        stack.destroy();
121
-        snackbarAndFabContainer.destroy();
122
-        if (sideMenu != null) {
123
-            sideMenu.destroy();
124
-        }
125
-    }
126
-
127
-    @Override
128
-    public void push(ScreenParams params) {
129
-        LayoutParams lp = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
130
-        stack.push(params, lp);
131
-        EventBus.instance.post(new ScreenChangedEvent(params));
132
-    }
133
-
134
-    @Override
135
-    public void pop(ScreenParams params) {
136
-        stack.pop(params.animateScreenTransitions);
137
-        EventBus.instance.post(new ScreenChangedEvent(stack.peek().getScreenParams()));
138
-    }
139
-
140
-    @Override
141
-    public void popToRoot(ScreenParams params) {
142
-        stack.popToRoot(params.animateScreenTransitions);
143
-        EventBus.instance.post(new ScreenChangedEvent(stack.peek().getScreenParams()));
144
-    }
145
-
146
-    @Override
147
-    public void newStack(ScreenParams params) {
148
-        removeView(stack.peek());
149
-        stack.destroy();
150
-
151
-        ScreenStack newStack = new ScreenStack(activity, getScreenStackParent(), params.getNavigatorId(), this);
152
-        LayoutParams lp = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
153
-        newStack.pushInitialScreenWithAnimation(params, lp);
154
-        stack = newStack;
155
-
156
-        EventBus.instance.post(new ScreenChangedEvent(params));
157
-    }
158
-
159
-    @Override
160
-    public void setTopBarVisible(String screenInstanceID, boolean visible, boolean animate) {
161
-        stack.setScreenTopBarVisible(screenInstanceID, visible, animate);
162
-    }
163
-
164
-    @Override
165
-    public void setTitleBarTitle(String screenInstanceId, String title) {
166
-        stack.setScreenTitleBarTitle(screenInstanceId, title);
167
-    }
168
-
169
-    @Override
170
-    public void setTitleBarSubtitle(String screenInstanceId, String subtitle) {
171
-        stack.setScreenTitleBarSubtitle(screenInstanceId, subtitle);
172
-    }
173
-
174
-    @Override
175
-    public View asView() {
176
-        return this;
177
-    }
178
-
179
-    @Override
180
-    public void setTitleBarRightButtons(String screenInstanceId, String navigatorEventId,
181
-                                        List<TitleBarButtonParams> titleBarRightButtons) {
182
-        stack.setScreenTitleBarRightButtons(screenInstanceId, navigatorEventId, titleBarRightButtons);
183
-    }
184
-
185
-    @Override
186
-    public void setTitleBarLeftButton(String screenInstanceId, String navigatorEventId, TitleBarLeftButtonParams titleBarLeftButtonParams) {
187
-        stack.setScreenTitleBarLeftButton(screenInstanceId, navigatorEventId, titleBarLeftButtonParams);
188
-    }
189
-
190
-    @Override
191
-    public void setFab(String screenInstanceId, String navigatorEventId, FabParams fabParams) {
192
-        stack.setFab(screenInstanceId, navigatorEventId, fabParams);
193
-    }
194
-
195
-    @Override
196
-    public void toggleSideMenuVisible(boolean animated, Side side) {
197
-        if (sideMenu != null) {
198
-            sideMenu.toggleVisible(animated, side);
199
-        }
200
-    }
201
-
202
-    @Override
203
-    public void setSideMenuVisible(boolean animated, boolean visible, Side side) {
204
-        if (sideMenu != null) {
205
-            sideMenu.setVisible(visible, animated, side);
206
-        }
207
-    }
208
-
209
-    @Override
210
-    public void showSnackbar(SnackbarParams params) {
211
-        final String navigatorEventId = stack.peek().getNavigatorEventId();
212
-        snackbarAndFabContainer.showSnackbar(navigatorEventId, params);
213
-    }
214
-
215
-    @Override
216
-    public void onModalDismissed() {
217
-        EventBus.instance.post(new ScreenChangedEvent(stack.peek().getScreenParams()));
218
-    }
219
-
220
-    @Override
221
-    public boolean containsNavigator(String navigatorId) {
222
-        return stack.getNavigatorId().equals(navigatorId);
223
-    }
224
-
225
-    @Override
226
-    public void showContextualMenu(String screenInstanceId, ContextualMenuParams params, Callback onButtonClicked) {
227
-        stack.showContextualMenu(screenInstanceId, params, onButtonClicked);
228
-    }
229
-
230
-    @Override
231
-    public void dismissContextualMenu(String screenInstanceId) {
232
-        stack.dismissContextualMenu(screenInstanceId);
233
-    }
234
-
235
-    @Override
236
-    public Screen getCurrentScreen() {
237
-        return stack.peek();
238
-    }
239
-
240
-    @Override
241
-    public boolean onTitleBarBackButtonClick() {
242
-        if (leftButtonOnClickListener != null) {
243
-            return leftButtonOnClickListener.onTitleBarBackButtonClick();
244
-        }
245
-
246
-        return onBackPressed();
247
-    }
248
-
249
-    @Override
250
-    public void onSideMenuButtonClick() {
251
-        final String navigatorEventId = stack.peek().getNavigatorEventId();
252
-        NavigationApplication.instance.getEventEmitter().sendNavigatorEvent("sideMenu", navigatorEventId);
253
-        if (sideMenu != null) {
254
-            sideMenu.openDrawer(Side.Left);
255
-        }
256
-    }
257
-}

+ 0
- 16
lib/android/app/deprecated/java/com/reactnativenavigation/params/ActivityParams.java 查看文件

@@ -1,16 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-import java.util.List;
4
-
5
-public class ActivityParams {
6
-    public enum Type {
7
-        SingleScreen, TabBased
8
-    }
9
-
10
-    public Type type;
11
-    public ScreenParams screenParams;
12
-    public List<ScreenParams> tabParams;
13
-    public SideMenuParams leftSideMenuParams;
14
-    public SideMenuParams rightSideMenuParams;
15
-    public boolean animateShow;
16
-}

+ 0
- 13
lib/android/app/deprecated/java/com/reactnativenavigation/params/AppStyle.java 查看文件

@@ -1,13 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-import android.os.Bundle;
4
-
5
-import com.reactnativenavigation.params.parsers.StyleParamsParser;
6
-
7
-public class AppStyle {
8
-    public static StyleParams appStyle;
9
-
10
-    public static void setAppStyle(Bundle params) {
11
-        appStyle = new StyleParamsParser(params.getBundle("appStyle")).parse();
12
-    }
13
-}

+ 0
- 45
lib/android/app/deprecated/java/com/reactnativenavigation/params/BaseScreenParams.java 查看文件

@@ -1,45 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-import android.os.Bundle;
4
-
5
-import java.util.List;
6
-
7
-public class BaseScreenParams {
8
-    public String screenId;
9
-    public String title;
10
-    public String subtitle;
11
-    public NavigationParams navigationParams;
12
-    public List<TitleBarButtonParams> rightButtons;
13
-    public TitleBarLeftButtonParams leftButton;
14
-    public FabParams fabParams;
15
-
16
-    public boolean overrideBackPressInJs;
17
-    public StyleParams styleParams;
18
-    public String fragmentCreatorClassName;
19
-    public Bundle fragmentCreatorPassProps;
20
-    public boolean animateScreenTransitions;
21
-
22
-    public boolean isFragmentScreen() {
23
-        return fragmentCreatorClassName != null;
24
-    }
25
-
26
-    public String getScreenInstanceId() {
27
-        return navigationParams.screenInstanceId;
28
-    }
29
-
30
-    public String getNavigatorId() {
31
-        return navigationParams.navigatorId;
32
-    }
33
-
34
-    public String getNavigatorEventId() {
35
-        return navigationParams.navigatorEventId;
36
-    }
37
-
38
-    public boolean hasCollapsingTopBar() {
39
-        return styleParams.collapsingTopBarParams != null;
40
-    }
41
-
42
-    public FabParams getFab() {
43
-        return fabParams;
44
-    }
45
-}

+ 0
- 33
lib/android/app/deprecated/java/com/reactnativenavigation/params/BaseTitleBarButtonParams.java 查看文件

@@ -1,33 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-import android.graphics.drawable.Drawable;
4
-import android.view.MenuItem;
5
-
6
-public class BaseTitleBarButtonParams {
7
-    public enum ShowAsAction {
8
-        IfRoom(MenuItem.SHOW_AS_ACTION_IF_ROOM),
9
-        Always(MenuItem.SHOW_AS_ACTION_ALWAYS),
10
-        Never(MenuItem.SHOW_AS_ACTION_NEVER),
11
-        WithText(MenuItem.SHOW_AS_ACTION_WITH_TEXT);
12
-
13
-        public final int action;
14
-
15
-        ShowAsAction(int action) {
16
-            this.action = action;
17
-        }
18
-    }
19
-
20
-    public String eventId;
21
-    public String label;
22
-    public Drawable icon;
23
-    public StyleParams.Color color;
24
-    public StyleParams.Color disabledColor;
25
-    public ShowAsAction showAsAction;
26
-    public boolean enabled = true;
27
-
28
-    public void setColorFromScreenStyle(StyleParams.Color titleBarButtonColor) {
29
-        if (!color.hasColor() && titleBarButtonColor.hasColor()) {
30
-            color = titleBarButtonColor;
31
-        }
32
-    }
33
-}

+ 0
- 15
lib/android/app/deprecated/java/com/reactnativenavigation/params/CollapsingTopBarParams.java 查看文件

@@ -1,15 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-import android.support.annotation.Nullable;
4
-
5
-import com.reactnativenavigation.views.collapsingToolbar.behaviours.CollapseBehaviour;
6
-
7
-public class CollapsingTopBarParams {
8
-    public @Nullable String imageUri;
9
-    public StyleParams.Color scrimColor;
10
-    public CollapseBehaviour collapseBehaviour;
11
-
12
-    public boolean hasBackgroundImage() {
13
-        return imageUri != null;
14
-    }
15
-}

+ 0
- 5
lib/android/app/deprecated/java/com/reactnativenavigation/params/ContextualMenuButtonParams.java 查看文件

@@ -1,5 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-public class ContextualMenuButtonParams extends TitleBarButtonParams {
4
-    public int index;
5
-}

+ 0
- 16
lib/android/app/deprecated/java/com/reactnativenavigation/params/ContextualMenuParams.java 查看文件

@@ -1,16 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-import java.util.List;
4
-
5
-public class ContextualMenuParams {
6
-    public List<ContextualMenuButtonParams> buttons;
7
-    public TitleBarLeftButtonParams leftButton;
8
-    public NavigationParams navigationParams;
9
-
10
-    public void setButtonsColor(StyleParams.Color buttonColor) {
11
-        for (ContextualMenuButtonParams button : buttons) {
12
-            button.color = buttonColor;
13
-        }
14
-        leftButton.color = buttonColor;
15
-    }
16
-}

+ 0
- 10
lib/android/app/deprecated/java/com/reactnativenavigation/params/FabActionParams.java 查看文件

@@ -1,10 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-import android.graphics.drawable.Drawable;
4
-
5
-public class FabActionParams {
6
-    public String id;
7
-    public String navigatorEventId;
8
-    public Drawable icon;
9
-    public StyleParams.Color backgroundColor;
10
-}

+ 0
- 24
lib/android/app/deprecated/java/com/reactnativenavigation/params/FabParams.java 查看文件

@@ -1,24 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-import android.graphics.drawable.Drawable;
4
-
5
-import java.util.List;
6
-
7
-public class FabParams {
8
-    public Drawable collapsedIcon;
9
-    public Drawable expendedIcon;
10
-    public StyleParams.Color backgroundColor;
11
-    public String collapsedId;
12
-    public String expendedId;
13
-    public String navigatorEventId;
14
-    public List<FabActionParams> actions;
15
-    public String screenInstanceId;
16
-
17
-    public boolean hasExpendedState() {
18
-        return actions != null && actions.size() > 0;
19
-    }
20
-
21
-    public boolean isValid() {
22
-        return collapsedId != null;
23
-    }
24
-}

+ 0
- 27
lib/android/app/deprecated/java/com/reactnativenavigation/params/NavigationParams.java 查看文件

@@ -1,27 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-import android.os.Bundle;
4
-
5
-public class NavigationParams {
6
-    private static final String SCREEN_INSTANCE_ID = "screenInstanceID";
7
-    private static final String NAVIGATOR_ID = "navigatorID";
8
-    private static final String NAVIGATOR_EVENT_ID = "navigatorEventID";
9
-
10
-    public String screenInstanceId;
11
-    public String navigatorId;
12
-    public String navigatorEventId;
13
-
14
-    public NavigationParams(Bundle bundle) {
15
-        screenInstanceId = bundle.getString(SCREEN_INSTANCE_ID);
16
-        navigatorId = bundle.getString(NAVIGATOR_ID);
17
-        navigatorEventId = bundle.getString(NAVIGATOR_EVENT_ID);
18
-    }
19
-
20
-    public Bundle toBundle() {
21
-        Bundle b = new Bundle();
22
-        b.putString(SCREEN_INSTANCE_ID, screenInstanceId);
23
-        b.putString(NAVIGATOR_ID, navigatorId);
24
-        b.putString(NAVIGATOR_EVENT_ID, navigatorEventId);
25
-        return b;
26
-    }
27
-}

+ 0
- 6
lib/android/app/deprecated/java/com/reactnativenavigation/params/PageParams.java 查看文件

@@ -1,6 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-public class PageParams extends BaseScreenParams {
4
-
5
-
6
-}

+ 0
- 19
lib/android/app/deprecated/java/com/reactnativenavigation/params/ScreenParams.java 查看文件

@@ -1,19 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-import android.graphics.drawable.Drawable;
4
-
5
-import java.util.List;
6
-
7
-public class ScreenParams extends BaseScreenParams {
8
-    public String tabLabel;
9
-    public Drawable tabIcon;
10
-    public List<PageParams> topTabParams;
11
-
12
-    public boolean hasTopTabs() {
13
-        return topTabParams != null && !topTabParams.isEmpty();
14
-    }
15
-
16
-    public FabParams getFab() {
17
-        return hasTopTabs() ? topTabParams.get(0).fabParams : fabParams;
18
-    }
19
-}

+ 0
- 10
lib/android/app/deprecated/java/com/reactnativenavigation/params/SideMenuParams.java 查看文件

@@ -1,10 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-import com.reactnativenavigation.views.SideMenu;
4
-
5
-public class SideMenuParams {
6
-    public String screenId;
7
-    public NavigationParams navigationParams;
8
-    public boolean disableOpenGesture;
9
-    public SideMenu.Side side;
10
-}

+ 0
- 9
lib/android/app/deprecated/java/com/reactnativenavigation/params/SnackbarParams.java 查看文件

@@ -1,9 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-public class SnackbarParams {
4
-    public String text;
5
-    public String buttonText;
6
-    public StyleParams.Color buttonColor;
7
-    public String eventId;
8
-    public int duration;
9
-}

+ 0
- 79
lib/android/app/deprecated/java/com/reactnativenavigation/params/StyleParams.java 查看文件

@@ -1,79 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-import android.os.Bundle;
4
-import android.support.annotation.ColorInt;
5
-
6
-public class StyleParams {
7
-    public static class Color {
8
-        @ColorInt
9
-        private Integer color = null;
10
-
11
-        public Color() {
12
-            color = null;
13
-        }
14
-
15
-        public Color(Integer color) {
16
-            this.color = color;
17
-        }
18
-
19
-        public boolean hasColor() {
20
-            return color != null;
21
-        }
22
-
23
-        @ColorInt
24
-        public int getColor() {
25
-            if (!hasColor()) {
26
-                throw new RuntimeException("Color undefined");
27
-            }
28
-            return color;
29
-        }
30
-
31
-        public static Color parse(Bundle bundle, String key) {
32
-            return bundle.containsKey(key) ? new Color(bundle.getInt(key)) : new Color();
33
-        }
34
-    }
35
-
36
-    public Color statusBarColor;
37
-    public Color contextualMenuStatusBarColor;
38
-    public Color contextualMenuButtonsColor;
39
-    public Color contextualMenuBackgroundColor;
40
-
41
-    public Color topBarColor;
42
-    public CollapsingTopBarParams collapsingTopBarParams;
43
-    public boolean topBarHidden;
44
-    public boolean topBarElevationShadowEnabled;
45
-    public boolean topTabsHidden;
46
-    public boolean drawScreenBelowTopBar;
47
-
48
-    public boolean titleBarHidden;
49
-    public boolean titleBarHideOnScroll;
50
-    public boolean topBarTransparent;
51
-    public boolean topBarTranslucent;
52
-    public Color titleBarTitleColor;
53
-    public Color titleBarSubtitleColor;
54
-    public Color titleBarButtonColor;
55
-    public Color titleBarDisabledButtonColor;
56
-    public boolean backButtonHidden;
57
-
58
-    public Color topTabTextColor;
59
-    public Color selectedTopTabTextColor;
60
-    public int selectedTopTabIndicatorHeight;
61
-    public Color selectedTopTabIndicatorColor;
62
-
63
-    public Color screenBackgroundColor;
64
-
65
-    public boolean drawScreenAboveBottomTabs;
66
-
67
-    public Color snackbarButtonColor;
68
-
69
-    public boolean bottomTabsHidden;
70
-    public boolean bottomTabsHiddenOnScroll;
71
-    public Color bottomTabsColor;
72
-    public Color selectedBottomTabsButtonColor;
73
-    public Color bottomTabsButtonColor;
74
-    public boolean forceTitlesDisplay;
75
-    public Color bottomTabBadgeTextColor;
76
-    public Color bottomTabBadgeBackgroundColor;
77
-
78
-    public Color navigationBarColor;
79
-}

+ 0
- 22
lib/android/app/deprecated/java/com/reactnativenavigation/params/TitleBarButtonParams.java 查看文件

@@ -1,22 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-public class TitleBarButtonParams extends BaseTitleBarButtonParams {
4
-    public String eventId;
5
-    public StyleParams.Color color;
6
-    public StyleParams.Color disabledColor;
7
-    public boolean enabled = true;
8
-    public String hint;
9
-
10
-    public void setColorFromScreenStyle(StyleParams.Color titleBarButtonColor) {
11
-        if (!color.hasColor() && titleBarButtonColor.hasColor()) {
12
-            color = titleBarButtonColor;
13
-        }
14
-    }
15
-
16
-    public StyleParams.Color getColor() {
17
-        if (enabled) {
18
-            return color;
19
-        }
20
-        return disabledColor.hasColor() ? disabledColor : AppStyle.appStyle.titleBarDisabledButtonColor;
21
-    }
22
-}

+ 0
- 23
lib/android/app/deprecated/java/com/reactnativenavigation/params/TitleBarLeftButtonParams.java 查看文件

@@ -1,23 +0,0 @@
1
-package com.reactnativenavigation.params;
2
-
3
-import com.balysv.materialmenu.MaterialMenuDrawable;
4
-
5
-public class TitleBarLeftButtonParams extends TitleBarButtonParams {
6
-    public MaterialMenuDrawable.IconState iconState;
7
-    public boolean overrideBackPressInJs;
8
-
9
-    public TitleBarLeftButtonParams(TitleBarButtonParams params) {
10
-        icon = params.icon;
11
-        color = params.color;
12
-        eventId = params.eventId;
13
-        enabled = params.enabled;
14
-    }
15
-
16
-    public boolean isBackButton() {
17
-        return eventId.equals("back");
18
-    }
19
-
20
-    public void setOverrideBackPressInJs(boolean overrideBackPressInJs) {
21
-        this.overrideBackPressInJs = overrideBackPressInJs;
22
-    }
23
-}

+ 0
- 36
lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/ActivityParamsParser.java 查看文件

@@ -1,36 +0,0 @@
1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.os.Bundle;
4
-
5
-import com.reactnativenavigation.params.ActivityParams;
6
-import com.reactnativenavigation.params.AppStyle;
7
-import com.reactnativenavigation.params.SideMenuParams;
8
-import com.reactnativenavigation.views.SideMenu;
9
-
10
-public class ActivityParamsParser extends Parser {
11
-    public static ActivityParams parse(Bundle params) {
12
-        ActivityParams result = new ActivityParams();
13
-
14
-        AppStyle.setAppStyle(params);
15
-
16
-        if (hasKey(params, "screen")) {
17
-            result.type = ActivityParams.Type.SingleScreen;
18
-            result.screenParams = ScreenParamsParser.parse(params.getBundle("screen"));
19
-        }
20
-
21
-        if (hasKey(params, "tabs")) {
22
-            result.type = ActivityParams.Type.TabBased;
23
-            result.tabParams = new ScreenParamsParser().parseTabs(params.getBundle("tabs"));
24
-        }
25
-
26
-        if (hasKey(params, "sideMenu")) {
27
-            SideMenuParams[] sideMenus = SideMenuParamsParser.parse(params.getBundle("sideMenu"));
28
-            result.leftSideMenuParams = sideMenus[SideMenu.Side.Left.ordinal()];
29
-            result.rightSideMenuParams = sideMenus[SideMenu.Side.Right.ordinal()];
30
-        }
31
-
32
-        result.animateShow = params.getBoolean("animateShow", true);
33
-
34
-        return result;
35
-    }
36
-}

+ 0
- 45
lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/ButtonParser.java 查看文件

@@ -1,45 +0,0 @@
1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.os.Bundle;
4
-
5
-import com.reactnativenavigation.params.FabParams;
6
-import com.reactnativenavigation.params.TitleBarButtonParams;
7
-import com.reactnativenavigation.params.TitleBarLeftButtonParams;
8
-
9
-import java.util.List;
10
-
11
-public class ButtonParser extends Parser {
12
-    private static final String KEY_RIGHT_BUTTONS = "rightButtons";
13
-    private static final String KEY_LEFT_BUTTON = "leftButton";
14
-    private static final String KEY_FAB = "fab";
15
-    private static final String KEY_BACK_BUTTON_HIDDEN = "backButtonHidden";
16
-
17
-    public static List<TitleBarButtonParams> parseRightButton(Bundle params) {
18
-        List<TitleBarButtonParams> rightButtons = null;
19
-        if (hasKey(params, KEY_RIGHT_BUTTONS)) {
20
-            rightButtons = new TitleBarButtonParamsParser().parseButtons(params.getBundle(KEY_RIGHT_BUTTONS));
21
-        }
22
-        return rightButtons;
23
-    }
24
-
25
-    public static TitleBarLeftButtonParams parseLeftButton(Bundle params) {
26
-        TitleBarLeftButtonParams leftButton = null;
27
-        if (hasKey(params, KEY_LEFT_BUTTON)) {
28
-            leftButton =  new TitleBarLeftButtonParamsParser().parseSingleButton(params.getBundle(KEY_LEFT_BUTTON));
29
-
30
-            boolean backButtonHidden = params.getBoolean(KEY_BACK_BUTTON_HIDDEN, false);
31
-            if (backButtonHidden && leftButton.isBackButton()) {
32
-                leftButton = null;
33
-            }
34
-        }
35
-        return leftButton;
36
-    }
37
-
38
-    public static FabParams parseFab(Bundle params, String navigatorEventId, String screenInstanceId) {
39
-        FabParams fabParams = null;
40
-        if (hasKey(params, KEY_FAB)) {
41
-            fabParams = new FabParamsParser().parse(params.getBundle(KEY_FAB), navigatorEventId, screenInstanceId);
42
-        }
43
-        return fabParams;
44
-    }
45
-}

+ 0
- 51
lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/CollapsingTopBarParamsParser.java 查看文件

@@ -1,51 +0,0 @@
1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.graphics.Color;
4
-import android.os.Bundle;
5
-
6
-import com.reactnativenavigation.params.CollapsingTopBarParams;
7
-import com.reactnativenavigation.params.StyleParams;
8
-import com.reactnativenavigation.views.collapsingToolbar.behaviours.CollapseBehaviour;
9
-import com.reactnativenavigation.views.collapsingToolbar.behaviours.CollapseTitleBarBehaviour;
10
-import com.reactnativenavigation.views.collapsingToolbar.behaviours.CollapseTopBarBehaviour;
11
-import com.reactnativenavigation.views.collapsingToolbar.behaviours.TitleBarHideOnScrollBehaviour;
12
-
13
-class CollapsingTopBarParamsParser extends Parser {
14
-    private Bundle params;
15
-    private boolean titleBarHideOnScroll;
16
-    private boolean drawBelowTopBar;
17
-
18
-    CollapsingTopBarParamsParser(Bundle params, boolean titleBarHideOnScroll, boolean drawBelowTopBar) {
19
-        this.params = params;
20
-        this.titleBarHideOnScroll = titleBarHideOnScroll;
21
-        this.drawBelowTopBar = drawBelowTopBar;
22
-    }
23
-
24
-    public CollapsingTopBarParams parse() {
25
-        if (!hasBackgroundImage() && !titleBarHideOnScroll) {
26
-            return null;
27
-        }
28
-
29
-        CollapsingTopBarParams result = new CollapsingTopBarParams();
30
-        if (hasBackgroundImage()) {
31
-            result.imageUri = params.getString("collapsingToolBarImage");
32
-        }
33
-        result.scrimColor = getColor(params, "collapsingToolBarCollapsedColor", new StyleParams.Color(Color.WHITE));
34
-        result.collapseBehaviour = getCollapseBehaviour();
35
-        return result;
36
-    }
37
-
38
-    private CollapseBehaviour getCollapseBehaviour() {
39
-        if (hasBackgroundImage()) {
40
-            return new CollapseTopBarBehaviour();
41
-        }
42
-        if (titleBarHideOnScroll && drawBelowTopBar) {
43
-            return new CollapseTitleBarBehaviour();
44
-        }
45
-        return new TitleBarHideOnScrollBehaviour();
46
-    }
47
-
48
-    private boolean hasBackgroundImage() {
49
-        return params.containsKey("collapsingToolBarImage");
50
-    }
51
-}

+ 0
- 32
lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/ContextualMenuButtonParamsParser.java 查看文件

@@ -1,32 +0,0 @@
1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.os.Bundle;
4
-
5
-import com.reactnativenavigation.params.ContextualMenuButtonParams;
6
-import com.reactnativenavigation.params.StyleParams;
7
-import com.reactnativenavigation.react.ImageLoader;
8
-
9
-import java.util.List;
10
-
11
-public class ContextualMenuButtonParamsParser extends TitleBarButtonParamsParser {
12
-    public List<ContextualMenuButtonParams> parseContextualMenuButtons(Bundle params) {
13
-        return parseBundle(params, new ParseStrategy<ContextualMenuButtonParams>() {
14
-            @Override
15
-            public ContextualMenuButtonParams parse(Bundle button) {
16
-                return parseSingleContextualMenuButton(button);
17
-            }
18
-        });
19
-    }
20
-
21
-    private ContextualMenuButtonParams parseSingleContextualMenuButton(Bundle button) {
22
-        ContextualMenuButtonParams result = new ContextualMenuButtonParams();
23
-        if (button.get("icon") != null) {
24
-            result.icon = ImageLoader.loadImage(button.getString("icon"));
25
-        }
26
-        result.showAsAction = parseShowAsAction(button.getString("showAsAction"));
27
-        result.color = StyleParams.Color.parse(button, "color");
28
-        result.label = button.getString("label");
29
-        result.index = button.getInt("index");
30
-        return result;
31
-    }
32
-}

+ 0
- 16
lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/ContextualMenuParamsParser.java 查看文件

@@ -1,16 +0,0 @@
1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.os.Bundle;
4
-
5
-import com.reactnativenavigation.params.ContextualMenuParams;
6
-import com.reactnativenavigation.params.NavigationParams;
7
-
8
-public class ContextualMenuParamsParser extends Parser {
9
-    public ContextualMenuParams parse(Bundle bundle) {
10
-        ContextualMenuParams result = new ContextualMenuParams();
11
-        result.buttons = new ContextualMenuButtonParamsParser().parseContextualMenuButtons(bundle.getBundle("buttons"));
12
-        result.leftButton = new TitleBarLeftButtonParamsParser().parseSingleButton(bundle.getBundle("backButton"));
13
-        result.navigationParams = new NavigationParams(bundle.getBundle("navigationParams"));
14
-        return result;
15
-    }
16
-}

+ 0
- 18
lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/FabActionParamsParser.java 查看文件

@@ -1,18 +0,0 @@
1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.os.Bundle;
4
-
5
-import com.reactnativenavigation.params.FabActionParams;
6
-import com.reactnativenavigation.params.StyleParams;
7
-import com.reactnativenavigation.react.ImageLoader;
8
-
9
-public class FabActionParamsParser extends Parser {
10
-    public FabActionParams parse(Bundle params, String navigatorEventId) {
11
-        FabActionParams fabActionParams = new FabActionParams();
12
-        fabActionParams.id = params.getString("id");
13
-        fabActionParams.navigatorEventId = navigatorEventId;
14
-        fabActionParams.icon = ImageLoader.loadImage(params.getString("icon"));
15
-        fabActionParams.backgroundColor = StyleParams.Color.parse(params, "backgroundColor");
16
-        return fabActionParams;
17
-    }
18
-}

+ 0
- 35
lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/FabParamsParser.java 查看文件

@@ -1,35 +0,0 @@
1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.os.Bundle;
4
-
5
-import com.reactnativenavigation.params.FabActionParams;
6
-import com.reactnativenavigation.params.FabParams;
7
-import com.reactnativenavigation.params.StyleParams;
8
-import com.reactnativenavigation.react.ImageLoader;
9
-
10
-public class FabParamsParser extends Parser {
11
-    public FabParams parse(Bundle params, final String navigatorEventId, String screenInstanceId) {
12
-        FabParams fabParams = new FabParams();
13
-        fabParams.collapsedId = params.getString("collapsedId");
14
-        fabParams.expendedId = params.getString("expendedId");
15
-        fabParams.navigatorEventId = navigatorEventId;
16
-        fabParams.screenInstanceId = screenInstanceId;
17
-        fabParams.backgroundColor = getColor(params, "backgroundColor", new StyleParams.Color());
18
-
19
-        if (hasKey(params, "collapsedIcon")) {
20
-            fabParams.collapsedIcon = ImageLoader.loadImage(params.getString("collapsedIcon"));
21
-        }
22
-        if (hasKey(params, "expendedIcon")) {
23
-            fabParams.expendedIcon = ImageLoader.loadImage(params.getString("expendedIcon"));
24
-        }
25
-        if (hasKey(params, "actions")) {
26
-            fabParams.actions = parseBundle(params.getBundle("actions"), new ParseStrategy<FabActionParams>() {
27
-                @Override
28
-                public FabActionParams parse(Bundle params) {
29
-                    return new FabActionParamsParser().parse(params, navigatorEventId);
30
-                }
31
-            });
32
-        }
33
-        return fabParams;
34
-    }
35
-}

+ 0
- 44
lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/Parser.java 查看文件

@@ -1,44 +0,0 @@
1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.os.Bundle;
4
-
5
-import com.reactnativenavigation.params.StyleParams;
6
-
7
-import java.util.ArrayList;
8
-import java.util.Collections;
9
-import java.util.List;
10
-
11
-public class Parser {
12
-    static boolean hasKey(Bundle bundle, String key) {
13
-        return bundle.keySet().contains(key);
14
-    }
15
-
16
-    static void assertKeyExists(Bundle bundle, String key) {
17
-        if (!hasKey(bundle, key)) {
18
-            throw new KeyDoesNotExistsException(key);
19
-        }
20
-    }
21
-
22
-    private static class KeyDoesNotExistsException extends RuntimeException {
23
-        KeyDoesNotExistsException(String key) {
24
-            super(key);
25
-        }
26
-    }
27
-
28
-    interface ParseStrategy<T> {
29
-        T parse(Bundle params);
30
-    }
31
-
32
-    <T> List<T> parseBundle(Bundle params, ParseStrategy<T> strategy) {
33
-        ArrayList<T> result = new ArrayList<>(Collections.nCopies(params.keySet().size(), (T) null));
34
-        for (String key : params.keySet()) {
35
-            result.set(Integer.parseInt(key), strategy.parse(params.getBundle(key)));
36
-        }
37
-        return result;
38
-    }
39
-
40
-    protected StyleParams.Color getColor(Bundle bundle, String key, StyleParams.Color defaultColor) {
41
-        StyleParams.Color color = StyleParams.Color.parse(bundle, key);
42
-        return color.hasColor() || defaultColor == null ? color : defaultColor;
43
-    }
44
-}

+ 0
- 88
lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/ScreenParamsParser.java 查看文件

@@ -1,88 +0,0 @@
1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.graphics.drawable.Drawable;
4
-import android.os.Bundle;
5
-
6
-import com.reactnativenavigation.params.NavigationParams;
7
-import com.reactnativenavigation.params.ScreenParams;
8
-import com.reactnativenavigation.params.PageParams;
9
-import com.reactnativenavigation.react.ImageLoader;
10
-
11
-import java.util.List;
12
-
13
-public class ScreenParamsParser extends Parser {
14
-    private static final String KEY_TITLE = "title";
15
-    private static final String KEY_SUBTITLE = "subtitle";
16
-    private static final String KEY_SCREEN_ID = "screenId";
17
-    private static final String KEY_NAVIGATION_PARAMS = "navigationParams";
18
-    private static final String STYLE_PARAMS = "styleParams";
19
-    private static final String TOP_TABS = "topTabs";
20
-    private static final String FRAGMENT_CREATOR_CLASS_NAME = "fragmentCreatorClassName";
21
-    private static final String FRAGMENT_CREATOR_PASS_PROPS = "fragmentCreatorPassProps";
22
-    private static final String OVERRIDE_BACK_PRESS = "overrideBackPress";
23
-
24
-    @SuppressWarnings("ConstantConditions")
25
-    public static ScreenParams parse(Bundle params) {
26
-        ScreenParams result = new ScreenParams();
27
-        result.screenId = params.getString(KEY_SCREEN_ID);
28
-        assertKeyExists(params, KEY_NAVIGATION_PARAMS);
29
-        result.navigationParams = new NavigationParams(params.getBundle(KEY_NAVIGATION_PARAMS));
30
-
31
-        result.styleParams = new StyleParamsParser(params.getBundle(STYLE_PARAMS)).parse();
32
-
33
-        result.title = params.getString(KEY_TITLE);
34
-        result.subtitle = params.getString(KEY_SUBTITLE);
35
-        result.rightButtons = ButtonParser.parseRightButton(params);
36
-        result.overrideBackPressInJs = params.getBoolean(OVERRIDE_BACK_PRESS, false);
37
-        result.leftButton = ButtonParser.parseLeftButton(params);
38
-
39
-        result.topTabParams = parseTopTabs(params);
40
-
41
-        if (hasKey(params, FRAGMENT_CREATOR_CLASS_NAME)) {
42
-            result.fragmentCreatorClassName = params.getString(FRAGMENT_CREATOR_CLASS_NAME);
43
-            result.fragmentCreatorPassProps = params.getBundle(FRAGMENT_CREATOR_PASS_PROPS);
44
-        }
45
-
46
-        result.fabParams = ButtonParser.parseFab(params, result.navigationParams.navigatorEventId, result.navigationParams.screenInstanceId);
47
-
48
-        result.tabLabel = getTabLabel(params);
49
-        result.tabIcon = getTabIcon(params);
50
-
51
-        result.animateScreenTransitions = params.getBoolean("animated", true);
52
-
53
-        return result;
54
-    }
55
-
56
-    private static Drawable getTabIcon(Bundle params) {
57
-        Drawable tabIcon = null;
58
-        if (hasKey(params, "icon")) {
59
-            tabIcon = ImageLoader.loadImage(params.getString("icon"));
60
-        }
61
-        return tabIcon;
62
-    }
63
-
64
-    private static String getTabLabel(Bundle params) {
65
-        String tabLabel = null;
66
-        if (hasKey(params, "label")) {
67
-            tabLabel = params.getString("label");
68
-        }
69
-        return tabLabel;
70
-    }
71
-
72
-    private static List<PageParams> parseTopTabs(Bundle params) {
73
-        List<PageParams> topTabParams = null;
74
-        if (hasKey(params, TOP_TABS)) {
75
-            topTabParams = new TopTabParamsParser().parse(params.getBundle(TOP_TABS));
76
-        }
77
-        return topTabParams;
78
-    }
79
-
80
-    List<ScreenParams> parseTabs(Bundle params) {
81
-        return parseBundle(params, new ParseStrategy<ScreenParams>() {
82
-            @Override
83
-            public ScreenParams parse(Bundle screen) {
84
-                return ScreenParamsParser.parse(screen);
85
-            }
86
-        });
87
-    }
88
-}

+ 0
- 29
lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/SideMenuParamsParser.java 查看文件

@@ -1,29 +0,0 @@
1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.os.Bundle;
4
-import android.support.annotation.Nullable;
5
-
6
-import com.reactnativenavigation.params.NavigationParams;
7
-import com.reactnativenavigation.params.SideMenuParams;
8
-import com.reactnativenavigation.views.SideMenu.Side;
9
-
10
-class SideMenuParamsParser extends Parser {
11
-    public static SideMenuParams[] parse(Bundle sideMenues) {
12
-        SideMenuParams[] result = new SideMenuParams[2];
13
-        result[Side.Left.ordinal()] = parseSideMenu(sideMenues.getBundle("left"), Side.Left);
14
-        result[Side.Right.ordinal()] = parseSideMenu(sideMenues.getBundle("right"), Side.Right);
15
-        return result;
16
-    }
17
-
18
-    private static SideMenuParams parseSideMenu(@Nullable Bundle sideMenu, Side side) {
19
-        if (sideMenu == null || sideMenu.isEmpty()) {
20
-            return null;
21
-        }
22
-        SideMenuParams result = new SideMenuParams();
23
-        result.screenId = sideMenu.getString("screenId");
24
-        result.navigationParams = new NavigationParams(sideMenu.getBundle("navigationParams"));
25
-        result.disableOpenGesture = sideMenu.getBoolean("disableOpenGesture", false);
26
-        result.side = side;
27
-        return result;
28
-    }
29
-}

+ 0
- 32
lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/SnackbarParamsParser.java 查看文件

@@ -1,32 +0,0 @@
1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.os.Bundle;
4
-import android.support.design.widget.Snackbar;
5
-
6
-import com.reactnativenavigation.params.AppStyle;
7
-import com.reactnativenavigation.params.SnackbarParams;
8
-
9
-public class SnackbarParamsParser extends Parser {
10
-    public SnackbarParams parse(Bundle params) {
11
-        SnackbarParams result = new SnackbarParams();
12
-        result.text = params.getString("text");
13
-        result.buttonText = params.getString("actionText");
14
-        result.buttonColor = getColor(params, "actionColor", AppStyle.appStyle.snackbarButtonColor);
15
-        result.duration = getDuration(params.getString("duration", "short"));
16
-        result.eventId = params.getString("actionId");
17
-        return result;
18
-    }
19
-
20
-    private int getDuration(String duration) {
21
-        switch (duration) {
22
-            case "short":
23
-                return Snackbar.LENGTH_SHORT;
24
-            case "long":
25
-                return Snackbar.LENGTH_LONG;
26
-            case "indefinite":
27
-                return Snackbar.LENGTH_INDEFINITE;
28
-            default:
29
-                return Snackbar.LENGTH_SHORT;
30
-        }
31
-    }
32
-}

+ 0
- 221
lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/StyleParamsParser.java 查看文件

@@ -1,221 +0,0 @@
1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.graphics.Color;
4
-import android.os.Bundle;
5
-
6
-import com.reactnativenavigation.params.AppStyle;
7
-import com.reactnativenavigation.params.StyleParams;
8
-
9
-public class StyleParamsParser {
10
-    private Bundle params;
11
-
12
-    public StyleParamsParser(Bundle params) {
13
-        this.params = params;
14
-    }
15
-
16
-    public StyleParams parse() {
17
-        if (params == null) {
18
-            return createDefaultStyleParams();
19
-        }
20
-
21
-        StyleParams result = new StyleParams();
22
-        result.statusBarColor = getColor("statusBarColor", getDefaultStatusBarColor());
23
-        result.contextualMenuStatusBarColor = getColor("contextualMenuStatusBarColor", getDefaultContextualMenuStatusBarColor());
24
-        result.contextualMenuButtonsColor = getColor("contextualMenuButtonsColor", getDefaultContextualMenuButtonsColor());
25
-        result.contextualMenuBackgroundColor = getColor("contextualMenuBackgroundColor", getDefaultContextualMenuBackgroundColor());
26
-
27
-        result.topBarColor = getColor("topBarColor", getDefaultTopBarColor());
28
-        result.titleBarHideOnScroll = getBoolean("titleBarHideOnScroll", getDefaultTitleBarHideOnScroll());
29
-        result.topBarTransparent = getBoolean("topBarTransparent", getDefaultTopBarHidden());
30
-        result.drawScreenBelowTopBar = params.getBoolean("drawBelowTopBar", getDefaultScreenBelowTopBar());
31
-        if (result.topBarTransparent) {
32
-            result.drawScreenBelowTopBar = false;
33
-        }
34
-        result.collapsingTopBarParams = new CollapsingTopBarParamsParser(params, result.titleBarHideOnScroll, result.drawScreenBelowTopBar).parse();
35
-        result.titleBarHidden = getBoolean("titleBarHidden", getDefaultTopBarHidden());
36
-        result.topBarElevationShadowEnabled = getBoolean("topBarElevationShadowEnabled", getDefaultTopBarElevationShadowEnabled());
37
-        result.titleBarTitleColor = getColor("titleBarTitleColor", getDefaultTitleBarColor());
38
-        result.topBarTranslucent = getBoolean("topBarTranslucent", getDefaultTopBarTranslucent());
39
-
40
-        result.titleBarSubtitleColor = getColor("titleBarSubtitleColor", getDefaultSubtitleBarColor());
41
-        result.titleBarButtonColor = getColor("titleBarButtonColor", getTitleBarButtonColor());
42
-        result.titleBarDisabledButtonColor = getColor("titleBarDisabledButtonColor", getTitleBarDisabledButtonColor());
43
-        result.backButtonHidden = getBoolean("backButtonHidden", getDefaultBackButtonHidden());
44
-        result.topTabsHidden = getBoolean("topTabsHidden", getDefaultTopTabsHidden());
45
-
46
-        result.topTabTextColor = getColor("topTabTextColor", getDefaultTopTabTextColor());
47
-        result.selectedTopTabTextColor = getColor("selectedTopTabTextColor", getDefaultSelectedTopTabTextColor());
48
-        result.selectedTopTabIndicatorHeight = getInt("selectedTopTabIndicatorHeight", getDefaultSelectedTopTabIndicatorHeight());
49
-        result.selectedTopTabIndicatorColor = getColor("selectedTopTabIndicatorColor", getDefaultSelectedTopTabIndicatorColor());
50
-
51
-        result.screenBackgroundColor = getColor("screenBackgroundColor", getDefaultScreenBackgroundColor());
52
-
53
-        result.bottomTabsHidden = getBoolean("bottomTabsHidden", getDefaultBottomTabsHidden());
54
-        result.drawScreenAboveBottomTabs = !result.bottomTabsHidden &&
55
-                                           params.getBoolean("drawScreenAboveBottomTabs", getDefaultDrawScreenAboveBottomTabs());
56
-        if (result.titleBarHideOnScroll) {
57
-            result.drawScreenAboveBottomTabs = false;
58
-        }
59
-        result.bottomTabsHiddenOnScroll = getBoolean("bottomTabsHiddenOnScroll", getDefaultBottomTabsHiddenOnScroll());
60
-        result.bottomTabsColor = getColor("bottomTabsColor", getDefaultBottomTabsColor());
61
-        result.bottomTabsButtonColor = getColor("bottomTabsButtonColor", getDefaultBottomTabsButtonColor());
62
-        result.selectedBottomTabsButtonColor =
63
-                getColor("bottomTabsSelectedButtonColor", getDefaultSelectedBottomTabsButtonColor());
64
-        result.bottomTabBadgeTextColor = getColor("bottomTabBadgeTextColor", getBottomTabBadgeTextColor());
65
-        result.bottomTabBadgeBackgroundColor = getColor("bottomTabBadgeBackgroundColor", getBottomTabBadgeBackgroundColor());
66
-
67
-        result.navigationBarColor = getColor("navigationBarColor", getDefaultNavigationColor());
68
-        result.forceTitlesDisplay = getBoolean("forceTitlesDisplay", getDefaultForceTitlesDisplay());
69
-
70
-        return result;
71
-    }
72
-
73
-    private StyleParams createDefaultStyleParams() {
74
-        StyleParams result = new StyleParams();
75
-        result.titleBarDisabledButtonColor = getTitleBarDisabledButtonColor();
76
-        result.topBarElevationShadowEnabled = true;
77
-        result.titleBarHideOnScroll = false;
78
-        return result;
79
-    }
80
-
81
-    private StyleParams.Color getDefaultContextualMenuStatusBarColor() {
82
-        return new StyleParams.Color(Color.parseColor("#7c7c7c"));
83
-    }
84
-
85
-    private StyleParams.Color getDefaultContextualMenuBackgroundColor() {
86
-        return new StyleParams.Color(Color.WHITE);
87
-    }
88
-
89
-    private StyleParams.Color getDefaultContextualMenuButtonsColor() {
90
-        return new StyleParams.Color(Color.parseColor("#757575"));
91
-    }
92
-
93
-    private boolean getDefaultDrawScreenAboveBottomTabs() {
94
-        return AppStyle.appStyle == null || AppStyle.appStyle.drawScreenAboveBottomTabs;
95
-    }
96
-
97
-    private StyleParams.Color getDefaultSelectedTopTabIndicatorColor() {
98
-        return AppStyle.appStyle == null ? new StyleParams.Color() : AppStyle.appStyle.selectedTopTabIndicatorColor;
99
-    }
100
-
101
-    private int getDefaultSelectedTopTabIndicatorHeight() {
102
-        return AppStyle.appStyle == null ? -1 : AppStyle.appStyle.selectedTopTabIndicatorHeight;
103
-    }
104
-
105
-    private StyleParams.Color getDefaultSelectedTopTabTextColor() {
106
-        return AppStyle.appStyle == null ? new StyleParams.Color() : AppStyle.appStyle.selectedTopTabTextColor;
107
-    }
108
-
109
-    private StyleParams.Color getDefaultNavigationColor() {
110
-        return AppStyle.appStyle == null ? new StyleParams.Color() : AppStyle.appStyle.navigationBarColor;
111
-    }
112
-
113
-    private boolean getDefaultForceTitlesDisplay() {
114
-        return AppStyle.appStyle != null && AppStyle.appStyle.forceTitlesDisplay;
115
-    }
116
-
117
-    private StyleParams.Color getDefaultSelectedBottomTabsButtonColor() {
118
-        return AppStyle.appStyle == null ? new StyleParams.Color() : AppStyle.appStyle.selectedBottomTabsButtonColor;
119
-    }
120
-
121
-    private StyleParams.Color getBottomTabBadgeTextColor() {
122
-        return new StyleParams.Color();
123
-    }
124
-
125
-    private StyleParams.Color getBottomTabBadgeBackgroundColor() {
126
-        return new StyleParams.Color();
127
-    }
128
-
129
-    private StyleParams.Color getDefaultBottomTabsButtonColor() {
130
-        return AppStyle.appStyle == null ? new StyleParams.Color() : AppStyle.appStyle.bottomTabsButtonColor;
131
-    }
132
-
133
-    private StyleParams.Color getDefaultBottomTabsColor() {
134
-        return AppStyle.appStyle == null ? new StyleParams.Color() : AppStyle.appStyle.bottomTabsColor;
135
-    }
136
-
137
-    private boolean getDefaultBottomTabsHiddenOnScroll() {
138
-        return AppStyle.appStyle != null && AppStyle.appStyle.bottomTabsHiddenOnScroll;
139
-    }
140
-
141
-    private boolean getDefaultBottomTabsHidden() {
142
-        return AppStyle.appStyle != null && AppStyle.appStyle.bottomTabsHidden;
143
-    }
144
-
145
-    private boolean getDefaultScreenBelowTopBar() {
146
-        return AppStyle.appStyle != null && AppStyle.appStyle.drawScreenBelowTopBar;
147
-    }
148
-
149
-    private StyleParams.Color getDefaultScreenBackgroundColor() {
150
-        return AppStyle.appStyle != null ? AppStyle.appStyle.screenBackgroundColor : getColor("screenBackgroundColor", new StyleParams.Color());
151
-    }
152
-
153
-    private boolean getDefaultTopTabsHidden() {
154
-        return AppStyle.appStyle != null && AppStyle.appStyle.topTabsHidden;
155
-    }
156
-
157
-    private StyleParams.Color getDefaultTopTabTextColor() {
158
-        return AppStyle.appStyle == null ? new StyleParams.Color() : AppStyle.appStyle.topTabTextColor;
159
-    }
160
-
161
-    private boolean getDefaultBackButtonHidden() {
162
-        return AppStyle.appStyle != null && AppStyle.appStyle.backButtonHidden;
163
-    }
164
-
165
-    private StyleParams.Color getDefaultTitleBarColor() {
166
-        return AppStyle.appStyle == null ? new StyleParams.Color() : AppStyle.appStyle.titleBarTitleColor;
167
-    }
168
-
169
-    private StyleParams.Color getDefaultSubtitleBarColor() {
170
-        return AppStyle.appStyle == null ? new StyleParams.Color() : AppStyle.appStyle.titleBarSubtitleColor;
171
-    }
172
-
173
-    private StyleParams.Color getTitleBarButtonColor() {
174
-        return AppStyle.appStyle == null ? new StyleParams.Color() : AppStyle.appStyle.titleBarButtonColor;
175
-    }
176
-
177
-    private StyleParams.Color getTitleBarDisabledButtonColor() {
178
-        return AppStyle.appStyle == null ? new StyleParams.Color(Color.LTGRAY) : AppStyle.appStyle.titleBarDisabledButtonColor;
179
-    }
180
-
181
-    private boolean getDefaultTopBarHidden() {
182
-        return AppStyle.appStyle != null && AppStyle.appStyle.topBarTransparent;
183
-    }
184
-
185
-    private boolean getDefaultTopBarElevationShadowEnabled() {
186
-        return AppStyle.appStyle == null || AppStyle.appStyle.topBarElevationShadowEnabled;
187
-    }
188
-
189
-    private boolean getDefaultTopBarTranslucent() {
190
-        return AppStyle.appStyle != null && AppStyle.appStyle.topBarTranslucent;
191
-    }
192
-
193
-    private boolean getDefaultTitleBarHideOnScroll() {
194
-        return AppStyle.appStyle != null && AppStyle.appStyle.titleBarHideOnScroll;
195
-    }
196
-
197
-    private StyleParams.Color getDefaultTopBarColor() {
198
-        return AppStyle.appStyle == null ? new StyleParams.Color() : AppStyle.appStyle.topBarColor;
199
-    }
200
-
201
-    private StyleParams.Color getDefaultStatusBarColor() {
202
-        return AppStyle.appStyle == null ? new StyleParams.Color() : AppStyle.appStyle.statusBarColor;
203
-    }
204
-
205
-    private boolean getBoolean(String key, boolean defaultValue) {
206
-        return params.containsKey(key) ? params.getBoolean(key) : defaultValue;
207
-    }
208
-
209
-    private StyleParams.Color getColor(String key, StyleParams.Color defaultColor) {
210
-        StyleParams.Color color = StyleParams.Color.parse(params, key);
211
-        if (color.hasColor()) {
212
-            return color;
213
-        } else {
214
-            return defaultColor != null && defaultColor.hasColor() ? defaultColor : color;
215
-        }
216
-    }
217
-
218
-    private int getInt(String key, int defaultValue) {
219
-        return params.containsKey(key) ? params.getInt(key) : defaultValue;
220
-    }
221
-}

+ 0
- 55
lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/TitleBarButtonParamsParser.java 查看文件

@@ -1,55 +0,0 @@
1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.os.Bundle;
4
-
5
-import com.reactnativenavigation.params.AppStyle;
6
-import com.reactnativenavigation.params.BaseTitleBarButtonParams;
7
-import com.reactnativenavigation.params.TitleBarButtonParams;
8
-import com.reactnativenavigation.react.ImageLoader;
9
-
10
-import java.util.List;
11
-
12
-public class TitleBarButtonParamsParser extends Parser {
13
-    public List<TitleBarButtonParams> parseButtons(Bundle params) {
14
-        return parseBundle(params, new ParseStrategy<TitleBarButtonParams>() {
15
-            @Override
16
-            public TitleBarButtonParams parse(Bundle button) {
17
-                return parseSingleButton(button);
18
-            }
19
-        });
20
-    }
21
-
22
-    public TitleBarButtonParams parseSingleButton(Bundle bundle) {
23
-        TitleBarButtonParams result = new TitleBarButtonParams();
24
-        result.label = bundle.getString("title");
25
-        if (hasKey(bundle, "icon")) {
26
-            result.icon = ImageLoader.loadImage(bundle.getString("icon"));
27
-        }
28
-        result.color = getColor(bundle, "color", AppStyle.appStyle.titleBarButtonColor);
29
-        result.disabledColor =
30
-                getColor(bundle, "titleBarDisabledButtonColor", AppStyle.appStyle.titleBarDisabledButtonColor);
31
-        result.showAsAction = parseShowAsAction(bundle.getString("showAsAction"));
32
-        result.enabled = bundle.getBoolean("enabled", true);
33
-        result.hint = bundle.getString("hint", "");
34
-        result.eventId = bundle.getString("id");
35
-        return result;
36
-    }
37
-
38
-    BaseTitleBarButtonParams.ShowAsAction parseShowAsAction(String showAsAction) {
39
-        if (showAsAction == null) {
40
-            return BaseTitleBarButtonParams.ShowAsAction.IfRoom;
41
-        }
42
-
43
-        switch (showAsAction) {
44
-            case "always":
45
-                return BaseTitleBarButtonParams.ShowAsAction.Always;
46
-            case "never":
47
-                return BaseTitleBarButtonParams.ShowAsAction.Never;
48
-            case "withText":
49
-                return BaseTitleBarButtonParams.ShowAsAction.WithText;
50
-            case "ifRoom":
51
-            default:
52
-                return BaseTitleBarButtonParams.ShowAsAction.IfRoom;
53
-        }
54
-    }
55
-}

+ 0
- 29
lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/TitleBarLeftButtonParamsParser.java 查看文件

@@ -1,29 +0,0 @@
1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.os.Bundle;
4
-
5
-import com.balysv.materialmenu.MaterialMenuDrawable;
6
-import com.reactnativenavigation.params.TitleBarLeftButtonParams;
7
-
8
-public class TitleBarLeftButtonParamsParser extends TitleBarButtonParamsParser {
9
-
10
-    public TitleBarLeftButtonParams parseSingleButton(Bundle params) {
11
-        TitleBarLeftButtonParams leftButtonParams = new TitleBarLeftButtonParams(super.parseSingleButton(params));
12
-        leftButtonParams.iconState = getIconStateFromId(leftButtonParams.eventId);
13
-        return leftButtonParams;
14
-    }
15
-
16
-    private MaterialMenuDrawable.IconState getIconStateFromId(String id) {
17
-        switch (id) {
18
-            case "back":
19
-                return MaterialMenuDrawable.IconState.ARROW;
20
-            case "cancel":
21
-                return MaterialMenuDrawable.IconState.X;
22
-            case "accept":
23
-                return MaterialMenuDrawable.IconState.CHECK;
24
-            case "sideMenu":
25
-            default:
26
-                return MaterialMenuDrawable.IconState.BURGER;
27
-        }
28
-    }
29
-}

+ 0
- 38
lib/android/app/deprecated/java/com/reactnativenavigation/params/parsers/TopTabParamsParser.java 查看文件

@@ -1,38 +0,0 @@
1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.os.Bundle;
4
-import android.support.annotation.NonNull;
5
-
6
-import com.reactnativenavigation.params.NavigationParams;
7
-import com.reactnativenavigation.params.PageParams;
8
-
9
-import java.util.List;
10
-
11
-public class TopTabParamsParser extends Parser {
12
-    private static final String KEY_SCREEN_ID = "screenId";
13
-    private static final String KEY_TITLE = "title";
14
-    private static final String NAVIGATION_PARAMS = "navigationParams";
15
-
16
-    @SuppressWarnings("ConstantConditions")
17
-    public List<PageParams> parse(Bundle params) {
18
-        return parseBundle(params, new ParseStrategy<PageParams>() {
19
-            @Override
20
-            public PageParams parse(Bundle topTabs) {
21
-                return parseItem(topTabs);
22
-            }
23
-        });
24
-    }
25
-
26
-    @NonNull
27
-    private static PageParams parseItem(Bundle params) {
28
-        PageParams result = new PageParams();
29
-        result.screenId = params.getString(KEY_SCREEN_ID);
30
-        result.title = params.getString(KEY_TITLE);
31
-        result.navigationParams = new NavigationParams(params.getBundle(NAVIGATION_PARAMS));
32
-        result.leftButton = ButtonParser.parseLeftButton(params);
33
-        result.rightButtons = ButtonParser.parseRightButton(params);
34
-        result.fabParams = ButtonParser.parseFab(params, result.navigationParams.navigatorEventId, result.navigationParams.screenInstanceId);
35
-        result.styleParams = new StyleParamsParser(params.getBundle("styleParams")).parse();
36
-        return result;
37
-    }
38
-}

+ 0
- 36
lib/android/app/deprecated/java/com/reactnativenavigation/react/ImageLoader.java 查看文件

@@ -1,36 +0,0 @@
1
-package com.reactnativenavigation.react;
2
-
3
-import android.graphics.drawable.BitmapDrawable;
4
-import android.graphics.drawable.Drawable;
5
-import android.net.Uri;
6
-
7
-import com.reactnativenavigation.NavigationApplication;
8
-
9
-public class ImageLoader {
10
-    private static final String FILE_SCHEME = "file";
11
-
12
-    public static Drawable loadImage(String iconSource) {
13
-        if (NavigationApplication.instance.isDebug()) {
14
-            return JsDevImageLoader.loadIcon(iconSource);
15
-        } else {
16
-            Uri uri = Uri.parse(iconSource);
17
-            if (isLocalFile(uri)) {
18
-                return loadFile(uri);
19
-            } else {
20
-                return loadResource(iconSource);
21
-            }
22
-        }
23
-    }
24
-
25
-    private static boolean isLocalFile(Uri uri) {
26
-        return FILE_SCHEME.equals(uri.getScheme());
27
-    }
28
-
29
-    private static Drawable loadFile(Uri uri) {
30
-        return new BitmapDrawable(NavigationApplication.instance.getResources(), uri.getPath());
31
-    }
32
-
33
-    private static Drawable loadResource(String iconSource) {
34
-        return ResourceDrawableIdHelper.instance.getResourceDrawable(NavigationApplication.instance, iconSource);
35
-    }
36
-}

+ 0
- 37
lib/android/app/deprecated/java/com/reactnativenavigation/react/JsDevImageLoader.java 查看文件

@@ -1,37 +0,0 @@
1
-package com.reactnativenavigation.react;
2
-
3
-import android.graphics.Bitmap;
4
-import android.graphics.BitmapFactory;
5
-import android.graphics.drawable.BitmapDrawable;
6
-import android.graphics.drawable.Drawable;
7
-import android.os.StrictMode;
8
-import android.support.annotation.NonNull;
9
-
10
-import com.reactnativenavigation.NavigationApplication;
11
-
12
-import java.io.IOException;
13
-import java.net.URL;
14
-
15
-public class JsDevImageLoader {
16
-
17
-    public static Drawable loadIcon(String iconDevUri) {
18
-        try {
19
-            StrictMode.ThreadPolicy threadPolicy = StrictMode.getThreadPolicy();
20
-            StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitNetwork().build());
21
-
22
-            Drawable drawable = tryLoadIcon(iconDevUri);
23
-
24
-            StrictMode.setThreadPolicy(threadPolicy);
25
-            return drawable;
26
-        } catch (Exception e) {
27
-            throw new RuntimeException(iconDevUri, e);
28
-        }
29
-    }
30
-
31
-    @NonNull
32
-    private static Drawable tryLoadIcon(String iconDevUri) throws IOException {
33
-        URL url = new URL(iconDevUri);
34
-        Bitmap bitmap = BitmapFactory.decodeStream(url.openStream());
35
-        return new BitmapDrawable(NavigationApplication.instance.getResources(), bitmap);
36
-    }
37
-}

+ 0
- 48
lib/android/app/deprecated/java/com/reactnativenavigation/react/JsDevReloadHandler.java 查看文件

@@ -1,48 +0,0 @@
1
-package com.reactnativenavigation.react;
2
-
3
-import android.view.KeyEvent;
4
-import android.view.View;
5
-import android.widget.EditText;
6
-
7
-import com.facebook.react.ReactInstanceManager;
8
-import com.reactnativenavigation.NavigationApplication;
9
-
10
-public class JsDevReloadHandler {
11
-
12
-    private static boolean shouldRefreshOnRR = false;
13
-
14
-    //TODO yuck.
15
-    public static boolean onKeyUp(View currentFocus, int keyCode) {
16
-        ReactInstanceManager reactInstanceManager = NavigationApplication
17
-                .instance
18
-                .getReactGateway()
19
-                .getReactInstanceManager();
20
-
21
-        if (reactInstanceManager != null &&
22
-                reactInstanceManager.getDevSupportManager().getDevSupportEnabled()) {
23
-            if (keyCode == KeyEvent.KEYCODE_MENU) {
24
-                reactInstanceManager.showDevOptionsDialog();
25
-                return true;
26
-            }
27
-            if (keyCode == KeyEvent.KEYCODE_R && !(currentFocus instanceof EditText)) {
28
-                // Enable double-tap-R-to-reload
29
-                if (shouldRefreshOnRR) {
30
-                    reactInstanceManager.getDevSupportManager().handleReloadJS();
31
-                    shouldRefreshOnRR = false;
32
-                    return true;
33
-                } else {
34
-                    shouldRefreshOnRR = true;
35
-                    NavigationApplication.instance.runOnMainThread(
36
-                            new Runnable() {
37
-                                @Override
38
-                                public void run() {
39
-                                    shouldRefreshOnRR = false;
40
-                                }
41
-                            },
42
-                            500);
43
-                }
44
-            }
45
-        }
46
-        return false;
47
-    }
48
-}

+ 0
- 69
lib/android/app/deprecated/java/com/reactnativenavigation/react/JsDevReloadListenerReplacer.java 查看文件

@@ -1,69 +0,0 @@
1
-package com.reactnativenavigation.react;
2
-
3
-import com.facebook.react.ReactInstanceManager;
4
-import com.facebook.react.bridge.JavaJSExecutor;
5
-import com.facebook.react.devsupport.DevSupportManager;
6
-import com.facebook.react.devsupport.ReactInstanceDevCommandsHandler;
7
-import com.reactnativenavigation.utils.ReflectionUtils;
8
-
9
-public class JsDevReloadListenerReplacer {
10
-    private final ReactInstanceManager reactInstanceManager;
11
-    private final Listener listener;
12
-
13
-    public interface Listener {
14
-        void onJsDevReload();
15
-    }
16
-
17
-    public JsDevReloadListenerReplacer(ReactInstanceManager reactInstanceManager, Listener listener) {
18
-        this.reactInstanceManager = reactInstanceManager;
19
-        this.listener = listener;
20
-    }
21
-
22
-    public void replace() {
23
-        ReactInstanceDevCommandsHandler originalHandler = getOriginalHandler();
24
-        DevCommandsHandlerProxy proxy = new DevCommandsHandlerProxy(originalHandler, listener);
25
-        replaceInReactInstanceManager(proxy);
26
-        replaceInDevSupportManager(proxy);
27
-    }
28
-
29
-    private void replaceInDevSupportManager(DevCommandsHandlerProxy proxy) {
30
-        DevSupportManager devSupportManager = (DevSupportManager)
31
-                ReflectionUtils.getDeclaredField(reactInstanceManager, "mDevSupportManager");
32
-        ReflectionUtils.setField(devSupportManager, "mReactInstanceCommandsHandler", proxy);
33
-    }
34
-
35
-    private ReactInstanceDevCommandsHandler getOriginalHandler() {
36
-        return (ReactInstanceDevCommandsHandler) ReflectionUtils.getDeclaredField(reactInstanceManager, "mDevInterface");
37
-    }
38
-
39
-    private void replaceInReactInstanceManager(DevCommandsHandlerProxy proxy) {
40
-        ReflectionUtils.setField(reactInstanceManager, "mDevInterface", proxy);
41
-    }
42
-
43
-    private static class DevCommandsHandlerProxy implements ReactInstanceDevCommandsHandler {
44
-        private ReactInstanceDevCommandsHandler originalReactHandler;
45
-        private final Listener listener;
46
-
47
-        public DevCommandsHandlerProxy(ReactInstanceDevCommandsHandler originalReactHandler, Listener listener) {
48
-            this.originalReactHandler = originalReactHandler;
49
-            this.listener = listener;
50
-        }
51
-
52
-        @Override
53
-        public void onReloadWithJSDebugger(JavaJSExecutor.Factory proxyExecutorFactory) {
54
-            listener.onJsDevReload();
55
-            originalReactHandler.onReloadWithJSDebugger(proxyExecutorFactory);
56
-        }
57
-
58
-        @Override
59
-        public void onJSBundleLoadedFromServer() {
60
-            listener.onJsDevReload();
61
-            originalReactHandler.onJSBundleLoadedFromServer();
62
-        }
63
-
64
-        @Override
65
-        public void toggleElementInspector() {
66
-            originalReactHandler.toggleElementInspector();
67
-        }
68
-    }
69
-}

+ 0
- 183
lib/android/app/deprecated/java/com/reactnativenavigation/react/NavigationReactGateway.java 查看文件

@@ -1,183 +0,0 @@
1
-package com.reactnativenavigation.react;
2
-
3
-import android.app.Activity;
4
-import android.content.Intent;
5
-
6
-import com.facebook.react.ReactInstanceManager;
7
-import com.facebook.react.ReactNativeHost;
8
-import com.facebook.react.ReactPackage;
9
-import com.facebook.react.bridge.ReactContext;
10
-import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
11
-import com.facebook.react.shell.MainReactPackage;
12
-import com.reactnativenavigation.NavigationApplication;
13
-import com.reactnativenavigation.bridge.NavigationReactEventEmitter;
14
-import com.reactnativenavigation.bridge.NavigationReactPackage;
15
-import com.reactnativenavigation.events.EventBus;
16
-import com.reactnativenavigation.events.JsDevReloadEvent;
17
-
18
-import java.util.ArrayList;
19
-import java.util.List;
20
-
21
-import javax.annotation.Nullable;
22
-
23
-public class NavigationReactGateway implements ReactGateway {
24
-
25
-    private final ReactNativeHost host;
26
-    private NavigationReactEventEmitter reactEventEmitter;
27
-
28
-    public NavigationReactGateway() {
29
-        host = new ReactNativeHostImpl();
30
-    }
31
-
32
-    @Override
33
-    public void startReactContextOnceInBackgroundAndExecuteJS() {
34
-        getReactInstanceManager().createReactContextInBackground();
35
-    }
36
-
37
-    public boolean isInitialized() {
38
-        return host.hasInstance() && getReactInstanceManager().getCurrentReactContext() != null;
39
-    }
40
-
41
-    @Override
42
-    public boolean hasStartedCreatingContext() {
43
-        return getReactInstanceManager().hasStartedCreatingInitialContext();
44
-    }
45
-
46
-    public ReactContext getReactContext() {
47
-        return getReactInstanceManager().getCurrentReactContext();
48
-    }
49
-
50
-    public NavigationReactEventEmitter getReactEventEmitter() {
51
-        return reactEventEmitter;
52
-    }
53
-
54
-    @Override
55
-    public ReactInstanceManager getReactInstanceManager() {
56
-        return host.getReactInstanceManager();
57
-    }
58
-
59
-    public void onBackPressed() {
60
-        getReactInstanceManager().onBackPressed();
61
-    }
62
-
63
-    public void onDestroyApp() {
64
-        getReactInstanceManager().onHostDestroy();
65
-        host.clear();
66
-    }
67
-
68
-    public void onPauseActivity() {
69
-        getReactInstanceManager().onHostPause();
70
-    }
71
-
72
-    public void onResumeActivity(Activity activity, DefaultHardwareBackBtnHandler defaultHardwareBackBtnHandler) {
73
-        getReactInstanceManager().onHostResume(activity, defaultHardwareBackBtnHandler);
74
-    }
75
-
76
-    public void onActivityResult(int requestCode, int resultCode, Intent data) {
77
-        Activity currentActivity = getReactInstanceManager().getCurrentReactContext().getCurrentActivity();
78
-        getReactInstanceManager().onActivityResult(currentActivity, requestCode, resultCode, data);
79
-    }
80
-
81
-    public ReactNativeHost getReactNativeHost() {
82
-        return host;
83
-    }
84
-
85
-    //TODO temp hack
86
-    void onReactContextInitialized() {
87
-        reactEventEmitter = new NavigationReactEventEmitter(getReactContext());
88
-    }
89
-
90
-    private static class ReactNativeHostImpl extends ReactNativeHost implements ReactInstanceManager.ReactInstanceEventListener {
91
-
92
-        public ReactNativeHostImpl() {
93
-            super(NavigationApplication.instance);
94
-        }
95
-
96
-        @Override
97
-        protected boolean getUseDeveloperSupport() {
98
-            return NavigationApplication.instance.isDebug();
99
-        }
100
-
101
-        @Override
102
-        protected List<ReactPackage> getPackages() {
103
-            List<ReactPackage> list = new ArrayList<>();
104
-            list.add(new MainReactPackage());
105
-            list.add(new NavigationReactPackage());
106
-            addAdditionalReactPackagesIfNeeded(list);
107
-            return list;
108
-        }
109
-
110
-        private void addAdditionalReactPackagesIfNeeded(List<ReactPackage> list) {
111
-            List<ReactPackage> additionalReactPackages = NavigationApplication.instance.createAdditionalReactPackages();
112
-            if (additionalReactPackages == null) {
113
-                return;
114
-            }
115
-
116
-            for (ReactPackage reactPackage : additionalReactPackages) {
117
-                if (reactPackage instanceof MainReactPackage)
118
-                    throw new RuntimeException("Do not create a new MainReactPackage. This is created for you.");
119
-                if (reactPackage instanceof NavigationReactPackage)
120
-                    throw new RuntimeException("Do not create a new NavigationReactPackage. This is created for you.");
121
-            }
122
-
123
-            list.addAll(additionalReactPackages);
124
-        }
125
-
126
-        @Override
127
-        protected ReactInstanceManager createReactInstanceManager() {
128
-            ReactInstanceManager manager = super.createReactInstanceManager();
129
-            if (NavigationApplication.instance.isDebug()) {
130
-                replaceJsDevReloadListener(manager);
131
-            }
132
-            manager.addReactInstanceEventListener(this);
133
-            return manager;
134
-        }
135
-
136
-        private void replaceJsDevReloadListener(ReactInstanceManager manager) {
137
-            new JsDevReloadListenerReplacer(manager, new JsDevReloadListenerReplacer.Listener() {
138
-                @Override
139
-                public void onJsDevReload() {
140
-                    EventBus.instance.post(new JsDevReloadEvent());
141
-                }
142
-            }).replace();
143
-        }
144
-
145
-        @Override
146
-        public void onReactContextInitialized(ReactContext context) {
147
-            ((NavigationReactGateway) NavigationApplication.instance.getReactGateway()).onReactContextInitialized();
148
-            NavigationApplication.instance.onReactInitialized(context);
149
-        }
150
-
151
-        @Override
152
-        public void clear() {
153
-            getReactInstanceManager().removeReactInstanceEventListener(this);
154
-            super.clear();
155
-        }
156
-
157
-        @Override
158
-        protected String getJSMainModuleName() {
159
-            String jsMainModuleName = NavigationApplication.instance.getJSMainModuleName();
160
-            if (jsMainModuleName != null)
161
-                return jsMainModuleName;
162
-            return super.getJSMainModuleName();
163
-        }
164
-
165
-        @Nullable
166
-        @Override
167
-        protected String getJSBundleFile() {
168
-            String jsBundleFile = NavigationApplication.instance.getJSBundleFile();
169
-            if (jsBundleFile != null)
170
-                return jsBundleFile;
171
-            return super.getJSBundleFile();
172
-        }
173
-
174
-        @Nullable
175
-        @Override
176
-        protected String getBundleAssetName() {
177
-            String bundleAssetName = NavigationApplication.instance.getBundleAssetName();
178
-            if (bundleAssetName != null)
179
-                return bundleAssetName;
180
-            return super.getBundleAssetName();
181
-        }
182
-    }
183
-}

+ 0
- 36
lib/android/app/deprecated/java/com/reactnativenavigation/react/ReactDevPermission.java 查看文件

@@ -1,36 +0,0 @@
1
-package com.reactnativenavigation.react;
2
-
3
-import android.annotation.TargetApi;
4
-import android.content.Context;
5
-import android.content.Intent;
6
-import android.os.Build;
7
-import android.provider.Settings;
8
-import android.util.Log;
9
-import android.widget.Toast;
10
-
11
-import com.facebook.react.common.ReactConstants;
12
-import com.reactnativenavigation.NavigationApplication;
13
-
14
-public class ReactDevPermission {
15
-
16
-    public static boolean shouldAskPermission() {
17
-        return NavigationApplication.instance.isDebug() &&
18
-                Build.VERSION.SDK_INT >= 23 &&
19
-                !Settings.canDrawOverlays(NavigationApplication.instance);
20
-    }
21
-
22
-    @TargetApi(23)
23
-    public static void askPermission(Context context) {
24
-        if (shouldAskPermission()) {
25
-            Intent serviceIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
26
-            context.startActivity(serviceIntent);
27
-            String msg = "Overlay permissions needs to be granted in order for react native apps to run in dev mode";
28
-            Log.w(ReactConstants.TAG, "======================================\n\n");
29
-            Log.w(ReactConstants.TAG, msg);
30
-            Log.w(ReactConstants.TAG, "\n\n======================================");
31
-            for (int i = 0; i < 5; i++) {
32
-                Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
33
-            }
34
-        }
35
-    }
36
-}

+ 0
- 34
lib/android/app/deprecated/java/com/reactnativenavigation/react/ReactGateway.java 查看文件

@@ -1,34 +0,0 @@
1
-package com.reactnativenavigation.react;
2
-
3
-import android.app.Activity;
4
-import android.content.Intent;
5
-
6
-import com.facebook.react.ReactInstanceManager;
7
-import com.facebook.react.bridge.ReactContext;
8
-import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
9
-import com.reactnativenavigation.bridge.NavigationReactEventEmitter;
10
-
11
-public interface ReactGateway {
12
-
13
-    void startReactContextOnceInBackgroundAndExecuteJS();
14
-
15
-    boolean isInitialized();
16
-
17
-    ReactContext getReactContext();
18
-
19
-    NavigationReactEventEmitter getReactEventEmitter();
20
-
21
-    ReactInstanceManager getReactInstanceManager();
22
-
23
-    void onResumeActivity(Activity activity, DefaultHardwareBackBtnHandler defaultHardwareBackBtnHandler);
24
-
25
-    void onPauseActivity();
26
-
27
-    void onDestroyApp();
28
-
29
-    void onBackPressed();
30
-
31
-    void onActivityResult(int requestCode, int resultCode, Intent data);
32
-
33
-    boolean hasStartedCreatingContext();
34
-}

+ 0
- 56
lib/android/app/deprecated/java/com/reactnativenavigation/react/ResourceDrawableIdHelper.java 查看文件

@@ -1,56 +0,0 @@
1
-package com.reactnativenavigation.react;// Copyright 2004-present Facebook. All Rights Reserved.
2
-
3
-import android.content.Context;
4
-import android.graphics.drawable.Drawable;
5
-import android.net.Uri;
6
-
7
-import com.facebook.common.util.UriUtil;
8
-
9
-import java.util.HashMap;
10
-import java.util.Map;
11
-
12
-import javax.annotation.Nullable;
13
-
14
-/**
15
- * Direct copy paste from react-native, because they made that class package scope. -_-"
16
- * Can be deleted in react-native ^0.29
17
- */
18
-public class ResourceDrawableIdHelper {
19
-    public static final ResourceDrawableIdHelper instance = new ResourceDrawableIdHelper();
20
-
21
-    private Map<String, Integer> mResourceDrawableIdMap;
22
-
23
-    public ResourceDrawableIdHelper() {
24
-        mResourceDrawableIdMap = new HashMap<>();
25
-    }
26
-
27
-    public int getResourceDrawableId(Context context, @Nullable String name) {
28
-        if (name == null || name.isEmpty()) {
29
-            return 0;
30
-        }
31
-        name = name.toLowerCase().replace("-", "_");
32
-        if (mResourceDrawableIdMap.containsKey(name)) {
33
-            return mResourceDrawableIdMap.get(name);
34
-        }
35
-        int id = context.getResources().getIdentifier(
36
-                name,
37
-                "drawable",
38
-                context.getPackageName());
39
-        mResourceDrawableIdMap.put(name, id);
40
-        return id;
41
-    }
42
-
43
-    @Nullable
44
-    public Drawable getResourceDrawable(Context context, @Nullable String name) {
45
-        int resId = getResourceDrawableId(context, name);
46
-        return resId > 0 ? context.getResources().getDrawable(resId) : null;
47
-    }
48
-
49
-    public Uri getResourceDrawableUri(Context context, @Nullable String name) {
50
-        int resId = getResourceDrawableId(context, name);
51
-        return resId > 0 ? new Uri.Builder()
52
-                .scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
53
-                .path(String.valueOf(resId))
54
-                .build() : Uri.EMPTY;
55
-    }
56
-}

+ 0
- 87
lib/android/app/deprecated/java/com/reactnativenavigation/screens/CollapsingSingleScreen.java 查看文件

@@ -1,87 +0,0 @@
1
-package com.reactnativenavigation.screens;
2
-
3
-import android.support.v7.app.AppCompatActivity;
4
-import android.widget.ScrollView;
5
-
6
-import com.reactnativenavigation.params.ScreenParams;
7
-import com.reactnativenavigation.views.CollapsingContentView;
8
-import com.reactnativenavigation.views.LeftButtonOnClickListener;
9
-import com.reactnativenavigation.views.collapsingToolbar.CollapseAmount;
10
-import com.reactnativenavigation.views.collapsingToolbar.CollapseCalculator;
11
-import com.reactnativenavigation.views.collapsingToolbar.CollapsingTopBar;
12
-import com.reactnativenavigation.views.collapsingToolbar.CollapsingView;
13
-import com.reactnativenavigation.views.collapsingToolbar.CollapsingViewMeasurer;
14
-import com.reactnativenavigation.views.collapsingToolbar.OnScrollListener;
15
-import com.reactnativenavigation.views.collapsingToolbar.OnScrollViewAddedListener;
16
-import com.reactnativenavigation.views.collapsingToolbar.ScrollListener;
17
-import com.reactnativenavigation.views.collapsingToolbar.behaviours.CollapseBehaviour;
18
-
19
-public class CollapsingSingleScreen extends SingleScreen {
20
-
21
-    public CollapsingSingleScreen(AppCompatActivity activity, ScreenParams screenParams, LeftButtonOnClickListener titleBarBarBackButtonListener) {
22
-        super(activity, screenParams, titleBarBarBackButtonListener);
23
-    }
24
-
25
-    @Override
26
-    public void destroy() {
27
-        super.destroy();
28
-        ((CollapsingContentView) contentView).destroy();
29
-    }
30
-
31
-    @Override
32
-    protected void createTopBar() {
33
-        final CollapsingTopBar topBar = new CollapsingTopBar(getContext(), styleParams.collapsingTopBarParams);
34
-        topBar.setScrollListener(getScrollListener(topBar));
35
-        this.topBar = topBar;
36
-    }
37
-
38
-    @Override
39
-    protected void createContent() {
40
-        contentView = new CollapsingContentView(getContext(), screenParams.screenId, screenParams.navigationParams);
41
-        setViewMeasurer();
42
-        setupCollapseDetection((CollapsingTopBar) topBar);
43
-        addView(contentView, createLayoutParams());
44
-    }
45
-
46
-    private void setViewMeasurer() {
47
-        if (screenParams.styleParams.drawScreenBelowTopBar || screenParams.styleParams.drawScreenAboveBottomTabs) {
48
-            contentView.setViewMeasurer(new CollapsingViewMeasurer((CollapsingTopBar) topBar, this, screenParams.styleParams));
49
-        }
50
-    }
51
-
52
-    private void setupCollapseDetection(final CollapsingTopBar topBar) {
53
-        ((CollapsingContentView) contentView).setupCollapseDetection(getScrollListener(topBar), new OnScrollViewAddedListener() {
54
-            @Override
55
-            public void onScrollViewAdded(ScrollView scrollView) {
56
-                topBar.onScrollViewAdded(scrollView);
57
-            }
58
-        });
59
-    }
60
-
61
-    private ScrollListener getScrollListener(final CollapsingTopBar topBar) {
62
-        return new ScrollListener(new CollapseCalculator(topBar, getCollapseBehaviour()),
63
-                new OnScrollListener() {
64
-                    @Override
65
-                    public void onScroll(CollapseAmount amount) {
66
-                        if (screenParams.styleParams.drawScreenBelowTopBar) {
67
-                            ((CollapsingView) contentView).collapse(amount);
68
-                        }
69
-                        topBar.collapse(amount);
70
-                    }
71
-
72
-                    @Override
73
-                    public void onFling(CollapseAmount amount) {
74
-                        if (screenParams.styleParams.drawScreenBelowTopBar) {
75
-                            ((CollapsingView) contentView).collapse(amount);
76
-                        }
77
-                        topBar.collapse(amount);
78
-                    }
79
-                },
80
-                getCollapseBehaviour()
81
-        );
82
-    }
83
-
84
-    private CollapseBehaviour getCollapseBehaviour() {
85
-        return screenParams.styleParams.collapsingTopBarParams.collapseBehaviour;
86
-    }
87
-}

+ 0
- 112
lib/android/app/deprecated/java/com/reactnativenavigation/screens/CollapsingViewPagerScreen.java 查看文件

@@ -1,112 +0,0 @@
1
-package com.reactnativenavigation.screens;
2
-
3
-import android.annotation.SuppressLint;
4
-import android.content.Context;
5
-import android.support.v4.view.ViewPager;
6
-import android.support.v7.app.AppCompatActivity;
7
-import android.widget.ScrollView;
8
-
9
-import com.reactnativenavigation.events.Event;
10
-import com.reactnativenavigation.events.ViewPagerScreenChangedEvent;
11
-import com.reactnativenavigation.events.ViewPagerScreenScrollStartEvent;
12
-import com.reactnativenavigation.params.PageParams;
13
-import com.reactnativenavigation.params.ScreenParams;
14
-import com.reactnativenavigation.views.CollapsingContentView;
15
-import com.reactnativenavigation.views.ContentView;
16
-import com.reactnativenavigation.views.LeftButtonOnClickListener;
17
-import com.reactnativenavigation.views.collapsingToolbar.CollapseAmount;
18
-import com.reactnativenavigation.views.collapsingToolbar.CollapseCalculator;
19
-import com.reactnativenavigation.views.collapsingToolbar.CollapsingTopBar;
20
-import com.reactnativenavigation.views.collapsingToolbar.CollapsingView;
21
-import com.reactnativenavigation.views.collapsingToolbar.CollapsingViewMeasurer;
22
-import com.reactnativenavigation.views.collapsingToolbar.CollapsingViewPager;
23
-import com.reactnativenavigation.views.collapsingToolbar.CollapsingViewPagerContentViewMeasurer;
24
-import com.reactnativenavigation.views.collapsingToolbar.OnScrollListener;
25
-import com.reactnativenavigation.views.collapsingToolbar.OnScrollViewAddedListener;
26
-import com.reactnativenavigation.views.collapsingToolbar.ScrollListener;
27
-import com.reactnativenavigation.views.collapsingToolbar.behaviours.CollapseBehaviour;
28
-
29
-@SuppressLint("ViewConstructor")
30
-public class CollapsingViewPagerScreen extends ViewPagerScreen {
31
-    public CollapsingViewPagerScreen(AppCompatActivity activity, ScreenParams screenParams, LeftButtonOnClickListener backButtonListener) {
32
-        super(activity, screenParams, backButtonListener);
33
-    }
34
-
35
-    @Override
36
-    protected void createTopBar() {
37
-        final CollapsingTopBar topBar = new CollapsingTopBar(getContext(), styleParams.collapsingTopBarParams);
38
-        topBar.setScrollListener(getScrollListener());
39
-        this.topBar = topBar;
40
-    }
41
-
42
-    @Override
43
-    protected ViewPager createViewPager(Context context) {
44
-        CollapsingViewPager viewPager = new CollapsingViewPager(context);
45
-        if (screenParams.styleParams.drawScreenBelowTopBar) {
46
-            viewPager.setViewMeasurer(new CollapsingViewMeasurer((CollapsingTopBar) topBar, this));
47
-        }
48
-        return viewPager;
49
-    }
50
-
51
-    protected ContentView createContentView(PageParams tab) {
52
-        if (tab.hasCollapsingTopBar()) {
53
-            CollapsingContentView contentView = new CollapsingContentView(getContext(), tab.screenId, tab.navigationParams);
54
-            contentView.setViewMeasurer(new CollapsingViewPagerContentViewMeasurer((CollapsingTopBar) topBar, this, screenParams.styleParams));
55
-            setupCollapseDetection(contentView);
56
-            return contentView;
57
-        } else {
58
-            return new ContentView(getContext(), tab.screenId, tab.navigationParams);
59
-        }
60
-    }
61
-
62
-    private void setupCollapseDetection(CollapsingContentView contentView) {
63
-        contentView.setupCollapseDetection(getScrollListener(), new OnScrollViewAddedListener() {
64
-            @Override
65
-            public void onScrollViewAdded(ScrollView scrollView) {
66
-                ((CollapsingTopBar) topBar).onScrollViewAdded(scrollView);
67
-            }
68
-        });
69
-    }
70
-
71
-    private ScrollListener getScrollListener() {
72
-        return new ScrollListener(new CollapseCalculator((CollapsingView) topBar, getCollapseBehaviour()),
73
-                new OnScrollListener() {
74
-                    @Override
75
-                    public void onScroll(CollapseAmount amount) {
76
-                        ((CollapsingView) topBar).collapse(amount);
77
-                        ((CollapsingView) viewPager).collapse(amount);
78
-                    }
79
-
80
-                    @Override
81
-                    public void onFling(CollapseAmount amount) {
82
-                        ((CollapsingView) topBar).collapse(amount);
83
-                        ((CollapsingView) viewPager).collapse(amount);
84
-                    }
85
-                },
86
-                getCollapseBehaviour()
87
-        );
88
-    }
89
-
90
-    private CollapseBehaviour getCollapseBehaviour() {
91
-        return screenParams.styleParams.collapsingTopBarParams.collapseBehaviour;
92
-    }
93
-
94
-    @Override
95
-    public void onEvent(Event event) {
96
-        super.onEvent(event);
97
-        if (ViewPagerScreenScrollStartEvent.TYPE.equals(event.getType()) || ViewPagerScreenChangedEvent.TYPE.equals(event.getType())) {
98
-            ((CollapsingView) topBar).collapse(new CollapseAmount(CollapseCalculator.Direction.Down));
99
-            ((CollapsingView) viewPager).collapse(new CollapseAmount(CollapseCalculator.Direction.Down));
100
-        }
101
-    }
102
-
103
-    @Override
104
-    public void destroy() {
105
-        super.destroy();
106
-        for (ContentView contentView : contentViews) {
107
-            if (contentView instanceof CollapsingContentView) {
108
-                ((CollapsingContentView) contentView).destroy();
109
-            }
110
-        }
111
-    }
112
-}

+ 0
- 75
lib/android/app/deprecated/java/com/reactnativenavigation/screens/ContentViewPagerAdapter.java 查看文件

@@ -1,75 +0,0 @@
1
-package com.reactnativenavigation.screens;
2
-
3
-import android.support.v4.view.PagerAdapter;
4
-import android.support.v4.view.ViewPager;
5
-import android.view.View;
6
-import android.view.ViewGroup;
7
-
8
-import com.facebook.react.bridge.Arguments;
9
-import com.facebook.react.bridge.WritableMap;
10
-import com.reactnativenavigation.NavigationApplication;
11
-import com.reactnativenavigation.events.EventBus;
12
-import com.reactnativenavigation.events.ScreenChangedEvent;
13
-import com.reactnativenavigation.events.ViewPagerScreenChangedEvent;
14
-import com.reactnativenavigation.events.ViewPagerScreenScrollStartEvent;
15
-import com.reactnativenavigation.params.PageParams;
16
-import com.reactnativenavigation.views.ContentView;
17
-
18
-import java.util.List;
19
-
20
-class ContentViewPagerAdapter extends PagerAdapter implements ViewPager.OnPageChangeListener {
21
-    private List<ContentView> contentViews;
22
-    private List<PageParams> pageParams;
23
-    private int currentPosition = 0;
24
-
25
-    ContentViewPagerAdapter(List<ContentView> contentViews, List<PageParams> pageParams) {
26
-        this.contentViews = contentViews;
27
-        this.pageParams = pageParams;
28
-    }
29
-
30
-    @Override
31
-    public Object instantiateItem(ViewGroup container, int position) {
32
-        return contentViews.get(position);
33
-    }
34
-
35
-    @Override
36
-    public int getCount() {
37
-        return contentViews.size();
38
-    }
39
-
40
-    @Override
41
-    public boolean isViewFromObject(View view, Object object) {
42
-        return view == object;
43
-    }
44
-
45
-    @Override
46
-    public CharSequence getPageTitle(int position) {
47
-        return pageParams.get(position).title;
48
-    }
49
-
50
-    @Override
51
-    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
52
-
53
-    }
54
-
55
-    @Override
56
-    public void onPageSelected(int position) {
57
-        EventBus.instance.post(new ViewPagerScreenChangedEvent());
58
-        currentPosition = position;
59
-        EventBus.instance.post(new ScreenChangedEvent(pageParams.get(currentPosition)));
60
-        sendTabSelectedEventToJs();
61
-    }
62
-
63
-    @Override
64
-    public void onPageScrollStateChanged(int state) {
65
-        if (state == ViewPager.SCROLL_STATE_DRAGGING) {
66
-            EventBus.instance.post(new ViewPagerScreenScrollStartEvent());
67
-        }
68
-    }
69
-
70
-    private void sendTabSelectedEventToJs() {
71
-        WritableMap data = Arguments.createMap();
72
-        String navigatorEventId = contentViews.get(currentPosition).getNavigatorEventId();
73
-        NavigationApplication.instance.getEventEmitter().sendNavigatorEvent("tabSelected", navigatorEventId, data);
74
-    }
75
-}

+ 0
- 131
lib/android/app/deprecated/java/com/reactnativenavigation/screens/FragmentScreen.java 查看文件

@@ -1,131 +0,0 @@
1
-package com.reactnativenavigation.screens;
2
-
3
-import android.app.Fragment;
4
-import android.app.FragmentManager;
5
-import android.app.FragmentTransaction;
6
-import android.os.Bundle;
7
-import android.support.annotation.Nullable;
8
-import android.support.v7.app.AppCompatActivity;
9
-import android.widget.FrameLayout;
10
-
11
-import com.reactnativenavigation.R;
12
-import com.reactnativenavigation.params.ScreenParams;
13
-import com.reactnativenavigation.utils.ViewUtils;
14
-import com.reactnativenavigation.views.ContentView;
15
-import com.reactnativenavigation.views.LeftButtonOnClickListener;
16
-
17
-import java.lang.reflect.InvocationTargetException;
18
-import java.lang.reflect.Method;
19
-
20
-import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
21
-
22
-@SuppressWarnings("ResourceType")
23
-public class FragmentScreen extends Screen {
24
-
25
-    private static final String CONTRACT_GET_FRAGMENT = "getFragment";
26
-    private static final String CONTRACT_GET_SUPPORT_FRAGMENT = "getSupportFragment";
27
-    private FrameLayout content;
28
-    private ContentView contentView;
29
-
30
-    public FragmentScreen(AppCompatActivity activity, ScreenParams screenParams, LeftButtonOnClickListener leftButtonOnClickListener) {
31
-        super(activity, screenParams, leftButtonOnClickListener);
32
-    }
33
-
34
-    @Override
35
-    protected void createContent() {
36
-        content = new FrameLayout(getContext());
37
-        content.setId(R.id.fragment_screen_content);
38
-        addContent();
39
-        addFragment();
40
-    }
41
-
42
-    private void addContent() {
43
-        contentView = new ContentView(getContext(),
44
-                screenParams.screenId,
45
-                screenParams.navigationParams);
46
-        addView(contentView, 0, 0);
47
-        LayoutParams params = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
48
-        if (screenParams.styleParams.drawScreenBelowTopBar) {
49
-            params.addRule(BELOW, topBar.getId());
50
-        }
51
-        addView(content, params);
52
-    }
53
-
54
-
55
-    private void addFragment() {
56
-        try {
57
-            Fragment fragment = tryGetFragment();
58
-            if (fragment != null) {
59
-                addFragment(fragment);
60
-                return;
61
-            }
62
-
63
-            android.support.v4.app.Fragment supportFragment = tryGetSupportFragment();
64
-            if (supportFragment != null) {
65
-                addSupportFragment(supportFragment);
66
-                return;
67
-            }
68
-            throw new RuntimeException("must provide public static method " + CONTRACT_GET_FRAGMENT + " or " + CONTRACT_GET_SUPPORT_FRAGMENT);
69
-        } catch (Exception e) {
70
-            throw new RuntimeException(e);
71
-        }
72
-    }
73
-
74
-    private void addFragment(Fragment fragment) {
75
-        FragmentManager fm = activity.getFragmentManager();
76
-        FragmentTransaction transaction = fm.beginTransaction();
77
-        transaction.add(R.id.fragment_screen_content, fragment);
78
-        transaction.commit();
79
-    }
80
-
81
-    private void addSupportFragment(android.support.v4.app.Fragment supportFragment) {
82
-        android.support.v4.app.FragmentManager fm = activity.getSupportFragmentManager();
83
-        android.support.v4.app.FragmentTransaction transaction = fm.beginTransaction();
84
-        transaction.add(R.id.fragment_screen_content, supportFragment);
85
-        transaction.commit();
86
-    }
87
-
88
-    @Nullable
89
-    private Fragment tryGetFragment() throws ClassNotFoundException, IllegalAccessException, InvocationTargetException {
90
-        try {
91
-            String className = screenParams.fragmentCreatorClassName;
92
-            Class<?> fragmentCreatorClass = Class.forName(className);
93
-            Method method = fragmentCreatorClass.getMethod(CONTRACT_GET_FRAGMENT, Bundle.class);
94
-            return (android.app.Fragment) method.invoke(null, screenParams.fragmentCreatorPassProps);
95
-        } catch (NoSuchMethodException noSuchMethod) {
96
-            return null;
97
-        }
98
-    }
99
-
100
-    @Nullable
101
-    private android.support.v4.app.Fragment tryGetSupportFragment() throws ClassNotFoundException, IllegalAccessException, InvocationTargetException {
102
-        try {
103
-            String className = screenParams.fragmentCreatorClassName;
104
-            Class<?> fragmentCreatorClass = Class.forName(className);
105
-            Method method = fragmentCreatorClass.getMethod(CONTRACT_GET_SUPPORT_FRAGMENT, Bundle.class);
106
-            return (android.support.v4.app.Fragment) method.invoke(null, screenParams.fragmentCreatorPassProps);
107
-        } catch (NoSuchMethodException noSuchMethod) {
108
-            return null;
109
-        }
110
-    }
111
-
112
-    @Override
113
-    public void unmountReactView() {
114
-        contentView.unmountReactView();
115
-    }
116
-
117
-    @Override
118
-    public String getNavigatorEventId() {
119
-        return screenParams.getNavigatorEventId();
120
-    }
121
-
122
-    @Override
123
-    public void setOnDisplayListener(final OnDisplayListener onContentViewDisplayedListener) {
124
-        ViewUtils.runOnPreDraw(content, new Runnable() {
125
-            @Override
126
-            public void run() {
127
-                onContentViewDisplayedListener.onDisplay();
128
-            }
129
-        });
130
-    }
131
-}

+ 0
- 250
lib/android/app/deprecated/java/com/reactnativenavigation/screens/Screen.java 查看文件

@@ -1,250 +0,0 @@
1
-package com.reactnativenavigation.screens;
2
-
3
-import android.annotation.TargetApi;
4
-import android.app.Activity;
5
-import android.graphics.Color;
6
-import android.os.Build;
7
-import android.support.v7.app.AppCompatActivity;
8
-import android.view.Window;
9
-import android.widget.RelativeLayout;
10
-
11
-import com.facebook.react.bridge.Callback;
12
-import com.reactnativenavigation.animation.VisibilityAnimator;
13
-import com.reactnativenavigation.events.ContextualMenuHiddenEvent;
14
-import com.reactnativenavigation.events.Event;
15
-import com.reactnativenavigation.events.EventBus;
16
-import com.reactnativenavigation.events.FabSetEvent;
17
-import com.reactnativenavigation.events.Subscriber;
18
-import com.reactnativenavigation.events.ViewPagerScreenChangedEvent;
19
-import com.reactnativenavigation.params.BaseScreenParams;
20
-import com.reactnativenavigation.params.ContextualMenuParams;
21
-import com.reactnativenavigation.params.FabParams;
22
-import com.reactnativenavigation.params.ScreenParams;
23
-import com.reactnativenavigation.params.StyleParams;
24
-import com.reactnativenavigation.params.TitleBarButtonParams;
25
-import com.reactnativenavigation.params.TitleBarLeftButtonParams;
26
-import com.reactnativenavigation.utils.ViewUtils;
27
-import com.reactnativenavigation.views.LeftButtonOnClickListener;
28
-import com.reactnativenavigation.views.TopBar;
29
-
30
-import java.util.List;
31
-
32
-import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
33
-import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
34
-
35
-public abstract class Screen extends RelativeLayout implements Subscriber {
36
-
37
-    public interface OnDisplayListener {
38
-        void onDisplay();
39
-    }
40
-
41
-    protected final AppCompatActivity activity;
42
-    protected final ScreenParams screenParams;
43
-    protected TopBar topBar;
44
-    private final LeftButtonOnClickListener leftButtonOnClickListener;
45
-    private VisibilityAnimator topBarVisibilityAnimator;
46
-    private ScreenAnimator screenAnimator;
47
-    protected final StyleParams styleParams;
48
-
49
-    public Screen(AppCompatActivity activity, ScreenParams screenParams, LeftButtonOnClickListener leftButtonOnClickListener) {
50
-        super(activity);
51
-        this.activity = activity;
52
-        this.screenParams = screenParams;
53
-        styleParams = screenParams.styleParams;
54
-        this.leftButtonOnClickListener = leftButtonOnClickListener;
55
-        screenAnimator = new ScreenAnimator(this);
56
-        createViews();
57
-        EventBus.instance.register(this);
58
-    }
59
-
60
-    @Override
61
-    public void onEvent(Event event) {
62
-        if (ContextualMenuHiddenEvent.TYPE.equals(event.getType()) && isShown()) {
63
-            setStyle();
64
-            topBar.onContextualMenuHidden();
65
-        }
66
-        if (ViewPagerScreenChangedEvent.TYPE.equals(event.getType()) && isShown() ) {
67
-            setStyle();
68
-            topBar.dismissContextualMenu();
69
-        }
70
-    }
71
-
72
-    public void setStyle() {
73
-        setStatusBarColor(styleParams.statusBarColor);
74
-        setNavigationBarColor(styleParams.navigationBarColor);
75
-        topBar.setStyle(styleParams);
76
-        if (styleParams.screenBackgroundColor.hasColor()) {
77
-            setBackgroundColor(styleParams.screenBackgroundColor.getColor());
78
-        }
79
-    }
80
-
81
-    private void createViews() {
82
-        createAndAddTopBar();
83
-        createTitleBar();
84
-        createContent();
85
-    }
86
-
87
-    protected abstract void createContent();
88
-
89
-    private void createTitleBar() {
90
-        addTitleBarButtons();
91
-        topBar.setTitle(screenParams.title);
92
-        topBar.setSubtitle(screenParams.subtitle);
93
-    }
94
-
95
-    private void addTitleBarButtons() {
96
-        setButtonColorFromScreen(screenParams.rightButtons);
97
-        if (screenParams.leftButton != null) {
98
-            screenParams.leftButton.setColorFromScreenStyle(screenParams.styleParams.titleBarButtonColor);
99
-        }
100
-        topBar.addTitleBarAndSetButtons(screenParams.rightButtons,
101
-                screenParams.leftButton,
102
-                leftButtonOnClickListener,
103
-                screenParams.getNavigatorEventId(),
104
-                screenParams.overrideBackPressInJs);
105
-    }
106
-
107
-    private void createAndAddTopBar() {
108
-        createTopBar();
109
-        addTopBar();
110
-    }
111
-
112
-    protected void createTopBar() {
113
-        topBar = new TopBar(getContext());
114
-    }
115
-
116
-    private void addTopBar() {
117
-        createTopBarVisibilityAnimator();
118
-        addView(topBar, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
119
-    }
120
-
121
-    private void createTopBarVisibilityAnimator() {
122
-        ViewUtils.runOnPreDraw(topBar, new Runnable() {
123
-            @Override
124
-            public void run() {
125
-                if (topBarVisibilityAnimator == null) {
126
-                    topBarVisibilityAnimator = new VisibilityAnimator(topBar,
127
-                            VisibilityAnimator.HideDirection.Up,
128
-                            topBar.getHeight());
129
-                }
130
-            }
131
-        });
132
-    }
133
-
134
-    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
135
-    private void setStatusBarColor(StyleParams.Color statusBarColor) {
136
-        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
137
-
138
-        final Activity context = (Activity) getContext();
139
-        final Window window = context.getWindow();
140
-        if (statusBarColor.hasColor()) {
141
-            window.setStatusBarColor(statusBarColor.getColor());
142
-        } else {
143
-            window.setStatusBarColor(Color.BLACK);
144
-        }
145
-    }
146
-
147
-    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
148
-    public void setNavigationBarColor(StyleParams.Color navigationBarColor) {
149
-        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
150
-
151
-        final Activity context = (Activity) getContext();
152
-        final Window window = context.getWindow();
153
-        if (navigationBarColor.hasColor()) {
154
-            window.setNavigationBarColor(navigationBarColor.getColor());
155
-        } else {
156
-            window.setNavigationBarColor(Color.BLACK);
157
-        }
158
-    }
159
-
160
-    public abstract void unmountReactView();
161
-
162
-    public String getScreenInstanceId() {
163
-        return screenParams.getScreenInstanceId();
164
-    }
165
-
166
-    public abstract String getNavigatorEventId();
167
-
168
-    public BaseScreenParams getScreenParams() {
169
-        return screenParams;
170
-    }
171
-
172
-    public void setTopBarVisible(boolean visible, boolean animate) {
173
-        topBarVisibilityAnimator.setVisible(visible, animate);
174
-    }
175
-
176
-    public void setTitleBarTitle(String title) {
177
-        topBar.setTitle(title);
178
-    }
179
-
180
-    public void setTitleBarSubtitle(String subtitle) {
181
-        topBar.setSubtitle(subtitle);
182
-    }
183
-
184
-    public void setTitleBarRightButtons(String navigatorEventId, List<TitleBarButtonParams> titleBarButtons) {
185
-        setButtonColorFromScreen(titleBarButtons);
186
-        topBar.setTitleBarRightButtons(navigatorEventId, titleBarButtons);
187
-    }
188
-
189
-    public void setTitleBarLeftButton(String navigatorEventId, LeftButtonOnClickListener backButtonListener,
190
-                                      TitleBarLeftButtonParams titleBarLeftButtonParams) {
191
-        topBar.setTitleBarLeftButton(navigatorEventId,
192
-                backButtonListener,
193
-                titleBarLeftButtonParams,
194
-                screenParams.overrideBackPressInJs);
195
-    }
196
-
197
-    public void setFab(FabParams fabParams) {
198
-        screenParams.fabParams = fabParams;
199
-        if (isShown()) {
200
-            EventBus.instance.post(new FabSetEvent(fabParams));
201
-        }
202
-    }
203
-
204
-    public StyleParams getStyleParams() {
205
-        return screenParams.styleParams;
206
-    }
207
-
208
-    private void setButtonColorFromScreen(List<TitleBarButtonParams> titleBarButtonParams) {
209
-        if (titleBarButtonParams == null) {
210
-            return;
211
-        }
212
-
213
-        for (TitleBarButtonParams titleBarButtonParam : titleBarButtonParams) {
214
-            titleBarButtonParam.setColorFromScreenStyle(screenParams.styleParams.titleBarButtonColor);
215
-        }
216
-    }
217
-
218
-    public abstract void setOnDisplayListener(OnDisplayListener onContentViewDisplayedListener);
219
-
220
-    public void show() {
221
-        screenAnimator.show(screenParams.animateScreenTransitions);
222
-    }
223
-
224
-    public void show(boolean animated) {
225
-        screenAnimator.show(animated);
226
-    }
227
-
228
-    public void show(boolean animated, Runnable onAnimationEnd) {
229
-        setStyle();
230
-        screenAnimator.show(animated, onAnimationEnd);
231
-    }
232
-
233
-    public void hide(boolean animated, Runnable onAnimatedEnd) {
234
-        screenAnimator.hide(animated, onAnimatedEnd);
235
-    }
236
-
237
-    public void showContextualMenu(ContextualMenuParams params, Callback onButtonClicked) {
238
-        topBar.showContextualMenu(params, styleParams, onButtonClicked);
239
-        setStatusBarColor(styleParams.contextualMenuStatusBarColor);
240
-    }
241
-
242
-    public void dismissContextualMenu() {
243
-        topBar.dismissContextualMenu();
244
-    }
245
-
246
-    public void destroy() {
247
-        unmountReactView();
248
-        EventBus.instance.unregister(this);
249
-    }
250
-}

+ 0
- 99
lib/android/app/deprecated/java/com/reactnativenavigation/screens/ScreenAnimator.java 查看文件

@@ -1,99 +0,0 @@
1
-package com.reactnativenavigation.screens;
2
-
3
-import android.animation.Animator;
4
-import android.animation.AnimatorListenerAdapter;
5
-import android.animation.AnimatorSet;
6
-import android.animation.ObjectAnimator;
7
-import android.view.View;
8
-import android.view.animation.AccelerateInterpolator;
9
-import android.view.animation.DecelerateInterpolator;
10
-import android.view.animation.LinearInterpolator;
11
-
12
-import com.reactnativenavigation.NavigationApplication;
13
-import com.reactnativenavigation.utils.ViewUtils;
14
-
15
-import javax.annotation.Nullable;
16
-
17
-public class ScreenAnimator {
18
-    private final float translationY;
19
-    private Screen screen;
20
-
21
-    public ScreenAnimator(Screen screen) {
22
-        this.screen = screen;
23
-        translationY = 0.08f * ViewUtils.getScreenHeight();
24
-    }
25
-
26
-    public void show(boolean animate, final Runnable onAnimationEnd) {
27
-        if (animate) {
28
-            createShowAnimator(onAnimationEnd).start();
29
-        } else {
30
-            screen.setVisibility(View.VISIBLE);
31
-            NavigationApplication.instance.runOnMainThread(onAnimationEnd, 200);
32
-        }
33
-    }
34
-
35
-    public void show(boolean animate) {
36
-        if (animate) {
37
-            createShowAnimator(null).start();
38
-        } else {
39
-            screen.setVisibility(View.VISIBLE);
40
-        }
41
-    }
42
-
43
-    public void hide(boolean animate, Runnable onAnimationEnd) {
44
-        if (animate) {
45
-            createHideAnimator(onAnimationEnd).start();
46
-        } else {
47
-            screen.setVisibility(View.INVISIBLE);
48
-            onAnimationEnd.run();
49
-        }
50
-    }
51
-
52
-    private Animator createShowAnimator(final @Nullable Runnable onAnimationEnd) {
53
-        ObjectAnimator alpha = ObjectAnimator.ofFloat(screen, View.ALPHA, 0, 1);
54
-        alpha.setInterpolator(new DecelerateInterpolator());
55
-        alpha.setDuration(200);
56
-
57
-        ObjectAnimator translationY = ObjectAnimator.ofFloat(screen, View.TRANSLATION_Y, this.translationY, 0);
58
-        translationY.setInterpolator(new DecelerateInterpolator());
59
-        translationY.setDuration(280);
60
-
61
-        AnimatorSet set = new AnimatorSet();
62
-        set.playTogether(translationY, alpha);
63
-        set.addListener(new AnimatorListenerAdapter() {
64
-            @Override
65
-            public void onAnimationStart(Animator animation) {
66
-                screen.setVisibility(View.VISIBLE);
67
-            }
68
-
69
-            @Override
70
-            public void onAnimationEnd(Animator animation) {
71
-                if (onAnimationEnd != null) {
72
-                    onAnimationEnd.run();
73
-                }
74
-            }
75
-        });
76
-        return set;
77
-    }
78
-
79
-    private Animator createHideAnimator(final Runnable onAnimationEnd) {
80
-        ObjectAnimator alpha = ObjectAnimator.ofFloat(screen, View.ALPHA, 0);
81
-        alpha.setInterpolator(new LinearInterpolator());
82
-        alpha.setStartDelay(100);
83
-        alpha.setDuration(150);
84
-
85
-        ObjectAnimator translationY = ObjectAnimator.ofFloat(screen, View.TRANSLATION_Y, this.translationY);
86
-        translationY.setInterpolator(new AccelerateInterpolator());
87
-        translationY.setDuration(250);
88
-
89
-        AnimatorSet set = new AnimatorSet();
90
-        set.playTogether(translationY, alpha);
91
-        set.addListener(new AnimatorListenerAdapter() {
92
-            @Override
93
-            public void onAnimationEnd(Animator animation) {
94
-                onAnimationEnd.run();
95
-            }
96
-        });
97
-        return set;
98
-    }
99
-}

+ 0
- 26
lib/android/app/deprecated/java/com/reactnativenavigation/screens/ScreenFactory.java 查看文件

@@ -1,26 +0,0 @@
1
-package com.reactnativenavigation.screens;
2
-
3
-import android.support.v7.app.AppCompatActivity;
4
-
5
-import com.reactnativenavigation.params.ScreenParams;
6
-import com.reactnativenavigation.views.LeftButtonOnClickListener;
7
-
8
-class ScreenFactory {
9
-    static Screen create(AppCompatActivity activity,
10
-                         ScreenParams screenParams,
11
-                         LeftButtonOnClickListener leftButtonOnClickListener) {
12
-        if (screenParams.isFragmentScreen()) {
13
-            return new FragmentScreen(activity, screenParams, leftButtonOnClickListener);
14
-        } else if (screenParams.hasTopTabs()) {
15
-            if (screenParams.hasCollapsingTopBar()) {
16
-                return new CollapsingViewPagerScreen(activity, screenParams, leftButtonOnClickListener);
17
-            } else {
18
-                return new ViewPagerScreen(activity, screenParams, leftButtonOnClickListener);
19
-            }
20
-        } else if (screenParams.hasCollapsingTopBar()) {
21
-            return new CollapsingSingleScreen(activity, screenParams, leftButtonOnClickListener);
22
-        } else {
23
-            return new SingleScreen(activity, screenParams, leftButtonOnClickListener);
24
-        }
25
-    }
26
-}

+ 0
- 301
lib/android/app/deprecated/java/com/reactnativenavigation/screens/ScreenStack.java 查看文件

@@ -1,301 +0,0 @@
1
-package com.reactnativenavigation.screens;
2
-
3
-import android.support.annotation.Nullable;
4
-import android.support.v7.app.AppCompatActivity;
5
-import android.util.Log;
6
-import android.view.View;
7
-import android.widget.RelativeLayout;
8
-import android.widget.RelativeLayout.LayoutParams;
9
-
10
-import com.facebook.react.bridge.Callback;
11
-import com.reactnativenavigation.NavigationApplication;
12
-import com.reactnativenavigation.params.ContextualMenuParams;
13
-import com.reactnativenavigation.params.FabParams;
14
-import com.reactnativenavigation.params.ScreenParams;
15
-import com.reactnativenavigation.params.StyleParams;
16
-import com.reactnativenavigation.params.TitleBarButtonParams;
17
-import com.reactnativenavigation.params.TitleBarLeftButtonParams;
18
-import com.reactnativenavigation.utils.KeyboardVisibilityDetector;
19
-import com.reactnativenavigation.utils.Task;
20
-import com.reactnativenavigation.views.LeftButtonOnClickListener;
21
-
22
-import java.util.List;
23
-import java.util.Stack;
24
-
25
-public class ScreenStack {
26
-    private static final String TAG = "ScreenStack";
27
-
28
-    public interface OnScreenPop {
29
-        void onScreenPopAnimationEnd();
30
-    }
31
-
32
-    private final AppCompatActivity activity;
33
-    private RelativeLayout parent;
34
-    private LeftButtonOnClickListener leftButtonOnClickListener;
35
-    private Stack<Screen> stack = new Stack<>();
36
-    private final KeyboardVisibilityDetector keyboardVisibilityDetector;
37
-    private boolean isStackVisible = false;
38
-    private final String navigatorId;
39
-
40
-    public String getNavigatorId() {
41
-        return navigatorId;
42
-    }
43
-
44
-    public ScreenStack(AppCompatActivity activity,
45
-                       RelativeLayout parent,
46
-                       String navigatorId,
47
-                       LeftButtonOnClickListener leftButtonOnClickListener) {
48
-        this.activity = activity;
49
-        this.parent = parent;
50
-        this.navigatorId = navigatorId;
51
-        this.leftButtonOnClickListener = leftButtonOnClickListener;
52
-        keyboardVisibilityDetector = new KeyboardVisibilityDetector(parent);
53
-    }
54
-
55
-    public void pushInitialScreenWithAnimation(final ScreenParams initialScreenParams, LayoutParams params) {
56
-        isStackVisible = true;
57
-        pushInitialScreen(initialScreenParams, params);
58
-        final Screen screen = stack.peek();
59
-        screen.setOnDisplayListener(new Screen.OnDisplayListener() {
60
-            @Override
61
-            public void onDisplay() {
62
-                screen.show(initialScreenParams.animateScreenTransitions);
63
-                screen.setStyle();
64
-            }
65
-        });
66
-    }
67
-
68
-    public void pushInitialScreen(ScreenParams initialScreenParams, LayoutParams params) {
69
-        Screen initialScreen = ScreenFactory.create(activity, initialScreenParams, leftButtonOnClickListener);
70
-        initialScreen.setVisibility(View.INVISIBLE);
71
-        addScreen(initialScreen, params);
72
-    }
73
-
74
-    public void push(final ScreenParams params, LayoutParams layoutParams) {
75
-        Screen nextScreen = ScreenFactory.create(activity, params, leftButtonOnClickListener);
76
-        final Screen previousScreen = stack.peek();
77
-        if (isStackVisible) {
78
-            pushScreenToVisibleStack(layoutParams, nextScreen, previousScreen);
79
-        } else {
80
-            pushScreenToInvisibleStack(layoutParams, nextScreen, previousScreen);
81
-        }
82
-    }
83
-
84
-    private void pushScreenToVisibleStack(LayoutParams layoutParams, final Screen nextScreen, final Screen previousScreen) {
85
-        nextScreen.setVisibility(View.INVISIBLE);
86
-        addScreen(nextScreen, layoutParams);
87
-        nextScreen.setOnDisplayListener(new Screen.OnDisplayListener() {
88
-            @Override
89
-            public void onDisplay() {
90
-                nextScreen.show(nextScreen.screenParams.animateScreenTransitions, new Runnable() {
91
-                    @Override
92
-                    public void run() {
93
-                        parent.removeView(previousScreen);
94
-                    }
95
-                });
96
-            }
97
-        });
98
-    }
99
-
100
-    private void pushScreenToInvisibleStack(LayoutParams layoutParams, Screen nextScreen, Screen previousScreen) {
101
-        nextScreen.setVisibility(View.INVISIBLE);
102
-        addScreen(nextScreen, layoutParams);
103
-        parent.removeView(previousScreen);
104
-    }
105
-
106
-    private void addScreen(Screen screen, LayoutParams layoutParams) {
107
-        addScreenBeforeSnackbarAndFabLayout(screen, layoutParams);
108
-        stack.push(screen);
109
-    }
110
-
111
-    private void addScreenBeforeSnackbarAndFabLayout(Screen screen, LayoutParams layoutParams) {
112
-        parent.addView(screen, parent.getChildCount() - 1, layoutParams);
113
-    }
114
-
115
-    public void pop(boolean animated) {
116
-        pop(animated, null);
117
-    }
118
-
119
-    public void pop(final boolean animated, @Nullable final OnScreenPop onScreenPop) {
120
-        if (!canPop()) {
121
-            return;
122
-        }
123
-
124
-        final Screen toRemove = stack.pop();
125
-        final Screen previous = stack.peek();
126
-
127
-        if (keyboardVisibilityDetector.isKeyboardVisible()) {
128
-            keyboardVisibilityDetector.setKeyboardCloseListener(new Runnable() {
129
-                @Override
130
-                public void run() {
131
-                    keyboardVisibilityDetector.setKeyboardCloseListener(null);
132
-                    swapScreens(animated, toRemove, previous, onScreenPop);
133
-                }
134
-            });
135
-            keyboardVisibilityDetector.closeKeyboard();
136
-        } else {
137
-            swapScreens(animated, toRemove, previous, onScreenPop);
138
-        }
139
-    }
140
-
141
-    private void swapScreens(boolean animated, final Screen toRemove, Screen previous, OnScreenPop onScreenPop) {
142
-        readdPrevious(previous);
143
-        previous.setStyle();
144
-        toRemove.hide(animated, new Runnable() {
145
-            @Override
146
-            public void run() {
147
-                toRemove.unmountReactView();
148
-                parent.removeView(toRemove);
149
-            }
150
-        });
151
-
152
-        if (onScreenPop != null) {
153
-            onScreenPop.onScreenPopAnimationEnd();
154
-        }
155
-    }
156
-
157
-    public Screen peek() {
158
-        return stack.peek();
159
-    }
160
-
161
-    private void readdPrevious(Screen previous) {
162
-        previous.setVisibility(View.VISIBLE);
163
-        parent.addView(previous, 0);
164
-    }
165
-
166
-    public void popToRoot(boolean animated) {
167
-        while (canPop()) {
168
-            pop(animated);
169
-        }
170
-    }
171
-
172
-    public void destroy() {
173
-        for (Screen screen : stack) {
174
-            screen.destroy();
175
-            parent.removeView(screen);
176
-        }
177
-        stack.clear();
178
-    }
179
-
180
-    public boolean canPop() {
181
-        return stack.size() > 1 && !isPreviousScreenAttachedToWindow();
182
-    }
183
-
184
-    private boolean isPreviousScreenAttachedToWindow() {
185
-        Screen previousScreen = stack.get(stack.size() - 2);
186
-        if (previousScreen.getParent() != null) {
187
-            Log.w(TAG, "Can't pop stack. reason: previous screen is already attached");
188
-            return true;
189
-        }
190
-        return false;
191
-    }
192
-
193
-    public void setScreenTopBarVisible(String screenInstanceId, final boolean visible, final boolean animate) {
194
-        performOnScreen(screenInstanceId, new Task<Screen>() {
195
-            @Override
196
-            public void run(Screen param) {
197
-                param.setTopBarVisible(visible, animate);
198
-            }
199
-        });
200
-    }
201
-
202
-    public void setScreenTitleBarTitle(String screenInstanceId, final String title) {
203
-        performOnScreen(screenInstanceId, new Task<Screen>() {
204
-            @Override
205
-            public void run(Screen param) {
206
-                param.setTitleBarTitle(title);
207
-            }
208
-        });
209
-    }
210
-
211
-    public void setScreenTitleBarSubtitle(String screenInstanceId, final String subtitle) {
212
-        performOnScreen(screenInstanceId, new Task<Screen>() {
213
-            @Override
214
-            public void run(Screen param) {
215
-                param.setTitleBarSubtitle(subtitle);
216
-            }
217
-        });
218
-    }
219
-
220
-    public void setScreenTitleBarRightButtons(String screenInstanceId, final String navigatorEventId, final List<TitleBarButtonParams> titleBarButtons) {
221
-        performOnScreen(screenInstanceId, new Task<Screen>() {
222
-            @Override
223
-            public void run(Screen param) {
224
-                param.setTitleBarRightButtons(navigatorEventId, titleBarButtons);
225
-            }
226
-        });
227
-    }
228
-
229
-    public void setScreenTitleBarLeftButton(String screenInstanceId, final String navigatorEventId, final TitleBarLeftButtonParams titleBarLeftButtonParams) {
230
-        performOnScreen(screenInstanceId, new Task<Screen>() {
231
-            @Override
232
-            public void run(Screen param) {
233
-                param.setTitleBarLeftButton(navigatorEventId, leftButtonOnClickListener, titleBarLeftButtonParams);
234
-            }
235
-        });
236
-    }
237
-
238
-    public void setFab(String screenInstanceId, final String navigatorEventId, final FabParams fabParams) {
239
-        performOnScreen(screenInstanceId, new Task<Screen>() {
240
-            @Override
241
-            public void run(Screen param) {
242
-                param.setFab(fabParams);
243
-            }
244
-        });
245
-    }
246
-
247
-    public void showContextualMenu(String screenInstanceId, final ContextualMenuParams params, final Callback onButtonClicked) {
248
-        performOnScreen(screenInstanceId, new Task<Screen>() {
249
-            @Override
250
-            public void run(Screen screen) {
251
-                screen.showContextualMenu(params, onButtonClicked);
252
-            }
253
-        });
254
-    }
255
-
256
-    public void dismissContextualMenu(String screenInstanceId) {
257
-        performOnScreen(screenInstanceId, new Task<Screen>() {
258
-            @Override
259
-            public void run(Screen screen) {
260
-                screen.dismissContextualMenu();
261
-            }
262
-        });
263
-    }
264
-
265
-    public StyleParams getCurrentScreenStyleParams() {
266
-        return stack.peek().getStyleParams();
267
-    }
268
-
269
-    public boolean handleBackPressInJs() {
270
-        ScreenParams currentScreen = stack.peek().screenParams;
271
-        if (currentScreen.overrideBackPressInJs) {
272
-            NavigationApplication.instance.getEventEmitter().sendNavigatorEvent("backPress", currentScreen.getNavigatorEventId());
273
-            return true;
274
-        }
275
-        return false;
276
-    }
277
-
278
-    private void performOnScreen(String screenInstanceId, Task<Screen> task) {
279
-        if (stack.isEmpty()) {
280
-            return;
281
-        }
282
-
283
-        for (Screen screen : stack) {
284
-            if (screen.getScreenInstanceId().equals(screenInstanceId)) {
285
-                task.run(screen);
286
-                return;
287
-            }
288
-        }
289
-    }
290
-
291
-    public void show() {
292
-        isStackVisible = true;
293
-        stack.peek().setStyle();
294
-        stack.peek().setVisibility(View.VISIBLE);
295
-    }
296
-
297
-    public void hide() {
298
-        isStackVisible = false;
299
-        stack.peek().setVisibility(View.INVISIBLE);
300
-    }
301
-}

+ 0
- 47
lib/android/app/deprecated/java/com/reactnativenavigation/screens/SingleScreen.java 查看文件

@@ -1,47 +0,0 @@
1
-package com.reactnativenavigation.screens;
2
-
3
-import android.support.v7.app.AppCompatActivity;
4
-
5
-import com.reactnativenavigation.params.ScreenParams;
6
-import com.reactnativenavigation.views.ContentView;
7
-import com.reactnativenavigation.views.LeftButtonOnClickListener;
8
-
9
-import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
10
-
11
-public class SingleScreen extends Screen {
12
-    protected ContentView contentView;
13
-
14
-    public SingleScreen(AppCompatActivity activity, ScreenParams screenParams,
15
-                        LeftButtonOnClickListener titleBarBarBackButtonListener) {
16
-        super(activity, screenParams, titleBarBarBackButtonListener);
17
-    }
18
-
19
-    @Override
20
-    protected void createContent() {
21
-        contentView = new ContentView(getContext(), screenParams.screenId, screenParams.navigationParams);
22
-        addView(contentView, 0, createLayoutParams());
23
-    }
24
-
25
-    protected LayoutParams createLayoutParams() {
26
-        LayoutParams params = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
27
-        if (screenParams.styleParams.drawScreenBelowTopBar) {
28
-            params.addRule(BELOW, topBar.getId());
29
-        }
30
-        return params;
31
-    }
32
-
33
-    @Override
34
-    public void unmountReactView() {
35
-        contentView.unmountReactView();
36
-    }
37
-
38
-    @Override
39
-    public String getNavigatorEventId() {
40
-        return screenParams.getNavigatorEventId();
41
-    }
42
-
43
-    @Override
44
-    public void setOnDisplayListener(OnDisplayListener onContentViewDisplayedListener) {
45
-        contentView.setOnDisplayListener(onContentViewDisplayedListener);
46
-    }
47
-}

+ 0
- 108
lib/android/app/deprecated/java/com/reactnativenavigation/screens/ViewPagerScreen.java 查看文件

@@ -1,108 +0,0 @@
1
-package com.reactnativenavigation.screens;
2
-
3
-import android.content.Context;
4
-import android.support.design.widget.TabLayout;
5
-import android.support.v4.view.ViewPager;
6
-import android.support.v7.app.AppCompatActivity;
7
-
8
-import com.reactnativenavigation.events.Event;
9
-import com.reactnativenavigation.events.ViewPagerScreenChangedEvent;
10
-import com.reactnativenavigation.params.BaseScreenParams;
11
-import com.reactnativenavigation.params.PageParams;
12
-import com.reactnativenavigation.params.ScreenParams;
13
-import com.reactnativenavigation.views.ContentView;
14
-import com.reactnativenavigation.views.LeftButtonOnClickListener;
15
-
16
-import java.util.ArrayList;
17
-import java.util.List;
18
-
19
-import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
20
-
21
-public class ViewPagerScreen extends Screen {
22
-
23
-    private static final int OFFSCREEN_PAGE_LIMIT = 99;
24
-    protected List<ContentView> contentViews;
25
-    protected ViewPager viewPager;
26
-
27
-    public ViewPagerScreen(AppCompatActivity activity, ScreenParams screenParams, LeftButtonOnClickListener backButtonListener) {
28
-        super(activity, screenParams, backButtonListener);
29
-    }
30
-
31
-    @Override
32
-    public BaseScreenParams getScreenParams() {
33
-        return screenParams.topTabParams.get(viewPager.getCurrentItem());
34
-    }
35
-
36
-    @Override
37
-    protected void createContent() {
38
-        TabLayout tabLayout = topBar.initTabs();
39
-        createViewPager();
40
-        addPages();
41
-        setupViewPager(tabLayout);
42
-    }
43
-
44
-    private void createViewPager() {
45
-        viewPager = createViewPager(getContext());
46
-        viewPager.setOffscreenPageLimit(OFFSCREEN_PAGE_LIMIT);
47
-        LayoutParams lp = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
48
-        if (screenParams.styleParams.drawScreenBelowTopBar) {
49
-            lp.addRule(BELOW, topBar.getId());
50
-        }
51
-        addView(viewPager, lp);
52
-    }
53
-
54
-    protected ViewPager createViewPager(Context context) {
55
-        return new ViewPager(context);
56
-    }
57
-
58
-    private void addPages() {
59
-        contentViews = new ArrayList<>();
60
-        for (PageParams tab : screenParams.topTabParams) {
61
-            addPage(tab);
62
-        }
63
-    }
64
-
65
-    private void addPage(PageParams tab) {
66
-        ContentView contentView = createContentView(tab);
67
-        addContent(contentView);
68
-        contentViews.add(contentView);
69
-    }
70
-
71
-    protected ContentView createContentView(PageParams tab) {
72
-        return new ContentView(getContext(), tab.screenId, tab.navigationParams);
73
-    }
74
-
75
-    private void setupViewPager(TabLayout tabLayout) {
76
-        ContentViewPagerAdapter adapter = new ContentViewPagerAdapter(contentViews, screenParams.topTabParams);
77
-        viewPager.setAdapter(adapter);
78
-        viewPager.addOnPageChangeListener(adapter);
79
-        tabLayout.setupWithViewPager(viewPager);
80
-    }
81
-
82
-    private void addContent(ContentView contentView) {
83
-        LayoutParams params = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
84
-        viewPager.addView(contentView, params);
85
-    }
86
-
87
-    @Override
88
-    public void unmountReactView() {
89
-        for (ContentView contentView : contentViews) {
90
-            contentView.unmountReactView();
91
-        }
92
-    }
93
-
94
-    @Override
95
-    public void setOnDisplayListener(OnDisplayListener onContentViewDisplayedListener) {
96
-        contentViews.get(0).setOnDisplayListener(onContentViewDisplayedListener);
97
-    }
98
-
99
-    @Override
100
-    public String getScreenInstanceId() {
101
-        return screenParams.topTabParams.get(viewPager.getCurrentItem()).navigationParams.screenInstanceId;
102
-    }
103
-
104
-    @Override
105
-    public String getNavigatorEventId() {
106
-        return screenParams.topTabParams.get(viewPager.getCurrentItem()).navigationParams.navigatorEventId;
107
-    }
108
-}

+ 0
- 79
lib/android/app/deprecated/java/com/reactnativenavigation/utils/KeyboardVisibilityDetector.java 查看文件

@@ -1,79 +0,0 @@
1
-package com.reactnativenavigation.utils;
2
-
3
-import android.content.Context;
4
-import android.graphics.Rect;
5
-import android.view.View;
6
-import android.view.ViewTreeObserver;
7
-import android.view.inputmethod.InputMethodManager;
8
-
9
-import com.reactnativenavigation.NavigationApplication;
10
-
11
-public class KeyboardVisibilityDetector {
12
-    // 0.15 ratio is perhaps enough to determine keypad height.
13
-    public static final double KEYBOARD_VISIBLE_RATIO = 0.15;
14
-
15
-    private final KeyboardVisibilityLayoutListener keyboardVisibilityListener;
16
-    private final View screen;
17
-    private Runnable keyboardCloseListener;
18
-
19
-    public KeyboardVisibilityDetector(final View screen) {
20
-        this.screen = screen;
21
-        keyboardVisibilityListener = new KeyboardVisibilityLayoutListener(this);
22
-        screen.getViewTreeObserver().addOnGlobalLayoutListener(keyboardVisibilityListener);
23
-    }
24
-
25
-    public boolean isKeyboardVisible() {
26
-        return keyboardVisibilityListener.isKeyboardVisible();
27
-    }
28
-
29
-    public void setKeyboardCloseListener(Runnable keyboardCloseListener) {
30
-        this.keyboardCloseListener = keyboardCloseListener;
31
-    }
32
-
33
-    public void closeKeyboard() {
34
-        InputMethodManager imm = (InputMethodManager) screen.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
35
-        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
36
-    }
37
-
38
-    private static class KeyboardVisibilityLayoutListener implements ViewTreeObserver.OnGlobalLayoutListener {
39
-        public static final int KEYBOARD_CLOSE_DURATION = 100;
40
-        private View screen;
41
-        private boolean isVisible = false;
42
-        private KeyboardVisibilityDetector detector;
43
-
44
-        public KeyboardVisibilityLayoutListener(KeyboardVisibilityDetector detector) {
45
-            this.detector = detector;
46
-            this.screen = detector.screen;
47
-        }
48
-
49
-        public boolean isKeyboardVisible() {
50
-            return isVisible;
51
-        }
52
-
53
-        @Override
54
-        public void onGlobalLayout() {
55
-            int screenHeight = screen.getRootView().getHeight();
56
-            int screenBottomY = getScreenBottomY(screen);
57
-
58
-            int keyboardHeight = screenHeight - screenBottomY;
59
-            if (isKeyboardVisible(screenHeight, keyboardHeight)) {
60
-                isVisible = true;
61
-            } else {
62
-                if (isVisible && detector.keyboardCloseListener != null) {
63
-                    NavigationApplication.instance.runOnMainThread(detector.keyboardCloseListener, KEYBOARD_CLOSE_DURATION);
64
-                }
65
-                isVisible = false;
66
-            }
67
-        }
68
-
69
-        private boolean isKeyboardVisible(int screenHeight, int keypadHeight) {
70
-            return keypadHeight > screenHeight * KEYBOARD_VISIBLE_RATIO;
71
-        }
72
-
73
-        private int getScreenBottomY(View screen) {
74
-            Rect r = new Rect();
75
-            screen.getWindowVisibleDisplayFrame(r);
76
-            return r.bottom;
77
-        }
78
-    }
79
-}

+ 0
- 46
lib/android/app/deprecated/java/com/reactnativenavigation/utils/ReflectionUtils.java 查看文件

@@ -1,46 +0,0 @@
1
-package com.reactnativenavigation.utils;
2
-
3
-import android.support.annotation.Nullable;
4
-
5
-import java.lang.reflect.Field;
6
-
7
-public class ReflectionUtils {
8
-
9
-    public static void setField(Object obj, String name, Object value) {
10
-        try {
11
-            Field field = getField(obj.getClass(), name);
12
-            if (field == null) {
13
-                return;
14
-            }
15
-            field.setAccessible(true);
16
-            field.set(obj, value);
17
-        } catch (Exception e) {
18
-            e.printStackTrace();
19
-        }
20
-    }
21
-
22
-    @Nullable
23
-    public static Object getDeclaredField(Object obj, String fieldName) {
24
-        try {
25
-            Field f = getField(obj.getClass(), fieldName);
26
-            if (f == null) {
27
-                return null;
28
-            }
29
-            f.setAccessible(true);
30
-            return f.get(obj);
31
-        } catch (Exception e) {
32
-            e.printStackTrace();
33
-        }
34
-        return null;
35
-    }
36
-
37
-    private static Field getField(Class clazz, String name) {
38
-        try {
39
-            return clazz.getDeclaredField(name);
40
-        } catch (NoSuchFieldException nsfe) {
41
-            return getField(clazz.getSuperclass(), name);
42
-        } catch (Exception e) {
43
-            return null;
44
-        }
45
-    }
46
-}

+ 0
- 5
lib/android/app/deprecated/java/com/reactnativenavigation/utils/Task.java 查看文件

@@ -1,5 +0,0 @@
1
-package com.reactnativenavigation.utils;
2
-
3
-public interface Task<T> {
4
-    void run(T param);
5
-}

+ 0
- 138
lib/android/app/deprecated/java/com/reactnativenavigation/utils/ViewUtils.java 查看文件

@@ -1,138 +0,0 @@
1
-package com.reactnativenavigation.utils;
2
-
3
-import android.content.Context;
4
-import android.graphics.PorterDuff;
5
-import android.graphics.PorterDuffColorFilter;
6
-import android.graphics.drawable.Drawable;
7
-import android.os.Build;
8
-import android.support.annotation.Nullable;
9
-import android.util.DisplayMetrics;
10
-import android.view.View;
11
-import android.view.ViewGroup;
12
-import android.view.ViewParent;
13
-import android.view.ViewTreeObserver;
14
-import android.view.WindowManager;
15
-
16
-import com.reactnativenavigation.NavigationApplication;
17
-import com.reactnativenavigation.params.AppStyle;
18
-import com.reactnativenavigation.screens.Screen;
19
-
20
-import java.util.concurrent.atomic.AtomicInteger;
21
-
22
-public class ViewUtils {
23
-    private static final AtomicInteger viewId = new AtomicInteger(1);
24
-
25
-    public static void runOnPreDraw(final View view, final Runnable task) {
26
-        view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
27
-            @Override
28
-            public boolean onPreDraw() {
29
-                if (!view.getViewTreeObserver().isAlive()) {
30
-                    return true;
31
-                }
32
-                view.getViewTreeObserver().removeOnPreDrawListener(this);
33
-                task.run();
34
-                return true;
35
-            }
36
-        });
37
-    }
38
-
39
-    public static void tintDrawable(Drawable drawable, int tint, boolean enabled) {
40
-        drawable.setColorFilter(new PorterDuffColorFilter(enabled ? tint :
41
-                AppStyle.appStyle.titleBarDisabledButtonColor.getColor(),
42
-                PorterDuff.Mode.SRC_IN));
43
-    }
44
-
45
-    public static float convertDpToPixel(float dp) {
46
-        float scale = NavigationApplication.instance.getResources().getDisplayMetrics().density;
47
-        return dp * scale + 0.5f;
48
-    }
49
-
50
-    public static float convertPixelToSp(float pixels) {
51
-        float scaledDensity = NavigationApplication.instance.getResources().getDisplayMetrics().scaledDensity;
52
-        return pixels/scaledDensity;
53
-    }
54
-
55
-    public static float convertSpToPixel(float pixels) {
56
-        float scaledDensity = NavigationApplication.instance.getResources().getDisplayMetrics().scaledDensity;
57
-        return pixels * scaledDensity;
58
-    }
59
-
60
-    public static float getScreenHeight() {
61
-        WindowManager wm = (WindowManager) NavigationApplication.instance.getSystemService(Context.WINDOW_SERVICE);
62
-        DisplayMetrics metrics = new DisplayMetrics();
63
-        wm.getDefaultDisplay().getMetrics(metrics);
64
-        return metrics.heightPixels;
65
-    }
66
-
67
-    public static int generateViewId() {
68
-        if (Build.VERSION.SDK_INT >= 17) {
69
-            return View.generateViewId();
70
-        } else {
71
-            return compatGenerateViewId();
72
-        }
73
-    }
74
-
75
-    private static int compatGenerateViewId() {
76
-        for (; ; ) {
77
-            final int result = viewId.get();
78
-            // aapt-generated IDs have the high byte nonzero; clamp to the range under that.
79
-            int newValue = result + 1;
80
-            if (newValue > 0x00FFFFFF) newValue = 1; // Roll over to 1, not 0.
81
-            if (viewId.compareAndSet(result, newValue)) {
82
-                return result;
83
-            }
84
-        }
85
-    }
86
-
87
-    /**
88
-     * Returns the first instance of clazz in root
89
-     */
90
-    @Nullable public static <T> T findChildByClass(ViewGroup root, Class clazz) {
91
-        for (int i = 0; i < root.getChildCount(); i++) {
92
-            View view = root.getChildAt(i);
93
-            if (clazz.isAssignableFrom(view.getClass())) {
94
-                return (T) view;
95
-            }
96
-
97
-            if (view instanceof ViewGroup) {
98
-                view = findChildByClass((ViewGroup) view, clazz);
99
-                if (view != null && clazz.isAssignableFrom(view.getClass())) {
100
-                    return (T) view;
101
-                }
102
-            }
103
-        }
104
-        return null;
105
-    }
106
-
107
-    public static void performOnChildren(ViewGroup root, PerformOnViewTask task) {
108
-        for (int i = 0; i < root.getChildCount(); i++) {
109
-            View child = root.getChildAt(i);
110
-            if (child instanceof ViewGroup) {
111
-                performOnChildren((ViewGroup) child, task);
112
-            }
113
-            task.runOnView(child);
114
-        }
115
-    }
116
-
117
-    public interface PerformOnViewTask {
118
-        void runOnView(View view);
119
-    }
120
-
121
-    public static void performOnParentScreen(View child, Task<Screen> task) {
122
-        Screen parentScreen = findParentScreen(child.getParent());
123
-        if (parentScreen != null) {
124
-            task.run(parentScreen);
125
-        }
126
-    }
127
-
128
-    private static Screen findParentScreen(ViewParent parent) {
129
-        if (parent == null) {
130
-            return null;
131
-        }
132
-        if (parent instanceof Screen) {
133
-            return (Screen) parent;
134
-        }
135
-        return findParentScreen(parent.getParent());
136
-    }
137
-}
138
-

+ 0
- 100
lib/android/app/deprecated/java/com/reactnativenavigation/views/BottomTabs.java 查看文件

@@ -1,100 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-import android.content.Context;
4
-import android.graphics.Color;
5
-
6
-import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
7
-import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem;
8
-import com.reactnativenavigation.animation.VisibilityAnimator;
9
-import com.reactnativenavigation.params.AppStyle;
10
-import com.reactnativenavigation.params.ScreenParams;
11
-import com.reactnativenavigation.params.StyleParams;
12
-import com.reactnativenavigation.utils.ViewUtils;
13
-
14
-import java.util.List;
15
-
16
-public class BottomTabs extends AHBottomNavigation {
17
-
18
-    private VisibilityAnimator visibilityAnimator;
19
-
20
-    public BottomTabs(Context context) {
21
-        super(context);
22
-        setForceTint(true);
23
-        setId(ViewUtils.generateViewId());
24
-        createVisibilityAnimator();
25
-        setStyle();
26
-    }
27
-
28
-    public void addTabs(List<ScreenParams> params, OnTabSelectedListener onTabSelectedListener) {
29
-        for (ScreenParams screenParams : params) {
30
-            AHBottomNavigationItem item = new AHBottomNavigationItem(screenParams.tabLabel, screenParams.tabIcon,
31
-                    Color.GRAY);
32
-            addItem(item);
33
-            setOnTabSelectedListener(onTabSelectedListener);
34
-        }
35
-    }
36
-
37
-    public void setStyleFromScreen(StyleParams params) {
38
-        if (params.bottomTabsColor.hasColor()) {
39
-            setBackgroundColor(params.bottomTabsColor);
40
-        }
41
-        if (params.bottomTabsButtonColor.hasColor()) {
42
-            setInactiveColor(params.bottomTabsButtonColor.getColor());
43
-        }
44
-        if (params.selectedBottomTabsButtonColor.hasColor()) {
45
-            setAccentColor(params.selectedBottomTabsButtonColor.getColor());
46
-        }
47
-
48
-        setForceTitlesDisplay(params.forceTitlesDisplay);
49
-
50
-        setVisibility(params.bottomTabsHidden, true);
51
-    }
52
-
53
-    public void setVisibility(boolean hidden, boolean animated) {
54
-        if (visibilityAnimator != null) {
55
-            visibilityAnimator.setVisible(!hidden, animated);
56
-        } else {
57
-            setVisibility(hidden);
58
-        }
59
-    }
60
-
61
-    private void setBackgroundColor(StyleParams.Color bottomTabsColor) {
62
-        if (bottomTabsColor.hasColor()) {
63
-            setDefaultBackgroundColor(bottomTabsColor.getColor());
64
-        } else {
65
-            setDefaultBackgroundColor(Color.WHITE);
66
-        }
67
-    }
68
-
69
-    private void setVisibility(boolean bottomTabsHidden) {
70
-        setVisibility(bottomTabsHidden ? GONE : VISIBLE);
71
-    }
72
-
73
-    private void createVisibilityAnimator() {
74
-        ViewUtils.runOnPreDraw(this, new Runnable() {
75
-            @Override
76
-            public void run() {
77
-                visibilityAnimator = new VisibilityAnimator(BottomTabs.this,
78
-                        VisibilityAnimator.HideDirection.Down,
79
-                        getHeight());
80
-            }
81
-        });
82
-    }
83
-
84
-    private void setStyle() {
85
-        if (hasBadgeBackgroundColor()) {
86
-            setNotificationBackgroundColor(AppStyle.appStyle.bottomTabBadgeBackgroundColor.getColor());
87
-        }
88
-        if (hasBadgeTextColor()) {
89
-            setNotificationTextColor(AppStyle.appStyle.bottomTabBadgeTextColor.getColor());
90
-        }
91
-    }
92
-
93
-    private boolean hasBadgeTextColor() {
94
-        return AppStyle.appStyle.bottomTabBadgeTextColor != null && AppStyle.appStyle.bottomTabBadgeTextColor.hasColor();
95
-    }
96
-
97
-    private boolean hasBadgeBackgroundColor() {
98
-        return AppStyle.appStyle.bottomTabBadgeBackgroundColor != null && AppStyle.appStyle.bottomTabBadgeBackgroundColor.hasColor();
99
-    }
100
-}

+ 0
- 18
lib/android/app/deprecated/java/com/reactnativenavigation/views/ButtonFactory.java 查看文件

@@ -1,18 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-import android.view.Menu;
4
-import android.view.View;
5
-
6
-import com.reactnativenavigation.params.TitleBarButtonParams;
7
-
8
-class ButtonFactory {
9
-
10
-    public static TitleBarButton create(Menu menu, View parent, TitleBarButtonParams params, String navigatorEventId) {
11
-        switch (params.eventId) {
12
-            case TitleBarSearchButton.BUTTON_ID:
13
-                return new TitleBarSearchButton(menu, parent, params, navigatorEventId);
14
-            default:
15
-                return new TitleBarButton(menu, parent, params, navigatorEventId);
16
-        }
17
-    }
18
-}

+ 0
- 83
lib/android/app/deprecated/java/com/reactnativenavigation/views/CollapsingContentView.java 查看文件

@@ -1,83 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-import android.annotation.SuppressLint;
4
-import android.content.Context;
5
-import android.support.annotation.Nullable;
6
-import android.view.MotionEvent;
7
-import android.view.View;
8
-
9
-import com.reactnativenavigation.params.NavigationParams;
10
-import com.reactnativenavigation.views.collapsingToolbar.CollapseAmount;
11
-import com.reactnativenavigation.views.collapsingToolbar.CollapsingView;
12
-import com.reactnativenavigation.views.collapsingToolbar.CollapsingViewMeasurer;
13
-import com.reactnativenavigation.views.collapsingToolbar.OnScrollViewAddedListener;
14
-import com.reactnativenavigation.views.collapsingToolbar.ScrollListener;
15
-import com.reactnativenavigation.views.collapsingToolbar.ScrollViewDelegate;
16
-import com.reactnativenavigation.views.collapsingToolbar.ViewCollapser;
17
-import com.reactnativenavigation.views.utils.ScrollViewDetector;
18
-
19
-@SuppressLint("ViewConstructor")
20
-public class CollapsingContentView extends ContentView implements CollapsingView {
21
-
22
-    private @Nullable ScrollViewDelegate scrollViewDelegate;
23
-    private @Nullable ScrollViewDetector scrollViewDetector;
24
-    private final ViewCollapser viewCollapser;
25
-
26
-    public CollapsingContentView(Context context, String screenId, NavigationParams navigationParams) {
27
-        super(context, screenId, navigationParams);
28
-        viewCollapser = new ViewCollapser(this);
29
-    }
30
-
31
-    public void setupCollapseDetection(ScrollListener scrollListener, OnScrollViewAddedListener onScrollViewAddedListener) {
32
-        scrollViewDelegate = new ScrollViewDelegate(scrollListener);
33
-        scrollViewDetector = new ScrollViewDetector(this, onScrollViewAddedListener, scrollViewDelegate);
34
-    }
35
-
36
-    @Override
37
-    public boolean dispatchTouchEvent(MotionEvent ev) {
38
-        if (scrollViewDelegate != null && scrollViewDelegate.hasScrollView()) {
39
-            boolean consumed = scrollViewDelegate.didInterceptTouchEvent(ev);
40
-            if (consumed) {
41
-                return true;
42
-            }
43
-        }
44
-        return super.dispatchTouchEvent(ev);
45
-    }
46
-
47
-    @Override
48
-    public void onViewAdded(final View child) {
49
-        super.onViewAdded(child);
50
-        if (scrollViewDetector != null) {
51
-            scrollViewDetector.findScrollView(child);
52
-        }
53
-    }
54
-
55
-    @Override
56
-    public void collapse(CollapseAmount amount) {
57
-        viewCollapser.collapse(amount);
58
-    }
59
-
60
-    public void destroy() {
61
-        if (scrollViewDetector != null) {
62
-            scrollViewDetector.destroy();
63
-        }
64
-        if (scrollViewDelegate != null) {
65
-            scrollViewDelegate.destroy();
66
-        }
67
-    }
68
-
69
-    @Override
70
-    public float getFinalCollapseValue() {
71
-        return ((CollapsingViewMeasurer) viewMeasurer).getFinalCollapseValue();
72
-    }
73
-
74
-    @Override
75
-    public float getCurrentCollapseValue() {
76
-        return getTranslationY();
77
-    }
78
-
79
-    @Override
80
-    public View asView() {
81
-        return this;
82
-    }
83
-}

+ 0
- 78
lib/android/app/deprecated/java/com/reactnativenavigation/views/ContentView.java 查看文件

@@ -1,78 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-import android.content.Context;
4
-import android.view.View;
5
-
6
-import com.facebook.react.ReactRootView;
7
-import com.reactnativenavigation.NavigationApplication;
8
-import com.reactnativenavigation.params.NavigationParams;
9
-import com.reactnativenavigation.screens.SingleScreen;
10
-import com.reactnativenavigation.utils.ViewUtils;
11
-import com.reactnativenavigation.views.utils.ViewMeasurer;
12
-
13
-public class ContentView extends ReactRootView {
14
-    private final String screenId;
15
-    private final NavigationParams navigationParams;
16
-
17
-    boolean isContentVisible = false;
18
-    private SingleScreen.OnDisplayListener onDisplayListener;
19
-    protected ViewMeasurer viewMeasurer;
20
-
21
-    public void setOnDisplayListener(SingleScreen.OnDisplayListener onDisplayListener) {
22
-        this.onDisplayListener = onDisplayListener;
23
-    }
24
-
25
-    public ContentView(Context context, String screenId, NavigationParams navigationParams) {
26
-        super(context);
27
-        this.screenId = screenId;
28
-        this.navigationParams = navigationParams;
29
-        attachToJS();
30
-        viewMeasurer = new ViewMeasurer();
31
-    }
32
-
33
-    public void setViewMeasurer(ViewMeasurer viewMeasurer) {
34
-        this.viewMeasurer = viewMeasurer;
35
-    }
36
-
37
-    private void attachToJS() {
38
-        startReactApplication(NavigationApplication.instance.getReactGateway().getReactInstanceManager(), screenId,
39
-                navigationParams.toBundle());
40
-    }
41
-
42
-    public String getNavigatorEventId() {
43
-        return navigationParams.navigatorEventId;
44
-    }
45
-
46
-    public void unmountReactView() {
47
-        unmountReactApplication();
48
-    }
49
-
50
-    @Override
51
-    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
52
-        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
53
-        int measuredHeight = viewMeasurer.getMeasuredHeight(heightMeasureSpec);
54
-        setMeasuredDimension(viewMeasurer.getMeasuredWidth(widthMeasureSpec),
55
-                measuredHeight);
56
-    }
57
-
58
-    @Override
59
-    public void onViewAdded(final View child) {
60
-        super.onViewAdded(child);
61
-        detectContentViewVisible(child);
62
-    }
63
-
64
-    private void detectContentViewVisible(View child) {
65
-        if (onDisplayListener != null) {
66
-            ViewUtils.runOnPreDraw(child, new Runnable() {
67
-                @Override
68
-                public void run() {
69
-                    if (!isContentVisible) {
70
-                        isContentVisible = true;
71
-                        onDisplayListener.onDisplay();
72
-                        onDisplayListener = null;
73
-                    }
74
-                }
75
-            });
76
-        }
77
-    }
78
-}

+ 0
- 83
lib/android/app/deprecated/java/com/reactnativenavigation/views/ContextualMenu.java 查看文件

@@ -1,83 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-import android.content.Context;
4
-import android.view.Menu;
5
-import android.view.ViewManager;
6
-
7
-import com.facebook.react.bridge.Callback;
8
-import com.reactnativenavigation.NavigationApplication;
9
-import com.reactnativenavigation.events.ContextualMenuHiddenEvent;
10
-import com.reactnativenavigation.events.EventBus;
11
-import com.reactnativenavigation.params.ContextualMenuButtonParams;
12
-import com.reactnativenavigation.params.ContextualMenuParams;
13
-import com.reactnativenavigation.params.StyleParams;
14
-import com.reactnativenavigation.params.TitleBarLeftButtonParams;
15
-
16
-import java.util.List;
17
-
18
-public class ContextualMenu extends TitleBar implements LeftButtonOnClickListener, ContextualMenuButton.ContextualButtonClickListener {
19
-    private ContextualMenuParams params;
20
-    private Callback onButtonClicked;
21
-    private final String navigatorEventId;
22
-
23
-    public ContextualMenu(Context context, ContextualMenuParams params, StyleParams styleParams, Callback onButtonClicked) {
24
-        super(context);
25
-        this.params = params;
26
-        this.onButtonClicked = onButtonClicked;
27
-        navigatorEventId = params.navigationParams.navigatorEventId;
28
-        setStyle(styleParams);
29
-        setButtons();
30
-    }
31
-
32
-    public void setStyle(StyleParams styleParams) {
33
-        params.setButtonsColor(styleParams.contextualMenuButtonsColor);
34
-        if (styleParams.contextualMenuBackgroundColor.hasColor()) {
35
-            setBackgroundColor(styleParams.contextualMenuBackgroundColor.getColor());
36
-        }
37
-    }
38
-
39
-    public void setButtons() {
40
-        addButtonsToContextualMenu(params.buttons, getMenu());
41
-        setBackButton(params.leftButton);
42
-    }
43
-
44
-    private void setBackButton(TitleBarLeftButtonParams leftButton) {
45
-        setLeftButton(leftButton, this, null, false);
46
-    }
47
-
48
-    private void addButtonsToContextualMenu(List<ContextualMenuButtonParams> buttons, Menu menu) {
49
-        for (int i = 0; i < buttons.size(); i++) {
50
-            final TitleBarButton button = new ContextualMenuButton(menu, this, buttons.get(i), this);
51
-            addButtonInReverseOrder(buttons, i, button);
52
-        }
53
-    }
54
-
55
-    @Override
56
-    public boolean onTitleBarBackButtonClick() {
57
-        dismiss();
58
-        EventBus.instance.post(new ContextualMenuHiddenEvent());
59
-        return true;
60
-    }
61
-
62
-    @Override
63
-    public void onSideMenuButtonClick() {
64
-        // nothing
65
-    }
66
-
67
-    @Override
68
-    public void onClick(int index) {
69
-        dismiss();
70
-        EventBus.instance.post(new ContextualMenuHiddenEvent());
71
-        onButtonClicked.invoke(index);
72
-    }
73
-
74
-    public void dismiss() {
75
-        hide(new Runnable() {
76
-            @Override
77
-            public void run() {
78
-                ((ViewManager) getParent()).removeView(ContextualMenu.this);
79
-            }
80
-        });
81
-        NavigationApplication.instance.getEventEmitter().sendNavigatorEvent("contextualMenuDismissed", navigatorEventId);
82
-    }
83
-}

+ 0
- 28
lib/android/app/deprecated/java/com/reactnativenavigation/views/ContextualMenuButton.java 查看文件

@@ -1,28 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-import android.view.Menu;
4
-import android.view.MenuItem;
5
-import android.view.View;
6
-
7
-import com.reactnativenavigation.params.ContextualMenuButtonParams;
8
-
9
-class ContextualMenuButton extends TitleBarButton {
10
-    private ContextualMenuButtonParams contextualMenuButtonParams;
11
-    private ContextualButtonClickListener contextualButtonClickListener;
12
-
13
-    interface ContextualButtonClickListener {
14
-        void onClick(int index);
15
-    }
16
-
17
-    ContextualMenuButton(Menu menu, View parent, ContextualMenuButtonParams contextualMenuButtonParams, ContextualButtonClickListener contextualButtonClickListener) {
18
-        super(menu, parent, contextualMenuButtonParams, null);
19
-        this.contextualMenuButtonParams = contextualMenuButtonParams;
20
-        this.contextualButtonClickListener = contextualButtonClickListener;
21
-    }
22
-
23
-    @Override
24
-    public boolean onMenuItemClick(MenuItem item) {
25
-        contextualButtonClickListener.onClick(contextualMenuButtonParams.index);
26
-        return true;
27
-    }
28
-}

+ 0
- 120
lib/android/app/deprecated/java/com/reactnativenavigation/views/FloatingActionButtonAnimator.java 查看文件

@@ -1,120 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-import android.animation.Animator;
4
-import android.animation.AnimatorListenerAdapter;
5
-import android.support.design.widget.FloatingActionButton;
6
-import android.view.View;
7
-
8
-import java.util.List;
9
-
10
-public class FloatingActionButtonAnimator {
11
-
12
-    private final FloatingActionButton collapsedFab;
13
-    private final FloatingActionButton expendedFab;
14
-    private int crossFadeAnimationDuration;
15
-
16
-    private enum State{Showing, Idle, Removing}
17
-    private State state = State.Idle;
18
-
19
-    public FloatingActionButtonAnimator(FloatingActionButton collapsedFab, FloatingActionButton expendedFab, int crossFadeAnimationDuration) {
20
-        this.collapsedFab = collapsedFab;
21
-        this.expendedFab = expendedFab;
22
-        this.crossFadeAnimationDuration = crossFadeAnimationDuration;
23
-    }
24
-
25
-    boolean isAnimating() {
26
-        return state == State.Showing || state == State.Removing;
27
-    }
28
-
29
-    void show() {
30
-        state = State.Showing;
31
-        collapsedFab.setScaleX(0);
32
-        collapsedFab.setScaleY(0);
33
-        collapsedFab.animate()
34
-                .alpha(1)
35
-                .scaleX(1)
36
-                .scaleY(1)
37
-                .setListener(new AnimatorListenerAdapter() {
38
-                    @Override
39
-                    public void onAnimationEnd(Animator animation) {
40
-                        state = State.Idle;
41
-                    }
42
-                })
43
-                .setDuration(crossFadeAnimationDuration)
44
-                .start();
45
-    }
46
-
47
-    public void collapse() {
48
-        hideExpended();
49
-        showCollapsed();
50
-    }
51
-
52
-    void hideCollapsed() {
53
-        animateFab(collapsedFab, 0, 90);
54
-    }
55
-
56
-    void showExpended() {
57
-        animateFab(expendedFab, 1, 0);
58
-    }
59
-
60
-    void showCollapsed() {
61
-        animateFab(collapsedFab, 1, 0);
62
-    }
63
-
64
-    void hideExpended() {
65
-        animateFab(expendedFab, 0, -90);
66
-    }
67
-
68
-    private void animateFab(final FloatingActionButton fab, final int alpha, int rotation) {
69
-        fab.animate()
70
-                .alpha(alpha)
71
-                .setDuration(crossFadeAnimationDuration)
72
-                .rotation(rotation)
73
-                .setListener(new AnimatorListenerAdapter() {
74
-                    @Override
75
-                    public void onAnimationStart(Animator animation) {
76
-                        if (fab.getVisibility() == View.GONE) {
77
-                            fab.setVisibility(View.VISIBLE);
78
-                        }
79
-                    }
80
-
81
-                    @Override
82
-                    public void onAnimationEnd(Animator animation) {
83
-                        fab.setVisibility(alpha == 0 ? View.GONE : View.VISIBLE);
84
-                    }
85
-                })
86
-                .start();
87
-    }
88
-
89
-    void removeFabFromScreen(FloatingActionButton fab, final AnimatorListenerAdapter animationListener) {
90
-        if (fab == null) {
91
-            return;
92
-        }
93
-        state = State.Removing;
94
-        fab.animate()
95
-                .alpha(0)
96
-                .scaleX(0)
97
-                .scaleY(0)
98
-                .setDuration(crossFadeAnimationDuration)
99
-                .setListener(new AnimatorListenerAdapter() {
100
-                    @Override
101
-                    public void onAnimationEnd(Animator animation) {
102
-                        if (animationListener != null) {
103
-                            animationListener.onAnimationEnd(animation);
104
-                        }
105
-                    }
106
-                })
107
-                .start();
108
-    }
109
-
110
-    void removeActionsFromScreen(List<FloatingActionButton> actions) {
111
-        for (FloatingActionButton action : actions) {
112
-            action.animate()
113
-                    .alpha(0)
114
-                    .scaleX(0)
115
-                    .scaleY(0)
116
-                    .setDuration(crossFadeAnimationDuration)
117
-                    .start();
118
-        }
119
-    }
120
-}

+ 0
- 237
lib/android/app/deprecated/java/com/reactnativenavigation/views/FloatingActionButtonCoordinator.java 查看文件

@@ -1,237 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-import android.animation.Animator;
4
-import android.animation.AnimatorListenerAdapter;
5
-import android.content.res.ColorStateList;
6
-import android.graphics.drawable.Drawable;
7
-import android.os.Build;
8
-import android.support.annotation.FloatRange;
9
-import android.support.annotation.NonNull;
10
-import android.support.annotation.Nullable;
11
-import android.support.design.widget.CoordinatorLayout;
12
-import android.support.design.widget.FloatingActionButton;
13
-import android.util.Log;
14
-import android.view.Gravity;
15
-import android.view.View;
16
-
17
-import com.reactnativenavigation.NavigationApplication;
18
-import com.reactnativenavigation.params.FabActionParams;
19
-import com.reactnativenavigation.params.FabParams;
20
-import com.reactnativenavigation.utils.ViewUtils;
21
-
22
-import java.util.ArrayList;
23
-
24
-import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
25
-
26
-public class FloatingActionButtonCoordinator {
27
-    private static final String TAG = "FloatingActionButtonCoo";
28
-    private static final int INITIAL_EXPENDED_FAB_ROTATION = -90;
29
-    private CoordinatorLayout parent;
30
-    private FabParams params;
31
-    private FloatingActionButton collapsedFab;
32
-    private FloatingActionButton expendedFab;
33
-    private final int crossFadeAnimationDuration;
34
-    private final int actionSize;
35
-    final int margin = (int) ViewUtils.convertDpToPixel(16);
36
-    FloatingActionButtonAnimator fabAnimator;
37
-    private final ArrayList<FloatingActionButton> actions;
38
-
39
-    public FloatingActionButtonCoordinator(CoordinatorLayout parent) {
40
-        this.parent = parent;
41
-        actions = new ArrayList<>();
42
-        crossFadeAnimationDuration = parent.getResources().getInteger(android.R.integer.config_shortAnimTime);
43
-        actionSize = (int) ViewUtils.convertDpToPixel(40);
44
-    }
45
-
46
-    public void add(final FabParams params) {
47
-        Log.i(TAG, "add() called with: params = [" + params + "]");
48
-        if (parent.getChildCount() > 0) {
49
-            remove(new Runnable() {
50
-                @Override
51
-                public void run() {
52
-                    add(params);
53
-                }
54
-            });
55
-            return;
56
-        }
57
-
58
-        this.params = params;
59
-        if (!params.isValid()) {
60
-            return;
61
-        }
62
-        createCollapsedFab();
63
-        createExpendedFab();
64
-        setStyle();
65
-        fabAnimator = new FloatingActionButtonAnimator(collapsedFab, expendedFab, crossFadeAnimationDuration);
66
-        fabAnimator.show();
67
-    }
68
-
69
-    public void remove(@Nullable final Runnable onComplete) {
70
-        Log.w(TAG, "remove: ");
71
-        if (parent.getChildCount() == 0) {
72
-            if (onComplete != null) {
73
-                onComplete.run();
74
-            }
75
-            return;
76
-        }
77
-
78
-        fabAnimator.removeFabFromScreen(expendedFab, new AnimatorListenerAdapter() {
79
-            @Override
80
-            public void onAnimationEnd(Animator animation) {
81
-                removeAllViews();
82
-                if (onComplete != null) {
83
-                    onComplete.run();
84
-                }
85
-            }
86
-        });
87
-        fabAnimator.removeFabFromScreen(collapsedFab, null);
88
-        fabAnimator.removeActionsFromScreen(actions);
89
-    }
90
-
91
-    private void removeAllViews() {
92
-        parent.removeView(collapsedFab);
93
-        parent.removeView(expendedFab);
94
-        collapsedFab = null;
95
-        expendedFab = null;
96
-        for (FloatingActionButton action : actions) {
97
-            parent.removeView(action);
98
-        }
99
-        actions.clear();
100
-    }
101
-
102
-    private void createCollapsedFab() {
103
-        collapsedFab = createFab(params.collapsedIcon);
104
-        parent.addView(collapsedFab, createFabLayoutParams());
105
-        collapsedFab.setOnClickListener(new View.OnClickListener() {
106
-            @Override
107
-            public void onClick(View v) {
108
-                if (params.hasExpendedState()) {
109
-                    fabAnimator.hideCollapsed();
110
-                    fabAnimator.showExpended();
111
-                    showActions();
112
-                }
113
-                NavigationApplication.instance.getEventEmitter().sendNavigatorEvent(params.collapsedId, params.navigatorEventId);
114
-            }
115
-        });
116
-    }
117
-
118
-    private void createExpendedFab() {
119
-        expendedFab = createFab(params.expendedIcon);
120
-        parent.addView(expendedFab, createFabLayoutParams());
121
-        expendedFab.setVisibility(View.GONE);
122
-        expendedFab.setRotation(INITIAL_EXPENDED_FAB_ROTATION);
123
-        expendedFab.setOnClickListener(new View.OnClickListener() {
124
-            @Override
125
-            public void onClick(View v) {
126
-                fabAnimator.collapse();
127
-                NavigationApplication.instance.getEventEmitter().sendNavigatorEvent(params.expendedId, params.navigatorEventId);
128
-            }
129
-        });
130
-    }
131
-
132
-    private FloatingActionButton createFab(Drawable icon) {
133
-        FloatingActionButton fab = new FloatingActionButton(parent.getContext());
134
-        fab.setId(ViewUtils.generateViewId());
135
-        fab.setImageDrawable(icon);
136
-        return fab;
137
-    }
138
-
139
-    private CoordinatorLayout.LayoutParams createFabLayoutParams() {
140
-        final CoordinatorLayout.LayoutParams lp = new CoordinatorLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
141
-        lp.gravity = Gravity.RIGHT | Gravity.BOTTOM;
142
-        lp.bottomMargin = margin;
143
-        lp.rightMargin = margin;
144
-        lp.topMargin = margin;
145
-        return lp;
146
-    }
147
-
148
-    private void setStyle() {
149
-        collapsedFab.setBackgroundTintList(ColorStateList.valueOf(params.backgroundColor.getColor()));
150
-        expendedFab.setBackgroundTintList(ColorStateList.valueOf(params.backgroundColor.getColor()));
151
-    }
152
-
153
-    private void showActions() {
154
-        if (actions.size() > 0) {
155
-            return;
156
-        }
157
-
158
-        for (int i = 0; i < params.actions.size(); i++) {
159
-            FloatingActionButton action = createAction(i);
160
-            actions.add(action);
161
-            parent.addView(action);
162
-        }
163
-    }
164
-
165
-    private FloatingActionButton createAction(int index) {
166
-        final FabActionParams actionParams = params.actions.get(index);
167
-        FloatingActionButton action = createFab(actionParams.icon);
168
-        action.setLayoutParams(createActionLayoutParams(index));
169
-        action.setOnClickListener(new View.OnClickListener() {
170
-            @Override
171
-            public void onClick(View v) {
172
-                NavigationApplication.instance.getEventEmitter().sendNavigatorEvent(actionParams.id, actionParams.navigatorEventId);
173
-                fabAnimator.collapse();
174
-            }
175
-        });
176
-        if (actionParams.backgroundColor.hasColor()) {
177
-            action.setBackgroundTintList(ColorStateList.valueOf(actionParams.backgroundColor.getColor()));
178
-        }
179
-        action.setSize(FloatingActionButton.SIZE_MINI);
180
-        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
181
-            action.setCompatElevation(0);
182
-        }
183
-        return action;
184
-    }
185
-
186
-    @NonNull
187
-    private CoordinatorLayout.LayoutParams createActionLayoutParams(int actionIndex) {
188
-        CoordinatorLayout.LayoutParams lp = new CoordinatorLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
189
-        lp.setAnchorId(expendedFab.getId());
190
-        lp.anchorGravity = Gravity.CENTER_HORIZONTAL;
191
-        lp.setBehavior(new ActionBehaviour(expendedFab, (actionIndex + 1) * (actionSize + margin / 2)));
192
-        return lp;
193
-    }
194
-
195
-    public static class ActionBehaviour extends CoordinatorLayout.Behavior<FloatingActionButton> {
196
-        private final int MAX_VALUE = 90;
197
-        private int dependencyId;
198
-        private float yStep;
199
-
200
-        public ActionBehaviour(View anchor, float yStep) {
201
-            this.yStep = yStep;
202
-            this.dependencyId = anchor.getId();
203
-        }
204
-
205
-        @Override
206
-        public boolean layoutDependsOn(CoordinatorLayout parent, FloatingActionButton child, View dependency) {
207
-            return dependency.getId() == dependencyId;
208
-        }
209
-
210
-        @Override
211
-        public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency) {
212
-            final float dependentValue = dependency.getRotation();
213
-            float fraction = calculateTransitionFraction(dependentValue);
214
-            child.setY(calculateY(parent, fraction));
215
-            child.setAlpha(calculateAlpha(fraction));
216
-            setVisibility(child);
217
-            return true;
218
-        }
219
-
220
-        private void setVisibility(FloatingActionButton child) {
221
-            child.setVisibility(child.getAlpha() == 0 ? View.GONE : View.VISIBLE);
222
-        }
223
-
224
-        private float calculateAlpha(float fraction) {
225
-            return 1 * fraction;
226
-        }
227
-
228
-        private float calculateY(CoordinatorLayout parent, float fraction) {
229
-            return parent.findViewById(dependencyId).getY() - yStep * fraction;
230
-        }
231
-
232
-        @FloatRange(from=0.0, to=1.0)
233
-        private float calculateTransitionFraction(float dependentValue) {
234
-            return 1 - Math.abs(dependentValue / MAX_VALUE);
235
-        }
236
-    }
237
-}

+ 0
- 84
lib/android/app/deprecated/java/com/reactnativenavigation/views/LeftButton.java 查看文件

@@ -1,84 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-import android.content.Context;
4
-import android.graphics.Color;
5
-import android.view.View;
6
-
7
-import com.balysv.materialmenu.MaterialMenuDrawable;
8
-import com.reactnativenavigation.NavigationApplication;
9
-import com.reactnativenavigation.params.TitleBarButtonParams;
10
-import com.reactnativenavigation.params.TitleBarLeftButtonParams;
11
-
12
-class LeftButton extends MaterialMenuDrawable implements View.OnClickListener {
13
-
14
-    private static int getColor(TitleBarButtonParams params) {
15
-        return params != null && params.color.hasColor() ?
16
-                params.color.getColor() :
17
-                Color.BLACK;
18
-    }
19
-
20
-    private TitleBarLeftButtonParams params;
21
-    private final LeftButtonOnClickListener onClickListener;
22
-    private final String navigatorEventId;
23
-    private final boolean overrideBackPressInJs;
24
-
25
-    LeftButton(Context context,
26
-               TitleBarLeftButtonParams params,
27
-               LeftButtonOnClickListener onClickListener,
28
-               String navigatorEventId,
29
-               boolean overrideBackPressInJs) {
30
-        super(context, getColor(params), Stroke.THIN);
31
-        this.params = params;
32
-        this.onClickListener = onClickListener;
33
-        this.navigatorEventId = navigatorEventId;
34
-        this.overrideBackPressInJs = overrideBackPressInJs;
35
-        setInitialState();
36
-    }
37
-
38
-    void setIconState(TitleBarLeftButtonParams params) {
39
-        this.params = params;
40
-        if (params.color.hasColor()) {
41
-            setColor(params.color.getColor());
42
-        }
43
-        animateIconState(params.iconState);
44
-    }
45
-
46
-    @Override
47
-    public void onClick(View v) {
48
-        if (isBackButton()) {
49
-            handleBackButtonClick();
50
-        } else if (isSideMenuButton()) {
51
-            onClickListener.onSideMenuButtonClick();
52
-        } else {
53
-            sendClickEvent();
54
-        }
55
-    }
56
-
57
-    private void handleBackButtonClick() {
58
-        if (overrideBackPressInJs) {
59
-            NavigationApplication.instance.getEventEmitter().sendNavigatorEvent("backPress", navigatorEventId);
60
-        } else {
61
-            onClickListener.onTitleBarBackButtonClick();
62
-        }
63
-    }
64
-
65
-    private void setInitialState() {
66
-        if (params != null) {
67
-            setIconState(params.iconState);
68
-        } else {
69
-            setVisible(false);
70
-        }
71
-    }
72
-
73
-    private boolean isBackButton() {
74
-        return getIconState() == IconState.ARROW;
75
-    }
76
-
77
-    private boolean isSideMenuButton() {
78
-        return getIconState() == IconState.BURGER;
79
-    }
80
-
81
-    private void sendClickEvent() {
82
-        NavigationApplication.instance.getEventEmitter().sendNavigatorEvent(params.eventId, navigatorEventId);
83
-    }
84
-}

+ 0
- 7
lib/android/app/deprecated/java/com/reactnativenavigation/views/LeftButtonOnClickListener.java 查看文件

@@ -1,7 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-public interface LeftButtonOnClickListener {
4
-    boolean onTitleBarBackButtonClick();
5
-
6
-    void onSideMenuButtonClick();
7
-}

+ 0
- 61
lib/android/app/deprecated/java/com/reactnativenavigation/views/Scrim.java 查看文件

@@ -1,61 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-import android.content.Context;
4
-import android.view.View;
5
-import android.view.animation.DecelerateInterpolator;
6
-import android.view.animation.Interpolator;
7
-
8
-import com.reactnativenavigation.params.StyleParams;
9
-
10
-import static com.reactnativenavigation.views.Scrim.State.Invisible;
11
-import static com.reactnativenavigation.views.Scrim.State.Visible;
12
-
13
-public class Scrim extends View {
14
-    enum State {Visible, Invisible}
15
-
16
-    private State state = Invisible;
17
-    private final float collapseThreshold;
18
-    private final static int ANIMATION_DURATION = 600;
19
-    private final Interpolator interpolator;
20
-
21
-    public Scrim(Context context, StyleParams.Color color, float collapseThreshold) {
22
-        super(context);
23
-        this.collapseThreshold = collapseThreshold;
24
-        setBackgroundColor(color.getColor());
25
-        setAlpha(0);
26
-        interpolator = new DecelerateInterpolator();
27
-    }
28
-
29
-    public void collapse(float collapse) {
30
-        if (shouldShowScrim(collapse)) {
31
-            showScrim();
32
-        } else if (shouldHideScrim(collapse)) {
33
-            hideScrim();
34
-        }
35
-
36
-    }
37
-
38
-    private boolean shouldShowScrim(float collapse) {
39
-        return Math.abs(collapse) >= collapseThreshold && state == Invisible;
40
-    }
41
-
42
-    private boolean shouldHideScrim(float collapse) {
43
-        return Math.abs(collapse) < collapseThreshold && state == Visible;
44
-    }
45
-
46
-    private void showScrim() {
47
-        state = Visible;
48
-        animate()
49
-                .alpha(1)
50
-                .setDuration(ANIMATION_DURATION)
51
-                .setInterpolator(interpolator);
52
-    }
53
-
54
-    private void hideScrim() {
55
-        state = Invisible;
56
-        animate()
57
-                .alpha(0)
58
-                .setDuration(ANIMATION_DURATION)
59
-                .setInterpolator(interpolator);
60
-    }
61
-}

+ 0
- 53
lib/android/app/deprecated/java/com/reactnativenavigation/views/ScrollDirectionListener.java 查看文件

@@ -1,53 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-import android.view.ViewGroup;
4
-import android.view.ViewTreeObserver;
5
-
6
-public class ScrollDirectionListener implements ViewTreeObserver.OnScrollChangedListener {
7
-    public enum Direction {
8
-        Up, Down
9
-    }
10
-
11
-    public interface OnScrollChanged {
12
-        void onScrollChanged(Direction direction);
13
-    }
14
-
15
-    private final ViewGroup view;
16
-    private OnScrollChanged onChanged;
17
-    private int lastScrollY = -1;
18
-
19
-    public ScrollDirectionListener(ViewGroup view, OnScrollChanged onChanged) {
20
-        this.view = view;
21
-        this.onChanged = onChanged;
22
-    }
23
-
24
-    @Override
25
-    public void onScrollChanged() {
26
-        if (!view.getViewTreeObserver().isAlive()) {
27
-            return;
28
-        }
29
-
30
-        final int scrollY = view.getScrollY();
31
-        if (isScrollPositionChanged(scrollY) && !isTopOverscroll(scrollY) && !isBottomOverscroll(scrollY)) {
32
-            onChanged.onScrollChanged(getScrollDirection(scrollY));
33
-            lastScrollY = scrollY;
34
-        }
35
-    }
36
-
37
-    private Direction getScrollDirection(int scrollY) {
38
-        return scrollY > lastScrollY ? Direction.Down : Direction.Up;
39
-    }
40
-
41
-    private boolean isBottomOverscroll(int scrollY) {
42
-        return scrollY >= (view.getChildAt(0).getHeight() - view.getHeight());
43
-    }
44
-
45
-    private boolean isTopOverscroll(int scrollY) {
46
-        return scrollY <= 0;
47
-    }
48
-
49
-    private boolean isScrollPositionChanged(int scrollY) {
50
-        return scrollY != lastScrollY;
51
-    }
52
-
53
-}

+ 0
- 127
lib/android/app/deprecated/java/com/reactnativenavigation/views/SideMenu.java 查看文件

@@ -1,127 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-import android.content.Context;
4
-import android.support.annotation.Nullable;
5
-import android.support.v4.widget.DrawerLayout;
6
-import android.view.Gravity;
7
-import android.view.ViewGroup;
8
-import android.widget.RelativeLayout;
9
-
10
-import com.reactnativenavigation.params.SideMenuParams;
11
-import com.reactnativenavigation.screens.Screen;
12
-import com.reactnativenavigation.utils.ViewUtils;
13
-
14
-public class SideMenu extends DrawerLayout {
15
-    public enum Side {
16
-        Left(Gravity.LEFT), Right(Gravity.RIGHT);
17
-
18
-        int gravity;
19
-
20
-        Side(int gravity) {
21
-            this.gravity = gravity;
22
-        }
23
-
24
-        public static Side fromString(String side) {
25
-            return "left".equals(side.toLowerCase()) ? Left : Right;
26
-        }
27
-    }
28
-
29
-    private ContentView leftSideMenuView;
30
-    private ContentView rightSideMenuView;
31
-    private RelativeLayout contentContainer;
32
-
33
-    public RelativeLayout getContentContainer() {
34
-        return contentContainer;
35
-    }
36
-
37
-    public void destroy() {
38
-        destroySideMenu(leftSideMenuView);
39
-        destroySideMenu(rightSideMenuView);
40
-    }
41
-
42
-    private void destroySideMenu(ContentView sideMenuView) {
43
-        if (sideMenuView == null) {
44
-            return;
45
-        }
46
-        sideMenuView.unmountReactView();
47
-        removeView(sideMenuView);
48
-    }
49
-
50
-    public void setVisible(boolean visible, boolean animated, Side side) {
51
-        if (!isShown() && visible) {
52
-            openDrawer(animated, side);
53
-        }
54
-
55
-        if (isShown() && !visible) {
56
-            closeDrawer(animated, side);
57
-        }
58
-    }
59
-
60
-    public void openDrawer(Side side) {
61
-        openDrawer(side.gravity);
62
-    }
63
-
64
-    public void openDrawer(boolean animated, Side side) {
65
-        openDrawer(side.gravity, animated);
66
-    }
67
-
68
-    public void toggleVisible(boolean animated, Side side) {
69
-        if (isDrawerOpen(side.gravity)) {
70
-            closeDrawer(animated, side);
71
-        } else {
72
-            openDrawer(animated, side);
73
-        }
74
-    }
75
-
76
-    public void closeDrawer(boolean animated, Side side) {
77
-        closeDrawer(side.gravity, animated);
78
-    }
79
-
80
-    public SideMenu(Context context, SideMenuParams leftMenuParams, SideMenuParams rightMenuParams) {
81
-        super(context);
82
-        createContentContainer();
83
-        leftSideMenuView = createSideMenu(leftMenuParams);
84
-        rightSideMenuView = createSideMenu(rightMenuParams);
85
-        setStyle(leftMenuParams);
86
-        setStyle(rightMenuParams);
87
-    }
88
-
89
-    private void createContentContainer() {
90
-        LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
91
-        contentContainer = new RelativeLayout(getContext());
92
-        contentContainer.setId(ViewUtils.generateViewId());
93
-        addView(contentContainer, lp);
94
-    }
95
-
96
-    private ContentView createSideMenu(@Nullable SideMenuParams params) {
97
-        if (params == null) {
98
-            return null;
99
-        }
100
-        ContentView sideMenuView = new ContentView(getContext(), params.screenId, params.navigationParams);
101
-        LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
102
-        lp.gravity = params.side.gravity;
103
-        setSideMenuWidth(sideMenuView);
104
-        addView(sideMenuView, lp);
105
-        return sideMenuView;
106
-    }
107
-
108
-    private void setSideMenuWidth(final ContentView sideMenuView) {
109
-        sideMenuView.setOnDisplayListener(new Screen.OnDisplayListener() {
110
-            @Override
111
-            public void onDisplay() {
112
-                ViewGroup.LayoutParams lp = sideMenuView.getLayoutParams();
113
-                lp.width = sideMenuView.getChildAt(0).getWidth();
114
-                sideMenuView.setLayoutParams(lp);
115
-            }
116
-        });
117
-    }
118
-
119
-    private void setStyle(SideMenuParams params) {
120
-        if (params == null) {
121
-            return;
122
-        }
123
-        if (params.disableOpenGesture) {
124
-            setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, params.side.gravity);
125
-        }
126
-    }
127
-}

+ 0
- 0
lib/android/app/deprecated/java/com/reactnativenavigation/views/SnackbarAndFabContainer.java 查看文件


部分文件因为文件数量过多而无法显示