Browse Source

try to make scroll anim work

Daniel Zlotin 8 years ago
parent
commit
37f59a9d03

+ 3
- 0
android/app/build.gradle View File

@@ -50,4 +50,7 @@ dependencies {
50 50
     compile "com.android.support:appcompat-v7:23.0.1"
51 51
     compile 'com.android.support:design:23.1.1'
52 52
     compile "com.facebook.react:react-native:+"  // From node_modules
53
+
54
+    testCompile "junit:junit:4.12"
55
+    testCompile "org.robolectric:robolectric:3.1.1"
53 56
 }

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/animation/HideOnScrollAnimator.java View File

@@ -33,7 +33,7 @@ public class HideOnScrollAnimator {
33 33
 
34 34
     public void onScrollChanged(ScrollDirectionListener.Direction scrollDirection) {
35 35
         if (hideDirection == HideDirection.Down) {
36
-            handleDownHidingViews(scrollDirection); //TODO better name
36
+            handleDownHidingViews(scrollDirection);
37 37
         } else {
38 38
             handleUpHidingViews(scrollDirection);
39 39
         }

+ 8
- 1
android/app/src/main/java/com/reactnativenavigation/layouts/ScreenImpl.java View File

@@ -5,10 +5,12 @@ import android.app.Activity;
5 5
 import android.content.Context;
6 6
 import android.graphics.Color;
7 7
 import android.os.Build;
8
+import android.util.Log;
8 9
 import android.view.View;
9 10
 import android.view.Window;
10 11
 import android.widget.LinearLayout;
11 12
 
13
+import com.reactnativenavigation.animation.HideOnScrollAnimator;
12 14
 import com.reactnativenavigation.params.ScreenParams;
13 15
 import com.reactnativenavigation.params.ScreenStyleParams;
14 16
 import com.reactnativenavigation.utils.SdkSupports;
@@ -24,6 +26,7 @@ public class ScreenImpl extends LinearLayout implements Screen, ScrollDirectionL
24 26
     private final ScreenParams screenParams;
25 27
     private ContentView contentView;
26 28
     private TopBar topBar;
29
+    private HideOnScrollAnimator scrollAnimator;
27 30
 
28 31
     public ScreenImpl(Context context, ScreenParams screenParams) {
29 32
         super(context);
@@ -102,7 +105,11 @@ public class ScreenImpl extends LinearLayout implements Screen, ScrollDirectionL
102 105
 
103 106
     @Override
104 107
     public void onScrollChanged(ScrollDirectionListener.Direction direction) {
105
-        // TODO handle if needed
108
+        Log.d("TAG", "onScrollChanged: ");
109
+        if (scrollAnimator == null) {
110
+            scrollAnimator = new HideOnScrollAnimator(topBar, HideOnScrollAnimator.HideDirection.Up, topBar.getHeight());
111
+        }
112
+        scrollAnimator.onScrollChanged(direction);
106 113
     }
107 114
 
108 115
     @Override

+ 2
- 0
android/app/src/main/java/com/reactnativenavigation/views/ScrollViewAttacher.java View File

@@ -1,5 +1,6 @@
1 1
 package com.reactnativenavigation.views;
2 2
 
3
+import android.util.Log;
3 4
 import android.view.View;
4 5
 import android.view.ViewGroup;
5 6
 import android.widget.ScrollView;
@@ -38,6 +39,7 @@ public class ScrollViewAttacher implements View.OnAttachStateChangeListener {
38 39
 
39 40
     private void findScrollAndStartListening() {
40 41
         scrollView = findScrollView(view);
42
+        Log.d("LOG", "ScrollViewAttacher.findScrollAndStartListening " + scrollView);
41 43
         if (scrollView != null) {
42 44
             scrollDirectionListener = new ScrollDirectionListener(scrollView, onChanged);
43 45
             scrollView.getViewTreeObserver().addOnScrollChangedListener(scrollDirectionListener);

+ 1
- 1
example-redux/src/app.js View File

@@ -37,7 +37,7 @@ export default class App {
37 37
       case 'login':
38 38
         Navigation.startSingleScreenApp({
39 39
           screen: {
40
-            screen: 'example.FirstTabScreen',
40
+            screen: 'example.ListScreen',
41 41
             title: 'Login',
42 42
             navigatorStyle: {}
43 43
           },