-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathSimpleViewController.java
More file actions
114 lines (88 loc) · 3.33 KB
/
SimpleViewController.java
File metadata and controls
114 lines (88 loc) · 3.33 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
113
114
package com.reactnativenavigation.mocks;
import static com.reactnativenavigation.utils.ObjectUtils.perform;
import android.app.Activity;
import android.content.Context;
import android.view.MotionEvent;
import androidx.annotation.NonNull;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import com.reactnativenavigation.options.Options;
import com.reactnativenavigation.viewcontrollers.child.ChildController;
import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
import com.reactnativenavigation.viewcontrollers.component.ComponentPresenterBase;
import com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter;
import com.reactnativenavigation.viewcontrollers.viewcontroller.ScrollEventListener;
import com.reactnativenavigation.views.component.ReactComponent;
public class SimpleViewController extends ChildController<SimpleViewController.SimpleView> {
private final ComponentPresenterBase presenter = new ComponentPresenterBase();
public SimpleViewController(Activity activity, ChildControllersRegistry childRegistry, String id, Options options) {
this(activity, childRegistry, id, new Presenter(activity, new Options()), options);
}
public SimpleViewController(Activity activity, ChildControllersRegistry childRegistry, String id, Presenter presenter, Options options) {
super(activity, childRegistry, id, presenter, options);
}
@Override
public SimpleView createView() {
return new SimpleView(getActivity());
}
@Override
public void sendOnNavigationButtonPressed(String buttonId) {
getView().sendOnNavigationButtonPressed(buttonId);
}
@Override
public void destroy() {
if (!isDestroyed()) performOnParentController(parent -> parent.onChildDestroyed(this));
super.destroy();
}
@NonNull
@Override
public String toString() {
return "SimpleViewController " + getId();
}
@Override
public int getTopInset() {
int statusBarInset = resolveCurrentOptions().statusBar.isHiddenOrDrawBehind() ? 0 : 63;
return statusBarInset + perform(getParentController(), 0, p -> p.getTopInset(this));
}
@Override
public void applyBottomInset() {
if (view != null) presenter.applyBottomInset(view, getBottomInset());
}
@Override
public String getCurrentComponentName() {
return null;
}
public static class SimpleView extends FrameLayout implements ReactComponent {
public SimpleView(@NonNull Context context) {
super(context);
}
@Override
public boolean isRendered() {
return getChildCount() >= 1;
}
@Override
public boolean isReady() {
return false;
}
@Override
public ViewGroup asView() {
return this;
}
@Override
public void destroy() {}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
start();
}
public void start() {}
@Override
public void sendOnNavigationButtonPressed(String buttonId) {}
@Override
public ScrollEventListener getScrollEventListener() {
return null;
}
@Override
public void dispatchTouchEventToJs(MotionEvent event) {}
}
}