|
|
@@ -2,6 +2,8 @@ import * as _ from 'lodash';
|
|
2
|
2
|
import { CommandsObserver } from '../events/CommandsObserver';
|
|
3
|
3
|
import { NativeCommandsSender } from '../adapters/NativeCommandsSender';
|
|
4
|
4
|
import { UniqueIdProvider } from '../adapters/UniqueIdProvider';
|
|
|
5
|
+import { Options } from '../interfaces/Options';
|
|
|
6
|
+import { Layout, LayoutRoot } from '../interfaces/Layout';
|
|
5
|
7
|
|
|
6
|
8
|
export class Commands {
|
|
7
|
9
|
constructor(
|
|
|
@@ -12,7 +14,7 @@ export class Commands {
|
|
12
|
14
|
private readonly uniqueIdProvider: UniqueIdProvider) {
|
|
13
|
15
|
}
|
|
14
|
16
|
|
|
15
|
|
- public setRoot(simpleApi) {
|
|
|
17
|
+ public setRoot(simpleApi: LayoutRoot) {
|
|
16
|
18
|
const input = _.cloneDeep(simpleApi);
|
|
17
|
19
|
const root = this.layoutTreeParser.parse(input.root);
|
|
18
|
20
|
this.layoutTreeCrawler.crawl(root);
|
|
|
@@ -35,7 +37,7 @@ export class Commands {
|
|
35
|
37
|
return result;
|
|
36
|
38
|
}
|
|
37
|
39
|
|
|
38
|
|
- public setDefaultOptions(options) {
|
|
|
40
|
+ public setDefaultOptions(options: Options) {
|
|
39
|
41
|
const input = _.cloneDeep(options);
|
|
40
|
42
|
this.layoutTreeCrawler.processOptions(input);
|
|
41
|
43
|
|
|
|
@@ -43,7 +45,7 @@ export class Commands {
|
|
43
|
45
|
this.commandsObserver.notify('setDefaultOptions', { options });
|
|
44
|
46
|
}
|
|
45
|
47
|
|
|
46
|
|
- public mergeOptions(componentId, options) {
|
|
|
48
|
+ public mergeOptions(componentId: string, options: Options) {
|
|
47
|
49
|
const input = _.cloneDeep(options);
|
|
48
|
50
|
this.layoutTreeCrawler.processOptions(input);
|
|
49
|
51
|
|
|
|
@@ -51,7 +53,7 @@ export class Commands {
|
|
51
|
53
|
this.commandsObserver.notify('mergeOptions', { componentId, options });
|
|
52
|
54
|
}
|
|
53
|
55
|
|
|
54
|
|
- public showModal(simpleApi) {
|
|
|
56
|
+ public showModal(simpleApi: Layout) {
|
|
55
|
57
|
const input = _.cloneDeep(simpleApi);
|
|
56
|
58
|
const layout = this.layoutTreeParser.parse(input);
|
|
57
|
59
|
this.layoutTreeCrawler.crawl(layout);
|
|
|
@@ -62,21 +64,21 @@ export class Commands {
|
|
62
|
64
|
return result;
|
|
63
|
65
|
}
|
|
64
|
66
|
|
|
65
|
|
- public dismissModal(componentId, mergeOptions?) {
|
|
|
67
|
+ public dismissModal(componentId, mergeOptions?: Options) {
|
|
66
|
68
|
const commandId = this.uniqueIdProvider.generate('dismissModal');
|
|
67
|
69
|
const result = this.nativeCommandsSender.dismissModal(commandId, componentId, mergeOptions);
|
|
68
|
70
|
this.commandsObserver.notify('dismissModal', { commandId, componentId, mergeOptions});
|
|
69
|
71
|
return result;
|
|
70
|
72
|
}
|
|
71
|
73
|
|
|
72
|
|
- public dismissAllModals(mergeOptions?) {
|
|
|
74
|
+ public dismissAllModals(mergeOptions?: Options) {
|
|
73
|
75
|
const commandId = this.uniqueIdProvider.generate('dismissAllModals');
|
|
74
|
76
|
const result = this.nativeCommandsSender.dismissAllModals(commandId, mergeOptions);
|
|
75
|
77
|
this.commandsObserver.notify('dismissAllModals', { commandId, mergeOptions });
|
|
76
|
78
|
return result;
|
|
77
|
79
|
}
|
|
78
|
80
|
|
|
79
|
|
- public push(componentId, simpleApi) {
|
|
|
81
|
+ public push(componentId: string, simpleApi: Layout) {
|
|
80
|
82
|
const input = _.cloneDeep(simpleApi);
|
|
81
|
83
|
|
|
82
|
84
|
const layout = this.layoutTreeParser.parse(input);
|
|
|
@@ -88,28 +90,28 @@ export class Commands {
|
|
88
|
90
|
return result;
|
|
89
|
91
|
}
|
|
90
|
92
|
|
|
91
|
|
- public pop(componentId, mergeOptions?) {
|
|
|
93
|
+ public pop(componentId: string, mergeOptions?: Options) {
|
|
92
|
94
|
const commandId = this.uniqueIdProvider.generate('pop');
|
|
93
|
95
|
const result = this.nativeCommandsSender.pop(commandId, componentId, mergeOptions);
|
|
94
|
96
|
this.commandsObserver.notify('pop', { commandId, componentId, mergeOptions });
|
|
95
|
97
|
return result;
|
|
96
|
98
|
}
|
|
97
|
99
|
|
|
98
|
|
- public popTo(componentId, mergeOptions?) {
|
|
|
100
|
+ public popTo(componentId: string, mergeOptions?: Options) {
|
|
99
|
101
|
const commandId = this.uniqueIdProvider.generate('popTo');
|
|
100
|
102
|
const result = this.nativeCommandsSender.popTo(commandId, componentId, mergeOptions);
|
|
101
|
103
|
this.commandsObserver.notify('popTo', { commandId, componentId, mergeOptions });
|
|
102
|
104
|
return result;
|
|
103
|
105
|
}
|
|
104
|
106
|
|
|
105
|
|
- public popToRoot(componentId, mergeOptions?) {
|
|
|
107
|
+ public popToRoot(componentId: string, mergeOptions?: Options) {
|
|
106
|
108
|
const commandId = this.uniqueIdProvider.generate('popToRoot');
|
|
107
|
109
|
const result = this.nativeCommandsSender.popToRoot(commandId, componentId, mergeOptions);
|
|
108
|
110
|
this.commandsObserver.notify('popToRoot', { commandId, componentId, mergeOptions });
|
|
109
|
111
|
return result;
|
|
110
|
112
|
}
|
|
111
|
113
|
|
|
112
|
|
- public setStackRoot(componentId, simpleApi) {
|
|
|
114
|
+ public setStackRoot(componentId: string, simpleApi: Layout) {
|
|
113
|
115
|
const input = _.cloneDeep(simpleApi);
|
|
114
|
116
|
|
|
115
|
117
|
const layout = this.layoutTreeParser.parse(input);
|
|
|
@@ -121,7 +123,7 @@ export class Commands {
|
|
121
|
123
|
return result;
|
|
122
|
124
|
}
|
|
123
|
125
|
|
|
124
|
|
- public showOverlay(simpleApi) {
|
|
|
126
|
+ public showOverlay(simpleApi: Layout) {
|
|
125
|
127
|
const input = _.cloneDeep(simpleApi);
|
|
126
|
128
|
|
|
127
|
129
|
const layout = this.layoutTreeParser.parse(input);
|
|
|
@@ -133,7 +135,7 @@ export class Commands {
|
|
133
|
135
|
return result;
|
|
134
|
136
|
}
|
|
135
|
137
|
|
|
136
|
|
- public dismissOverlay(componentId) {
|
|
|
138
|
+ public dismissOverlay(componentId: string) {
|
|
137
|
139
|
const commandId = this.uniqueIdProvider.generate('dismissOverlay');
|
|
138
|
140
|
const result = this.nativeCommandsSender.dismissOverlay(commandId, componentId);
|
|
139
|
141
|
this.commandsObserver.notify('dismissOverlay', { commandId, componentId });
|