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/SwitchDemo.ts
2020-03-13 13:03:23 +08:00

35 lines
1.2 KiB
TypeScript

import { Group, Panel, switchView, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout, scroller, layoutConfig, Text } from "doric";
@Entry
class SwitchDemo extends Panel {
build(rootView: Group): void {
let switchStatus: Text
vlayout(
[
switchStatus = text({
text: "Switch开关"
}),
switchView({
state: true,
onSwitch: (state) => {
switchStatus.text = `Switch 当前状态:${state ? "ON" : "OFF"}`
},
}),
switchView({
state: true,
onSwitch: (state) => {
switchStatus.text = `Switch 当前状态:${state ? "ON" : "OFF"}`
},
// backgroundColor: Color.RED,
offTintColor: Color.RED,
onTintColor: Color.YELLOW,
//thumbTintColor: Color.RED,
}),
],
{
layoutConfig: layoutConfig().most(),
space: 20,
gravity: Gravity.Center
}).in(rootView)
}
}