Skip to main content

GalleryVC

A viewcontroller to showcase and slide through multiple attachments (images and videos by default).

open class GalleryVC:
_ViewController,
UIGestureRecognizerDelegate,
AppearanceProvider,
UICollectionViewDataSource,
UICollectionViewDelegate,
UICollectionViewDelegateFlowLayout,
ComponentsProvider

Inheritance

_ViewController, AppearanceProvider, ComponentsProvider, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, UIGestureRecognizerDelegate

Properties

content

Content to display.

open var content: Content!

items

Items to display.

open var items: [AnyChatMessageAttachment] 

lastSeenDateFormatter

Returns the date formatter function used to represent when the user was last seen online

open var lastSeenDateFormatter: (Date) -> String? 

transitionController

Controller for handling the transition for dismissal

open var transitionController: ZoomTransitionController!

dateFormatter

DateComponentsFormatter for showing when the message was sent.

open private(set) lazy var dateFormatter: DateComponentsFormatter 

attachmentsFlowLayout

UICollectionViewFlowLayout instance for attachmentsCollectionView.

open private(set) lazy var attachmentsFlowLayout: UICollectionViewFlowLayout 

attachmentsCollectionView

UICollectionView instance to display attachments.

open private(set) lazy var attachmentsCollectionView: UICollectionView = UICollectionView(
frame: .zero,
collectionViewLayout: attachmentsFlowLayout
)
.withoutAutoresizingMaskConstraints

topBarView

Bar view displayed at the top.

open private(set) lazy var topBarView: UIView = UIView()
.withoutAutoresizingMaskConstraints

userLabel

Label to show information about the user that sent the message.

open private(set) lazy var userLabel: UILabel = UILabel()
.withoutAutoresizingMaskConstraints
.withBidirectionalLanguagesSupport
.withAdjustingFontForContentSizeCategory

dateLabel

Label to show information about the date the message was sent at.

open private(set) lazy var dateLabel: UILabel = UILabel()
.withoutAutoresizingMaskConstraints
.withBidirectionalLanguagesSupport
.withAdjustingFontForContentSizeCategory

bottomBarView

Bar view displayed at the bottom.

open private(set) lazy var bottomBarView: UIView = UIView()
.withoutAutoresizingMaskConstraints

currentPhotoLabel

Label to show which photo is currently being displayed.

open private(set) lazy var currentPhotoLabel: UILabel = UILabel()
.withoutAutoresizingMaskConstraints
.withBidirectionalLanguagesSupport
.withAdjustingFontForContentSizeCategory

closeButton

Button for closing this view controller.

open private(set) lazy var closeButton: UIButton = components
.closeButton.init()
.withoutAutoresizingMaskConstraints

videoPlaybackBar

View that controls the video player of currently visible cell.

open private(set) lazy var videoPlaybackBar: VideoPlaybackControlView = components
.videoPlaybackControlView.init()
.withoutAutoresizingMaskConstraints

shareButton

Button for sharing content.

open private(set) lazy var shareButton: UIButton = components
.shareButton.init()
.withoutAutoresizingMaskConstraints

topBarTopConstraint

A constraint between topBarView.topAnchor and view.topAnchor.

open private(set) var topBarTopConstraint: NSLayoutConstraint?

bottomBarBottomConstraint

A constraint between bottomBarView.bottomAnchor and view.bottomAnchor.

open private(set) var bottomBarBottomConstraint: NSLayoutConstraint?

currentItemIndexPath

An index path for the currently visible cell.

open var currentItemIndexPath: IndexPath 

currentItem

A currently visible gallery item.

open var currentItem: AnyChatMessageAttachment 

imageViewToAnimateWhenDismissing

Returns an image view to animate during interactive dismissing.

open var imageViewToAnimateWhenDismissing: UIImageView? 

Methods

setUpAppearance()

override open func setUpAppearance() 

setUp()

override open func setUp() 

setUpLayout()

override open func setUpLayout() 

viewDidLoad()

override open func viewDidLoad() 

viewWillDisappear(_:)

override open func viewWillDisappear(_ animated: Bool) 

updateContent()

override open func updateContent() 

handlePan(with:)

Called whenever user pans with a given gestureRecognizer.

@objc
open func handlePan(with gestureRecognizer: UIPanGestureRecognizer)

closeButtonTapped()

Called when closeButton is tapped.

@objc
open func closeButtonTapped()

shareButtonTapped()

Called when shareButton is tapped.

@objc
open func shareButtonTapped()

updateCurrentPage()

Updates currentPage.

open func updateCurrentPage() 

collectionView(_:numberOfItemsInSection:)

open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int 

collectionView(_:cellForItemAt:)

open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell 

collectionView(_:layout:sizeForItemAt:)

open func collectionView(
_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAt indexPath: IndexPath
) -> CGSize

collectionView(_:targetContentOffsetForProposedContentOffset:)

open func collectionView(
_ collectionView: UICollectionView,
targetContentOffsetForProposedContentOffset proposedContentOffset: CGPoint
) -> CGPoint

scrollViewDidEndDecelerating(_:)

open func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) 

scrollViewDidScroll(_:)

open func scrollViewDidScroll(_ scrollView: UIScrollView) 

viewWillTransition(to:with:)

override open func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) 

shareItem(at:)

Returns a share item for the gallery item at given index path.

open func shareItem(at indexPath: IndexPath) -> Any? 

Parameters

  • indexPath: An index path.

Returns

An item to share.

cellReuseIdentifierForItem(at:)

Returns cell reuse identifier for a gallery item at given index path.

open func cellReuseIdentifierForItem(at indexPath: IndexPath) -> String? 

Parameters

  • indexPath: An index path.

Returns

A cell reuse identifier.

handleSingleTapOnCell(at:)

Triggered when the current image is single tapped.

open func handleSingleTapOnCell(at indexPath: IndexPath) 

Did you find this page helpful?