feat: enhance plugin navigator,add popSelf and popToRoot

This commit is contained in:
pengfei.zhou
2021-06-08 11:55:21 +08:00
committed by osborn
parent 864ffa0de7
commit 4da1f3be9d
15 changed files with 162 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
import { Panel, scroller, vlayout, text, layoutConfig, LayoutSpec, Color, gravity, Group, navigator, modal } from "doric";
import { Panel, scroller, vlayout, text, layoutConfig, LayoutSpec, Color, gravity, Group, navigator, modal, notification } from "doric";
import { colors, label } from "./utils";
@Entry
class NaivgatorDemo extends Panel {
@@ -64,6 +64,46 @@ class NaivgatorDemo extends Panel {
navigator(context).pop()
},
}),
label('Register Pop Self').apply({
width: 200,
height: 50,
backgroundColor: colors[0],
textSize: 30,
textColor: Color.WHITE,
layoutConfig: layoutConfig().just(),
onClick: () => {
notification(context).subscribe({
name: "PopSelf",
callback: () => {
navigator(context).popSelf()
}
})
},
}),
label('Send Pop Self').apply({
width: 200,
height: 50,
backgroundColor: colors[0],
textSize: 30,
textColor: Color.WHITE,
layoutConfig: layoutConfig().just(),
onClick: () => {
notification(context).publish({
name: "PopSelf"
})
},
}),
label('Back to Root').apply({
width: 200,
height: 50,
backgroundColor: colors[0],
textSize: 30,
textColor: Color.WHITE,
layoutConfig: layoutConfig().just(),
onClick: () => {
navigator(context).popToRoot()
},
}),
label('OpenURL').apply({
width: 200,
height: 50,