SentenceSelectorViewPresenter.ts
1.45 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
import { Presenter } from "../../../common/classbase/PresenterBase";
import { RegPresenter } from "../PresenterCCViewFactory";
import { SentenceSelectorView, SentenceSelectorViewProps, SentenceSelectorViewType } from "../view/type/SentenceSelectorView";
@RegPresenter(SentenceSelectorViewType)
export default class SentenceSelectorViewPresenter extends Presenter<SentenceSelectorViewProps, SentenceSelectorView> {
static uuid = "SentenceSelectorView";
private _viewProps: SentenceSelectorViewProps;
selectIndexEventCall: (index: number) => void;
constructor() {
super();
this._viewProps =
{
sentence: undefined,
backgroundpath: "",
clickcausehide: false,
onSelectIndexCallback: this.onSelectIndexCallback
};
}
onSelectIndexCallback = (index: number) => {
if (this.selectIndexEventCall != undefined) {
this.selectIndexEventCall(index);
this.view.close();
}
}
onOpen(props: SentenceSelectorViewProps) {
super.onOpen(props);
this.selectIndexEventCall = props.onSelectIndexCallback;
this._viewProps = { ...props, onSelectIndexCallback: this.onSelectIndexCallback };
this._view.setProps(this._viewProps);
}
onClose() {
super.onClose();
this._viewProps.sentence = undefined;
this._view.setProps(this._viewProps);
}
}