wrap up media info container view
This commit is contained in:
parent
107231d5db
commit
94456edd2e
|
@ -109,6 +109,7 @@
|
|||
7B1D74AA27BCC16E0030B423 /* NSENotificationPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B1D74A927BCC16E0030B423 /* NSENotificationPresenter.swift */; };
|
||||
7B1D74AC27BDE7510030B423 /* Promise+Timeout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B1D74AB27BDE7510030B423 /* Promise+Timeout.swift */; };
|
||||
7B1D74B027C365960030B423 /* Timer+MainThread.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B1D74AF27C365960030B423 /* Timer+MainThread.swift */; };
|
||||
7B2561C22978B307005C086C /* MediaInfoVC+MediaInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B2561C12978B307005C086C /* MediaInfoVC+MediaInfoView.swift */; };
|
||||
7B3A392C2971100D002FE4AC /* ContextMenuVC+MessageInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B3A392B2971100D002FE4AC /* ContextMenuVC+MessageInfoView.swift */; };
|
||||
7B3A392E2977791E002FE4AC /* MediaInfoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B3A392D2977791E002FE4AC /* MediaInfoVC.swift */; };
|
||||
7B46AAAF28766DF4001AF2DC /* AllMediaViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B46AAAE28766DF4001AF2DC /* AllMediaViewController.swift */; };
|
||||
|
@ -1176,6 +1177,7 @@
|
|||
7B1D74A927BCC16E0030B423 /* NSENotificationPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSENotificationPresenter.swift; sourceTree = "<group>"; };
|
||||
7B1D74AB27BDE7510030B423 /* Promise+Timeout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Promise+Timeout.swift"; sourceTree = "<group>"; };
|
||||
7B1D74AF27C365960030B423 /* Timer+MainThread.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Timer+MainThread.swift"; sourceTree = "<group>"; };
|
||||
7B2561C12978B307005C086C /* MediaInfoVC+MediaInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MediaInfoVC+MediaInfoView.swift"; sourceTree = "<group>"; };
|
||||
7B2DB2AD26F1B0FF0035B509 /* si */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = si; path = si.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||
7B3A392B2971100D002FE4AC /* ContextMenuVC+MessageInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ContextMenuVC+MessageInfoView.swift"; sourceTree = "<group>"; };
|
||||
7B3A392D2977791E002FE4AC /* MediaInfoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaInfoVC.swift; sourceTree = "<group>"; };
|
||||
|
@ -2986,6 +2988,7 @@
|
|||
4C4AE69F224AF21900D4AF6F /* SendMediaNavigationController.swift */,
|
||||
7B46AAAE28766DF4001AF2DC /* AllMediaViewController.swift */,
|
||||
7B3A392D2977791E002FE4AC /* MediaInfoVC.swift */,
|
||||
7B2561C12978B307005C086C /* MediaInfoVC+MediaInfoView.swift */,
|
||||
);
|
||||
path = "Media Viewing & Editing";
|
||||
sourceTree = "<group>";
|
||||
|
@ -5740,6 +5743,7 @@
|
|||
FD39352C28F382920084DADA /* VersionFooterView.swift in Sources */,
|
||||
7B9F71D22852EEE2006DFE7B /* Emoji+SkinTones.swift in Sources */,
|
||||
7B7CB18E270D066F0079FF93 /* IncomingCallBanner.swift in Sources */,
|
||||
7B2561C22978B307005C086C /* MediaInfoVC+MediaInfoView.swift in Sources */,
|
||||
B8569AE325CBB19A00DBA3DB /* DocumentView.swift in Sources */,
|
||||
7BFD1A8A2745C4F000FB91B9 /* Permissions.swift in Sources */,
|
||||
B85357BF23A1AE0800AAF6CD /* SeedReminderView.swift in Sources */,
|
||||
|
|
|
@ -46,7 +46,7 @@ final class DocumentView: UIView {
|
|||
// Size label
|
||||
let sizeLabel = UILabel()
|
||||
sizeLabel.font = .systemFont(ofSize: Values.verySmallFontSize)
|
||||
sizeLabel.text = OWSFormat.formatFileSize(UInt(attachment.byteCount))
|
||||
sizeLabel.text = OWSFormat.formatFileSize(attachment.byteCount)
|
||||
sizeLabel.themeTextColor = textColor
|
||||
sizeLabel.lineBreakMode = .byTruncatingTail
|
||||
|
||||
|
|
|
@ -0,0 +1,174 @@
|
|||
// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
|
||||
|
||||
import UIKit
|
||||
import SessionUIKit
|
||||
import SessionUtilitiesKit
|
||||
|
||||
extension MediaInfoVC {
|
||||
final class MediaInfoView: UIView {
|
||||
private static let cornerRadius: CGFloat = 8
|
||||
|
||||
private let attachment: Attachment
|
||||
|
||||
// MARK: - UI
|
||||
|
||||
private lazy var fileIdLabel: UILabel = {
|
||||
let result: UILabel = UILabel()
|
||||
result.font = .systemFont(ofSize: Values.mediumFontSize)
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
|
||||
private lazy var fileTypeLabel: UILabel = {
|
||||
let result: UILabel = UILabel()
|
||||
result.font = .systemFont(ofSize: Values.mediumFontSize)
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
|
||||
private lazy var fileSizeLabel: UILabel = {
|
||||
let result: UILabel = UILabel()
|
||||
result.font = .systemFont(ofSize: Values.mediumFontSize)
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
|
||||
private lazy var resolutionLabel: UILabel = {
|
||||
let result: UILabel = UILabel()
|
||||
result.font = .systemFont(ofSize: Values.mediumFontSize)
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
|
||||
private lazy var durationLabel: UILabel = {
|
||||
let result: UILabel = UILabel()
|
||||
result.font = .systemFont(ofSize: Values.mediumFontSize)
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
|
||||
// MARK: - Lifecycle
|
||||
|
||||
init(attachment: Attachment) {
|
||||
self.attachment = attachment
|
||||
|
||||
super.init(frame: CGRect.zero)
|
||||
self.accessibilityLabel = "Media info"
|
||||
setUpViewHierarchy()
|
||||
}
|
||||
|
||||
override init(frame: CGRect) {
|
||||
preconditionFailure("Use init(attachment:) instead.")
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
preconditionFailure("Use init(attachment:) instead.")
|
||||
}
|
||||
|
||||
private func setUpViewHierarchy() {
|
||||
let backgroundView: UIView = UIView()
|
||||
backgroundView.clipsToBounds = true
|
||||
backgroundView.themeBackgroundColor = .contextMenu_background
|
||||
backgroundView.layer.cornerRadius = Self.cornerRadius
|
||||
addSubview(backgroundView)
|
||||
backgroundView.pin(to: self)
|
||||
|
||||
let container: UIView = UIView()
|
||||
container.set(.width, to: 245)
|
||||
|
||||
// File ID
|
||||
let fileIdTitleLabel: UILabel = {
|
||||
let result = UILabel()
|
||||
result.font = .boldSystemFont(ofSize: Values.mediumFontSize)
|
||||
result.text = "ATTACHMENT_INFO_FILE_ID".localized() + ":"
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
fileIdLabel.text = attachment.serverId
|
||||
let fileIdContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ fileIdTitleLabel, fileIdLabel ])
|
||||
fileIdContainerStackView.axis = .vertical
|
||||
container.addSubview(fileIdContainerStackView)
|
||||
fileIdContainerStackView.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing, UIView.VerticalEdge.top ], to: container)
|
||||
|
||||
// File Type
|
||||
let fileTypeTitleLabel: UILabel = {
|
||||
let result = UILabel()
|
||||
result.font = .boldSystemFont(ofSize: Values.mediumFontSize)
|
||||
result.text = "ATTACHMENT_INFO_FILE_TYPE".localized() + ":"
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
fileTypeLabel.text = attachment.contentType
|
||||
let fileTypeContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ fileTypeTitleLabel, fileTypeLabel ])
|
||||
fileTypeContainerStackView.axis = .vertical
|
||||
container.addSubview(fileTypeContainerStackView)
|
||||
fileTypeContainerStackView.pin(.leading, to: .leading, of: container)
|
||||
fileTypeContainerStackView.pin(.top, to: .bottom, of: fileIdContainerStackView, withInset: Values.mediumSpacing)
|
||||
|
||||
// File Size
|
||||
let fileSizeTitleLabel: UILabel = {
|
||||
let result = UILabel()
|
||||
result.font = .boldSystemFont(ofSize: Values.mediumFontSize)
|
||||
result.text = "ATTACHMENT_INFO_FILE_SIZE".localized() + ":"
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
fileSizeLabel.text = OWSFormat.formatFileSize(attachment.byteCount)
|
||||
let fileSizeContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ fileSizeTitleLabel, fileSizeLabel ])
|
||||
fileSizeContainerStackView.axis = .vertical
|
||||
container.addSubview(fileSizeContainerStackView)
|
||||
fileSizeContainerStackView.pin(.trailing, to: .trailing, of: container)
|
||||
fileSizeContainerStackView.pin(.top, to: .bottom, of: fileIdContainerStackView, withInset: Values.mediumSpacing)
|
||||
fileSizeContainerStackView.set(.width, to: 90)
|
||||
|
||||
// Resolution
|
||||
let resolutionTitleLabel: UILabel = {
|
||||
let result = UILabel()
|
||||
result.font = .boldSystemFont(ofSize: Values.mediumFontSize)
|
||||
result.text = "ATTACHMENT_INFO_RESOLUTION".localized() + ":"
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
resolutionLabel.text = {
|
||||
guard let width = attachment.width, let height = attachment.height else { return "N/A" }
|
||||
return "\(width)×\(height)"
|
||||
}()
|
||||
let resolutionContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ resolutionTitleLabel, resolutionLabel ])
|
||||
resolutionContainerStackView.axis = .vertical
|
||||
container.addSubview(resolutionContainerStackView)
|
||||
resolutionContainerStackView.pin(.leading, to: .leading, of: container)
|
||||
resolutionContainerStackView.pin(.top, to: .bottom, of: fileTypeContainerStackView, withInset: Values.mediumSpacing)
|
||||
|
||||
// File Size
|
||||
let durationTitleLabel: UILabel = {
|
||||
let result = UILabel()
|
||||
result.font = .boldSystemFont(ofSize: Values.mediumFontSize)
|
||||
result.text = "ATTACHMENT_INFO_DURATION".localized() + ":"
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
durationLabel.text = {
|
||||
guard let duration = attachment.duration else { return "N/A" }
|
||||
return "\(duration)"
|
||||
}()
|
||||
let durationContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ durationTitleLabel, durationLabel ])
|
||||
durationContainerStackView.axis = .vertical
|
||||
durationContainerStackView.pin(.trailing, to: .trailing, of: container)
|
||||
durationContainerStackView.pin(.top, to: .bottom, of: fileSizeContainerStackView, withInset: Values.mediumSpacing)
|
||||
durationContainerStackView.set(.width, to: 90)
|
||||
|
||||
addSubview(container)
|
||||
container.pin(to: self, withInset: Values.mediumSpacing)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,12 @@
|
|||
// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import SessionUIKit
|
||||
import SessionUtilitiesKit
|
||||
|
||||
final class MediaInfoVC: BaseVC {
|
||||
private static let mediaInfoContainerCornerRadius: CGFloat = 8
|
||||
|
||||
private let attachments: [Attachment]
|
||||
|
||||
// MARK: - UI
|
||||
|
||||
|
@ -13,58 +16,21 @@ final class MediaInfoVC: BaseVC {
|
|||
return result
|
||||
}()
|
||||
|
||||
private lazy var fileIdLabel: UILabel = {
|
||||
let result: UILabel = UILabel()
|
||||
result.font = .systemFont(ofSize: Values.mediumFontSize)
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
|
||||
private lazy var fileTypeLabel: UILabel = {
|
||||
let result: UILabel = UILabel()
|
||||
result.font = .systemFont(ofSize: Values.mediumFontSize)
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
|
||||
private lazy var fileSizeLabel: UILabel = {
|
||||
let result: UILabel = UILabel()
|
||||
result.font = .systemFont(ofSize: Values.mediumFontSize)
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
|
||||
private lazy var resolutionLabel: UILabel = {
|
||||
let result: UILabel = UILabel()
|
||||
result.font = .systemFont(ofSize: Values.mediumFontSize)
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
|
||||
private lazy var durationLabel: UILabel = {
|
||||
let result: UILabel = UILabel()
|
||||
result.font = .systemFont(ofSize: Values.mediumFontSize)
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
|
||||
// MARK: - Initialization
|
||||
|
||||
init() {
|
||||
init(attachments: [Attachment]) {
|
||||
self.attachments = attachments
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
override init(nibName: String?, bundle: Bundle?) {
|
||||
preconditionFailure("Use init() instead.")
|
||||
preconditionFailure("Use init(attachments:) instead.")
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
preconditionFailure("Use init() instead.")
|
||||
preconditionFailure("Use init(attachments:) instead.")
|
||||
}
|
||||
|
||||
// MARK: - Lifecycle
|
||||
|
@ -72,75 +38,6 @@ final class MediaInfoVC: BaseVC {
|
|||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
let mediaInfoContainer: UIView = UIView()
|
||||
mediaInfoContainer.clipsToBounds = true
|
||||
mediaInfoContainer.themeBackgroundColor = .contextMenu_background
|
||||
mediaInfoContainer.layer.cornerRadius = Self.mediaInfoContainerCornerRadius
|
||||
|
||||
// File ID
|
||||
let fileIdTitleLabel: UILabel = {
|
||||
let result = UILabel()
|
||||
result.font = .boldSystemFont(ofSize: Values.mediumFontSize)
|
||||
result.text = "ATTACHMENT_INFO_FILE_ID".localized() + ":"
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
fileIdLabel.text = "" // TODO:
|
||||
let fileIdContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ fileIdTitleLabel, fileIdLabel ])
|
||||
fileIdContainerStackView.axis = .vertical
|
||||
|
||||
// File Type
|
||||
let fileTypeTitleLabel: UILabel = {
|
||||
let result = UILabel()
|
||||
result.font = .boldSystemFont(ofSize: Values.mediumFontSize)
|
||||
result.text = "ATTACHMENT_INFO_FILE_TYPE".localized() + ":"
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
fileTypeLabel.text = "" // TODO:
|
||||
let fileTypeContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ fileTypeTitleLabel, fileTypeLabel ])
|
||||
fileTypeContainerStackView.axis = .vertical
|
||||
|
||||
// File Size
|
||||
let fileSizeTitleLabel: UILabel = {
|
||||
let result = UILabel()
|
||||
result.font = .boldSystemFont(ofSize: Values.mediumFontSize)
|
||||
result.text = "ATTACHMENT_INFO_FILE_SIZE".localized() + ":"
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
fileSizeLabel.text = "" // TODO:
|
||||
let fileSizeContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ fileSizeTitleLabel, fileSizeLabel ])
|
||||
fileSizeContainerStackView.axis = .vertical
|
||||
|
||||
// Resolution
|
||||
let resolutionTitleLabel: UILabel = {
|
||||
let result = UILabel()
|
||||
result.font = .boldSystemFont(ofSize: Values.mediumFontSize)
|
||||
result.text = "ATTACHMENT_INFO_RESOLUTION".localized() + ":"
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
resolutionLabel.text = "" // TODO:
|
||||
let resolutionContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ resolutionTitleLabel, resolutionLabel ])
|
||||
resolutionContainerStackView.axis = .vertical
|
||||
|
||||
// File Size
|
||||
let durationTitleLabel: UILabel = {
|
||||
let result = UILabel()
|
||||
result.font = .boldSystemFont(ofSize: Values.mediumFontSize)
|
||||
result.text = "ATTACHMENT_INFO_DURATION".localized() + ":"
|
||||
result.themeTextColor = .textPrimary
|
||||
|
||||
return result
|
||||
}()
|
||||
durationLabel.text = "" // TODO:
|
||||
let durationContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ durationTitleLabel, durationLabel ])
|
||||
durationContainerStackView.axis = .vertical
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue