NCShareAdvancePermissionHeader.swift 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // NCShareAdvancePermissionHeader.swift
  3. // Nextcloud
  4. //
  5. // Created by T-systems on 10/08/21.
  6. // Copyright © 2022 Henrik Storch. All rights reserved.
  7. //
  8. // Author Henrik Storch <henrik.storch@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. class NCShareAdvancePermissionHeader: UIView {
  25. @IBOutlet weak var imageView: UIImageView!
  26. @IBOutlet weak var fileName: UILabel!
  27. @IBOutlet weak var info: UILabel!
  28. @IBOutlet weak var fullWidthImageView: UIImageView!
  29. func setupUI(with metadata: tableMetadata) {
  30. if FileManager.default.fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
  31. fullWidthImageView.image = NCUtility.shared.getImageMetadata(metadata, for: frame.height)
  32. fullWidthImageView.contentMode = .scaleAspectFill
  33. imageView.isHidden = true
  34. } else {
  35. if metadata.directory {
  36. imageView.image = NCBrandColor.cacheImages.folder
  37. } else if !metadata.iconName.isEmpty {
  38. imageView.image = UIImage(named: metadata.iconName)
  39. } else {
  40. imageView.image = NCBrandColor.cacheImages.file
  41. }
  42. }
  43. fileName.text = metadata.fileNameView
  44. fileName.textColor = .label
  45. info.textColor = .secondaryLabel
  46. info.text = CCUtility.transformedSize(metadata.size) + ", " + CCUtility.dateDiff(metadata.date as Date)
  47. }
  48. }