SinInDayitemImpl.ts
1.84 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
67
68
import { DummyLabel, DummySprite, DummyNode } from "../../../../common/CCDummyObjects";
import { SininDayItemProps } from "../type/SininSevenDayView";
import { ResUtils } from "../../../../common/utils/ResUtils";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SininDayItemImpl extends cc.Component {
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
private _viewProps: SininDayItemProps =
{
key: "",
titlecontent: "",
itemicon: "",
number: "",
itemmask: true
};
@property(cc.Label)
item_title: cc.Label = DummyLabel;
@property(cc.Sprite)
item_icon: cc.Sprite = DummySprite;
@property(cc.Label)
number: cc.Label = DummyLabel;
@property(cc.Node)
item_mask: cc.Node = DummyNode;
setSininDayItem(item: SininDayItemProps) {
if (this._viewProps.key != item.key) {
this._viewProps.key = item.key;
}
if (this._viewProps.titlecontent != item.titlecontent) {
this._viewProps.titlecontent = item.titlecontent;
this.item_title.string = item.titlecontent;
}
if (this._viewProps.itemicon != item.itemicon) {
ResUtils.loadRes<cc.SpriteFrame>(item.itemicon, cc.SpriteFrame).then((value) => {
this.item_icon.spriteFrame = value;
});
this._viewProps.itemicon = item.itemicon;
}
if (this._viewProps.number != item.number) {
this.number.string = item.number;
this._viewProps.number = item.number;
}
if (this._viewProps.itemmask != item.itemmask) {
this.item_mask.active = item.itemmask;
this._viewProps.itemmask = item.itemmask;
}
}
// update (dt) {}
}