11 Commits

Author SHA1 Message Date
Khoa Pham 90fe59ffc6 Bump to 2.1.1 2017-11-21 14:24:34 +01:00
Khoa Pham 422b23b4c2 Update README.md 2017-11-21 10:41:26 +01:00
Khoa Pham 08a4c284f4 Merge pull request #156 from andreyrd/fix/no-window-bounds
Use view.bounds instead of UIApplicationDelegate.window.bounds
2017-11-20 21:59:07 +01:00
Khoa Pham b775f12fe5 Merge pull request #157 from hyperoslo/fix/truncating
Add test
2017-11-20 15:47:17 +01:00
Khoa Pham 9f75ddffdf Use just 1 test 2017-11-20 14:53:21 +01:00
Khoa Pham 225fac033a Remove fileprivate in order to test 2017-11-20 14:49:26 +01:00
Khoa Pham fe3229278d Add test 2017-11-20 14:48:57 +01:00
Khoa Pham de0d273258 Add quotes 2017-11-20 14:26:01 +01:00
Khoa Pham d1231f19ff Fix swiftlint warnings 2017-11-20 14:25:33 +01:00
Khoa Pham 20f927f338 Need to greater than startIndex 2017-11-20 14:22:40 +01:00
Andrey Radchishin 8144d96129 Use view.bounds instead of UIApplicationDelegate.window.bounds 2017-11-17 10:11:20 -08:00
10 changed files with 204 additions and 13 deletions
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
+13
View File
@@ -0,0 +1,13 @@
import XCTest
@testable import Lightbox
class InfoLabelTests: XCTestCase {
func testTruncating() {
let label = InfoLabel(text: "", expanded: false)
label.frame.size = CGSize(width: 10, height: 10)
let text = Array(repeating: "A", count: 4).joined(separator: "")
label.fullText = text
_ = label.truncatedText
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
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.1.0"
s.version = "2.1.1"
s.homepage = "https://github.com/hyperoslo/Lightbox"
s.license = 'MIT'
s.author = { "Hyper Interaktiv AS" => "ios@hyper.no" }
+133
View File
@@ -8,6 +8,8 @@
/* Begin PBXBuildFile section */
D22006741DFB4D9700E92898 /* Lightbox.bundle in Resources */ = {isa = PBXBuildFile; fileRef = D22006731DFB4D9700E92898 /* Lightbox.bundle */; };
D229B5E61FC3123F00F04123 /* Lightbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D523B0A91C43AA2A001AD1EC /* Lightbox.framework */; };
D229B5ED1FC3125D00F04123 /* InfoLabelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D229B5EC1FC3125D00F04123 /* InfoLabelTests.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 */; };
@@ -24,8 +26,21 @@
D58A18CB1C5ABF8F000024BB /* FooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D58A18CA1C5ABF8F000024BB /* FooterView.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
D229B5E71FC3123F00F04123 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = D523B0A01C43AA2A001AD1EC /* Project object */;
proxyType = 1;
remoteGlobalIDString = D523B0A81C43AA2A001AD1EC;
remoteInfo = "Lightbox-iOS";
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
D22006731DFB4D9700E92898 /* Lightbox.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Lightbox.bundle; sourceTree = "<group>"; };
D229B5E11FC3123F00F04123 /* Lightbox-iOS-Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Lightbox-iOS-Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
D229B5E51FC3123F00F04123 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
D229B5EC1FC3125D00F04123 /* InfoLabelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoLabelTests.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>"; };
@@ -45,6 +60,14 @@
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
D229B5DE1FC3123F00F04123 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D229B5E61FC3123F00F04123 /* Lightbox.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
D523B0A51C43AA2A001AD1EC /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -65,6 +88,15 @@
path = Resources;
sourceTree = "<group>";
};
D229B5E21FC3123F00F04123 /* Lightbox-iOS-Tests */ = {
isa = PBXGroup;
children = (
D229B5E51FC3123F00F04123 /* Info.plist */,
D229B5EC1FC3125D00F04123 /* InfoLabelTests.swift */,
);
path = "Lightbox-iOS-Tests";
sourceTree = "<group>";
};
D2A58F5C1F7943A30064F14E /* Frameworks */ = {
isa = PBXGroup;
children = (
@@ -80,6 +112,7 @@
D54DFCC01C5AAAF100ADEA0E /* Hue.framework */,
D523B0B41C43AA8A001AD1EC /* Source */,
D523B0AB1C43AA2A001AD1EC /* Lightbox */,
D229B5E21FC3123F00F04123 /* Lightbox-iOS-Tests */,
D523B0AA1C43AA2A001AD1EC /* Products */,
D2A58F5C1F7943A30064F14E /* Frameworks */,
);
@@ -89,6 +122,7 @@
isa = PBXGroup;
children = (
D523B0A91C43AA2A001AD1EC /* Lightbox.framework */,
D229B5E11FC3123F00F04123 /* Lightbox-iOS-Tests.xctest */,
);
name = Products;
sourceTree = "<group>";
@@ -149,6 +183,24 @@
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
D229B5E01FC3123F00F04123 /* Lightbox-iOS-Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = D229B5E91FC3123F00F04123 /* Build configuration list for PBXNativeTarget "Lightbox-iOS-Tests" */;
buildPhases = (
D229B5DD1FC3123F00F04123 /* Sources */,
D229B5DE1FC3123F00F04123 /* Frameworks */,
D229B5DF1FC3123F00F04123 /* Resources */,
);
buildRules = (
);
dependencies = (
D229B5E81FC3123F00F04123 /* PBXTargetDependency */,
);
name = "Lightbox-iOS-Tests";
productName = "Lightbox-iOS-Tests";
productReference = D229B5E11FC3123F00F04123 /* Lightbox-iOS-Tests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
D523B0A81C43AA2A001AD1EC /* Lightbox-iOS */ = {
isa = PBXNativeTarget;
buildConfigurationList = D523B0B11C43AA2A001AD1EC /* Build configuration list for PBXNativeTarget "Lightbox-iOS" */;
@@ -175,9 +227,14 @@
D523B0A01C43AA2A001AD1EC /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0910;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Hyper Interaktiv AS";
TargetAttributes = {
D229B5E01FC3123F00F04123 = {
CreatedOnToolsVersion = 9.1;
ProvisioningStyle = Automatic;
};
D523B0A81C43AA2A001AD1EC = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0900;
@@ -197,11 +254,19 @@
projectRoot = "";
targets = (
D523B0A81C43AA2A001AD1EC /* Lightbox-iOS */,
D229B5E01FC3123F00F04123 /* Lightbox-iOS-Tests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
D229B5DF1FC3123F00F04123 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
D523B0A71C43AA2A001AD1EC /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -246,6 +311,14 @@
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
D229B5DD1FC3123F00F04123 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D229B5ED1FC3125D00F04123 /* InfoLabelTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
D523B0A41C43AA2A001AD1EC /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -267,7 +340,58 @@
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
D229B5E81FC3123F00F04123 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = D523B0A81C43AA2A001AD1EC /* Lightbox-iOS */;
targetProxy = D229B5E71FC3123F00F04123 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
D229B5EA1FC3123F00F04123 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "Lightbox-iOS-Tests/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.fantageek.Lightbox-iOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
D229B5EB1FC3123F00F04123 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "Lightbox-iOS-Tests/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.fantageek.Lightbox-iOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
D523B0AF1C43AA2A001AD1EC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -423,6 +547,15 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
D229B5E91FC3123F00F04123 /* Build configuration list for PBXNativeTarget "Lightbox-iOS-Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D229B5EA1FC3123F00F04123 /* Debug */,
D229B5EB1FC3123F00F04123 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
D523B0A31C43AA2A001AD1EC /* Build configuration list for PBXProject "Lightbox" */ = {
isa = XCConfigurationList;
buildConfigurations = (
@@ -29,7 +29,26 @@
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D229B5E01FC3123F00F04123"
BuildableName = "Lightbox-iOS-Tests.xctest"
BlueprintName = "Lightbox-iOS-Tests"
ReferencedContainer = "container:Lightbox.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D523B0A81C43AA2A001AD1EC"
BuildableName = "Lightbox.framework"
BlueprintName = "Lightbox-iOS"
ReferencedContainer = "container:Lightbox.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
+1 -1
View File
@@ -110,7 +110,7 @@ extension ViewController: LightboxControllerDismissalDelegate: class {
### Image loading
By default images are loaded using [Imagary](https://github.com/hyperoslo/Imaginary) for reliable loading and caching. But it's easy to change this behavior using **LightboxConfig**
By default images are loaded using [Imaginary](https://github.com/hyperoslo/Imaginary) for reliable loading and caching. But it's easy to change this behavior using **LightboxConfig**
```swift
LightboxConfig.loadImage = {
+1 -2
View File
@@ -19,8 +19,7 @@ public class LightboxConfig {
}
/// How to load image onto UIImageView
public static var loadImage: (UIImageView, URL, ((UIImage?) -> Void)?) -> Void =
{ (imageView, imageURL , completion) in
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
+5 -5
View File
@@ -121,7 +121,7 @@ open class LightboxController: UIViewController {
open var spacing: CGFloat = 20 {
didSet {
configureLayout()
configureLayout(view.bounds.size)
}
}
@@ -184,7 +184,7 @@ open class LightboxController: UIViewController {
super.viewDidAppear(animated)
if !presented {
presented = true
configureLayout()
configureLayout(view.bounds.size)
}
}
@@ -235,7 +235,7 @@ open class LightboxController: UIViewController {
pageViews.append(pageView)
}
configureLayout()
configureLayout(view.bounds.size)
}
// MARK: - Pagination
@@ -271,7 +271,7 @@ open class LightboxController: UIViewController {
// MARK: - Layout
open func configureLayout(_ size: CGSize = UIApplication.shared.delegate?.window??.bounds.size ?? .zero) {
open func configureLayout(_ size: CGSize) {
scrollView.frame.size = size
scrollView.contentSize = CGSize(
width: size.width * CGFloat(numberOfPages) + spacing * CGFloat(numberOfPages - 1),
@@ -400,7 +400,7 @@ extension LightboxController: HeaderViewDelegate {
self.pageViews.remove(at: prevIndex).removeFromSuperview()
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5) {
self.configureLayout()
self.configureLayout(self.view.bounds.size)
self.currentPage = Int(self.scrollView.contentOffset.x / self.view.bounds.width)
deleteButton.isEnabled = true
}
+1 -1
View File
@@ -104,7 +104,7 @@ extension HeaderView: LayoutConfigurable {
x: bounds.width - closeButton.frame.width - 17,
y: topPadding
)
deleteButton.frame.origin = CGPoint(
x: 17,
y: topPadding
+8 -3
View File
@@ -41,7 +41,7 @@ open class InfoLabel: UILabel {
}
}
fileprivate var truncatedText: String {
var truncatedText: String {
var truncatedText = fullText
guard numberOfLines(fullText) > numberOfVisibleLines else {
@@ -60,8 +60,13 @@ open class InfoLabel: UILabel {
// Remove characters ahead of ellipsis until the text is the right number of lines
while numberOfLines(truncatedText) > numberOfVisibleLines {
truncatedTextCursor = truncatedText.index(before: truncatedTextCursor)
truncatedText.remove(at: truncatedTextCursor)
// To avoid "Cannot decrement before startIndex"
guard truncatedTextCursor > truncatedText.startIndex else {
break
}
truncatedTextCursor = truncatedText.index(before: truncatedTextCursor)
truncatedText.remove(at: truncatedTextCursor)
}
return truncatedText