From ec2e8569145943d1c20fffd49e250941703493d0 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Tue, 15 Aug 2023 11:50:56 +1000 Subject: [PATCH] clean --- Session.xcodeproj/project.pbxproj | 14 +- .../MediaInfoVC+MediaInfoView.swift | 194 ------------------ .../MediaInfoVC+MediaPreviewView.swift | 63 ------ .../Media Viewing & Editing/MediaInfoVC.swift | 151 -------------- 4 files changed, 1 insertion(+), 421 deletions(-) delete mode 100644 Session/Media Viewing & Editing/MediaInfoVC+MediaInfoView.swift delete mode 100644 Session/Media Viewing & Editing/MediaInfoVC+MediaPreviewView.swift delete mode 100644 Session/Media Viewing & Editing/MediaInfoVC.swift diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 6d3a1516a..f502f7d7c 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -104,10 +104,7 @@ 7B1B52E028580D51006069F2 /* EmojiSkinTonePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B1B52DC28580D50006069F2 /* EmojiSkinTonePicker.swift */; }; 7B1D74AA27BCC16E0030B423 /* NSENotificationPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B1D74A927BCC16E0030B423 /* NSENotificationPresenter.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 */; }; 7B2561C429874851005C086C /* SessionCarouselView+Info.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B2561C329874851005C086C /* SessionCarouselView+Info.swift */; }; - 7B3A392E2977791E002FE4AC /* MediaInfoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B3A392D2977791E002FE4AC /* MediaInfoVC.swift */; }; - 7B3A3930297A3919002FE4AC /* MediaInfoVC+MediaPreviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B3A392F297A3919002FE4AC /* MediaInfoVC+MediaPreviewView.swift */; }; 7B3A39322980D02B002FE4AC /* SessionCarouselView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B3A39312980D02B002FE4AC /* SessionCarouselView.swift */; }; 7B3A3934298882D6002FE4AC /* SessionCarouselViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B3A3933298882D6002FE4AC /* SessionCarouselViewDelegate.swift */; }; 7B46AAAF28766DF4001AF2DC /* AllMediaViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B46AAAE28766DF4001AF2DC /* AllMediaViewController.swift */; }; @@ -1218,11 +1215,8 @@ 7B1B52DC28580D50006069F2 /* EmojiSkinTonePicker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmojiSkinTonePicker.swift; sourceTree = ""; }; 7B1D74A927BCC16E0030B423 /* NSENotificationPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSENotificationPresenter.swift; sourceTree = ""; }; 7B1D74AF27C365960030B423 /* Timer+MainThread.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Timer+MainThread.swift"; sourceTree = ""; }; - 7B2561C12978B307005C086C /* MediaInfoVC+MediaInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MediaInfoVC+MediaInfoView.swift"; sourceTree = ""; }; 7B2561C329874851005C086C /* SessionCarouselView+Info.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SessionCarouselView+Info.swift"; sourceTree = ""; }; 7B2DB2AD26F1B0FF0035B509 /* si */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = si; path = si.lproj/Localizable.strings; sourceTree = ""; }; - 7B3A392D2977791E002FE4AC /* MediaInfoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaInfoVC.swift; sourceTree = ""; }; - 7B3A392F297A3919002FE4AC /* MediaInfoVC+MediaPreviewView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MediaInfoVC+MediaPreviewView.swift"; sourceTree = ""; }; 7B3A39312980D02B002FE4AC /* SessionCarouselView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionCarouselView.swift; sourceTree = ""; }; 7B3A3933298882D6002FE4AC /* SessionCarouselViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionCarouselViewDelegate.swift; sourceTree = ""; }; 7B46AAAE28766DF4001AF2DC /* AllMediaViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllMediaViewController.swift; sourceTree = ""; }; @@ -3096,9 +3090,6 @@ 4C1885D1218F8E1C00B67051 /* PhotoGridViewCell.swift */, 4C4AE69F224AF21900D4AF6F /* SendMediaNavigationController.swift */, 7B46AAAE28766DF4001AF2DC /* AllMediaViewController.swift */, - 7B3A392D2977791E002FE4AC /* MediaInfoVC.swift */, - 7B3A392F297A3919002FE4AC /* MediaInfoVC+MediaPreviewView.swift */, - 7B2561C12978B307005C086C /* MediaInfoVC+MediaInfoView.swift */, 7BD687D02A5D0D1200D8E455 /* MessageInfoView.swift */, ); path = "Media Viewing & Editing"; @@ -5864,7 +5855,7 @@ B8DE1FB426C22F2F0079C9CE /* WebRTCSession.swift in Sources */, FDC6D6F32860607300B04575 /* SessionEnvironment.swift in Sources */, FDC13D5A2A1721C5007267C7 /* LegacyNotifyRequest.swift in Sources */, - FDC6D6F32860607300B04575 /* Environment.swift in Sources */, + FDC6D6F32860607300B04575 /* SessionEnvironment.swift in Sources */, C3A3A171256E1D25004D228D /* SSKReachabilityManager.swift in Sources */, FD245C59285065FC00B966DD /* ControlMessage.swift in Sources */, FD6E4C8A2A1AEE4700C7C243 /* LegacyUnsubscribeRequest.swift in Sources */, @@ -6007,7 +5998,6 @@ 7BAF54D027ACCEEC003D12F8 /* EmptySearchResultCell.swift in Sources */, B8783E9E23EB948D00404FB8 /* UILabel+Interaction.swift in Sources */, FD37E9D928A230F2003AE748 /* TraitObservingWindow.swift in Sources */, - 7B3A3930297A3919002FE4AC /* MediaInfoVC+MediaPreviewView.swift in Sources */, B893063F2383961A005EAA8E /* ScanQRCodeWrapperVC.swift in Sources */, FD848B8F283EF2A8000E298B /* UIScrollView+Utilities.swift in Sources */, B879D449247E1BE300DB3608 /* PathVC.swift in Sources */, @@ -6050,7 +6040,6 @@ C3548F0624456447009433A8 /* PNModeVC.swift in Sources */, FD71164828E2CE8700B47552 /* SessionCell+AccessoryView.swift in Sources */, B80A579F23DFF1F300876683 /* NewClosedGroupVC.swift in Sources */, - 7B3A392E2977791E002FE4AC /* MediaInfoVC.swift in Sources */, 7BA68909272A27BE00EFC32F /* SessionCall.swift in Sources */, B835247925C38D880089A44F /* MessageCell.swift in Sources */, B86BD08623399CEF000F5AE3 /* SeedModal.swift in Sources */, @@ -6161,7 +6150,6 @@ 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 */, FDF848F529413EEC007DCAE5 /* SessionCell+Styling.swift in Sources */, 7BFD1A8A2745C4F000FB91B9 /* Permissions.swift in Sources */, diff --git a/Session/Media Viewing & Editing/MediaInfoVC+MediaInfoView.swift b/Session/Media Viewing & Editing/MediaInfoVC+MediaInfoView.swift deleted file mode 100644 index a41368931..000000000 --- a/Session/Media Viewing & Editing/MediaInfoVC+MediaInfoView.swift +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved. - -import UIKit -import SessionUIKit -import SessionUtilitiesKit -import SessionMessagingKit -import SignalUtilitiesKit - -extension MediaInfoVC { - final class MediaInfoView: UIView { - private static let cornerRadius: CGFloat = 12 - - private var attachment: Attachment? - private let width: CGFloat = MediaInfoVC.mediaSize - 2 * MediaInfoVC.arrowSize.width - - // 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() - update(attachment: attachment) - } - - 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: self.width) - - // 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 - }() - let fileIdContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ fileIdTitleLabel, fileIdLabel ]) - fileIdContainerStackView.axis = .vertical - fileIdContainerStackView.spacing = 6 - 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 - }() - let fileTypeContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ fileTypeTitleLabel, fileTypeLabel ]) - fileTypeContainerStackView.axis = .vertical - fileTypeContainerStackView.spacing = 6 - container.addSubview(fileTypeContainerStackView) - fileTypeContainerStackView.pin(.leading, to: .leading, of: container) - fileTypeContainerStackView.pin(.top, to: .bottom, of: fileIdContainerStackView, withInset: Values.largeSpacing) - - // 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 - }() - let fileSizeContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ fileSizeTitleLabel, fileSizeLabel ]) - fileSizeContainerStackView.axis = .vertical - fileSizeContainerStackView.spacing = 6 - container.addSubview(fileSizeContainerStackView) - fileSizeContainerStackView.pin(.trailing, to: .trailing, of: container) - fileSizeContainerStackView.pin(.top, to: .bottom, of: fileIdContainerStackView, withInset: Values.largeSpacing) - 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 - }() - let resolutionContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ resolutionTitleLabel, resolutionLabel ]) - resolutionContainerStackView.axis = .vertical - resolutionContainerStackView.spacing = 6 - container.addSubview(resolutionContainerStackView) - resolutionContainerStackView.pin(.leading, to: .leading, of: container) - resolutionContainerStackView.pin(.top, to: .bottom, of: fileTypeContainerStackView, withInset: Values.largeSpacing) - - // Duration - let durationTitleLabel: UILabel = { - let result = UILabel() - result.font = .boldSystemFont(ofSize: Values.mediumFontSize) - result.text = "ATTACHMENT_INFO_DURATION".localized() + ":" - result.themeTextColor = .textPrimary - - return result - }() - let durationContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ durationTitleLabel, durationLabel ]) - durationContainerStackView.axis = .vertical - durationContainerStackView.spacing = 6 - container.addSubview(durationContainerStackView) - durationContainerStackView.pin(.trailing, to: .trailing, of: container) - durationContainerStackView.pin(.top, to: .bottom, of: fileSizeContainerStackView, withInset: Values.largeSpacing) - durationContainerStackView.set(.width, to: 90) - container.pin(.bottom, to: .bottom, of: durationContainerStackView) - - backgroundView.addSubview(container) - container.pin(to: backgroundView, withInset: Values.largeSpacing) - } - - // MARK: - Interaction - - public func update(attachment: Attachment?) { - guard let attachment: Attachment = attachment else { return } - - self.attachment = attachment - - fileIdLabel.text = attachment.serverId - fileTypeLabel.text = attachment.contentType - fileSizeLabel.text = Format.fileSize(attachment.byteCount) - resolutionLabel.text = { - guard let width = attachment.width, let height = attachment.height else { return "N/A" } - return "\(width)×\(height)" - }() - durationLabel.text = { - guard let duration = attachment.duration else { return "N/A" } - return floor(duration).formatted(format: .videoDuration) - }() - } - } -} diff --git a/Session/Media Viewing & Editing/MediaInfoVC+MediaPreviewView.swift b/Session/Media Viewing & Editing/MediaInfoVC+MediaPreviewView.swift deleted file mode 100644 index 462e143ff..000000000 --- a/Session/Media Viewing & Editing/MediaInfoVC+MediaPreviewView.swift +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved. - -import UIKit -import SessionUIKit -import SessionUtilitiesKit -import SessionMessagingKit - -extension MediaInfoVC { - final class MediaPreviewView: UIView { - private static let cornerRadius: CGFloat = 8 - - private let attachment: Attachment - private let isOutgoing: Bool - - // MARK: - UI - - private lazy var mediaView: MediaView = { - let result: MediaView = MediaView.init( - attachment: attachment, - isOutgoing: isOutgoing, - cornerRadius: 0 - ) - - return result - }() - - // MARK: - Lifecycle - - init(attachment: Attachment, isOutgoing: Bool) { - self.attachment = attachment - self.isOutgoing = isOutgoing - - 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() { - set(.width, to: MediaInfoVC.mediaSize) - set(.height, to: MediaInfoVC.mediaSize) - - addSubview(mediaView) - mediaView.pin(to: self) - - mediaView.loadMedia() - } - - // MARK: - Copy - - /// This function is used to make sure the carousel view contains this class can loop infinitely - func copyView() -> MediaPreviewView { - return MediaPreviewView(attachment: self.attachment, isOutgoing: self.isOutgoing) - } - } -} diff --git a/Session/Media Viewing & Editing/MediaInfoVC.swift b/Session/Media Viewing & Editing/MediaInfoVC.swift deleted file mode 100644 index 1d8991d4c..000000000 --- a/Session/Media Viewing & Editing/MediaInfoVC.swift +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved. - -import UIKit -import SessionUIKit -import SessionMessagingKit -import SessionUtilitiesKit -import SignalUtilitiesKit - -final class MediaInfoVC: BaseVC, SessionCarouselViewDelegate { - internal static let mediaSize: CGFloat = UIScreen.main.bounds.width - 2 * Values.veryLargeSpacing - internal static let arrowSize: CGSize = CGSize(width: 20, height: 30) - - private let attachments: [Attachment] - private let isOutgoing: Bool - private let threadId: String - private let threadVariant: SessionThread.Variant - private let interactionId: Int64 - - private var currentPage: Int = 0 - - // MARK: - UI - private lazy var mediaInfoView: MediaInfoView = MediaInfoView(attachment: nil) - private lazy var mediaCarouselView: SessionCarouselView = { - let slices: [MediaPreviewView] = self.attachments.map { - MediaPreviewView( - attachment: $0, - isOutgoing: self.isOutgoing - ) - } - let result: SessionCarouselView = SessionCarouselView( - info: SessionCarouselView.Info( - slices: slices, - copyOfFirstSlice: slices.first?.copyView(), - copyOfLastSlice: slices.last?.copyView(), - sliceSize: CGSize( - width: Self.mediaSize, - height: Self.mediaSize - ), - shouldShowPageControl: true, - pageControlStyle: SessionCarouselView.PageControlStyle( - size: .medium, - backgroundColor: .init(white: 0, alpha: 0.4), - bottomInset: Values.mediumSpacing - ), - shouldShowArrows: true, - arrowsSize: Self.arrowSize, - cornerRadius: 8 - ) - ) - result.set(.height, to: Self.mediaSize) - result.delegate = self - - return result - }() - - private lazy var fullScreenButton: UIButton = { - let result: UIButton = UIButton(type: .custom) - result.setImage( - UIImage(systemName: "arrow.up.left.and.arrow.down.right")? - .withRenderingMode(.alwaysTemplate), - for: .normal - ) - result.themeTintColor = .textPrimary - result.backgroundColor = .init(white: 0, alpha: 0.4) - result.layer.cornerRadius = 14 - result.set(.width, to: 28) - result.set(.height, to: 28) - result.addTarget(self, action: #selector(showMediaFullScreen), for: .touchUpInside) - - return result - }() - - // MARK: - Initialization - - init( - attachments: [Attachment], - isOutgoing: Bool, - threadId: String, - threadVariant: SessionThread.Variant, - interactionId: Int64 - ) { - self.threadId = threadId - self.threadVariant = threadVariant - self.interactionId = interactionId - self.isOutgoing = isOutgoing - self.attachments = attachments - super.init(nibName: nil, bundle: nil) - } - - override init(nibName: String?, bundle: Bundle?) { - preconditionFailure("Use init(attachments:) instead.") - } - - required init?(coder: NSCoder) { - preconditionFailure("Use init(attachments:) instead.") - } - - // MARK: - Lifecycle - - override func viewDidLoad() { - super.viewDidLoad() - - ViewControllerUtilities.setUpDefaultSessionStyle( - for: self, - title: "message_info_title".localized(), - hasCustomBackButton: false - ) - - let mediaStackView: UIStackView = UIStackView() - mediaStackView.axis = .horizontal - - mediaInfoView.update(attachment: attachments[0]) - - mediaCarouselView.addSubview(fullScreenButton) - fullScreenButton.pin(.trailing, to: .trailing, of: mediaCarouselView, withInset: -(Values.smallSpacing + Values.veryLargeSpacing)) - fullScreenButton.pin(.bottom, to: .bottom, of: mediaCarouselView, withInset: -Values.smallSpacing) - - let stackView: UIStackView = UIStackView(arrangedSubviews: [ mediaCarouselView, mediaInfoView ]) - stackView.axis = .vertical - stackView.alignment = .center - stackView.spacing = Values.largeSpacing - - self.view.addSubview(stackView) - stackView.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing ], to: self.view) - stackView.pin(.top, to: .top, of: self.view, withInset: Values.veryLargeSpacing) - } - - // MARK: - Interaction - - @objc func showMediaFullScreen() { - let attachment = self.attachments[self.currentPage] - let viewController: UIViewController? = MediaGalleryViewModel.createDetailViewController( - for: self.threadId, - threadVariant: self.threadVariant, - interactionId: self.interactionId, - selectedAttachmentId: attachment.id, - options: [ .sliderEnabled ] - ) - if let viewController: UIViewController = viewController { - viewController.transitioningDelegate = nil - self.present(viewController, animated: true) - } - } - - // MARK: - SessionCarouselViewDelegate - - func carouselViewDidScrollToNewSlice(currentPage: Int) { - self.currentPage = currentPage - mediaInfoView.update(attachment: attachments[currentPage]) - } -}