MessageEntryItem.ts
2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { MessageEntryItemProps } from "../type/MessageView";
import { DummyLabel, DummyNode, DummyRichText, DummySprite } from "../../../../common/CCDummyObjects";
import { ListItemImpl } from "../../baseview/impl/ListItemImpl";
import { ResUtils } from "simba-cc-resutils";
const { ccclass, property } = cc._decorator;
@ccclass
export class MessageEntryItemImpl extends ListItemImpl<MessageEntryItemProps> {
@property({ type: cc.RichText })
protected lastMsgLabel: cc.RichText = DummyRichText;
@property(cc.Sprite)
protected iconSprite: cc.Sprite = DummySprite;
@property(cc.Sprite)
protected nameSprite: cc.Sprite = DummySprite;
@property(cc.Node)
private addGraceBtnNode: cc.Node = DummyNode;
@property(cc.Node)
private addNode: cc.Node = DummyNode;
@property(cc.Label)
private graceLevel: cc.Label = DummyLabel;
@property(cc.Node)
redDotNode: cc.Node = DummyNode;
onLoad() {
this.bindProp("nameSpr", async (value) => {
if (value && "" !== value.trim()) {
this.nameSprite.spriteFrame = await ResUtils.loadRes(value, cc.SpriteFrame);
}
});
this.bindProp("lastMsg", this.lastMsgLabel, "string");
this.bindProp("redDot", this.redDotNode, "active");
this.bindProp("icons", async (value) => {
if (value.length == 1) {
this.iconSprite.spriteFrame = await ResUtils.loadRes(value[0], cc.SpriteFrame);
}
});
this.bindProp("level", (v) => {
this.graceLevel.string = v + "";
});
this.bindProp("isShowAddGrace", async (value) => {
this.addNode.active = value;
if (value) {
cc.tween(this.addGraceBtnNode)
.repeatForever(cc.tween()
.to(0.8, { scale: 1.15 }, { easing: 'sineInOut' })
.to(0.8, { scale: 1 }, { easing: 'sineInOut' }))
.start();
}
});
this.bindProp("isShowGrace", this.addGraceBtnNode, "active");
}
onAddGraceClickCallBack() {
this._props.addGraceClickCallBack(this._props.roleId);
}
}