Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 398ee143f0 | |||
| b7166be79f | |||
| 0119309a25 | |||
| 2ac28e0497 | |||
| 44c91b41c6 | |||
| 619cbba91e | |||
| 2fbb4ba5af | |||
| 9cc8c1972d | |||
| 88b08b262d | |||
| a3825a081a | |||
| 63004497df | |||
| daca12b64a | |||
| 3ac333b6a8 | |||
| 64573991e0 | |||
| 7e06642187 | |||
| 256610707e | |||
| a07de07adb | |||
| fbd246db01 | |||
| 7b1b9370ab | |||
| 502f9a6f92 | |||
| 2cac1cf4b2 | |||
| 918918649c | |||
| e36c794651 | |||
| 1f42c0229c | |||
| 6f0ead5af5 | |||
| 4a70c08f37 | |||
| 7830a7512a | |||
| 2bb85661b1 | |||
| dbffe4f688 | |||
| ed69a9fdee | |||
| 6344062be2 | |||
| 8dcf50b722 |
@@ -1,2 +1,2 @@
|
||||
github "hyperoslo/Imaginary" ~> 4.3
|
||||
github "hyperoslo/Cache" ~> 5.3
|
||||
github "hyperoslo/Imaginary" ~> 5.0.0
|
||||
github "hyperoslo/Cache" ~> 6.0.0
|
||||
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
github "hyperoslo/Cache" "5.3.0"
|
||||
github "hyperoslo/Imaginary" "4.3.1"
|
||||
github "hyperoslo/Cache" "6.0.0"
|
||||
github "hyperoslo/Imaginary" "5.0.0"
|
||||
|
||||
+2
-3
@@ -1,19 +1,18 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Lightbox"
|
||||
s.summary = "A a convenient and easy to use image viewer for your iOS app, packed with all the features you expect"
|
||||
s.version = "2.4.0"
|
||||
s.version = "2.5.0"
|
||||
s.homepage = "https://github.com/hyperoslo/Lightbox"
|
||||
s.license = 'MIT'
|
||||
s.author = { "Hyper Interaktiv AS" => "ios@hyper.no" }
|
||||
s.source = { :git => "https://github.com/hyperoslo/Lightbox.git", :tag => s.version.to_s }
|
||||
s.social_media_url = 'https://twitter.com/hyperoslo'
|
||||
s.platform = :ios, '9.0'
|
||||
s.platform = :ios, '11.0'
|
||||
s.requires_arc = true
|
||||
s.source_files = 'Source/**/*'
|
||||
s.ios.resource = 'Resources/Lightbox.bundle'
|
||||
|
||||
s.frameworks = 'UIKit', 'AVFoundation', 'AVKit'
|
||||
s.dependency 'Imaginary', '~> 4.3.1'
|
||||
s.swift_version = '5.0'
|
||||
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objectVersion = 52;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
@@ -14,11 +14,9 @@
|
||||
44E6A65C2495BFD400543CF0 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44E6A65B2495BFD400543CF0 /* ViewController.swift */; };
|
||||
44E6A6652495C0EB00543CF0 /* Lightbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D523B0A91C43AA2A001AD1EC /* Lightbox.framework */; };
|
||||
44E6A6662495C0EB00543CF0 /* Lightbox.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D523B0A91C43AA2A001AD1EC /* Lightbox.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
44E6A66A2495C13F00543CF0 /* Imaginary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2A58F5D1F7943A30064F14E /* Imaginary.framework */; };
|
||||
44E6A66B2495C13F00543CF0 /* Imaginary.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D2A58F5D1F7943A30064F14E /* Imaginary.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
85CB007027B16C6900A47BB3 /* SDWebImage in Frameworks */ = {isa = PBXBuildFile; productRef = 85CB006F27B16C6900A47BB3 /* SDWebImage */; };
|
||||
D22006741DFB4D9700E92898 /* Lightbox.bundle in Resources */ = {isa = PBXBuildFile; fileRef = D22006731DFB4D9700E92898 /* Lightbox.bundle */; };
|
||||
D2258CC4215CD035005A9A1C /* Color+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2258CC3215CD035005A9A1C /* Color+Extensions.swift */; };
|
||||
D2A58F5E1F7943A30064F14E /* Imaginary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2A58F5D1F7943A30064F14E /* Imaginary.framework */; };
|
||||
D2D71BBC1D54DA77006AB907 /* AssetManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D71BBB1D54DA77006AB907 /* AssetManager.swift */; };
|
||||
D5026B3C1C5BF3FD003BC1A3 /* LightboxImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5026B3B1C5BF3FD003BC1A3 /* LightboxImage.swift */; };
|
||||
D523B0BD1C43AA8B001AD1EC /* LightboxConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = D523B0B61C43AA8A001AD1EC /* LightboxConfig.swift */; };
|
||||
@@ -50,7 +48,6 @@
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
44E6A66B2495C13F00543CF0 /* Imaginary.framework in Embed Frameworks */,
|
||||
44E6A6662495C0EB00543CF0 /* Lightbox.framework in Embed Frameworks */,
|
||||
);
|
||||
name = "Embed Frameworks";
|
||||
@@ -68,7 +65,6 @@
|
||||
44E6A65B2495BFD400543CF0 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
|
||||
D22006731DFB4D9700E92898 /* Lightbox.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Lightbox.bundle; sourceTree = "<group>"; };
|
||||
D2258CC3215CD035005A9A1C /* Color+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Color+Extensions.swift"; sourceTree = "<group>"; };
|
||||
D2A58F5D1F7943A30064F14E /* Imaginary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Imaginary.framework; path = Carthage/Build/iOS/Imaginary.framework; sourceTree = "<group>"; };
|
||||
D2D71BBB1D54DA77006AB907 /* AssetManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssetManager.swift; sourceTree = "<group>"; };
|
||||
D5026B3B1C5BF3FD003BC1A3 /* LightboxImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LightboxImage.swift; sourceTree = "<group>"; };
|
||||
D523B0A91C43AA2A001AD1EC /* Lightbox.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Lightbox.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@@ -90,7 +86,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
44E6A66A2495C13F00543CF0 /* Imaginary.framework in Frameworks */,
|
||||
44E6A6652495C0EB00543CF0 /* Lightbox.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -99,7 +94,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D2A58F5E1F7943A30064F14E /* Imaginary.framework in Frameworks */,
|
||||
85CB007027B16C6900A47BB3 /* SDWebImage in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -129,7 +124,6 @@
|
||||
D2A58F5C1F7943A30064F14E /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D2A58F5D1F7943A30064F14E /* Imaginary.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
@@ -248,6 +242,9 @@
|
||||
dependencies = (
|
||||
);
|
||||
name = "Lightbox-iOS";
|
||||
packageProductDependencies = (
|
||||
85CB006F27B16C6900A47BB3 /* SDWebImage */,
|
||||
);
|
||||
productName = Lightbox;
|
||||
productReference = D523B0A91C43AA2A001AD1EC /* Lightbox.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
@@ -259,7 +256,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 1150;
|
||||
LastUpgradeCheck = 1150;
|
||||
LastUpgradeCheck = 1320;
|
||||
ORGANIZATIONNAME = "Hyper Interaktiv AS";
|
||||
TargetAttributes = {
|
||||
44E6A6462495BFAB00543CF0 = {
|
||||
@@ -281,6 +278,9 @@
|
||||
Base,
|
||||
);
|
||||
mainGroup = D523B09F1C43AA2A001AD1EC;
|
||||
packageReferences = (
|
||||
85CB006E27B16C6900A47BB3 /* XCRemoteSwiftPackageReference "SDWebImage" */,
|
||||
);
|
||||
productRefGroup = D523B0AA1C43AA2A001AD1EC /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
@@ -381,8 +381,11 @@
|
||||
);
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
INFOPLIST_FILE = iOSDemo/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.5;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.elvisnunez.iOSDemo;
|
||||
@@ -410,8 +413,11 @@
|
||||
);
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
INFOPLIST_FILE = iOSDemo/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.5;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.elvisnunez.iOSDemo;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -443,6 +449,7 @@
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
@@ -468,12 +475,12 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 4.2;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
@@ -503,6 +510,7 @@
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
@@ -522,11 +530,12 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 4.2;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
@@ -548,12 +557,18 @@
|
||||
);
|
||||
INFOPLIST_FILE = Lightbox/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Lightbox;
|
||||
PRODUCT_NAME = Lightbox;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -571,12 +586,18 @@
|
||||
);
|
||||
INFOPLIST_FILE = Lightbox/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Lightbox;
|
||||
PRODUCT_NAME = Lightbox;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@@ -611,6 +632,25 @@
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
|
||||
/* Begin XCRemoteSwiftPackageReference section */
|
||||
85CB006E27B16C6900A47BB3 /* XCRemoteSwiftPackageReference "SDWebImage" */ = {
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://github.com/SDWebImage/SDWebImage.git";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 5.0.0;
|
||||
};
|
||||
};
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
/* Begin XCSwiftPackageProductDependency section */
|
||||
85CB006F27B16C6900A47BB3 /* SDWebImage */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = 85CB006E27B16C6900A47BB3 /* XCRemoteSwiftPackageReference "SDWebImage" */;
|
||||
productName = SDWebImage;
|
||||
};
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
};
|
||||
rootObject = D523B0A01C43AA2A001AD1EC /* Project object */;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:Lightbox.xcodeproj">
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1150"
|
||||
LastUpgradeVersion = "1320"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
+2
-4
@@ -8,13 +8,11 @@ let package = Package(
|
||||
name: "Lightbox",
|
||||
targets: ["Lightbox"]),
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/hyperoslo/Imaginary", .branch("master"))
|
||||
],
|
||||
dependencies: [],
|
||||
targets: [
|
||||
.target(
|
||||
name: "Lightbox",
|
||||
dependencies: ["Imaginary"],
|
||||
dependencies: [],
|
||||
path: "Source"
|
||||
)
|
||||
],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
protocol LayoutConfigurable: class {
|
||||
protocol LayoutConfigurable: AnyObject {
|
||||
|
||||
func configureLayout()
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import UIKit
|
||||
import AVKit
|
||||
import AVFoundation
|
||||
import Imaginary
|
||||
|
||||
public class LightboxConfig {
|
||||
/// Whether to show status bar while Lightbox is presented
|
||||
public static var hideStatusBar = true
|
||||
|
||||
public static var imageBackgroundColor = UIColor.black
|
||||
|
||||
/// Provide a closure to handle selected video
|
||||
public static var handleVideo: (_ from: UIViewController, _ videoURL: URL) -> Void = { from, videoURL in
|
||||
@@ -17,19 +18,8 @@ public class LightboxConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/// How to load image onto UIImageView
|
||||
public static var loadImage: (UIImageView, URL, ((UIImage?) -> Void)?) -> Void = { (imageView, imageURL, completion) in
|
||||
|
||||
// Use Imaginary by default
|
||||
imageView.setImage(url: imageURL, placeholder: nil, completion: { result in
|
||||
switch result {
|
||||
case .value(let image):
|
||||
completion?(image)
|
||||
case .error:
|
||||
completion?(nil)
|
||||
}
|
||||
})
|
||||
}
|
||||
/// How to load image onto SDAnimatedImageView
|
||||
public static var loadImage: ((UIImageView, URL, ((UIImage?) -> Void)?) -> Void)?
|
||||
|
||||
/// Indicator is used to show while image is being fetched
|
||||
public static var makeLoadingIndicator: () -> UIView = {
|
||||
|
||||
@@ -1,20 +1,32 @@
|
||||
import UIKit
|
||||
|
||||
public protocol LightboxControllerPageDelegate: class {
|
||||
public protocol LightboxControllerPageDelegate: AnyObject {
|
||||
|
||||
func lightboxController(_ controller: LightboxController, didMoveToPage page: Int)
|
||||
}
|
||||
|
||||
public protocol LightboxControllerDismissalDelegate: class {
|
||||
public protocol LightboxControllerDismissalDelegate: AnyObject {
|
||||
|
||||
func lightboxControllerWillDismiss(_ controller: LightboxController)
|
||||
}
|
||||
|
||||
public protocol LightboxControllerTouchDelegate: class {
|
||||
public protocol LightboxControllerTouchDelegate: AnyObject {
|
||||
|
||||
func lightboxController(_ controller: LightboxController, didTouch image: LightboxImage, at index: Int)
|
||||
}
|
||||
|
||||
public protocol LightboxControllerTapDelegate: AnyObject {
|
||||
|
||||
func lightboxController(_ controller: LightboxController, didTap image: LightboxImage, at index: Int)
|
||||
|
||||
func lightboxController(_ controller: LightboxController, didDoubleTap image: LightboxImage, at index: Int)
|
||||
}
|
||||
|
||||
public protocol LightboxControllerDeleteDelegate: AnyObject {
|
||||
|
||||
func lightboxController(_ controller: LightboxController, willDeleteAt index: Int)
|
||||
}
|
||||
|
||||
open class LightboxController: UIViewController {
|
||||
|
||||
// MARK: - Internal views
|
||||
@@ -139,6 +151,8 @@ open class LightboxController: UIViewController {
|
||||
open weak var pageDelegate: LightboxControllerPageDelegate?
|
||||
open weak var dismissalDelegate: LightboxControllerDismissalDelegate?
|
||||
open weak var imageTouchDelegate: LightboxControllerTouchDelegate?
|
||||
open weak var imageTapDelegate: LightboxControllerTapDelegate?
|
||||
open weak var imageDeleteDelegate: LightboxControllerDeleteDelegate?
|
||||
open internal(set) var presented = false
|
||||
open fileprivate(set) var seen = false
|
||||
|
||||
@@ -166,9 +180,13 @@ open class LightboxController: UIViewController {
|
||||
open override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// 9 July 2020: @3lvis
|
||||
// Lightbox hasn't been optimized to be used in presentation styles other than fullscreen.
|
||||
modalPresentationStyle = .fullScreen
|
||||
|
||||
statusBarHidden = UIApplication.shared.isStatusBarHidden
|
||||
|
||||
view.backgroundColor = UIColor.black
|
||||
view.backgroundColor = LightboxConfig.imageBackgroundColor
|
||||
transitionManager.lightboxController = self
|
||||
transitionManager.scrollView = scrollView
|
||||
transitioningDelegate = transitionManager
|
||||
@@ -181,14 +199,6 @@ open class LightboxController: UIViewController {
|
||||
goTo(initialPage, animated: false)
|
||||
}
|
||||
|
||||
open override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
if !presented {
|
||||
presented = true
|
||||
configureLayout(view.bounds.size)
|
||||
}
|
||||
}
|
||||
|
||||
open override func viewDidLayoutSubviews() {
|
||||
super.viewDidLayoutSubviews()
|
||||
|
||||
@@ -209,6 +219,11 @@ open class LightboxController: UIViewController {
|
||||
width: view.bounds.width,
|
||||
height: 100
|
||||
)
|
||||
|
||||
if !presented {
|
||||
presented = true
|
||||
configureLayout(view.bounds.size)
|
||||
}
|
||||
}
|
||||
|
||||
open override var prefersStatusBarHidden: Bool {
|
||||
@@ -412,6 +427,14 @@ extension LightboxController: PageViewDelegate {
|
||||
let visible = (headerView.alpha == 1.0)
|
||||
toggleControls(pageView: pageView, visible: !visible)
|
||||
}
|
||||
|
||||
func pageViewDidTap(_ pageView: PageView) {
|
||||
imageTapDelegate?.lightboxController(self, didTap: images[currentPage], at: currentPage)
|
||||
}
|
||||
|
||||
func pageViewDidDoubleTap(_ pageView: PageView) {
|
||||
imageTapDelegate?.lightboxController(self, didDoubleTap: images[currentPage], at: currentPage)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - HeaderViewDelegate
|
||||
@@ -421,6 +444,8 @@ extension LightboxController: HeaderViewDelegate {
|
||||
func headerView(_ headerView: HeaderView, didPressDeleteButton deleteButton: UIButton) {
|
||||
deleteButton.isEnabled = false
|
||||
|
||||
imageDeleteDelegate?.lightboxController(self, willDeleteAt: currentPage)
|
||||
|
||||
guard numberOfPages != 1 else {
|
||||
pageViews.removeAll()
|
||||
self.headerView(headerView, didPressCloseButton: headerView.closeButton)
|
||||
@@ -436,6 +461,7 @@ extension LightboxController: HeaderViewDelegate {
|
||||
currentPage -= 1
|
||||
}
|
||||
|
||||
self.initialImages.remove(at: prevIndex)
|
||||
self.pageViews.remove(at: prevIndex).removeFromSuperview()
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import UIKit
|
||||
import Imaginary
|
||||
|
||||
open class LightboxImage {
|
||||
|
||||
@@ -38,7 +37,14 @@ open class LightboxImage {
|
||||
imageView.image = image
|
||||
completion?(image)
|
||||
} else if let imageURL = imageURL {
|
||||
LightboxConfig.loadImage(imageView, imageURL, completion)
|
||||
guard let loadImage = LightboxConfig.loadImage else {
|
||||
print("Lightbox: To use `imageURL`, you must use `LightboxConfig.loadImage`.")
|
||||
imageView.image = nil
|
||||
completion?(nil)
|
||||
return
|
||||
}
|
||||
|
||||
loadImage(imageView, imageURL, completion)
|
||||
} else if let imageClosure = imageClosure {
|
||||
let img = imageClosure()
|
||||
imageView.image = img
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import UIKit
|
||||
|
||||
public protocol FooterViewDelegate: class {
|
||||
public protocol FooterViewDelegate: AnyObject {
|
||||
|
||||
func footerView(_ footerView: FooterView, didExpand expanded: Bool)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import UIKit
|
||||
|
||||
protocol HeaderViewDelegate: class {
|
||||
protocol HeaderViewDelegate: AnyObject {
|
||||
func headerView(_ headerView: HeaderView, didPressDeleteButton deleteButton: UIButton)
|
||||
func headerView(_ headerView: HeaderView, didPressCloseButton closeButton: UIButton)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import UIKit
|
||||
|
||||
public protocol InfoLabelDelegate: class {
|
||||
public protocol InfoLabelDelegate: AnyObject {
|
||||
|
||||
func infoLabel(_ infoLabel: InfoLabel, didExpand expanded: Bool)
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import UIKit
|
||||
|
||||
protocol PageViewDelegate: class {
|
||||
protocol PageViewDelegate: AnyObject {
|
||||
|
||||
func pageViewDidZoom(_ pageView: PageView)
|
||||
func remoteImageDidLoad(_ image: UIImage?, imageView: UIImageView)
|
||||
func pageView(_ pageView: PageView, didTouchPlayButton videoURL: URL)
|
||||
func pageViewDidTouch(_ pageView: PageView)
|
||||
}
|
||||
func pageViewDidTap(_ pageView: PageView)
|
||||
func pageViewDidDoubleTap(_ pageView: PageView)}
|
||||
|
||||
class PageView: UIScrollView {
|
||||
|
||||
@@ -22,8 +23,20 @@ class PageView: UIScrollView {
|
||||
lazy var playButton: UIButton = {
|
||||
let button = UIButton(type: .custom)
|
||||
button.frame.size = CGSize(width: 60, height: 60)
|
||||
button.setBackgroundImage(AssetManager.image("lightbox_play"), for: UIControl.State())
|
||||
var buttonImage = AssetManager.image("lightbox_play")
|
||||
|
||||
// Note by Elvis Nuñez on Mon 22 Jun 08:06
|
||||
// When using SPM you might find that assets are note included. This is a workaround to provide default assets
|
||||
// under iOS 13 so using SPM can work without problems.
|
||||
if #available(iOS 13.0, *) {
|
||||
if buttonImage == nil {
|
||||
buttonImage = UIImage(systemName: "play.circle.fill")
|
||||
}
|
||||
}
|
||||
|
||||
button.setBackgroundImage(buttonImage, for: UIControl.State())
|
||||
button.addTarget(self, action: #selector(playButtonTouched(_:)), for: .touchUpInside)
|
||||
button.tintColor = .white
|
||||
|
||||
button.layer.shadowOffset = CGSize(width: 1, height: 1)
|
||||
button.layer.shadowColor = UIColor.gray.cgColor
|
||||
@@ -134,10 +147,12 @@ class PageView: UIScrollView {
|
||||
let rectToZoomTo = CGRect(x: x, y: y, width: width, height: height)
|
||||
|
||||
zoom(to: rectToZoomTo, animated: true)
|
||||
pageViewDelegate?.pageViewDidDoubleTap(self)
|
||||
}
|
||||
|
||||
@objc func viewTapped(_ recognizer: UITapGestureRecognizer) {
|
||||
pageViewDelegate?.pageViewDidTouch(self)
|
||||
pageViewDelegate?.pageViewDidTap(self)
|
||||
}
|
||||
|
||||
// MARK: - Layout
|
||||
|
||||
@@ -3,7 +3,7 @@ import UIKit
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
lazy var controller: UIViewController = ViewController()
|
||||
lazy var controller: UINavigationController = UINavigationController(rootViewController: ViewController())
|
||||
|
||||
var window: UIWindow?
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import UIKit
|
||||
import Lightbox
|
||||
import SDWebImage
|
||||
|
||||
class ViewController: UIViewController {
|
||||
|
||||
@@ -21,33 +22,46 @@ class ViewController: UIViewController {
|
||||
view.autoresizingMask = [.flexibleTopMargin, .flexibleLeftMargin, .flexibleRightMargin, .flexibleBottomMargin]
|
||||
view.backgroundColor = UIColor.white
|
||||
view.addSubview(showButton)
|
||||
title = "Lightbox"
|
||||
LightboxConfig.preload = 2
|
||||
LightboxConfig.loadImage = { imageView, url, completion in
|
||||
imageView.sd_setImage(with: url) { image, _, _ , _ in
|
||||
completion?(image)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Action methods
|
||||
|
||||
@objc func showLightbox() {
|
||||
let images = [
|
||||
LightboxImage(imageURL: URL(string: "https://cdn.arstechnica.net/2011/10/05/iphone4s_sample_apple-4e8c706-intro.jpg")!),
|
||||
LightboxImage(
|
||||
image: UIImage(named: "photo1")!,
|
||||
text: "Photography is the science, art, application and practice of creating durable images by recording light or other electromagnetic radiation, either electronically by means of an image sensor, or chemically by means of a light-sensitive material such as photographic film"
|
||||
),
|
||||
LightboxImage(
|
||||
image: UIImage(named: "photo2")!,
|
||||
text: "Emoji 😍 (/ɪˈmoʊdʒi/; singular emoji, plural emoji or emojis;[4] from the Japanese 絵文字えもじ, pronounced [emodʑi]) are ideograms and smileys used in electronic messages and web pages. Emoji are used much like emoticons and exist in various genres, including facial expressions, common objects, places and types of weather 🌅☔️💦, and animals 🐶🐱",
|
||||
videoURL: URL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
|
||||
),
|
||||
LightboxImage(
|
||||
image: UIImage(named: "photo3")!,
|
||||
text: "A lightbox is a translucent surface illuminated from behind, used for situations where a shape laid upon the surface needs to be seen with high contrast."
|
||||
)
|
||||
]
|
||||
|
||||
let controller = LightboxController(images: images)
|
||||
controller.modalPresentationStyle = .fullScreen
|
||||
controller.dynamicBackground = true
|
||||
|
||||
present(controller, animated: true, completion: nil)
|
||||
}
|
||||
@objc func showLightbox() {
|
||||
let images = [
|
||||
LightboxImage(imageURL: URL(string: "https://media.giphy.com/media/Ku65904QQe4yez448B/giphy.gif")!),
|
||||
LightboxImage(imageURL: URL(string: "https://media.giphy.com/media/lQDLwWUMPaAHvh8pAG/giphy.gif")!),
|
||||
LightboxImage(imageURL: URL(string: "https://media.giphy.com/media/ontKwPWJxARsuKaKqJ/giphy.gif")!),
|
||||
LightboxImage(
|
||||
image: UIImage(named: "photo1")!,
|
||||
text: "Photography is the science, art, application and practice of creating durable images by recording light or other electromagnetic radiation, either electronically by means of an image sensor, or chemically by means of a light-sensitive material such as photographic film"
|
||||
),
|
||||
|
||||
LightboxImage(imageURL: URL(string: "https://via.placeholder.com/300.png/09f/fff")!),
|
||||
|
||||
|
||||
LightboxImage(
|
||||
image: UIImage(named: "photo2")!,
|
||||
text: "Emoji 😍 (/ɪˈmoʊdʒi/; singular emoji, plural emoji or emojis;[4] from the Japanese 絵文字えもじ, pronounced [emodʑi]) are ideograms and smileys used in electronic messages and web pages. Emoji are used much like emoticons and exist in various genres, including facial expressions, common objects, places and types of weather 🌅☔️💦, and animals 🐶🐱",
|
||||
videoURL: URL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
|
||||
),
|
||||
LightboxImage(
|
||||
image: UIImage(named: "photo3")!,
|
||||
text: "A lightbox is a translucent surface illuminated from behind, used for situations where a shape laid upon the surface needs to be seen with high contrast."
|
||||
),
|
||||
LightboxImage(imageURL: URL(string: "https://c.tenor.com/kccsHXtdDn0AAAAC/alcohol-wine.gif")!)
|
||||
]
|
||||
|
||||
let controller = LightboxController(images: images)
|
||||
controller.dynamicBackground = true
|
||||
|
||||
present(controller, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user