80 lines
1.8 KiB
TypeScript
80 lines
1.8 KiB
TypeScript
import { WALLET_SHOW_QR } from "../common/WalletEvent";
|
|
import JCWallet from "../JCWallet";
|
|
import ChainTab from "./ChainTab";
|
|
import { IQRCfg } from "./comp/QRCodeComp";
|
|
import ListNode from "./ListNode";
|
|
import WalletBase from "./WallerBase";
|
|
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class WalletMainPanel extends WalletBase {
|
|
|
|
@property({
|
|
type: ChainTab
|
|
})
|
|
chainTab: ChainTab = null
|
|
|
|
@property({
|
|
type: ListNode
|
|
})
|
|
listNode: ListNode = null
|
|
|
|
@property(cc.Prefab)
|
|
menuPreb: cc.Prefab = null
|
|
|
|
@property(cc.Prefab)
|
|
qrPreb: cc.Prefab = null
|
|
|
|
subNodeMap: Map<string, cc.Node> = new Map()
|
|
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {}
|
|
|
|
start () {
|
|
super.start()
|
|
this.wallet.mainHandlers.on(WALLET_SHOW_QR, this.showQrNode.bind(this))
|
|
}
|
|
|
|
// update (dt) {}
|
|
|
|
hideWallet() {
|
|
this.node.active = false
|
|
}
|
|
|
|
updateChainList() {
|
|
const chains = this.wallet.chainList
|
|
if (!chains || chains.length === 0) {
|
|
return;
|
|
}
|
|
for (const chain of chains) {
|
|
|
|
}
|
|
}
|
|
private fetchNode(tag: string, preb: cc.Prefab) {
|
|
if (!this.subNodeMap.has(tag)) {
|
|
const node = cc.instantiate(preb)
|
|
node.x = 0
|
|
node.y = 0
|
|
this.node.addChild(node)
|
|
this.subNodeMap.set(tag, node)
|
|
}
|
|
return this.subNodeMap.get(tag)
|
|
}
|
|
|
|
onMenuClick() {
|
|
const tag = 'menu-node'
|
|
const node = this.fetchNode(tag, this.menuPreb)
|
|
node.active = true
|
|
}
|
|
|
|
showQrNode(data: IQRCfg) {
|
|
const tag = 'qr-node'
|
|
const node = this.fetchNode(tag, this.qrPreb)
|
|
node.getComponent('QrNode').showQr(data)
|
|
node.active = true
|
|
}
|
|
}
|