PromptAlertDialogViewPresenter.ts 1.12 KB
import { ResUtils } from "simba-cc-resutils";
import { Presenter } from "../../../../common/classbase/PresenterBase";
import { RegPresenter } from "../../PresenterCCViewFactory";
import { PromptAlertDialogViewType, PromptAlertDialogViewProps, PromptAlertDialogView } from "../../view/type/PromptAlertDialogView";

@RegPresenter(PromptAlertDialogViewType)
export default class PromptAlertDialogViewPresenter extends Presenter<PromptAlertDialogViewProps, PromptAlertDialogView>{
    static uuid = "PromptAlertDialogView";
    private _viewProps: PromptAlertDialogViewProps;

    constructor() {
        super();
    }

    onOpen(props: PromptAlertDialogViewProps) {
        super.onOpen(props);
        this._viewProps = props;
        this.view.setProps(this._viewProps);
        this.onShow();
    }

    onShow() {
        super.onShow();
        this.setPromptConfig();
    }

    async setPromptConfig() {
        this.view.getIconSprite().spriteFrame = await ResUtils.loadRes(this._viewProps.iconSpritePath, cc.SpriteFrame);
        this.view.getContentLable().string = this._viewProps.contentLabel;
    }
}