AXPhotosViewController

final class AXPhotosViewController: UIViewController,
                                    // swiftlint:disable:previous type_body_length
                                    UIPageViewControllerDelegate,
                                    UIPageViewControllerDataSource,
                                    UIGestureRecognizerDelegate,
                                    AXPhotoViewControllerDelegate,
                                    AXNetworkIntegrationDelegate,
                                    AXPhotosTransitionControllerDelegate

AXPhotosViewController

  • The underlying OverlayView that is used for displaying photo captions, titles, and actions.

    Declaration

    Swift

    let overlayView: AXOverlayView
  • The photos to display in the PhotosViewController.

    Declaration

    Swift

    var dataSource: AXPhotosDataSource { get set }
  • The configuration object applied to the internal pager at initialization.

    Declaration

    Swift

    fileprivate(set) var pagingConfig: AXPagingConfig
  • The AXTransitionInfo passed in at initialization. Defines functionality for the presentation and dismissal of the PhotosViewController.

    Declaration

    Swift

    fileprivate(set) var transitionInfo: AXTransitionInfo
  • The NetworkIntegration passed in at initialization. TFetches images asynchronously from a cache or URL.

    • Initialized by the end of commonInit(dataSource:pagingConfig:transitionInfo:networkIntegration:).

    Declaration

    Swift

    fileprivate(set) var networkIntegration: AXNetworkIntegrationProtocol!
  • The underlying UIPageViewController that is used for swiping horizontally and vertically.

    Important

    AXPhotosViewController is this page view controller’s UIPageViewControllerDelegate, UIPageViewControllerDataSource. Changing these values will result in breakage.

    Note

    Initialized by the end of commonInit(dataSource:pagingConfig:transitionInfo:networkIntegration:).

    Declaration

    Swift

    fileprivate(set) var pageViewController: UIPageViewController!
  • The internal tap gesture recognizer that is used to hide/show the overlay interface.

    Declaration

    Swift

    let singleTapGestureRecognizer: UITapGestureRecognizer
  • The view controller containing the photo currently being shown.

    Declaration

    Swift

    var currentPhotoViewController: AXPhotoViewController? { get }
  • The index of the photo currently being shown.

    Declaration

    Swift

    private(set) var currentPhotoIndex: Int { get set }

Initialization

Navigation

  • Convenience method to programmatically navigate to a photo

    Declaration

    Swift

    func navigateToPhotoIndex(_ photoIndex: Int, animated: Bool)

    Parameters

    photoIndex

    The index of the photo to navigate to

    animated

    Whether or not to animate the transition

Default bar button actions

  • Share

    Declaration

    Swift

    @objc
    func shareAction(_ barButtonItem: UIBarButtonItem)

    Parameters

    barButtonItem

    UIBarButtonItem

  • Close

    Declaration

    Swift

    @objc
    func closeAction(_ sender: UIBarButtonItem)

    Parameters

    sender

    UIBarButtonItem

KVO

  • KVO observation

    Declaration

    Swift

    override func observeValue(forKeyPath keyPath: String?,
                               // swiftlint:disable:previous block_based_kvo
                               of object: Any?,
                               // swiftlint:disable:next discouraged_optional_collection
                               change: [NSKeyValueChangeKey: Any]?,
                               context: UnsafeMutableRawPointer?)

    Parameters

    keyPath

    Key path

    object

    Object observed

    change

    Change

    context

    Context

AXPhotosViewControllerDelegate calls

  • Called when the AXPhotosViewController navigates to a new photo. This is defined as when the swipe percent between pages is greater than the threshold (>0.5). If you override this and fail to call super, the corresponding delegate method will not be called!

    Declaration

    Swift

    func didNavigateTo(photo: AXPhotoProtocol, at index: Int)

    Parameters

    photo

    The AXPhoto that was navigated to.

    index

    The index in the dataSource of the AXPhoto being transitioned to.

  • Called when the AXPhotosViewController is configuring its OverlayView for a new photo. This should be used to update the the overlay’s title or any other overlay-specific properties. If you override this and fail to call super, the corresponding delegate method will not be called!

    Declaration

    Swift

    func willUpdate(overlayView: AXOverlayView, for photo: AXPhotoProtocol, at index: Int, totalNumberOfPhotos: Int)

    Parameters

    overlayView

    The AXOverlayView that is being updated.

    photo

    The AXPhoto the overlay is being configured for.

    index

    The index of the AXPhoto that the overlay is being configured for.

    totalNumberOfPhotos

    The total number of photos in the current dataSource.

  • Called when the AXPhotoViewController will show/hide its OverlayView. This method will be called inside of an animation context, so perform any coordinated animations here. If you override this and fail to call super, the corresponding delegate method will not be called!

    Declaration

    Swift

    func overlayView(_ overlayView: AXOverlayView, visibilityWillChange visible: Bool)

    Parameters

    overlayView

    The AXOverlayView whose visibility is changing.

    visible

    A boolean that denotes whether or not the overlay will be visible or invisible.

  • If implemented and returns a valid zoom scale for the photo (valid meaning >= the photo’s minimum zoom scale), the underlying zooming image view will adopt the returned maximumZoomScale instead of the default calculated by the library. A good implementation of this method will use a combination of the provided minimumZoomScale and imageSize to extrapolate a maximumZoomScale to return. If the minimumZoomScale is returned (ie. minimumZoomScale == maximumZoomScale), zooming will be disabled for this image. If you override this and fail to call super, the corresponding delegate method will not be called!

    Declaration

    Swift

    func maximumZoomScale(for photo: AXPhotoProtocol,
                          minimumZoomScale: CGFloat,
                          imageSize: CGSize) -> CGFloat

    Parameters

    photo

    The Photo that the zoom scale will affect.

    minimumZoomScale

    The minimum zoom scale that is calculated by the library. This value cannot be changed.

    imageSize

    The size of the image that belongs to the AXPhoto.

    Return Value

    A “maximum” zoom scale that >= minimumZoomScale.

  • Called when the action button is tapped for a photo. If you override this and fail to call super, the corresponding delegate method will not be called!

    Declaration

    Swift

    func handleActionButtonTapped(photo: AXPhotoProtocol) -> Bool

    Parameters

    photo

    The related AXPhoto.

    Return Value

    true if the action button tap was handled, false if the default action button behavior should be invoked.

  • Called when an action button action is completed. If you override this and fail to call super, the corresponding delegate method will not be called!

    Note

    This is only called for the default action.

    Declaration

    Swift

    func actionCompleted(activityType: UIActivity.ActivityType, for photo: AXPhotoProtocol)

    Parameters

    photo

    The related AXPhoto.