| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import { _decorator, instantiate, Label, Node, ScrollView, size, Size } from 'cc';
- import { AppKernel } from '@scripts/app/AppKernel';
- import { UIView } from '@scripts/framework/ui/UIView';
- import { UIViewID } from '@scripts/define/UIDefine';
- import { GameItem } from './GameItem';
- import { addBtnClick } from '@scripts/utils/UIHelper';
- import { IGameInfo } from '@scripts/store/gameStore/data';
- import LoopList from '@scripts/components/loopList/LoopList';
- const { ccclass, property } = _decorator;
- @ccclass('HomeView')
- export class HomeView extends UIView {
- readonly viewId = UIViewID.HomeView;
-
- @property(Node)
- gameRoot: Node;
- @property(Node)
- btnMail: Node;
- @property(Node)
- btnStore: Node;
- @property(Node)
- gamePrefab: Node;
- @property(ScrollView)
- gameScroll: ScrollView;
- @property(Node)
- gameRender: Node;
- protected onCreate(): void | Promise<void> {
- // AppKernel.events.on('login:success', this.updateView, this);
- addBtnClick(this.btnMail, this.onBtnMailClick, this);
- addBtnClick(this.btnStore, this.onBtnStoreClick, this);
- }
- protected onOpen(_params: unknown): void | Promise<void> {
- this.updateView();
- }
- private updateView() {
- const mainStore = AppKernel.stores.mainStore;
- // this.gameRoot.destroyAllChildren();
- const gameStore = AppKernel.stores.gameStore;
- const gameList = gameStore.getGameList();
- // gameList.map(game => this.initGameItem(game));
- LoopList.ins<IGameInfo>("HomeGameList").init(this.gameScroll, this.gameRender, 20);
- LoopList.ins<IGameInfo>("HomeGameList").initData(gameList, this.gamePrefab, size(115, 140))
- }
- private async initGameItem(game: IGameInfo) {
- const gameNode = instantiate(this.gamePrefab).getComponent(GameItem);
- gameNode.node.setParent(this.gameRoot);
- gameNode.node.active = true;
- }
- private onBtnMailClick() {
- AppKernel.ui.open(UIViewID.MailView);
- }
- private onBtnStoreClick() {
- AppKernel.ui.open(UIViewID.StoreView);
- }
- }
|