mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			65 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Swift
		
	
			
		
		
	
	
			65 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Swift
		
	
// 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,
 | 
						|
                shouldSupressControls: false,
 | 
						|
                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)
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |