Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objective-C Backwards Compatibility #2

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Example/MediaView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed for Travis. Scheme should set this to NO when building framework for release.

SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
Expand Down
17 changes: 15 additions & 2 deletions MediaView/Classes/Extensions/Notification+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,26 @@
//
//

fileprivate let mediaViewWillRotateNotificationName = "mediaViewWillRotateNotification"
fileprivate let mediaViewDidRotateNotificationName = "mediaViewDidRotateNotification"

@objc
public extension NSNotification {

/// Notification for when the mediaView will rotate between landscape and portrait
public static let mediaViewWillRotateNotification = mediaViewWillRotateNotificationName

/// Notification for when the mediaView will rotate between portrait and landscape
public static let mediaViewDidRotateNotification = mediaViewDidRotateNotificationName
}

public extension Notification.Name {

/// Notification for when the mediaView will rotate between landscape and portrait
public static let mediaViewWillRotateNotification = Notification.Name(rawValue: "mediaViewWillRotateNotification")
public static let mediaViewWillRotateNotification = Notification.Name(rawValue: mediaViewWillRotateNotificationName)

/// Notification for when the mediaView will rotate between portrait and landscape
public static let mediaViewDidRotateNotification = Notification.Name(rawValue: "mediaViewDidRotateNotification")
public static let mediaViewDidRotateNotification = Notification.Name(rawValue: mediaViewDidRotateNotificationName)
}

public extension Notification {
Expand Down
3 changes: 2 additions & 1 deletion MediaView/Classes/Managers/MediaQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import Foundation

public class MediaQueue {
@objcMembers
public class MediaQueue: NSObject {

/// Shared Manager, which keeps track of mediaViews
public static let shared = MediaQueue()
Expand Down
3 changes: 2 additions & 1 deletion MediaView/Classes/MediaView/Media.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

import Foundation

class Media {
@objcMembers
class Media: NSObject {

/// URL endpoint for image
var imageURL: String?
Expand Down
1 change: 1 addition & 0 deletions MediaView/Classes/MediaView/MediaView+Delegates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Foundation
import AVFoundation

@objc
extension MediaView: UIGestureRecognizerDelegate, LabelDelegate, TrackViewDelegate, PlayerDelegate, PlayIndicatorDelegate {

// MARK: - LabelDelegate
Expand Down
4 changes: 3 additions & 1 deletion MediaView/Classes/MediaView/MediaView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import Foundation
import AVFoundation

/// UIImageView subclass capable of displaying images, videos, audio and gifs
@objcMembers
public class MediaView: UIImageView {

public enum SwipeMode {
@objc
public enum SwipeMode: NSInteger {
case none
case dismiss
case minimize
Expand Down
51 changes: 26 additions & 25 deletions MediaView/Classes/MediaView/MediaViewDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,82 +7,83 @@

import Foundation

@objc
public protocol MediaViewDelegate: class {

/// A listener to know what percentage that the view has minimized, at a value from 0 to 1
func mediaView(_ mediaView: MediaView, didChangeOffset offsetPercentage: CGFloat)
@objc optional func mediaView(_ mediaView: MediaView, didChangeOffset offsetPercentage: CGFloat)

/// When the mediaView begins playing a video
func didPlayMedia(for mediaView: MediaView)
@objc optional func didPlayMedia(for mediaView: MediaView)

/// When the mediaView fails to play a video
func didFailToPlayMedia(for mediaView: MediaView)
@objc optional func didFailToPlayMedia(for mediaView: MediaView)

/// When the mediaView pauses a video
func didPauseMedia(for mediaView: MediaView)
@objc optional func didPauseMedia(for mediaView: MediaView)

/// When the mediaView finishes playing a video, and whether it looped
func didFinishPlayableMedia(for mediaView: MediaView, withLoop didLoop: Bool)
@objc optional func didFinishPlayableMedia(for mediaView: MediaView, withLoop didLoop: Bool)

/// Called when the mediaView has begun the presentation process
func willPresent(mediaView: MediaView)
@objc optional func willPresent(mediaView: MediaView)

/// Called when the mediaView has been presented
func didPresent(mediaView: MediaView)
@objc optional func didPresent(mediaView: MediaView)

/// Called when the mediaView has begun the dismissal process
func willDismiss(mediaView: MediaView)
@objc optional func willDismiss(mediaView: MediaView)

/// Called when the mediaView has completed the dismissal process. Useful if not looking to utilize the dismissal completion block
func didDismiss(mediaView: MediaView)
@objc optional func didDismiss(mediaView: MediaView)

/// Called when the mediaView is in the process of minimizing, and is about to make a change in frame
func willChangeMinimization(for mediaView: MediaView)
@objc optional func willChangeMinimization(for mediaView: MediaView)

/// Called when the mediaView is in the process of minimizing, and has made a change in frame
func didChangeMinimization(for mediaView: MediaView)
@objc optional func didChangeMinimization(for mediaView: MediaView)

/// Called before the mediaView ends minimizing, and informs whether the minimized view will snap to minimized or fullscreen mode
func willEndMinimizing(for mediaView: MediaView, atMinimizedState isMinimized: Bool)
@objc optional func willEndMinimizing(for mediaView: MediaView, atMinimizedState isMinimized: Bool)

/// Called when the mediaView ends minimizing, and informs whether the minimized view has snapped to minimized or fullscreen mode
func didEndMinimizing(for mediaView: MediaView, atMinimizedState isMinimized: Bool)
@objc optional func didEndMinimizing(for mediaView: MediaView, atMinimizedState isMinimized: Bool)

/// Called when the 'image' value of the UIImageView has been set
func mediaView(_ mediaView: MediaView, didSetImage image: UIImage)
@objc optional func mediaView(_ mediaView: MediaView, didSetImage image: UIImage)

/// Called when the mediaView is in the process of minimizing, and is about to make a change in frame
func willChangeDismissing(for mediaView: MediaView)
@objc optional func willChangeDismissing(for mediaView: MediaView)

/// Called when the mediaView is in the process of minimizing, and has made a change in frame
func didChangeDismissing(for mediaView: MediaView)
@objc optional func didChangeDismissing(for mediaView: MediaView)

/// Called before the mediaView ends minimizing, and informs whether the minimized view will snap to minimized or fullscreen mode
func willEndDismissing(for mediaView: MediaView, withDismissal didDismiss: Bool)
@objc optional func willEndDismissing(for mediaView: MediaView, withDismissal didDismiss: Bool)

/// Called when the mediaView ends minimizing, and informs whether the minimized view has snapped to minimized or fullscreen mode
func didEndDismissing(for mediaView: MediaView, withDismissal didDismiss: Bool)
@objc optional func didEndDismissing(for mediaView: MediaView, withDismissal didDismiss: Bool)

/// Called when the mediaView has completed downloading the image from the web
func mediaView(_ mediaView: MediaView, didDownloadImage image: UIImage)
@objc optional func mediaView(_ mediaView: MediaView, didDownloadImage image: UIImage)

/// Called when the mediaView has completed downloading the video from the web
func mediaView(_ mediaView: MediaView, didDownloadVideo video: URL)
@objc optional func mediaView(_ mediaView: MediaView, didDownloadVideo video: URL)

/// Called when the mediaView has completed downloading the audio from the web
func mediaView(_ mediaView: MediaView, didDownloadAudio audio: URL)
@objc optional func mediaView(_ mediaView: MediaView, didDownloadAudio audio: URL)

/// Called when the mediaView has completed downloading the gif from the web
func mediaView(_ mediaView: MediaView, didDownloadGif gif: UIImage)
@objc optional func mediaView(_ mediaView: MediaView, didDownloadGif gif: UIImage)

/// Called when the user taps the title label
func handleTitleSelection(in mediaView: MediaView)
@objc optional func handleTitleSelection(in mediaView: MediaView)

/// Called when the user taps the details label
func handleDetailsSelection(in mediaView: MediaView)
@objc optional func handleDetailsSelection(in mediaView: MediaView)
}

extension MediaView: MediaViewDelegate {
extension MediaViewDelegate {

public func mediaView(_ mediaView: MediaView, didChangeOffset offsetPercentage: CGFloat) { }

Expand Down