6bc4c8b1-0f3e-4663-84cd-3d5670f40a40.js 5.09 KB
"use strict";
cc._RF.push(module, '6bc4cixDz5GY4TNPVZw9ApA', 'DatingEventViewPresenter');
// script/game/ui/presenter/DatingEventViewPresenter.ts

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DatingEventSubpresenter = void 0;
const PresenterBase_1 = require("../../../common/classbase/PresenterBase");
const DatingEventView_1 = require("../view/type/DatingEventView");
const PresenterCCViewFactory_1 = require("../PresenterCCViewFactory");
const DatingEventSubview_1 = require("../view/type/DatingEventSubview");
const GameModelManager_1 = require("../../model/GameModelManager");
const DatingEventSceneModel_1 = require("../../model/DatingEventSceneModel");
const UIManager_1 = require("../../../common/gameplay/managers/UIManager");
const DatingScenePresenter_1 = require("./DatingScenePresenter");
let DatingEventViewPresenter = /** @class */ (() => {
    let DatingEventViewPresenter = class DatingEventViewPresenter extends PresenterBase_1.Presenter {
        onOpen() {
            super.onOpen(undefined);
            this.checkRedDot();
        }
        onEnterForeground() {
            super.onEnterForeground();
            this.checkRedDot();
        }
        onShow() {
            super.onShow();
            this.checkRedDot();
        }
        checkRedDot() {
            let mainRedDot = false;
            for (let model of GameModelManager_1.GameModelManager.getMainDatingEventScenesModel()) {
                if (model.status === DatingEventSceneModel_1.DatingEventStatus.New || model.status === DatingEventSceneModel_1.DatingEventStatus.InProgress) {
                    mainRedDot = true;
                }
            }
            this.view.setProps({ mainEventRedDot: mainRedDot, extraEventRedDot: false });
        }
    };
    DatingEventViewPresenter.uuid = "DatingEventViewPresenter";
    DatingEventViewPresenter = __decorate([
        PresenterCCViewFactory_1.RegPresenter(DatingEventView_1.DatingEventViewType)
    ], DatingEventViewPresenter);
    return DatingEventViewPresenter;
})();
exports.default = DatingEventViewPresenter;
let DatingEventSubpresenter = /** @class */ (() => {
    let DatingEventSubpresenter = class DatingEventSubpresenter extends PresenterBase_1.Subpresenter {
        constructor() {
            super(...arguments);
            // private _items: DatingEventItemProps[];
            this._lineStyle = 0;
            this._modelMap = {};
        }
        sceneModelToViewModel(item) {
            this._modelMap[item.id] = item;
            return {
                key: item.id + "",
                title: item.config.name,
                date: item.config.date,
                time: item.config.time,
                status: item.status,
                coverImage: "textures/dating_event/cover/" + item.config.background,
                lineStyle: this._lineStyle
            };
        }
        refreshItems() {
            // if (!this._items) {
            if (this.view.name.indexOf("MainEvent") < 0)
                this._lineStyle = 1;
            let items = [];
            if (this.view.name.indexOf("MainEvent") === 0) {
                items = GameModelManager_1.GameModelManager.getMainDatingEventScenesModel().map(v => this.sceneModelToViewModel(v));
                if (items.length) {
                    items[items.length - 1].lineStyle = "none";
                }
            }
            this.view.setProps({
                items,
                onItemClick: (key) => {
                    console.log("start dating event", key);
                    UIManager_1.UIManager.pushPresenter(DatingScenePresenter_1.DatingScenePresenter, this._modelMap[key], true);
                }
            });
            // } else {
            //     this.view.updateProps({ items: [...this._items] });
            // }
        }
        onOwnerShow() {
            if (!this.view.isHidden) {
                this.refreshItems();
            }
        }
        onOwnerEnterForeground() {
            if (!this.view.isHidden) {
                this.refreshItems();
            }
        }
        onOpen() {
            super.onOpen();
            if (!this.view.isHidden) {
                this.refreshItems();
            }
        }
        onShow() {
            this.refreshItems();
        }
        onHide() {
        }
    };
    DatingEventSubpresenter = __decorate([
        PresenterCCViewFactory_1.RegSubpresenter(DatingEventSubview_1.DatingEventSubviewType)
    ], DatingEventSubpresenter);
    return DatingEventSubpresenter;
})();
exports.DatingEventSubpresenter = DatingEventSubpresenter;

cc._RF.pop();