dd21d7c7-1962-4dc5-a7f7-11c4893c4ce1.js 5.29 KB
"use strict";
cc._RF.push(module, 'dd21dfHGWJNxaf3EcSJPEzh', 'GiftListSubviewImpl');
// script/game/ui/view/impl/message/GiftListSubviewImpl.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.GiftListSubviewImpl = void 0;
const PresenterCCViewFactory_1 = require("../../../PresenterCCViewFactory");
const GiftListSubview_1 = require("../../type/GiftListSubview");
const ListSubviewImpl_1 = require("../../../baseview/impl/ListSubviewImpl");
const GiftListItemImpl_1 = require("./GiftListItemImpl");
const simba_cc_resutils_1 = require("simba-cc-resutils");
const CCDummyObjects_1 = require("../../../../../common/CCDummyObjects");
const { ccclass, property } = cc._decorator;
let GiftListSubviewImpl = /** @class */ (() => {
    let GiftListSubviewImpl = class GiftListSubviewImpl extends ListSubviewImpl_1.ListSubviewImpl {
        constructor() {
            super(...arguments);
            //#region editor bindings
            this.giftButton = CCDummyObjects_1.DummyButton;
            this._touchMoved = false;
        }
        onSendGiftClick() {
            this._props.onSendGift();
        }
        async createListItemView() {
            let node = await simba_cc_resutils_1.ResUtils.createWithPrefab("prefab/ui/message/GiftListItem");
            return node.getComponent(GiftListItemImpl_1.GiftListItemImpl);
        }
        onLoad() {
            this.giftButton.interactable = false;
        }
        onPropChange(key) {
            super.onPropChange(key);
            let hasSelect = false;
            if (key === "items") {
                for (let item of this._props.items) {
                    if (item.select) {
                        hasSelect = true;
                        break;
                    }
                }
            }
            this.giftButton.interactable = hasSelect;
        }
        onEnable() {
            this._registerNodeEvent();
        }
        onDisable() {
            this._unregisterNodeEvent();
        }
        _registerNodeEvent() {
            this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this);
            this.node.on(cc.Node.EventType.TOUCH_MOVE, this._onTouchMove, this);
            this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this);
            // this.node.on(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancel, this);
            // (this.node as any)._touchListener.swallowTouches = false;
        }
        _unregisterNodeEvent() {
            this.node.off(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this);
            this.node.off(cc.Node.EventType.TOUCH_MOVE, this._onTouchMove, this);
            this.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this);
            // this.node.off(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancel, this);
        }
        _onTouchBegan(event) {
            // this._startPos = event.touch.getLocation().clone();
            // this._touchMoved = false;
        }
        _onTouchMove(event) {
            // if (this._touchMoved) return;
            // let pos = event.touch.getLocation().clone();
            // let diffX = this._startPos.x - pos.x;
            // let diffY = this._startPos.y - pos.y;
            // if (diffX * diffX + diffY * diffY > 25) {
            //     this._touchMoved = true;
            // }
        }
        _onTouchEnded(event) {
            // if (!this._touchMoved) {
            this.hide();
            // event.stopPropagation();
            // }
        }
        getPannelHeight() {
            return this.node.children[0].height;
        }
        hide() {
            this.node.children[1].active = true;
            let node = this.node.children[0];
            node.stopAllActions();
            node.runAction(cc.sequence(cc.moveBy(0.3, 0, -node.height), cc.callFunc(() => {
                super.hide();
            })));
        }
        show() {
            super.show();
            this.node.opacity = 0;
            this.node.children[1].active = true;
            this.scheduleOnce(() => {
                this.node.opacity = 255;
                let node = this.node.children[0];
                node.stopAllActions();
                node.y = -this.node.height / 2 - node.height;
                node.runAction(cc.sequence(cc.moveBy(0.3, 0, node.height), cc.callFunc(() => {
                    this.node.children[1].active = false;
                })));
            });
        }
    };
    __decorate([
        property(cc.Button)
    ], GiftListSubviewImpl.prototype, "giftButton", void 0);
    GiftListSubviewImpl = __decorate([
        ccclass,
        PresenterCCViewFactory_1.RegSubview(GiftListSubview_1.GiftListSubviewType)
    ], GiftListSubviewImpl);
    return GiftListSubviewImpl;
})();
exports.GiftListSubviewImpl = GiftListSubviewImpl;

cc._RF.pop();