
import PanelCtrl from "../ctrls/panelCtrl";

export class AssistanceItem extends eui.Component{

    public nameLb:eui.Label;
    public icon:eui.Image;
    public maskRect:eui.Rect;
    constructor(friendData,index){
        super();
        this.skinName       = 'resource/skins/ui/AssistanceItem.exml';
    
        console.log('助力好友数据',friendData);
        
        if(friendData.avatar)
        {
            this.icon.source = friendData.avatar;
        }
        //小熊厨房好友
        let nickname = '';
        if(friendData.nickname)
        {
            //this.nameLb.text = friendData.nickname;
            // if(friendData.nickname.length > 6)
            // {
            //     nickname = friendData.nickname.substr(0,6) + "...";
            // }else{
            //     nickname = friendData.nickname;
            // }
            this.nameLb.text = friendData.nickname;
        }
        else
        {
            this.nameLb.text = '小熊厨房好友' + (index+1);
        }
        this.icon.mask = this.maskRect;

        this.addEventListener(egret.Event.COMPLETE, this.onSkinComplete, this);
        if (this.skin) {
            this.onSkinComplete();
        }
    }


    private onSkinComplete():void{
        this.removeEventListener(egret.Event.COMPLETE, this.onSkinComplete, this);
    }

    public removeEvent():void{
     
    }
}