feat:add switch for Android and iOS

This commit is contained in:
pengfei.zhou
2020-03-13 13:01:21 +08:00
committed by osborn
parent a6df529f8f
commit 4359eec700
23 changed files with 708 additions and 83 deletions

View File

@@ -0,0 +1,35 @@
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)
}
}