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/NavbarDemo.ts

138 lines
12 KiB
TypeScript
Raw Normal View History

import { Group, Panel, navbar, text, gravity, Color, LayoutSpec, vlayout, Gravity, hlayout, scroller, layoutConfig, image, IVLayout, modal, IText, navigator } from "doric";
2019-12-04 14:07:14 +08:00
import { title, label, colors } from "./utils";
const shareIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAMAAADDpiTIAAACZFBMVEUAAABEREBEREBEREBEREBEREBEREBEREBEREBEREBEREBEREBEREBEREBEREBDQ0NDQ0JCQkJCQkJDQ0JCQkJDQ0NBQUBBQUBAQEBAQEBBQUFCQkFCQkFBQUFCQkI8PDxDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NBQUE7OztDQ0NDQ0NDQ0NDQ0NERERDQ0NDQ0NCQkJCQkJCQkJDQ0NBQUFCQkJDQ0NAQD5AQEBDQ0NCQkJCQkJCQkJCQkJDQ0NEREQAAABBQUFCQkJBQUFCQkJDQ0NBQUGAgIBDQ0JDQ0NCQkJCQkJCQkJFRUVFRURBQUFCQkJCQkJCQkJDQ0JDQ0JDQ0NCQkJDQ0NDQ0FLS0dBQUFCQkJBQUEzMzNDQ0JCQkJCQkJCQkJCQkJCQkJCQkJAQD1CQkJCQkJAQEBAQD5CQkJCQkJCQkJCQkFCQkJDQ0JCQkJBQUFCQkFERENBQUBGRkRCQkJCQkI+Pj1AQDxDQ0NCQkJAQEBCQkJCQkJCQkJCQkJHR0VCQkJDQ0NCQkJDQ0JCQkJCQkJBQUFBQUFERENBQUFCQkJCQkJDQ0JDQ0NDQ0NBQUBDQ0NCQkJDQ0NCQkJBQUFCQkJCQkJCQkJCQkJAQEBDQ0NBQUFDQ0NBQUFCQkJBQUFCQkJCQkJBQUFBQUFBQUFBQUFDQ0NDQ0NCQkJAQEBDQ0NCQkJCQkFCQkJEREI9PT1CQkJAQEBCQkJDQ0FCQkJC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QLwLODl8xSL4ChCUm9ADw7eOks7Q
2019-12-04 14:07:14 +08:00
@Entry
class NavbarDemo extends Panel {
build(rootView: Group): void {
scroller(vlayout([
title("Navbar Demo"),
label('isHidden').apply({
width: 200,
height: 50,
backgroundColor: colors[0],
textSize: 30,
textColor: Color.WHITE,
2019-12-14 16:32:04 +08:00
layoutConfig: layoutConfig().just(),
2019-12-04 14:07:14 +08:00
onClick: () => {
navbar(context).isHidden().then(e => modal(context).alert(`Navbar isHidden:${e}`)).catch(e => {
modal(context).alert(e)
})
}
} as IText),
label('setHidden').apply({
width: 200,
height: 50,
backgroundColor: colors[0],
textSize: 30,
textColor: Color.WHITE,
2019-12-14 16:32:04 +08:00
layoutConfig: layoutConfig().just(),
2019-12-04 14:07:14 +08:00
onClick: () => {
navbar(context).isHidden()
.then(e => navbar(context).setHidden(!e))
.catch(e => {
modal(context).alert(e)
})
}
} as IText),
label('setTitle').apply({
width: 200,
height: 50,
backgroundColor: colors[0],
textSize: 30,
textColor: Color.WHITE,
2019-12-14 16:32:04 +08:00
layoutConfig: layoutConfig().just(),
2019-12-04 14:07:14 +08:00
onClick: () => {
navbar(context).setTitle('Setted Title')
.catch(e => {
modal(context).alert(e)
})
}
} as IText),
label('setBgColor').apply({
width: 200,
height: 50,
backgroundColor: colors[0],
textSize: 30,
textColor: Color.WHITE,
2019-12-14 16:32:04 +08:00
layoutConfig: layoutConfig().just(),
2019-12-04 14:07:14 +08:00
onClick: () => {
navbar(context).setBgColor(Color.YELLOW)
.catch(e => {
modal(context).alert(e)
})
}
} as IText),
label('setLeft').apply({
width: 200,
height: 50,
backgroundColor: colors[0],
textSize: 30,
textColor: Color.WHITE,
layoutConfig: layoutConfig().just(),
onClick: () => {
navbar(context).setLeft(text({
width: 70,
height: 44,
textColor: Color.BLACK,
layoutConfig: layoutConfig().just().configAlignment(Gravity.Center),
text: "Left",
}))
.catch(e => {
modal(context).alert(e)
})
}
} as IText),
label('setRight').apply({
width: 200,
height: 50,
backgroundColor: colors[0],
textSize: 30,
textColor: Color.WHITE,
layoutConfig: layoutConfig().just(),
onClick: () => {
navbar(context).setRight(hlayout([
text({
width: 70,
height: 44,
textColor: Color.BLACK,
layoutConfig: layoutConfig().just().configAlignment(Gravity.Center),
text: "Right",
}),
image({
imageBase64: shareIcon
}).apply({
layoutConfig: layoutConfig().just().configAlignment(gravity().centerY()),
width: 33,
height: 33,
onClick: () => {
modal(context).toast('Right Clicked', Gravity.Bottom)
}
})
]))
.catch(e => {
modal(context).alert(e)
})
}
} as IText),
2019-12-04 14:07:14 +08:00
label('Pop').apply({
width: 200,
height: 50,
backgroundColor: colors[0],
textSize: 30,
textColor: Color.WHITE,
2019-12-14 16:32:04 +08:00
layoutConfig: layoutConfig().just(),
2019-12-04 14:07:14 +08:00
onClick: () => {
navigator(context).pop()
}
} as IText),
]).apply({
2019-12-14 16:32:04 +08:00
layoutConfig: layoutConfig().most().configHeight(LayoutSpec.FIT),
2019-12-04 14:07:14 +08:00
gravity: gravity().center(),
space: 10,
} as IVLayout)).apply({
2019-12-14 16:32:04 +08:00
layoutConfig: layoutConfig().most(),
2019-12-04 14:07:14 +08:00
}).in(rootView)
}
}