This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-demo/src/NotchDemo.ts

36 lines
1.3 KiB
TypeScript
Raw Normal View History

2020-03-19 15:07:34 +08:00
import { Group, Panel, gravity, Color, LayoutSpec, vlayout, scroller, layoutConfig, IVLayout, IText, notch, modal, Gravity, log } from "doric";
2020-03-19 14:32:42 +08:00
import { title, label, colors } from "./utils";
@Entry
class NotchDemo extends Panel {
build(rootView: Group): void {
scroller(vlayout([
title("Notch Demo"),
2020-03-19 15:07:34 +08:00
label('inset').apply({
2020-03-19 14:32:42 +08:00
width: 200,
height: 50,
backgroundColor: colors[0],
textSize: 30,
textColor: Color.WHITE,
layoutConfig: layoutConfig().just(),
onClick: () => {
notch(context).inset()
.then((inset) => {
2020-03-19 15:07:34 +08:00
let result = "top: " + inset.top + "\n" + "left: " + inset.left + "\n" + "bottom: " + inset.bottom + "\n" + "right: " + inset.right
modal(context).toast(result, Gravity.Bottom)
log(result)
2020-03-19 14:32:42 +08:00
})
.catch(() => {
})
}
} as IText),
]).apply({
layoutConfig: layoutConfig().most().configHeight(LayoutSpec.FIT),
gravity: gravity().center(),
space: 10,
} as IVLayout)).apply({
layoutConfig: layoutConfig().most(),
}).in(rootView)
}
}