FLEXManager.m 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // FLEXManager.m
  3. // Flipboard
  4. //
  5. // Created by Ryan Olson on 4/4/14.
  6. // Copyright (c) 2014 Flipboard. All rights reserved.
  7. //
  8. #import "FLEXManager.h"
  9. #import "FLEXExplorerViewController.h"
  10. #import "FLEXWindow.h"
  11. @interface FLEXManager () <FLEXWindowEventDelegate, FLEXExplorerViewControllerDelegate>
  12. @property (nonatomic, strong) FLEXWindow *explorerWindow;
  13. @property (nonatomic, strong) FLEXExplorerViewController *explorerViewController;
  14. @end
  15. @implementation FLEXManager
  16. + (instancetype)sharedManager
  17. {
  18. static FLEXManager *sharedManager = nil;
  19. static dispatch_once_t onceToken;
  20. dispatch_once(&onceToken, ^{
  21. sharedManager = [[[self class] alloc] init];
  22. });
  23. return sharedManager;
  24. }
  25. - (instancetype)init
  26. {
  27. self = [super init];
  28. if (self) {
  29. self.explorerWindow = [[FLEXWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  30. self.explorerWindow.eventDelegate = self;
  31. self.explorerViewController = [[FLEXExplorerViewController alloc] init];
  32. self.explorerViewController.delegate = self;
  33. self.explorerWindow.rootViewController = self.explorerViewController;
  34. [self.explorerWindow addSubview:self.explorerViewController.view];
  35. }
  36. return self;
  37. }
  38. - (void)showExplorer
  39. {
  40. self.explorerWindow.hidden = NO;
  41. }
  42. - (void)hideExplorer
  43. {
  44. self.explorerWindow.hidden = YES;
  45. }
  46. - (BOOL)isHidden
  47. {
  48. return self.explorerWindow.isHidden;
  49. }
  50. #pragma mark - FLEXWindowEventDelegate
  51. - (BOOL)shouldHandleTouchAtPoint:(CGPoint)pointInWindow
  52. {
  53. // Ask the explorer view controller
  54. return [self.explorerViewController shouldReceiveTouchAtWindowPoint:pointInWindow];
  55. }
  56. #pragma mark - FLEXExplorerViewControllerDelegate
  57. - (void)explorerViewControllerDidFinish:(FLEXExplorerViewController *)explorerViewController
  58. {
  59. [self hideExplorer];
  60. }
  61. @end