CCMain+Swift.swift 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // CCMain+Swift.swift
  3. // Nextcloud
  4. //
  5. // Created by Philippe Weidmann on 24.04.20.
  6. // Copyright © 2020 Marino Faggiana. All rights reserved.
  7. //
  8. import Foundation
  9. extension CCMain {
  10. @objc func updateNavBarShadow(_ scrollView: UIScrollView, force: Bool) {
  11. if (scrollView.contentOffset.y > self.viewRichWorkspace.topView.frame.size.height || self.searchController.isActive || force) {
  12. if #available(iOS 13.0, *) {
  13. let navBarAppearance = UINavigationBarAppearance()
  14. navBarAppearance.configureWithOpaqueBackground()
  15. navBarAppearance.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
  16. navBarAppearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
  17. navBarAppearance.backgroundColor = NCBrandColor.sharedInstance.backgroundView
  18. self.navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
  19. navBarAppearance.backgroundColor = NCBrandColor.sharedInstance.tabBar
  20. self.navigationController?.navigationBar.standardAppearance = navBarAppearance
  21. } else {
  22. self.navigationController?.navigationBar.barStyle = .default
  23. self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
  24. self.navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
  25. self.navigationController?.navigationBar.barTintColor = NCBrandColor.sharedInstance.backgroundView
  26. self.navigationController?.navigationBar.tintColor = NCBrandColor.sharedInstance.brand
  27. self.navigationController?.navigationBar.shadowImage = nil
  28. self.navigationController?.navigationBar.setValue(false, forKey: "hidesShadow")
  29. }
  30. self.navigationController?.navigationBar.setNeedsLayout()
  31. } else {
  32. if #available(iOS 13.0, *) {
  33. let navBarAppearance = UINavigationBarAppearance()
  34. navBarAppearance.configureWithOpaqueBackground()
  35. navBarAppearance.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
  36. navBarAppearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
  37. navBarAppearance.backgroundColor = NCBrandColor.sharedInstance.backgroundView
  38. navBarAppearance.shadowColor = .clear
  39. navBarAppearance.shadowImage = UIImage()
  40. self.navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
  41. navBarAppearance.backgroundColor = NCBrandColor.sharedInstance.tabBar
  42. self.navigationController?.navigationBar.standardAppearance = navBarAppearance
  43. } else {
  44. self.navigationController?.navigationBar.barStyle = .default
  45. self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
  46. self.navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
  47. self.navigationController?.navigationBar.barTintColor = NCBrandColor.sharedInstance.backgroundView
  48. self.navigationController?.navigationBar.tintColor = NCBrandColor.sharedInstance.brand
  49. self.navigationController?.navigationBar.shadowImage = UIImage()
  50. self.navigationController?.navigationBar.setValue(true, forKey: "hidesShadow")
  51. }
  52. self.navigationController?.navigationBar.setNeedsLayout()
  53. }
  54. }
  55. }