CCMain+Swift.swift 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.standardAppearance = navBarAppearance
  19. self.navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
  20. } else {
  21. self.navigationController?.navigationBar.barStyle = .default
  22. self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
  23. self.navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
  24. self.navigationController?.navigationBar.barTintColor = NCBrandColor.sharedInstance.backgroundView
  25. self.navigationController?.navigationBar.tintColor = NCBrandColor.sharedInstance.brand
  26. self.navigationController?.navigationBar.shadowImage = nil
  27. self.navigationController?.navigationBar.setValue(false, forKey: "hidesShadow")
  28. }
  29. self.navigationController?.navigationBar.setNeedsLayout()
  30. } else {
  31. if #available(iOS 13.0, *) {
  32. let navBarAppearance = UINavigationBarAppearance()
  33. navBarAppearance.configureWithOpaqueBackground()
  34. navBarAppearance.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
  35. navBarAppearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
  36. navBarAppearance.backgroundColor = NCBrandColor.sharedInstance.backgroundView
  37. navBarAppearance.shadowColor = .clear
  38. navBarAppearance.shadowImage = UIImage()
  39. self.navigationController?.navigationBar.standardAppearance = navBarAppearance
  40. self.navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
  41. } else {
  42. self.navigationController?.navigationBar.barStyle = .default
  43. self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
  44. self.navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
  45. self.navigationController?.navigationBar.barTintColor = NCBrandColor.sharedInstance.backgroundView
  46. self.navigationController?.navigationBar.tintColor = NCBrandColor.sharedInstance.brand
  47. self.navigationController?.navigationBar.shadowImage = UIImage()
  48. self.navigationController?.navigationBar.setValue(true, forKey: "hidesShadow")
  49. }
  50. self.navigationController?.navigationBar.setNeedsLayout()
  51. }
  52. }
  53. }