Guy Carmeli 8 years ago
parent
commit
94519d37ba

+ 39
- 5
android/app/src/main/java/com/reactnativenavigation/layouts/ScreenLayout.java View File

@@ -1,17 +1,51 @@
1 1
 package com.reactnativenavigation.layouts;
2 2
 
3 3
 import android.content.Context;
4
+import android.os.Bundle;
4 5
 import android.widget.LinearLayout;
5 6
 
6
-public class ScreenLayout extends LinearLayout {
7
+import com.facebook.react.ReactInstanceManager;
8
+import com.reactnativenavigation.views.ContentView;
9
+import com.reactnativenavigation.views.ScrollDirectionListener;
7 10
 
8
-    public static class Params {
11
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
12
+import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
9 13
 
10
-    }
14
+public class ScreenLayout extends LinearLayout implements ScrollDirectionListener.OnScrollChanged {
15
+
16
+    private final ReactInstanceManager reactInstanceManager;
17
+    private final String moduleName;
18
+    private final Bundle passProps;
19
+    private ContentView contentView;
20
+    private TopBar topBar;
11 21
 
12
-    public ScreenLayout(Context context, Params params) {
22
+    public ScreenLayout(Context context, ReactInstanceManager reactInstanceManager, String moduleName, Bundle passProps) {
13 23
         super(context);
24
+        this.reactInstanceManager = reactInstanceManager;
25
+        this.moduleName = moduleName;
26
+        this.passProps = passProps;
14 27
         setOrientation(VERTICAL);
15
-        addView();
28
+
29
+        createViews();
30
+    }
31
+
32
+    private void createViews() {
33
+        addTopBar();
34
+        addContentView();
35
+    }
36
+
37
+    private void addTopBar() {
38
+        topBar = new TopBar(getContext());
39
+        addView(topBar, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
40
+    }
41
+
42
+    private void addContentView() {
43
+        contentView = new ContentView(getContext(), reactInstanceManager, moduleName, passProps, this);
44
+        addView(contentView, new LayoutParams(MATCH_PARENT, MATCH_PARENT));
45
+    }
46
+
47
+    @Override
48
+    public void onScrollChanged(ScrollDirectionListener.Direction direction) {
49
+
16 50
     }
17 51
 }

+ 0
- 22
android/app/src/main/java/com/reactnativenavigation/layouts/SomethingLayout.java View File

@@ -1,22 +0,0 @@
1
-package com.reactnativenavigation.layouts;
2
-
3
-import android.content.Context;
4
-
5
-import com.reactnativenavigation.core.objects.Screen;
6
-
7
-public class SomethingLayout extends BaseLayout {
8
-
9
-    public SomethingLayout(Context context, Screen initialScreen) {
10
-        super(context, initialScreen);
11
-    }
12
-
13
-    @Override
14
-    public boolean onBackPressed() {
15
-        return false;
16
-    }
17
-
18
-    @Override
19
-    public void onDestroy() {
20
-
21
-    }
22
-}

+ 12
- 0
android/app/src/main/java/com/reactnativenavigation/layouts/TopBar.java View File

@@ -0,0 +1,12 @@
1
+package com.reactnativenavigation.layouts;
2
+
3
+import android.content.Context;
4
+import android.support.design.widget.AppBarLayout;
5
+
6
+public class TopBar extends AppBarLayout {
7
+
8
+    public TopBar(Context context) {
9
+        super(context);
10
+        setFitsSystemWindows(true);
11
+    }
12
+}