token type tab 添加对链切换事件的监听
This commit is contained in:
parent
403a7944a9
commit
ecd3818bc2
@ -19,4 +19,6 @@ export { createWalletEvents }
|
|||||||
|
|
||||||
export const WALLET_CHAIN_CHANGE = 'wallet_chain_change'
|
export const WALLET_CHAIN_CHANGE = 'wallet_chain_change'
|
||||||
|
|
||||||
|
export const WALLET_ACCOUNT_CHANGE = 'wallet_account_change'
|
||||||
|
|
||||||
export const WALLET_TOKEN_TYPE_CHANGE = 'wallet_token_type_change'
|
export const WALLET_TOKEN_TYPE_CHANGE = 'wallet_token_type_change'
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { WALLET_CHAIN_CHANGE } from "../common/WalletEvent";
|
||||||
import { DEFAULT_NFT_TYPES } from "../config/chain_config";
|
import { DEFAULT_NFT_TYPES } from "../config/chain_config";
|
||||||
import JCWallet from "../JCWallet";
|
import JCWallet from "../JCWallet";
|
||||||
import ButtonGroup, { BTN_SELECT_INDEX_CHANGE } from "./ButtonGroup";
|
import ButtonGroup, { BTN_SELECT_INDEX_CHANGE } from "./ButtonGroup";
|
||||||
@ -29,7 +30,8 @@ export default class TokenTab extends WalletBase {
|
|||||||
this.btnGroup.resetBtns()
|
this.btnGroup.resetBtns()
|
||||||
this.btnGroup.node.on(BTN_SELECT_INDEX_CHANGE,
|
this.btnGroup.node.on(BTN_SELECT_INDEX_CHANGE,
|
||||||
this.onTokenTypeChange.bind(this))
|
this.onTokenTypeChange.bind(this))
|
||||||
this.showAllBtn();
|
this.updateAllBtn();
|
||||||
|
this.wallet.mainHandlers.on(WALLET_CHAIN_CHANGE, this.updateAllBtn.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
onDestroy() {
|
onDestroy() {
|
||||||
@ -37,7 +39,7 @@ export default class TokenTab extends WalletBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update (dt) {}
|
// update (dt) {}
|
||||||
showAllBtn() {
|
updateAllBtn() {
|
||||||
this.titles.length = 1
|
this.titles.length = 1
|
||||||
const chain = this.wallet.currentChain.id
|
const chain = this.wallet.currentChain.id
|
||||||
let nftData: any = DEFAULT_NFT_TYPES[chain]
|
let nftData: any = DEFAULT_NFT_TYPES[chain]
|
||||||
@ -46,12 +48,14 @@ export default class TokenTab extends WalletBase {
|
|||||||
this.titles.push(key)
|
this.titles.push(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.btnGroup.resetBtns()
|
||||||
console.log('show all token tab: ', this.titles)
|
console.log('show all token tab: ', this.titles)
|
||||||
for (let i = 0, l = this.titles.length; i < l; i++) {
|
for (let i = 0, l = this.titles.length; i < l; i++) {
|
||||||
const btn = cc.instantiate(this.btnPreb)
|
const btn = cc.instantiate(this.btnPreb)
|
||||||
const btnM: TextBtn = btn.getComponent(TextBtn)
|
const btnM: TextBtn = btn.getComponent(TextBtn)
|
||||||
this.btnGroup.addBtn(btnM);
|
this.btnGroup.addBtn(btnM);
|
||||||
btnM.title = this.titles[i].replace(/^\S/, s => s.toUpperCase())
|
// btnM.title = this.titles[i].replace(/^\S/, s => s.toUpperCase())
|
||||||
|
btnM.title = this.titles[i].toUpperCase()
|
||||||
btnM.index = i
|
btnM.index = i
|
||||||
btnM.selected = i === 0
|
btnM.selected = i === 0
|
||||||
}
|
}
|
||||||
|
@ -7400,7 +7400,7 @@
|
|||||||
},
|
},
|
||||||
"_position": {
|
"_position": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": -358,
|
"x": -433,
|
||||||
"y": 75,
|
"y": 75,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
@ -7488,7 +7488,7 @@
|
|||||||
},
|
},
|
||||||
"_position": {
|
"_position": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": -317,
|
"x": -392,
|
||||||
"y": 64,
|
"y": 64,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user