NCUserStatus.swift 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. //
  2. // NCUserStatus.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 25/05/21.
  6. // Copyright © 2021 Marino Faggiana. All rights reserved.
  7. //
  8. //
  9. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  10. //
  11. // This program is free software: you can redistribute it and/or modify
  12. // it under the terms of the GNU General Public License as published by
  13. // the Free Software Foundation, either version 3 of the License, or
  14. // (at your option) any later version.
  15. //
  16. // This program is distributed in the hope that it will be useful,
  17. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. // GNU General Public License for more details.
  20. //
  21. // You should have received a copy of the GNU General Public License
  22. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. //
  24. import UIKit
  25. import Foundation
  26. import NCCommunication
  27. class NCUserStatus: UIViewController {
  28. @IBOutlet weak var onlineButton: UIButton!
  29. @IBOutlet weak var onlineImage: UIImageView!
  30. @IBOutlet weak var onlineLabel: UILabel!
  31. @IBOutlet weak var awayButton: UIButton!
  32. @IBOutlet weak var awayImage: UIImageView!
  33. @IBOutlet weak var awayLabel: UILabel!
  34. @IBOutlet weak var dndButton: UIButton!
  35. @IBOutlet weak var dndImage: UIImageView!
  36. @IBOutlet weak var dndLabel: UILabel!
  37. @IBOutlet weak var dndDescrLabel: UILabel!
  38. @IBOutlet weak var invisibleButton: UIButton!
  39. @IBOutlet weak var invisibleImage: UIImageView!
  40. @IBOutlet weak var invisibleLabel: UILabel!
  41. @IBOutlet weak var invisibleDescrLabel: UILabel!
  42. @IBOutlet weak var statusMessageLabel: UILabel!
  43. // MARK: - View Life Cycle
  44. override func viewDidLoad() {
  45. super.viewDidLoad()
  46. onlineButton.layer.cornerRadius = 10
  47. onlineButton.layer.masksToBounds = true
  48. //onlineLabel.layer.borderWidth = 0.5
  49. //onlineLabel.layer.borderColor = NCBrandColor.shared.brand.cgColor
  50. let onLine = NCUtility.shared.getUserStatus(userIcon: nil, userStatus: "online", userMessage: nil)
  51. onlineImage.image = onLine.onlineStatus
  52. onlineLabel.text = onLine.statusMessage
  53. onlineLabel.textColor = NCBrandColor.shared.label
  54. awayButton.layer.cornerRadius = 10
  55. awayButton.layer.masksToBounds = true
  56. //onlineLabel.layer.borderWidth = 0.5
  57. //onlineLabel.layer.borderColor = NCBrandColor.shared.brand.cgColor
  58. let away = NCUtility.shared.getUserStatus(userIcon: nil, userStatus: "away", userMessage: nil)
  59. awayImage.image = away.onlineStatus
  60. awayLabel.text = away.statusMessage
  61. awayLabel.textColor = NCBrandColor.shared.label
  62. dndButton.layer.cornerRadius = 10
  63. dndButton.layer.masksToBounds = true
  64. //onlineLabel.layer.borderWidth = 0.5
  65. //onlineLabel.layer.borderColor = NCBrandColor.shared.brand.cgColor
  66. let dnd = NCUtility.shared.getUserStatus(userIcon: nil, userStatus: "dnd", userMessage: nil)
  67. dndImage.image = dnd.onlineStatus
  68. dndLabel.text = dnd.statusMessage
  69. dndLabel.textColor = NCBrandColor.shared.label
  70. dndDescrLabel.text = dnd.descriptionMessage
  71. dndDescrLabel.textColor = .darkGray
  72. invisibleButton.layer.cornerRadius = 10
  73. invisibleButton.layer.masksToBounds = true
  74. //onlineLabel.layer.borderWidth = 0.5
  75. //onlineLabel.layer.borderColor = NCBrandColor.shared.brand.cgColor
  76. let offline = NCUtility.shared.getUserStatus(userIcon: nil, userStatus: "offline", userMessage: nil)
  77. invisibleImage.image = offline.onlineStatus
  78. invisibleLabel.text = offline.statusMessage
  79. invisibleLabel.textColor = NCBrandColor.shared.label
  80. invisibleDescrLabel.text = offline.descriptionMessage
  81. invisibleDescrLabel.textColor = .darkGray
  82. statusMessageLabel.text = NSLocalizedString("_status_message_", comment: "")
  83. statusMessageLabel.textColor = NCBrandColor.shared.label
  84. }
  85. }
  86. /*
  87. @available(iOS 13.0, *)
  88. @available(iOS 13.0, *)
  89. @objc class NCUserStatusViewController: NSObject {
  90. @objc func makeUserStatusUI() -> UIViewController
  91. NCCommunication.shared.getUserStatusPredefinedStatuses { (account, userStatuses, errorCode, errorDescription) in
  92. if errorCode == 0 {
  93. if let userStatuses = userStatuses {
  94. NCManageDatabase.shared.addUserStatus(userStatuses, account: account, predefined: true)
  95. }
  96. }
  97. }
  98. NCCommunication.shared.getUserStatusRetrieveStatuses(limit: 1000, offset: 0, customUserAgent: nil, addCustomHeaders: nil) { (account, userStatuses, errorCode, errorDescription) in
  99. if errorCode == 0 {
  100. if let userStatuses = userStatuses {
  101. NCManageDatabase.shared.addUserStatus(userStatuses, account: account, predefined: false)
  102. }
  103. }
  104. }
  105. //let userStatus = NCUserStatus()
  106. //details.shipName = name
  107. return
  108. }
  109. }
  110. */