-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathQueueITWaitingRoomView.m
100 lines (81 loc) · 3.23 KB
/
QueueITWaitingRoomView.m
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
#import <Foundation/Foundation.h>
#import "QueueITWaitingRoomView.h"
#import "QueueITWKViewController.h"
@interface QueueITWaitingRoomView ()
@property (nonatomic, weak) UIViewController* host;
@property (nonatomic, weak) QueueITWKViewController* currentWebView;
@property NSString* customerId;
@property NSString* eventId;
@property int delayInterval;
@end
@implementation QueueITWaitingRoomView
-(instancetype _Nonnull)initWithHost:(UIViewController *)host
customerId: (NSString* _Nonnull) customerId
eventId: (NSString * _Nonnull)eventId
{
if(self = [super init]) {
self.host = host;
self.customerId = customerId;
self.eventId = eventId;
}
return self;
}
-(void) show:(NSString* _Nonnull)queueUrl targetUrl:(NSString* _Nonnull)targetUrl
{
[self raiseQueueViewWillOpen];
QueueITWKViewController *queueWKVC = [[QueueITWKViewController alloc] initWithHost:self.host
queueUrl:queueUrl
eventTargetUrl:targetUrl
customerId:self.customerId
eventId:self.eventId];
queueWKVC.delegate = self;
if (@available(iOS 13.0, *)) {
[queueWKVC setModalPresentationStyle: UIModalPresentationFullScreen];
}
if (self.delayInterval > 0) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(self.delayInterval * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.host presentViewController:queueWKVC animated:YES completion:^{
self.currentWebView = queueWKVC;
[self.delegate notifyViewQueueDidAppear:self ];
}];
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
[self.host presentViewController:queueWKVC animated:YES completion:^{
self.currentWebView = queueWKVC;
[self.delegate notifyViewQueueDidAppear:self ];
}];
});
}
}
-(void)close:(void (^ __nullable)(void))onComplete
{
if(self.currentWebView!=nil){
dispatch_async(dispatch_get_main_queue(), ^{
[self.currentWebView close: onComplete];
});
}
}
- (void)raiseQueueViewWillOpen {
[self.delegate notifyViewQueueWillOpen:self];
}
-(void)setViewDelay:(int)delayInterval {
self.delayInterval = delayInterval;
}
-(void) notifyViewControllerUserExited {
[self.delegate notifyViewUserExited:self];
}
-(void) notifyViewControllerClosed {
[self.delegate notifyViewUserClosed:self];
}
-(void) notifyViewControllerSessionRestart {
[self.delegate notifyViewSessionRestart:self];
}
-(void) notifyViewControllerQueuePassed:(NSString *)queueToken {
QueuePassedInfo* queuePassedInfo = [[QueuePassedInfo alloc] initWithQueueitToken:queueToken];
[self.delegate waitingRoomView:self notifyViewPassedQueue:queuePassedInfo];
}
-(void)notifyViewControllerPageUrlChanged:(NSString* _Nullable) urlString {
[self.delegate waitingRoomView:self notifyViewUpdatePageUrl:urlString];
}
@end