1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #import "KSDragWindowManager.h"
- @implementation KSDragWindowManager
- + (instancetype)sharedManager {
- static KSDragWindowManager *manager;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- manager = [[KSDragWindowManager alloc] init];
- });
- return manager;
- }
- - (void)initDragWindow {
- _hasShowWindow = YES;
- CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
- CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
- self.dragWindow = [[KSDragWindow alloc] initWithFrame:CGRectMake(screenWidth - KSDragWindowWidth, screenHeight - KSDragWindowHeight - KSDragWindowHeightBottomSpace , KSDragWindowWidth, KSDragWindowHeight)];
- MJWeakSelf;
- [self.dragWindow clickAction:^(DRAG_ACTION action) {
- [weakSelf dragAction:action];
- }];
-
- if (@available(iOS 13.0, *)) {
- NSSet* windowScene = [UIApplication sharedApplication].connectedScenes;
- self.dragWindow.windowScene = windowScene.anyObject;
- }
- }
- - (void)dragAction:(DRAG_ACTION)action {
- switch (action) {
- case DRAG_ACTION_CANCEL:
- {
- [self resignDragWindow];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:@"muteLiveAudio" object:nil];
- }
- break;
- case DRAG_ACTION_CLICK:
- {
-
-
- [self resignDragWindow];
-
- [self.rootVC popToRootViewControllerAnimated:YES];
- }
- break;
- default:
- break;
- }
- }
- - (void)resignDragWindow {
- _hasShowWindow = NO;
- [self.dragWindow.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
- self.dragWindow.rootViewController = nil;
- [self.dragWindow resignKeyWindow];
- [self.dragWindow removeFromSuperview];
- _dragWindow = nil;
- }
- @end
|