MessageViewImpl.ts 1.6 KB
import { MessageEntryItemProps, MessageViewProps, MessageViewType } from "../type/MessageView";
import { ResUtils } from "simba-cc-resutils";
import { MessageEntryItemImpl } from "./MessageEntryItem";
import { ListViewImpl } from "../../baseview/impl/ListViewImpl";
import { RegView } from "../../PresenterCCViewFactory";
import { GameModelManager } from "../../../model/GameModelManager";
import { DummyNode } from "../../../../common/CCDummyObjects";

const { ccclass, property } = cc._decorator;

@ccclass
@RegView(MessageViewType, "prefab/ui/MessageView")
export class MessageViewImpl extends ListViewImpl<MessageEntryItemProps, MessageViewProps> {

    @property(cc.Node)
    plotStopTipBtnNode: cc.Node = DummyNode;

    async createListItemView() {
        let node = await ResUtils.createWithPrefab("prefab/ui/message/MessageEntryItem");
        return node.getComponent(MessageEntryItemImpl);
    }

    onLoad() {
        super.onLoad();

        this.bindProp("isShowPlotStopTipBtn", (value) => {
            this.plotStopTipBtnNode.active = value;
        });
    }

    getItemNode = (k: string): cc.Node | undefined => {
        let ret: cc.Node | undefined = undefined;
        let v = this._itemViews[k];
        if (v) {
            ret = v.node;
            ret.getComponent(cc.Widget).updateAlignment();
        }
        return ret;
    }

    onRefreshListEnd() {
        this.scrollView.node.getComponent(cc.Widget).updateAlignment();
        this.contentLayout.updateLayout();
        GameModelManager.CheckMsgGuide.emit();
    }

    onPlotStopTipBtnCallback() {
        this._props.PlotStopTipBtnCallback();
    }
}