Skip to content

Commit

Permalink
Bump podspec, some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
JanGorman committed Sep 28, 2022
1 parent 72009dc commit cb52799
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 48 deletions.
8 changes: 4 additions & 4 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
excluded:
- Frameworks/SwiftyGif
- Carthage/Checkouts

identifier_name:
min_length:
error: 3
Expand Down Expand Up @@ -58,7 +62,3 @@ disabled_rules:
- vertical_parameter_alignment
- force_try
- object_literal

excluded:
- Frameworks/SwiftyGif
- Carthage/Checkouts
4 changes: 2 additions & 2 deletions Agrume.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "Agrume"
s.version = "5.8.4"
s.version = "5.8.5"
s.summary = "An iOS image viewer written in Swift."
s.swift_version = "5.0"

Expand All @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
s.author = { "Jan Gorman" => "[email protected]" }
s.social_media_url = "https://twitter.com/JanGorman"

s.platform = :ios, "9.0"
s.platform = :ios, "13.0"

s.source = { :git => "https://github.com/JanGorman/Agrume.git", :tag => s.version}

Expand Down
34 changes: 26 additions & 8 deletions Agrume.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -309,6 +309,7 @@
/* Begin PBXShellScriptBuildPhase section */
77CAF6741FADFD45000C0929 /* Run SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -412,7 +413,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -466,10 +467,11 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -489,7 +491,11 @@
ENABLE_TESTABILITY = YES;
INFOPLIST_FILE = Agrume/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.schnaub.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -510,7 +516,11 @@
ENABLE_TESTABILITY = YES;
INFOPLIST_FILE = Agrume/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.schnaub.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -527,7 +537,11 @@
"$(inherited)",
);
INFOPLIST_FILE = AgrumeTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.schnaub.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -541,7 +555,11 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
INFOPLIST_FILE = AgrumeTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.schnaub.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
Expand Down
117 changes: 94 additions & 23 deletions Agrume/Agrume.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,20 @@ public final class Agrume: UIViewController {
/// - dismissal: The dismiss configuration
/// - overlayView: View to overlay the image (does not display with 'button' dismissals)
/// - enableLiveText: Enables Live Text interaction, iOS 16 only
public convenience init(image: UIImage, background: Background = .colored(.black),
dismissal: Dismissal = .withPan(.standard), overlayView: AgrumeOverlayView? = nil, enableLiveText: Bool = false) {
self.init(images: [image], background: background, dismissal: dismissal, overlayView: overlayView, enableLiveText: enableLiveText)
public convenience init(
image: UIImage,
background: Background = .colored(.black),
dismissal: Dismissal = .withPan(.standard),
overlayView: AgrumeOverlayView? = nil,
enableLiveText: Bool = false
) {
self.init(
images: [image],
background: background,
dismissal: dismissal,
overlayView: overlayView,
enableLiveText: enableLiveText
)
}

/// Initialize with a single image url
Expand All @@ -78,9 +89,20 @@ public final class Agrume: UIViewController {
/// - dismissal: The dismiss configuration
/// - overlayView: View to overlay the image (does not display with 'button' dismissals)
/// - enableLiveText: Enables Live Text interaction, iOS 16 only
public convenience init(url: URL, background: Background = .colored(.black), dismissal: Dismissal = .withPan(.standard),
overlayView: AgrumeOverlayView? = nil, enableLiveText: Bool = false) {
self.init(urls: [url], background: background, dismissal: dismissal, overlayView: overlayView, enableLiveText: enableLiveText)
public convenience init(
url: URL,
background: Background = .colored(.black),
dismissal: Dismissal = .withPan(.standard),
overlayView: AgrumeOverlayView? = nil,
enableLiveText: Bool = false
) {
self.init(
urls: [url],
background: background,
dismissal: dismissal,
overlayView: overlayView,
enableLiveText: enableLiveText
)
}

/// Initialize with a data source
Expand All @@ -92,10 +114,23 @@ public final class Agrume: UIViewController {
/// - dismissal: The dismiss configuration
/// - overlayView: View to overlay the image (does not display with 'button' dismissals)
/// - enableLiveText: Enables Live Text interaction, iOS 16 only
public convenience init(dataSource: AgrumeDataSource, startIndex: Int = 0, background: Background = .colored(.black),
dismissal: Dismissal = .withPan(.standard), overlayView: AgrumeOverlayView? = nil, enableLiveText: Bool = false) {
self.init(images: nil, dataSource: dataSource, startIndex: startIndex, background: background, dismissal: dismissal,
overlayView: overlayView, enableLiveText: enableLiveText)
public convenience init(
dataSource: AgrumeDataSource,
startIndex: Int = 0,
background: Background = .colored(.black),
dismissal: Dismissal = .withPan(.standard),
overlayView: AgrumeOverlayView? = nil,
enableLiveText: Bool = false
) {
self.init(
images: nil,
dataSource: dataSource,
startIndex: startIndex,
background: background,
dismissal: dismissal,
overlayView: overlayView,
enableLiveText: enableLiveText
)
}

/// Initialize with an array of images
Expand All @@ -107,9 +142,23 @@ public final class Agrume: UIViewController {
/// - dismissal: The dismiss configuration
/// - overlayView: View to overlay the image (does not display with 'button' dismissals)
/// - enableLiveText: Enables Live Text interaction, iOS 16 only
public convenience init(images: [UIImage], startIndex: Int = 0, background: Background = .colored(.black),
dismissal: Dismissal = .withPan(.standard), overlayView: AgrumeOverlayView? = nil, enableLiveText: Bool = false) {
self.init(images: images, urls: nil, startIndex: startIndex, background: background, dismissal: dismissal, overlayView: overlayView, enableLiveText: enableLiveText)
public convenience init(
images: [UIImage],
startIndex: Int = 0,
background: Background = .colored(.black),
dismissal: Dismissal = .withPan(.standard),
overlayView: AgrumeOverlayView? = nil,
enableLiveText: Bool = false
) {
self.init(
images: images,
urls: nil,
startIndex: startIndex,
background: background,
dismissal: dismissal,
overlayView: overlayView,
enableLiveText: enableLiveText
)
}

/// Initialize with an array of image urls
Expand All @@ -121,13 +170,35 @@ public final class Agrume: UIViewController {
/// - dismissal: The dismiss configuration
/// - overlayView: View to overlay the image (does not display with 'button' dismissals)
/// - enableLiveText: Enables Live Text interaction, iOS 16 only
public convenience init(urls: [URL], startIndex: Int = 0, background: Background = .colored(.black),
dismissal: Dismissal = .withPan(.standard), overlayView: AgrumeOverlayView? = nil, enableLiveText: Bool = false) {
self.init(images: nil, urls: urls, startIndex: startIndex, background: background, dismissal: dismissal, overlayView: overlayView, enableLiveText: enableLiveText)
public convenience init(
urls: [URL],
startIndex: Int = 0,
background: Background = .colored(.black),
dismissal: Dismissal = .withPan(.standard),
overlayView: AgrumeOverlayView? = nil,
enableLiveText: Bool = false
) {
self.init(
images: nil,
urls: urls,
startIndex: startIndex,
background: background,
dismissal: dismissal,
overlayView: overlayView,
enableLiveText: enableLiveText
)
}

private init(images: [UIImage]? = nil, urls: [URL]? = nil, dataSource: AgrumeDataSource? = nil, startIndex: Int,
background: Background, dismissal: Dismissal, overlayView: AgrumeOverlayView? = nil, enableLiveText: Bool = false) {
private init(
images: [UIImage]? = nil,
urls: [URL]? = nil,
dataSource: AgrumeDataSource? = nil,
startIndex: Int,
background: Background,
dismissal: Dismissal,
overlayView: AgrumeOverlayView? = nil,
enableLiveText: Bool = false
) {
switch (images, urls) {
case (let images?, nil):
self.images = images.map { AgrumeImage(image: $0) }
Expand Down Expand Up @@ -216,9 +287,9 @@ public final class Agrume: UIViewController {
let indicatorStyle: UIActivityIndicatorView.Style
switch background {
case let .blurred(style):
indicatorStyle = style == .dark ? .whiteLarge : .gray
indicatorStyle = style == .dark ? .large : .medium
case let .colored(color):
indicatorStyle = color.isLight ? .gray : .whiteLarge
indicatorStyle = color.isLight ? .medium : .large
}
let spinner = UIActivityIndicatorView(style: indicatorStyle)
spinner.center = view.center
Expand Down Expand Up @@ -255,7 +326,7 @@ public final class Agrume: UIViewController {
let replacement = with(images[index]) {
$0.url = nil
$0.image = image
if let newTitle = newTitle {
if let newTitle {
$0.title = newTitle
}
}
Expand All @@ -275,7 +346,7 @@ public final class Agrume: UIViewController {
let replacement = with(images[index]) {
$0.image = nil
$0.url = url
if let newTitle = newTitle {
if let newTitle {
$0.title = newTitle
}
}
Expand Down Expand Up @@ -309,7 +380,7 @@ public final class Agrume: UIViewController {
return
}
fetchImage(forIndex: currentIndex) { [weak self] image in
guard let self = self else {
guard let self else {
return
}
self.onLongPress?(image, self)
Expand Down
8 changes: 4 additions & 4 deletions Agrume/AgrumeCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ extension AgrumeCell: UIGestureRecognizerDelegate {

CATransaction.begin()
CATransaction.setCompletionBlock { [weak self] in
// captures self weakly to avoid extending the lifetime of the cell
guard let self = self else { return }
// captures self weakly to avoid extending the lifetime of the cell
guard let self else { return }
self.contentView.isUserInteractionEnabled = true
}
scrollView.zoom(to: destination, animated: true)
Expand Down Expand Up @@ -257,7 +257,7 @@ extension AgrumeCell: UIGestureRecognizerDelegate {

@objc
private func dismissPan(_ gesture: UIPanGestureRecognizer) {
guard let panPhysics = panPhysics else { return }
guard let panPhysics else { return }

let translation = gesture.translation(in: gesture.view)
let locationInView = gesture.location(in: gesture.view)
Expand Down Expand Up @@ -311,7 +311,7 @@ extension AgrumeCell: UIGestureRecognizerDelegate {
}

private func dismissWithFlick(_ velocity: CGPoint) {
guard let panPhysics = panPhysics else { return }
guard let panPhysics else { return }

flickedToDismiss = true

Expand Down
2 changes: 1 addition & 1 deletion Agrume/AgrumePhotoLibraryHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public final class AgrumePhotoLibraryHelper: NSObject {
/// Save the current photo shown in the user's photo library using Long Press Gesture
/// Make sure to have NSPhotoLibraryUsageDescription (ios 10) and NSPhotoLibraryAddUsageDescription (ios 11+) in your info.plist
public func makeSaveToLibraryLongPressGesture(for image: UIImage?, viewController: UIViewController) {
guard let image = image else {
guard let image else {
return
}
let view = viewController.view!
Expand Down
9 changes: 5 additions & 4 deletions Agrume/ImageDownloader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class ImageDownloader {
completion(image)
}
}
guard let data = data, error == nil else {
guard let data, error == nil else {
return
}
if isAnimatedImage(data) {
Expand All @@ -41,9 +41,10 @@ final class ImageDownloader {

private static func isAnimatedImage(_ data: Data) -> Bool {
guard let imageSource = CGImageSourceCreateWithData(data as CFData, nil),
let imageType = CGImageSourceGetType(imageSource) else {
return false
}
let imageType = CGImageSourceGetType(imageSource)
else {
return false
}
return UTTypeConformsTo(imageType, kUTTypeGIF)
}

Expand Down
9 changes: 8 additions & 1 deletion Example/Agrume Example/LiveTextViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ final class LiveTextViewController: UIViewController {
return
}

let alert = UIAlertController(title: "Not supported on this device", message: "Live Text is available for devices with iOS 16 (or above) and A12 (or above) Bionic chip (iPhone XS and later, physical device only)", preferredStyle: .alert)
let alert = UIAlertController(
title: "Not supported on this device",
message: """
Live Text is available for devices with iOS 16 (or above) and A12 (or above)
Bionic chip (iPhone XS and later, physical device only)
""",
preferredStyle: .alert
)
alert.addAction(UIAlertAction(title: "OK", style: .cancel))
present(alert, animated: true)
}
Expand Down
2 changes: 1 addition & 1 deletion Frameworks/SwiftyGif

0 comments on commit cb52799

Please sign in to comment.