Refact:Devkit change msg format

This commit is contained in:
pengfeizhou
2021-02-20 17:58:09 +08:00
committed by osborn
parent d40cd13c56
commit 4c0237aec6
21 changed files with 459 additions and 319 deletions

View File

@@ -1,67 +1,87 @@
import { text, vlayout, ViewHolder, VMPanel, ViewModel, Gravity, NativeCall, Text, Color, log, logw, loge, Group, LayoutSpec, layoutConfig, } from "doric"
import {
text,
vlayout,
ViewHolder,
VMPanel,
ViewModel,
Gravity,
NativeCall,
Text,
Color,
log,
logw,
loge,
Group,
LayoutSpec,
layoutConfig,
modal,
Panel,
} from "doric";
interface CountModel {
count: number
count: number;
}
class CounterView extends ViewHolder {
number!: Text
counter!: Text
build(root: Group) {
vlayout(
[
text({
textSize: 40,
tag: "tvNumber"
}),
number!: Text;
counter!: Text;
build(root: Group) {
vlayout(
[
text({
textSize: 40,
tag: "tvNumber",
}),
text({
text: "Click To Count 1",
textSize: 20,
tag: "tvCounter"
}),
],
{
layoutConfig: layoutConfig().most(),
gravity: Gravity.Center,
space: 20,
}
).in(root)
this.number = root.findViewByTag("tvNumber")!
this.counter = root.findViewByTag("tvCounter")!
}
}
text({
text: "Click To Count 1",
textSize: 20,
tag: "tvCounter",
}),
],
{
layoutConfig: layoutConfig().most(),
gravity: Gravity.Center,
space: 20,
}
).in(root);
this.number = root.findViewByTag("tvNumber")!;
this.counter = root.findViewByTag("tvCounter")!;
}
}
class CounterVM extends ViewModel<CountModel, CounterView> {
onAttached(s: CountModel, vh: CounterView) {
vh.counter.onClick = () => {
this.updateState(state => {
state.count++
})
}
}
onBind(s: CountModel, vh: CounterView) {
vh.number.text = `${s.count}`
log("onBind\nseee")
logw("onBind")
loge("onBind")
}
onAttached(s: CountModel, vh: CounterView) {
vh.counter.onClick = () => {
this.updateState((state) => {
state.count++;
});
};
}
onBind(s: CountModel, vh: CounterView) {
vh.number.text = `${s.count}`;
log("onBind\nseee");
logw("onBind");
loge("onBind");
}
}
@Entry
export class CounterPage extends VMPanel<CountModel, CounterView>{
export class CounterPage extends VMPanel<CountModel, CounterView> {
constructor() {
super();
log("Constructor");
}
getViewHolderClass() {
return CounterView;
}
getViewModelClass() {
return CounterVM;
}
getViewHolderClass() {
return CounterView
}
getViewModelClass() {
return CounterVM
}
getState(): CountModel {
return {
count: 0
}
}
}
getState(): CountModel {
return {
count: 1,
};
}
}