diff --git a/assets/comp/wallet/scripts/common/WalletEvent.ts b/assets/comp/wallet/scripts/common/WalletEvent.ts index 380599a..9a49f9d 100644 --- a/assets/comp/wallet/scripts/common/WalletEvent.ts +++ b/assets/comp/wallet/scripts/common/WalletEvent.ts @@ -19,4 +19,6 @@ export { createWalletEvents } 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' diff --git a/assets/comp/wallet/scripts/ui/TokenTab.ts b/assets/comp/wallet/scripts/ui/TokenTab.ts index 21247ba..354089c 100644 --- a/assets/comp/wallet/scripts/ui/TokenTab.ts +++ b/assets/comp/wallet/scripts/ui/TokenTab.ts @@ -1,3 +1,4 @@ +import { WALLET_CHAIN_CHANGE } from "../common/WalletEvent"; import { DEFAULT_NFT_TYPES } from "../config/chain_config"; import JCWallet from "../JCWallet"; import ButtonGroup, { BTN_SELECT_INDEX_CHANGE } from "./ButtonGroup"; @@ -29,7 +30,8 @@ export default class TokenTab extends WalletBase { this.btnGroup.resetBtns() this.btnGroup.node.on(BTN_SELECT_INDEX_CHANGE, this.onTokenTypeChange.bind(this)) - this.showAllBtn(); + this.updateAllBtn(); + this.wallet.mainHandlers.on(WALLET_CHAIN_CHANGE, this.updateAllBtn.bind(this)) } onDestroy() { @@ -37,7 +39,7 @@ export default class TokenTab extends WalletBase { } // update (dt) {} - showAllBtn() { + updateAllBtn() { this.titles.length = 1 const chain = this.wallet.currentChain.id let nftData: any = DEFAULT_NFT_TYPES[chain] @@ -46,12 +48,14 @@ export default class TokenTab extends WalletBase { this.titles.push(key) } } + this.btnGroup.resetBtns() console.log('show all token tab: ', this.titles) for (let i = 0, l = this.titles.length; i < l; i++) { const btn = cc.instantiate(this.btnPreb) const btnM: TextBtn = btn.getComponent(TextBtn) 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.selected = i === 0 } diff --git a/assets/scenes/main.fire b/assets/scenes/main.fire index e440950..1cac2a7 100644 --- a/assets/scenes/main.fire +++ b/assets/scenes/main.fire @@ -7400,7 +7400,7 @@ }, "_position": { "__type__": "cc.Vec3", - "x": -358, + "x": -433, "y": 75, "z": 0 }, @@ -7488,7 +7488,7 @@ }, "_position": { "__type__": "cc.Vec3", - "x": -317, + "x": -392, "y": 64, "z": 0 },