GuideViewPresenter.ts 1.19 KB
import { Presenter } from "../../../common/classbase/PresenterBase";
import { DirectionType } from "../../Enums";
import { RegPresenter } from "../PresenterCCViewFactory";
import { GuideView, GuideViewProps, GuideViewType } from "../view/type/GuideView";
export interface GuideViewParamModel {
    x: number;
    y: number;
    w: number;
    h: number;
    d: DirectionType;
    call?: () => void;
}

@RegPresenter(GuideViewType)
export default class GuideViewPresenter extends Presenter<GuideViewParamModel, GuideView>{
    static uuid = "GuideViewPresenter";
    private _viewProps: GuideViewProps;
    private _callFunc?: () => void;

    constructor() {
        super();
        this._viewProps = {
            clickCallFunc: this.onGuideClick
        };
    }

    onOpen(param: GuideViewParamModel) {
        super.onOpen(param);
        this._callFunc = param.call;
        this.view.setGuideInfo(param.x, param.y, param.w, param.h, param.d);
        this.view.setProps(this._viewProps);
    }

    onGuideClick = () => {
        this.view.close();
        if (this._callFunc) {
            this._callFunc();
        }
        this._callFunc = undefined;
    }

    onClose() {
        super.onClose();
    }
}