-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathComponentLayout.java
More file actions
112 lines (88 loc) · 3.26 KB
/
ComponentLayout.java
File metadata and controls
112 lines (88 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package com.reactnativenavigation.views.component;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.MotionEvent;
import android.view.ViewGroup;
import android.view.WindowInsets;
import com.reactnativenavigation.options.ButtonOptions;
import com.reactnativenavigation.viewcontrollers.viewcontroller.ScrollEventListener;
import com.reactnativenavigation.options.Options;
import com.reactnativenavigation.options.params.Bool;
import com.reactnativenavigation.react.ReactView;
import com.reactnativenavigation.react.events.ComponentType;
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonController;
import com.reactnativenavigation.views.touch.OverlayTouchDelegate;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import static com.reactnativenavigation.utils.CoordinatorLayoutUtils.matchParentLP;
@SuppressLint("ViewConstructor")
public class ComponentLayout extends CoordinatorLayout implements ReactComponent, ButtonController.OnClickListener {
private boolean willAppearSent = false;
private ReactView reactView;
private final OverlayTouchDelegate touchDelegate;
public ComponentLayout(Context context, ReactView reactView) {
super(context);
this.reactView = reactView;
addView(reactView.asView(), matchParentLP());
touchDelegate = new OverlayTouchDelegate(this, reactView);
}
@Override
public boolean isReady() {
return reactView.isReady();
}
@Override
public ViewGroup asView() {
return this;
}
@Override
public void destroy() {
reactView.destroy();
}
public void start() {
reactView.start();
}
public void sendComponentWillStart() {
if (!willAppearSent)
reactView.sendComponentWillStart(ComponentType.Component);
willAppearSent = true;
}
public void sendComponentStart() {
reactView.sendComponentStart(ComponentType.Component);
}
public void sendComponentStop() {
willAppearSent = false;
reactView.sendComponentStop(ComponentType.Component);
}
public void applyOptions(Options options) {
touchDelegate.setInterceptTouchOutside(options.overlayOptions.interceptTouchOutside);
}
public void setInterceptTouchOutside(Bool interceptTouchOutside) {
touchDelegate.setInterceptTouchOutside(interceptTouchOutside);
}
@Override
public void sendOnNavigationButtonPressed(String buttonId) {
reactView.sendOnNavigationButtonPressed(buttonId);
}
@Override
public ScrollEventListener getScrollEventListener() {
return reactView.getScrollEventListener();
}
@Override
public void dispatchTouchEventToJs(MotionEvent event) {
reactView.dispatchTouchEventToJs(event);
}
@Override
public boolean isRendered() {
return reactView.isRendered();
}
@Override
public void onPress(ButtonOptions button) {
reactView.sendOnNavigationButtonPressed(button.id);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return touchDelegate.onInterceptTouchEvent(ev);
}
public boolean superOnInterceptTouchEvent(MotionEvent event) {
return super.onInterceptTouchEvent(event);
}
}