h5:add ListNode and ListItemNode
This commit is contained in:
parent
47faafae7e
commit
dd12ca765b
@ -36,7 +36,7 @@ export class DoricContext {
|
|||||||
for (let i = 0; i < arguments.length; i++) {
|
for (let i = 0; i < arguments.length; i++) {
|
||||||
argumentsList.push(arguments[i])
|
argumentsList.push(arguments[i])
|
||||||
}
|
}
|
||||||
Reflect.apply(jsCallEntityMethod, this.panel, argumentsList)
|
return Reflect.apply(jsCallEntityMethod, this.panel, argumentsList)
|
||||||
}
|
}
|
||||||
|
|
||||||
init(frame: {
|
init(frame: {
|
||||||
|
@ -11,6 +11,8 @@ import { ModalPlugin } from './plugins/ModalPlugin'
|
|||||||
import { StoragePlugin } from "./plugins/StoragePlugin"
|
import { StoragePlugin } from "./plugins/StoragePlugin"
|
||||||
import { NavigatorPlugin } from "./navigate/NavigatorPlugin"
|
import { NavigatorPlugin } from "./navigate/NavigatorPlugin"
|
||||||
import { PopoverPlugin } from './plugins/PopoverPlugin'
|
import { PopoverPlugin } from './plugins/PopoverPlugin'
|
||||||
|
import { DoricListItemNode } from "./shader/DoricListItemNode"
|
||||||
|
import { DoricListNode } from "./shader/DoricListNode"
|
||||||
|
|
||||||
const bundles: Map<string, string> = new Map
|
const bundles: Map<string, string> = new Map
|
||||||
|
|
||||||
@ -57,3 +59,5 @@ registerViewNode('HLayout', DoricHLayoutNode)
|
|||||||
registerViewNode('Text', DoricTextNode)
|
registerViewNode('Text', DoricTextNode)
|
||||||
registerViewNode('Image', DoricImageNode)
|
registerViewNode('Image', DoricImageNode)
|
||||||
registerViewNode('Scroller', DoricScrollerNode)
|
registerViewNode('Scroller', DoricScrollerNode)
|
||||||
|
registerViewNode('ListItem', DoricListItemNode)
|
||||||
|
registerViewNode('List', DoricListNode)
|
5
doric-h5/src/shader/DoricListItemNode.ts
Normal file
5
doric-h5/src/shader/DoricListItemNode.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { DoricStackNode } from "./DoricStackNode";
|
||||||
|
|
||||||
|
export class DoricListItemNode extends DoricStackNode {
|
||||||
|
|
||||||
|
}
|
75
doric-h5/src/shader/DoricListNode.ts
Normal file
75
doric-h5/src/shader/DoricListNode.ts
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
import { DoricSuperNode, DVModel, DoricViewNode } from "./DoricViewNode";
|
||||||
|
import { DoricListItemNode } from "./DoricListItemNode";
|
||||||
|
|
||||||
|
export class DoricListNode extends DoricSuperNode {
|
||||||
|
itemCount = 0
|
||||||
|
renderItemFuncId?: string
|
||||||
|
onLoadMoreFuncId?: string
|
||||||
|
loadMoreViewId?: string
|
||||||
|
batchCount = 15
|
||||||
|
loadMore = false
|
||||||
|
childNodes: DoricListItemNode[] = []
|
||||||
|
blendProps(v: HTMLParagraphElement, propName: string, prop: any) {
|
||||||
|
switch (propName) {
|
||||||
|
case "itemCount":
|
||||||
|
this.itemCount = prop as number
|
||||||
|
break
|
||||||
|
case "renderItem":
|
||||||
|
this.reset()
|
||||||
|
this.renderItemFuncId = prop as string
|
||||||
|
break
|
||||||
|
case "onLoadMore":
|
||||||
|
this.onLoadMoreFuncId = prop as string
|
||||||
|
break
|
||||||
|
case "loadMoreView":
|
||||||
|
this.loadMoreViewId = prop as string
|
||||||
|
break
|
||||||
|
case "batchCount":
|
||||||
|
this.batchCount = prop as number
|
||||||
|
break
|
||||||
|
case "loadMore":
|
||||||
|
this.loadMore = prop as boolean
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
super.blendProps(v, propName, prop)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
while (this.view.lastElementChild) {
|
||||||
|
this.view.removeChild(this.view.lastElementChild)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onBlended() {
|
||||||
|
super.onBlended()
|
||||||
|
if (this.childNodes.length !== this.itemCount) {
|
||||||
|
const ret = this.callJSResponse("renderBunchedItems", 0, this.itemCount) as DVModel[]
|
||||||
|
this.childNodes = ret.map(e => {
|
||||||
|
const viewNode = DoricViewNode.create(this.context, e.type) as DoricListItemNode
|
||||||
|
viewNode.viewId = e.id
|
||||||
|
viewNode.init(this)
|
||||||
|
viewNode.blend(e.props)
|
||||||
|
this.view.appendChild(viewNode.view)
|
||||||
|
return viewNode
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
blendSubNode(model: DVModel) {
|
||||||
|
const viewNode = this.getSubNodeById(model.id)
|
||||||
|
if (viewNode) {
|
||||||
|
viewNode.blend(model.props)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getSubNodeById(viewId: string) {
|
||||||
|
return this.childNodes.filter(e => e.viewId === viewId)[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
const ret = document.createElement('div')
|
||||||
|
ret.style.overflow = "scroll"
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
18
doric-h5/src/shader/DoricRefreshableNode.ts
Normal file
18
doric-h5/src/shader/DoricRefreshableNode.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { DoricSuperNode, DVModel } from "./DoricViewNode";
|
||||||
|
|
||||||
|
export class DoricRefreshableNode extends DoricSuperNode {
|
||||||
|
blendSubNode(model: DVModel) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
getSubNodeById(viewId: string) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
const ret = document.createElement('div')
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -12,7 +12,7 @@ export class DoricTextNode extends DoricViewNode {
|
|||||||
return div
|
return div
|
||||||
}
|
}
|
||||||
|
|
||||||
blendProps(v: HTMLParagraphElement, propName: string, prop: any) {
|
blendProps(v: HTMLElement, propName: string, prop: any) {
|
||||||
switch (propName) {
|
switch (propName) {
|
||||||
case 'text':
|
case 'text':
|
||||||
this.textElement.innerText = prop
|
this.textElement.innerText = prop
|
||||||
|
@ -309,7 +309,7 @@ export abstract class DoricViewNode {
|
|||||||
for (let i = 1; i < arguments.length; i++) {
|
for (let i = 1; i < arguments.length; i++) {
|
||||||
argumentsList.push(arguments[i])
|
argumentsList.push(arguments[i])
|
||||||
}
|
}
|
||||||
Reflect.apply(this.context.invokeEntityMethod, this.context, argumentsList)
|
return Reflect.apply(this.context.invokeEntityMethod, this.context, argumentsList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user