android: notch plugin implementation
This commit is contained in:
parent
f9a86a7f88
commit
9bb92f410e
@ -31,6 +31,7 @@ import pub.doric.plugin.ModalPlugin;
|
|||||||
import pub.doric.plugin.NavBarPlugin;
|
import pub.doric.plugin.NavBarPlugin;
|
||||||
import pub.doric.plugin.NavigatorPlugin;
|
import pub.doric.plugin.NavigatorPlugin;
|
||||||
import pub.doric.plugin.NetworkPlugin;
|
import pub.doric.plugin.NetworkPlugin;
|
||||||
|
import pub.doric.plugin.NotchPlugin;
|
||||||
import pub.doric.plugin.NotificationPlugin;
|
import pub.doric.plugin.NotificationPlugin;
|
||||||
import pub.doric.plugin.PopoverPlugin;
|
import pub.doric.plugin.PopoverPlugin;
|
||||||
import pub.doric.plugin.ShaderPlugin;
|
import pub.doric.plugin.ShaderPlugin;
|
||||||
@ -99,6 +100,7 @@ public class DoricRegistry {
|
|||||||
this.registerNativePlugin(NotificationPlugin.class);
|
this.registerNativePlugin(NotificationPlugin.class);
|
||||||
this.registerNativePlugin(StatusBarPlugin.class);
|
this.registerNativePlugin(StatusBarPlugin.class);
|
||||||
this.registerNativePlugin(CoordinatorPlugin.class);
|
this.registerNativePlugin(CoordinatorPlugin.class);
|
||||||
|
this.registerNativePlugin(NotchPlugin.class);
|
||||||
|
|
||||||
this.registerViewNode(RootNode.class);
|
this.registerViewNode(RootNode.class);
|
||||||
this.registerViewNode(TextNode.class);
|
this.registerViewNode(TextNode.class);
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package pub.doric.plugin;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.github.pengfeizhou.jscore.JSONBuilder;
|
||||||
|
import com.github.pengfeizhou.jscore.JSObject;
|
||||||
|
import com.github.pengfeizhou.jscore.JavaValue;
|
||||||
|
import com.qmuiteam.qmui.util.QMUINotchHelper;
|
||||||
|
|
||||||
|
import pub.doric.DoricContext;
|
||||||
|
import pub.doric.extension.bridge.DoricMethod;
|
||||||
|
import pub.doric.extension.bridge.DoricPlugin;
|
||||||
|
import pub.doric.extension.bridge.DoricPromise;
|
||||||
|
import pub.doric.utils.ThreadMode;
|
||||||
|
|
||||||
|
@DoricPlugin(name = "notch")
|
||||||
|
public class NotchPlugin extends DoricJavaPlugin {
|
||||||
|
|
||||||
|
public NotchPlugin(DoricContext doricContext) {
|
||||||
|
super(doricContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DoricMethod(thread = ThreadMode.UI)
|
||||||
|
public void inset(JSObject jsObject, final DoricPromise promise) {
|
||||||
|
View view = getDoricContext().getRootNode().getNodeView();
|
||||||
|
int top = QMUINotchHelper.getSafeInsetTop(view);
|
||||||
|
int left = QMUINotchHelper.getSafeInsetLeft(view);
|
||||||
|
int bottom = QMUINotchHelper.getSafeInsetBottom(view);
|
||||||
|
int right = QMUINotchHelper.getSafeInsetRight(view);
|
||||||
|
promise.resolve(new JavaValue(new JSONBuilder()
|
||||||
|
.put("top", top)
|
||||||
|
.put("left", left)
|
||||||
|
.put("bottom", bottom)
|
||||||
|
.put("right", right).toJSONObject()));
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user