NCRichWorkspace.swift 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // NCRichWorkspace.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 09/01/2020.
  6. // Copyright © 2020 TWS. All rights reserved.
  7. //
  8. import Foundation
  9. @objc class NCViewRichWorkspace: UIView {
  10. @IBOutlet weak var webView: WKWebView!
  11. required init?(coder: NSCoder) {
  12. super.init(coder: coder)
  13. NotificationCenter.default.addObserver(self, selector: #selector(self.changeTheming), name: NSNotification.Name(rawValue: "changeTheming"), object: nil)
  14. self.backgroundColor = NCBrandColor.sharedInstance.brand;
  15. }
  16. @objc func changeTheming() {
  17. self.backgroundColor = NCBrandColor.sharedInstance.brand;
  18. }
  19. @objc func setRichWorkspaceText(_ richWorkspace: String?) {
  20. let html = "<h2><span style=\"color: #000000;\">" + richWorkspace! + "</span></h2>"
  21. webView.loadHTMLString(html, baseURL: Bundle.main.bundleURL)
  22. webView.isUserInteractionEnabled = false
  23. }
  24. }
  25. @objc class NCRichWorkspaceViewTouch: UIView {
  26. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  27. var startPosition: CGPoint?
  28. var originalHeight: CGFloat = 0
  29. let minHeight: CGFloat = 0
  30. let maxHeight: CGFloat = UIScreen.main.bounds.size.height/3
  31. required init?(coder: NSCoder) {
  32. super.init(coder: coder)
  33. self.backgroundColor = NCBrandColor.sharedInstance.separator
  34. }
  35. /*
  36. override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
  37. return false
  38. }
  39. override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
  40. let touch = touches.first
  41. startPosition = touch?.location(in: self)
  42. originalHeight = self.frame.height
  43. }
  44. override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
  45. let touch = touches.first
  46. let endPosition = touch?.location(in: self)
  47. let difference = endPosition!.y - startPosition!.y
  48. if let viewRichWorkspace = appDelegate.activeMain.tableView.tableHeaderView {
  49. let differenceHeight = viewRichWorkspace.frame.height + difference
  50. if differenceHeight <= minHeight {
  51. CCUtility.setRichWorkspaceHeight(minHeight)
  52. } else if differenceHeight >= maxHeight {
  53. CCUtility.setRichWorkspaceHeight(maxHeight)
  54. } else {
  55. CCUtility.setRichWorkspaceHeight(differenceHeight)
  56. }
  57. appDelegate.activeMain.setTableViewHeader()
  58. }
  59. }
  60. override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
  61. // appDelegate.activeMain.tableView.reloadData()
  62. }
  63. */
  64. }