ExchangeCodeViewImpl.ts
2.16 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
import { ExchangeCodeViewType, ExchangeCodeViewProps, ExchangeCodeView } from "../type/ExChangeCodeView";
import { CCPureView } from "../../../../common/classbase/CCViewBase";
import { RegView } from "../../PresenterCCViewFactory";
import { DummyLabel, DummyNode, DymmyEditBox } from "../../../../common/CCDummyObjects";
import { SDK } from "simba-sdk";
import { GameConstData } from "../../../../common/gameplay/gamedata/GameConstData";
const { ccclass, property } = cc._decorator;
@ccclass
@RegView(ExchangeCodeViewType, "prefab/ui/ExchangeCodeView")
export class ExchangeCodeViewImpl extends CCPureView<ExchangeCodeViewProps> implements ExchangeCodeView {
@property(cc.Label)
titlelbl: cc.Label = DummyLabel;
@property(cc.EditBox)
editbox: cc.EditBox = DymmyEditBox;
@property(cc.Node)
banner: cc.Node = DummyNode;
setContentTxt(title: string, content: string) {
this.titlelbl.string = title;
this.editbox.string = content;
}
onLoad() {
}
onCancleClickCallback() {
this._props.onActionClick(false);
this.showBanner(false);
this.close();
}
onOkClickCallback() {
this._props.onActionClick(true, this.editbox.string);
this.showBanner(false);
this.close();
}
showBanner(isShow: boolean) {
if (isShow) {
let info = SDK.systemInfo.displayInfo;
let aspect = info.windowSize.height / cc.view.getVisibleSize().height;
this.node.getComponent(cc.Widget).updateAlignment();
let _width = this.banner.width * aspect;
let _height = this.banner.height * aspect;
let _left = (info.windowSize.width - _width) * 0.5;
let _top = info.windowSize.height - _height;
let style = {
left: _left,
top: _top,
width: _width,
height: _height,
anchorX: 0.5,
anchorY: 1,
}
SDK.showBannerAd(style, GameConstData.GAME_CONST_BANNER_REFRESH_TIME);
} else {
SDK.hideBannerAd();
}
}
}