NCMoreAppSuggestionsCell.swift 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // NCMoreAppSuggestionsCell.swift
  3. // Nextcloud
  4. //
  5. // Created by Milen on 14.06.23.
  6. // Copyright © 2023 Marino Faggiana. All rights reserved.
  7. //
  8. import Foundation
  9. import SafariServices
  10. class NCMoreAppSuggestionsCell: BaseNCMoreCell {
  11. @IBOutlet weak var talkView: UIStackView!
  12. @IBOutlet weak var notesView: UIStackView!
  13. @IBOutlet weak var moreAppsView: UIStackView!
  14. static let reuseIdentifier = "NCMoreAppSuggestionsCell"
  15. weak var delegate: NCMoreAppSuggestionsCellDelegate?
  16. static func fromNib() -> UINib {
  17. return UINib(nibName: "NCMoreAppSuggestionsCell", bundle: nil)
  18. }
  19. override func awakeFromNib() {
  20. super.awakeFromNib()
  21. backgroundColor = .clear
  22. talkView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(talkTapped)))
  23. notesView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(notesTapped)))
  24. moreAppsView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(moreAppsTapped)))
  25. }
  26. @objc func talkTapped() {
  27. guard let url = URL(string: NCGlobal.shared.talkSchemeUrl) else { return }
  28. if UIApplication.shared.canOpenURL(url) {
  29. UIApplication.shared.open(url)
  30. } else {
  31. guard let url = URL(string: NCGlobal.shared.talkAppStoreUrl) else { return }
  32. UIApplication.shared.open(url)
  33. }
  34. }
  35. @objc func notesTapped() {
  36. guard let url = URL(string: NCGlobal.shared.notesSchemeUrl) else { return }
  37. if UIApplication.shared.canOpenURL(url) {
  38. UIApplication.shared.open(url)
  39. } else {
  40. guard let url = URL(string: NCGlobal.shared.notesAppStoreUrl) else { return }
  41. UIApplication.shared.open(url)
  42. }
  43. }
  44. @objc func moreAppsTapped() {
  45. delegate?.moreAppsTapped()
  46. }
  47. }
  48. protocol NCMoreAppSuggestionsCellDelegate: AnyObject {
  49. func moreAppsTapped()
  50. }