AppCoordinator.swift 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*****************************************************************************
  2. * AppCoordinator.swift
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2018 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Carola Nitz <nitz.carola # gmail.com>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. @objc(VLCService)
  13. class Services: NSObject {
  14. @objc let medialibraryManager = VLCMediaLibraryManager()
  15. @objc let rendererDiscovererManager = VLCRendererDiscovererManager(presentingViewController: nil)
  16. }
  17. @objc class AppCoordinator: NSObject {
  18. private var childCoordinators: [NSObject] = []
  19. private var tabBarController: UITabBarController
  20. private var playerController: VLCPlayerDisplayController
  21. private var services = Services()
  22. @objc init(tabBarController: UITabBarController) {
  23. self.tabBarController = tabBarController
  24. self.playerController = VLCPlayerDisplayController(services: services)
  25. super.init()
  26. setupPlayerController()
  27. // Init the HTTP Server and clean its cache
  28. // FIXME: VLCHTTPUploaderController should perhaps be a service?
  29. VLCHTTPUploaderController.sharedInstance().cleanCache()
  30. }
  31. private func setupPlayerController() {
  32. tabBarController.addChildViewController(playerController)
  33. tabBarController.view.addSubview(playerController.view)
  34. playerController.view.layoutMargins = UIEdgeInsets(top: 0, left: 0, bottom: tabBarController.tabBar.frame.size.height, right: 0)
  35. playerController.didMove(toParentViewController: tabBarController)
  36. }
  37. @objc func start() {
  38. let tabbarCoordinator = VLCTabBarCoordinator(tabBarController: tabBarController, services: services)
  39. childCoordinators.append(tabbarCoordinator)
  40. }
  41. }