DiscoverViewImpl.ts
3.6 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import { SDK } from "simba-sdk";
import { DummyButton, DummyLabel, DummyNode, DummySprite } from "../../../../common/CCDummyObjects";
import { CCPureView } from "../../../../common/classbase/CCViewBase";
import { ResUtils } from "simba-cc-resutils";
import { RegView } from "../../PresenterCCViewFactory";
import { DiscoverView, DiscoverViewProps, DiscoverViewType } from "../type/DiscoverView";
import { DiscoverItemType } from "../../../Enums";
const enum Tabs {
forum,
edit,
customerService,
productionTeam,
};
const { ccclass, property } = cc._decorator;
@ccclass
@RegView(DiscoverViewType, "prefab/ui/DiscoverView")
export class DiscoverViewImpl extends CCPureView<DiscoverViewProps> implements DiscoverView {
//#region editor bindings
// @property({ type: cc.Label, tooltip: "人物名字" })
// private manName: cc.Label = DummyLabel;
@property({ type: cc.Label, tooltip: "人物 ID" })
private manId: cc.Label = DummyLabel;
@property({ type: cc.Sprite, tooltip: "人物头像" })
private menSprite: cc.Sprite = DummySprite;
@property({ type: cc.Node, tooltip: "人物根结点" })
private infoRootNode: cc.Node = DummyNode;
@property({ type: cc.Button, tooltip: "论坛按钮" })
private forum: cc.Button = DummyButton;
onLoad() {
// this.bindProp("manName", this.manName, "string");
this.bindProp("manId", this.manId, "string");
this.bindProp("manIcon", async (value) => {
if (value != "")
this.menSprite.spriteFrame = await ResUtils.loadRes(value, cc.SpriteFrame);
});
this.infoRootNode.on(cc.Node.EventType.TOUCH_END, this.onTouchMainInfo, this);
}
createGameClubBtn = () => {
this.node.getComponent(cc.Widget).updateAlignment();
this.node.getComponent(cc.Layout).updateLayout();
let info = SDK.systemInfo.displayInfo;
let aspect = info.windowSize.height / cc.view.getVisibleSize().height;
this.node.getComponent(cc.Widget).updateAlignment();
let pos = this.forum.node.convertToWorldSpaceAR(cc.v2(0, 0));
pos.x += cc.view.getViewportRect().x / cc.view.getScaleX();
let xPos = pos.x * aspect;
let yPos = info.windowSize.height - pos.y * aspect;
let width = this.forum.node.width * aspect;
let height = this.forum.node.height * aspect;
let left = xPos - width / 2;
let top = yPos - height / 2;
// this.forum.node.active = false;
SDK.createGameClubButton({
type: "text",
text: "",
style: {
left: left,
top: top,
width: width,
height: height
},
icon: "green"
});
}
onForumCallback() {
}
onTabClick(target: cc.Button, data: string) {
switch (parseInt(data)) {
case Tabs.forum:
this._props.onItemClick(DiscoverItemType.Forum);
break;
case Tabs.edit:
this._props.onItemClick(DiscoverItemType.Settings);
break;
case Tabs.customerService:
this._props.onItemClick(DiscoverItemType.CustomerService);
break;
case Tabs.productionTeam:
this._props.onItemClick(DiscoverItemType.ProductionTeam);
break;
}
}
onPropsLoad(props: Readonly<DiscoverViewProps>) {
super.onPropsLoad(props);
}
onPropChange(key: Extract<keyof DiscoverViewProps, string>) {
super.onPropChange(key);
}
onTouchMainInfo = () => {
this._props.onCopyInfo();
}
}