iOS support internal class
This commit is contained in:
@@ -9,15 +9,15 @@ class CounterView extends ViewHolder {
|
||||
build(root: Group) {
|
||||
vlayout(
|
||||
[
|
||||
text({
|
||||
textSize: 40,
|
||||
tag:"tvNumber"
|
||||
text({
|
||||
textSize: 40,
|
||||
tag: "tvNumber"
|
||||
}),
|
||||
|
||||
text({
|
||||
text: "Click To Count 1",
|
||||
textSize: 20,
|
||||
tag:"tvCounter"
|
||||
tag: "tvCounter"
|
||||
}),
|
||||
],
|
||||
{
|
||||
@@ -26,8 +26,8 @@ class CounterView extends ViewHolder {
|
||||
space: 20,
|
||||
}
|
||||
).in(root)
|
||||
this.number= root.findViewByTag("tvNumber")!
|
||||
this.counter= root.findViewByTag("tvCounter")!
|
||||
this.number = root.findViewByTag("tvNumber")!
|
||||
this.counter = root.findViewByTag("tvCounter")!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class CounterVM extends ViewModel<CountModel, CounterView> {
|
||||
}
|
||||
|
||||
@Entry
|
||||
class MyPage extends VMPanel<CountModel, CounterView>{
|
||||
export class CounterPage extends VMPanel<CountModel, CounterView>{
|
||||
|
||||
|
||||
getViewHolderClass() {
|
||||
|
@@ -1,77 +1,16 @@
|
||||
import { Group, Panel, navbar, text, gravity, Color, LayoutSpec, vlayout, Gravity, hlayout, scroller, layoutConfig, image, modal, navigator, ViewHolder, Text, ViewModel, VMPanel } from "doric";
|
||||
import { title, label, colors } from "./utils";
|
||||
import { ModalDemo } from "./ModalDemo";
|
||||
import { CounterPage } from './Counter'
|
||||
|
||||
interface CountModel {
|
||||
count: number
|
||||
}
|
||||
class CounterView extends ViewHolder {
|
||||
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")!
|
||||
}
|
||||
}
|
||||
|
||||
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}`
|
||||
}
|
||||
}
|
||||
|
||||
class MyPage extends VMPanel<CountModel, CounterView>{
|
||||
|
||||
|
||||
getViewHolderClass() {
|
||||
return CounterView
|
||||
}
|
||||
|
||||
getViewModelClass() {
|
||||
return CounterVM
|
||||
}
|
||||
|
||||
getState(): CountModel {
|
||||
return {
|
||||
count: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Entry(exports = [ModalDemo, MyPage])
|
||||
@Entry(exports = [ModalDemo, CounterPage])
|
||||
class MultiPanelDemo extends Panel {
|
||||
build(rootView: Group): void {
|
||||
scroller(
|
||||
vlayout(
|
||||
[
|
||||
title("Multi Panel"),
|
||||
label('isHidden').apply({
|
||||
label('ModalDemo').apply({
|
||||
width: 200,
|
||||
height: 50,
|
||||
backgroundColor: colors[0],
|
||||
@@ -82,6 +21,17 @@ class MultiPanelDemo extends Panel {
|
||||
navigator(context).push(ModalDemo)
|
||||
}
|
||||
}),
|
||||
label('Counter').apply({
|
||||
width: 200,
|
||||
height: 50,
|
||||
backgroundColor: colors[0],
|
||||
textSize: 30,
|
||||
textColor: Color.WHITE,
|
||||
layoutConfig: layoutConfig().just(),
|
||||
onClick: () => {
|
||||
navigator(context).push(CounterPage)
|
||||
}
|
||||
}),
|
||||
],
|
||||
{
|
||||
layoutConfig: layoutConfig().most().configHeight(LayoutSpec.FIT),
|
||||
|
Reference in New Issue
Block a user