|
@@ -7,12 +7,16 @@
|
7
|
7
|
@implementation RNNCommandsHandler {
|
8
|
8
|
RNNControllerFactory *_controllerFactory;
|
9
|
9
|
RNNStore *_store;
|
|
10
|
+ RNNNavigationStackManager* _navigationStackManager;
|
|
11
|
+ RNNModalManager* _modalManager;
|
10
|
12
|
}
|
11
|
13
|
|
12
|
14
|
-(instancetype) initWithStore:(RNNStore*)store controllerFactory:(RNNControllerFactory*)controllerFactory {
|
13
|
15
|
self = [super init];
|
14
|
16
|
_store = store;
|
15
|
17
|
_controllerFactory = controllerFactory;
|
|
18
|
+ _navigationStackManager = [[RNNNavigationStackManager alloc] initWithStore:_store];
|
|
19
|
+ _modalManager = [[RNNModalManager alloc] initWithStore:_store];
|
16
|
20
|
return self;
|
17
|
21
|
}
|
18
|
22
|
|
|
@@ -28,42 +32,29 @@
|
28
|
32
|
|
29
|
33
|
-(void) push:(NSString*)containerId layout:(NSDictionary*)layout {
|
30
|
34
|
[self assertReady];
|
31
|
|
-
|
32
|
35
|
UIViewController *newVc = [_controllerFactory createLayoutAndSaveToStore:layout];
|
33
|
|
-
|
34
|
|
- // find on who to push
|
35
|
|
- UIViewController *vc = [_store findContainerForId:containerId];
|
36
|
|
-
|
37
|
|
- // do the actual pushing
|
38
|
|
- [[[RNNNavigationStackManager alloc] initWithStore:_store] push:newVc onTop:vc animated:YES];
|
|
36
|
+ [_navigationStackManager push:newVc onTop:containerId];
|
39
|
37
|
}
|
40
|
38
|
|
41
|
39
|
-(void) pop:(NSString*)containerId {
|
42
|
40
|
[self assertReady];
|
43
|
|
-
|
44
|
|
- // find who to pop
|
45
|
|
- UIViewController *vc = [_store findContainerForId:containerId];
|
46
|
|
-
|
47
|
|
- // do the popping
|
48
|
|
- [[[RNNNavigationStackManager alloc] initWithStore:_store] pop:vc animated:YES];
|
49
|
|
- [_store removeContainer:containerId];
|
|
41
|
+ [_navigationStackManager pop:containerId];
|
50
|
42
|
}
|
51
|
43
|
|
52
|
44
|
-(void) showModal:(NSDictionary*)layout {
|
53
|
45
|
[self assertReady];
|
54
|
|
-
|
55
|
46
|
UIViewController *newVc = [_controllerFactory createLayoutAndSaveToStore:layout];
|
56
|
|
- [[[RNNModalManager alloc] initWithStore:_store] showModal:newVc];
|
|
47
|
+ [_modalManager showModal:newVc];
|
57
|
48
|
}
|
58
|
49
|
|
59
|
50
|
-(void) dismissModal:(NSString*)containerId {
|
60
|
51
|
[self assertReady];
|
61
|
|
- [[[RNNModalManager alloc] initWithStore:_store] dismissModal:containerId];
|
|
52
|
+ [_modalManager dismissModal:containerId];
|
62
|
53
|
}
|
63
|
54
|
|
64
|
55
|
-(void) dismissAllModals {
|
65
|
56
|
[self assertReady];
|
66
|
|
- [[[RNNModalManager alloc] initWithStore:_store] dismissAllModals];
|
|
57
|
+ [_modalManager dismissAllModals];
|
67
|
58
|
}
|
68
|
59
|
|
69
|
60
|
#pragma mark - private
|