NCSectionFirstHeaderEmptyData.swift 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // NCSectionFirstHeaderEmptyData.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 09/10/2018.
  6. // Copyright © 2018 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. import UIKit
  24. import MarkdownKit
  25. import RealmSwift
  26. protocol NCSectionFirstHeaderEmptyDataDelegate: AnyObject {
  27. }
  28. class NCSectionFirstHeaderEmptyData: UICollectionReusableView {
  29. @IBOutlet weak var viewTransfer: UIView!
  30. @IBOutlet weak var viewTransferHeightConstraint: NSLayoutConstraint!
  31. @IBOutlet weak var imageTransfer: UIImageView!
  32. @IBOutlet weak var labelTransfer: UILabel!
  33. @IBOutlet weak var progressTransfer: UIProgressView!
  34. @IBOutlet weak var transferSeparatorBottom: UIView!
  35. @IBOutlet weak var transferSeparatorBottomHeightConstraint: NSLayoutConstraint!
  36. @IBOutlet weak var emptyImage: UIImageView!
  37. @IBOutlet weak var emptyTitle: UILabel!
  38. @IBOutlet weak var emptyDescription: UILabel!
  39. weak var delegate: NCSectionFirstHeaderEmptyDataDelegate?
  40. override func awakeFromNib() {
  41. super.awakeFromNib()
  42. initHeader()
  43. }
  44. override func prepareForReuse() {
  45. super.prepareForReuse()
  46. initHeader()
  47. }
  48. func initHeader() {
  49. viewTransferHeightConstraint.constant = 0
  50. viewTransfer.isHidden = true
  51. imageTransfer.tintColor = NCBrandColor.shared.iconImageColor
  52. imageTransfer.image = NCUtility().loadImage(named: "icloud.and.arrow.up")
  53. progressTransfer.progress = 0
  54. progressTransfer.tintColor = NCBrandColor.shared.iconImageColor
  55. progressTransfer.trackTintColor = NCBrandColor.shared.customer.withAlphaComponent(0.2)
  56. transferSeparatorBottom.backgroundColor = .separator
  57. transferSeparatorBottomHeightConstraint.constant = 0.5
  58. emptyImage.image = nil
  59. emptyTitle.text = ""
  60. emptyDescription.text = ""
  61. }
  62. // MARK: - Transfer
  63. func setViewTransfer(isHidden: Bool, progress: Float? = nil) {
  64. viewTransfer.isHidden = isHidden
  65. if isHidden {
  66. viewTransferHeightConstraint.constant = 0
  67. progressTransfer.progress = 0
  68. } else {
  69. viewTransferHeightConstraint.constant = NCGlobal.shared.heightHeaderTransfer
  70. if NCTransferProgress.shared.haveUploadInForeground() {
  71. labelTransfer.text = String(format: NSLocalizedString("_upload_foreground_msg_", comment: ""), NCBrandOptions.shared.brand)
  72. if let progress {
  73. progressTransfer.progress = progress
  74. } else if let progress = NCTransferProgress.shared.getLastTransferProgressInForeground() {
  75. progressTransfer.progress = progress
  76. } else {
  77. progressTransfer.progress = 0.0
  78. }
  79. } else {
  80. labelTransfer.text = NSLocalizedString("_upload_background_msg_", comment: "")
  81. progressTransfer.progress = 0.0
  82. }
  83. }
  84. }
  85. }