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

34 lines
1.2 KiB
TypeScript
Raw Normal View History

import { Group, Panel, gravity, Color, LayoutSpec, vlayout, scroller, layoutConfig, modal, network } from "doric";
2019-12-04 14:07:14 +08:00
import { title, label, colors } from "./utils";
@Entry
class NetworkDemo extends Panel {
build(rootView: Group): void {
scroller(vlayout([
title("Network Demo"),
label('Click me').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: () => {
network(context).get('https://m.baidu.com').then(
e => {
modal(context).alert(JSON.stringify(e))
}
).catch(e => {
modal(context).toast('Catched:' + JSON.stringify(e))
})
}
}),
2019-12-04 14:07:14 +08:00
]).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,
})).apply({
2019-12-14 16:32:04 +08:00
layoutConfig: layoutConfig().most(),
2019-12-04 14:07:14 +08:00
}).in(rootView)
}
}