feat:Popover area do not over the root view's area
This commit is contained in:
parent
a8cbdc0c1d
commit
cf2b5b3fac
@ -1,5 +1,6 @@
|
|||||||
package pub.doric.plugin;
|
package pub.doric.plugin;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
@ -7,6 +8,7 @@ import com.github.pengfeizhou.jscore.JSDecoder;
|
|||||||
import com.github.pengfeizhou.jscore.JSObject;
|
import com.github.pengfeizhou.jscore.JSObject;
|
||||||
import com.github.pengfeizhou.jscore.JSValue;
|
import com.github.pengfeizhou.jscore.JSValue;
|
||||||
import com.github.pengfeizhou.jscore.JavaValue;
|
import com.github.pengfeizhou.jscore.JavaValue;
|
||||||
|
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
@ -40,11 +42,37 @@ public class PopoverPlugin extends DoricJavaPlugin {
|
|||||||
getDoricContext().getDriver().asyncCall(new Callable<Object>() {
|
getDoricContext().getDriver().asyncCall(new Callable<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object call() throws Exception {
|
public Object call() throws Exception {
|
||||||
|
ViewGroup decorView = (ViewGroup) getDoricContext().getRootNode().getNodeView().getRootView();
|
||||||
if (mFullScreenView == null) {
|
if (mFullScreenView == null) {
|
||||||
mFullScreenView = new FrameLayout(getDoricContext().getContext());
|
mFullScreenView = new FrameLayout(getDoricContext().getContext());
|
||||||
ViewGroup decorView = (ViewGroup) getDoricContext().getRootNode().getNodeView().getRootView();
|
View navBar = (View) getDoricContext().getDoricNavBar();
|
||||||
decorView.addView(mFullScreenView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.MarginLayoutParams layoutParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT));
|
ViewGroup.LayoutParams.MATCH_PARENT);
|
||||||
|
int marginTop = 0;
|
||||||
|
if (navBar != null && navBar.getVisibility() == View.VISIBLE) {
|
||||||
|
int[] navBarLocation = new int[2];
|
||||||
|
navBar.getLocationOnScreen(navBarLocation);
|
||||||
|
int[] decorViewLocation = new int[2];
|
||||||
|
decorView.getLocationOnScreen(decorViewLocation);
|
||||||
|
marginTop = navBarLocation[1] - decorViewLocation[1] + navBar.getHeight();
|
||||||
|
}
|
||||||
|
layoutParams.topMargin = marginTop;
|
||||||
|
layoutParams.bottomMargin = QMUIDisplayHelper.getNavMenuHeight(getDoricContext().getContext());
|
||||||
|
decorView.addView(mFullScreenView, layoutParams);
|
||||||
|
} else {
|
||||||
|
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) mFullScreenView.getLayoutParams();
|
||||||
|
View navBar = (View) getDoricContext().getDoricNavBar();
|
||||||
|
int marginTop = 0;
|
||||||
|
if (navBar != null && navBar.getVisibility() == View.VISIBLE) {
|
||||||
|
int[] navBarLocation = new int[2];
|
||||||
|
navBar.getLocationOnScreen(navBarLocation);
|
||||||
|
int[] decorViewLocation = new int[2];
|
||||||
|
decorView.getLocationOnScreen(decorViewLocation);
|
||||||
|
marginTop = navBarLocation[1] - decorViewLocation[1] + navBar.getHeight();
|
||||||
|
}
|
||||||
|
layoutParams.topMargin = marginTop;
|
||||||
|
layoutParams.bottomMargin = QMUIDisplayHelper.getNavMenuHeight(getDoricContext().getContext());
|
||||||
|
mFullScreenView.setLayoutParams(layoutParams);
|
||||||
}
|
}
|
||||||
mFullScreenView.bringToFront();
|
mFullScreenView.bringToFront();
|
||||||
String viewId = jsObject.getProperty("id").asString().value();
|
String viewId = jsObject.getProperty("id").asString().value();
|
||||||
|
@ -1,44 +1,97 @@
|
|||||||
import { Group, Panel, popover, text, gravity, Color, LayoutSpec, vlayout, Gravity, scroller, layoutConfig, modal, } from "doric";
|
import {
|
||||||
|
stack,
|
||||||
|
Group,
|
||||||
|
Panel,
|
||||||
|
popover,
|
||||||
|
text,
|
||||||
|
gravity,
|
||||||
|
Color,
|
||||||
|
LayoutSpec,
|
||||||
|
vlayout,
|
||||||
|
Gravity,
|
||||||
|
scroller,
|
||||||
|
layoutConfig,
|
||||||
|
modal,
|
||||||
|
navbar,
|
||||||
|
} from "doric";
|
||||||
import { title, label, colors } from "./utils";
|
import { title, label, colors } from "./utils";
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
class PopoverDemo extends Panel {
|
class PopoverDemo extends Panel {
|
||||||
build(rootView: Group): void {
|
build(rootView: Group): void {
|
||||||
scroller(vlayout([
|
scroller(
|
||||||
title("Popover Demo"),
|
vlayout([
|
||||||
label('Popover').apply({
|
title("Popover Demo"),
|
||||||
width: 200,
|
label("show navbar").apply({
|
||||||
height: 50,
|
width: 200,
|
||||||
backgroundColor: colors[0],
|
height: 50,
|
||||||
textSize: 30,
|
backgroundColor: colors[0],
|
||||||
textColor: Color.WHITE,
|
textSize: 30,
|
||||||
layoutConfig: layoutConfig().just(),
|
textColor: Color.WHITE,
|
||||||
onClick: () => {
|
layoutConfig: layoutConfig().just(),
|
||||||
popover(context).show(text({
|
onClick: () => {
|
||||||
width: 200,
|
navbar(context).setHidden(false);
|
||||||
height: 50,
|
},
|
||||||
backgroundColor: colors[0],
|
}),
|
||||||
textColor: Color.WHITE,
|
label("hide navbar").apply({
|
||||||
layoutConfig: layoutConfig().just().configAlignment(Gravity.Center),
|
width: 200,
|
||||||
text: "This is PopOver Window",
|
height: 50,
|
||||||
}).also(v => {
|
backgroundColor: colors[0],
|
||||||
let idx = 0
|
textSize: 30,
|
||||||
v.onClick = () => {
|
textColor: Color.WHITE,
|
||||||
v.backgroundColor = colors[(++idx) % colors.length]
|
layoutConfig: layoutConfig().just(),
|
||||||
}
|
onClick: () => {
|
||||||
modal(context).toast('Dismissed after 3 seconds')
|
navbar(context).setHidden(true);
|
||||||
setTimeout(() => {
|
},
|
||||||
popover(context).dismiss()
|
}),
|
||||||
}, 3000)
|
label("Popover").apply({
|
||||||
}))
|
width: 200,
|
||||||
|
height: 50,
|
||||||
|
backgroundColor: colors[0],
|
||||||
|
textSize: 30,
|
||||||
|
textColor: Color.WHITE,
|
||||||
|
layoutConfig: layoutConfig().just(),
|
||||||
|
onClick: () => {
|
||||||
|
popover(context).show(
|
||||||
|
stack(
|
||||||
|
[
|
||||||
|
text({
|
||||||
|
width: 200,
|
||||||
|
height: 50,
|
||||||
|
backgroundColor: colors[0],
|
||||||
|
textColor: Color.WHITE,
|
||||||
|
layoutConfig: layoutConfig()
|
||||||
|
.just()
|
||||||
|
.configAlignment(Gravity.Center),
|
||||||
|
text: "This is PopOver Window",
|
||||||
|
}).also((v) => {
|
||||||
|
let idx = 0;
|
||||||
|
v.onClick = () => {
|
||||||
|
v.backgroundColor = colors[++idx % colors.length];
|
||||||
|
};
|
||||||
|
modal(context).toast("Dismissed after 3 seconds");
|
||||||
|
setTimeout(() => {
|
||||||
|
popover(context).dismiss();
|
||||||
|
}, 3000);
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
{
|
||||||
|
layoutConfig: layoutConfig().most(),
|
||||||
|
backgroundColor: Color.RED.alpha(1),
|
||||||
}
|
}
|
||||||
}),
|
)
|
||||||
]).apply({
|
);
|
||||||
layoutConfig: layoutConfig().most().configHeight(LayoutSpec.FIT),
|
},
|
||||||
gravity: gravity().center(),
|
}),
|
||||||
space: 10,
|
]).apply({
|
||||||
})).apply({
|
layoutConfig: layoutConfig().most().configHeight(LayoutSpec.FIT),
|
||||||
layoutConfig: layoutConfig().most(),
|
gravity: gravity().center(),
|
||||||
}).in(rootView)
|
space: 10,
|
||||||
}
|
})
|
||||||
|
)
|
||||||
|
.apply({
|
||||||
|
layoutConfig: layoutConfig().most(),
|
||||||
|
})
|
||||||
|
.in(rootView);
|
||||||
|
}
|
||||||
}
|
}
|
@ -15,7 +15,7 @@ @implementation DoricPopoverPlugin
|
|||||||
|
|
||||||
- (void)show:(NSDictionary *)params withPromise:(DoricPromise *)promise {
|
- (void)show:(NSDictionary *)params withPromise:(DoricPromise *)promise {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
UIView *superView = [UIApplication sharedApplication].windows.lastObject;
|
UIView *superView = self.doricContext.vc.view;
|
||||||
if (!self.fullScreenView) {
|
if (!self.fullScreenView) {
|
||||||
self.fullScreenView = [[UIView new] also:^(UIView *it) {
|
self.fullScreenView = [[UIView new] also:^(UIView *it) {
|
||||||
it.width = superView.width;
|
it.width = superView.width;
|
||||||
@ -24,6 +24,9 @@ - (void)show:(NSDictionary *)params withPromise:(DoricPromise *)promise {
|
|||||||
it.doricLayout.layoutType = DoricStack;
|
it.doricLayout.layoutType = DoricStack;
|
||||||
[superView addSubview:it];
|
[superView addSubview:it];
|
||||||
}];
|
}];
|
||||||
|
} else {
|
||||||
|
self.fullScreenView.doricLayout.width = superView.width;
|
||||||
|
self.fullScreenView.doricLayout.height = superView.height;
|
||||||
}
|
}
|
||||||
[superView bringSubviewToFront:self.fullScreenView];
|
[superView bringSubviewToFront:self.fullScreenView];
|
||||||
self.fullScreenView.hidden = NO;
|
self.fullScreenView.hidden = NO;
|
||||||
|
Reference in New Issue
Block a user