105 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
Khoa Pham 0d9e3ef7ab Bump to 2.1.0 2017-11-17 16:21:51 +01:00
Khoa Pham 888067cae0 Merge pull request #155 from hyperoslo/fix/image_download
Allow custom download
2017-11-17 16:21:18 +01:00
Khoa Pham 0180ca76c7 Update README 2017-11-17 15:16:20 +01:00
Khoa Pham 951b95b0fb Update README 2017-11-17 15:08:28 +01:00
Khoa Pham 1803722b6a Expose LightboxConfig.loadImage. Use Imaginary by default 2017-11-17 15:04:31 +01:00
Khoa Pham 4f5ee72f97 Merge pull request #154 from hyperoslo/fix/layout
Update layout for iPhone X
2017-11-17 14:45:57 +01:00
Khoa Pham 9e17ebb58f Update README with 2 screenshots 2017-11-17 14:37:59 +01:00
Khoa Pham 28acb5a8d6 Layout HeaderView 2017-11-17 14:30:47 +01:00
Khoa Pham 5c6fa430e0 Remove HeaderView animation when dismissasl 2017-11-17 14:27:27 +01:00
Khoa Pham 5108f3651f Remove centerTextStyle 2017-11-17 14:26:59 +01:00
Khoa Pham 05ec840ffd Fix indentation 2017-11-17 14:20:20 +01:00
Khoa Pham 5189d880c4 Should not animate FooterView upon dismissal animation 2017-11-17 14:17:02 +01:00
Khoa Pham 308051a898 Remove unused isUserInteractionEnabled 2017-11-17 14:04:00 +01:00
Khoa Pham 56481d5f8a Update description text 2017-11-17 13:55:48 +01:00
Khoa Pham 3882befd7b Layout FooterView in viewDidLayoutSubviews 2017-11-17 13:52:50 +01:00
Khoa Pham cf88115eb6 Use view bounds instead of UIScreen 2017-11-17 13:31:56 +01:00
Khoa Pham 663bafce52 Use bottomPadding for pageLabel 2017-11-17 13:19:45 +01:00
Khoa Pham 6911104a98 Use topPadding for HeaderView buttons 2017-11-17 12:51:26 +01:00
Vadym Markov 369252ee7c Merge pull request #152 from andreyrd/string-characters-deprecated
Use String directly instead of String.characters
2017-11-13 20:08:00 +01:00
Andrey Radchishin 3322107688 Use String directly instead of String.characters 2017-11-13 09:02:46 -08:00
Khoa Pham 7731adc79c Update README.md 2017-11-06 12:15:10 +01:00
Khoa Pham 5c48b2482a Bump to 2.0.1 2017-11-02 13:03:21 +01:00
Khoa Pham 83416d6870 Merge pull request #147 from hyperoslo/fix/carthage
Update Carthage
2017-11-02 13:02:44 +01:00
Khoa Pham 4f9540b4df Update Cartfile 2017-11-02 12:57:58 +01:00
Khoa Pham 304c3e61f6 Just run carthage update 2017-11-02 12:51:28 +01:00
Khoa Pham 026153f502 Merge pull request #143 from bchrobot/fix-index-error
Refactored truncatedText getter to prevent occasional EXC_BREAKPOINT crash
2017-10-15 18:20:15 +02:00
Benjamin Chrobot 6e53ee01c7 Refactored truncatedText getter to prevent occassional 'EXC_BREAKPOINT: cannot decrement invalid index' crash. 2017-10-13 13:49:51 -04:00
Khoa Pham 9882c474a6 Merge pull request #139 from hyperoslo/swift4
Swift4
2017-10-03 15:33:55 +02:00
Khoa Pham 593c2ac5f3 Merge from master 2017-10-03 14:47:18 +02:00
Khoa Pham 23340fc075 Update demo 2017-10-03 14:44:55 +02:00
Khoa Pham 0bd57097aa Lock dependencies versions 2017-10-03 14:41:40 +02:00
Khoa Pham 9ede29331a Make demo app universal 2017-10-03 14:34:08 +02:00
Khoa Pham 8f51e95e35 Add emojis 2017-10-03 14:34:02 +02:00
Khoa Pham eb4b12f633 Bump 1.1.0 2017-10-03 13:34:07 +02:00
Khoa Pham c00d8b62dd Update demo 2017-10-03 13:31:18 +02:00
Khoa Pham 0d60426da2 Lock to 2.0 2017-10-03 13:28:30 +02:00
Khoa Pham fec46dbd52 Merge pull request #138 from TParizek/master
Specified Hue dependency version in podspec - Issue 137
2017-10-03 13:26:01 +02:00
Tomáš Pařízek 54da63c4a1 Specified Hue dependency version in podspec 2017-10-02 14:16:02 +02:00
Khoa Pham 9d0a0a9811 Merge pull request #136 from hyperoslo/fix/config
Allow loadingIndicator to be configured
2017-09-26 16:22:46 +02:00
Khoa Pham 401cfe185a Use loadingIndicator from Config 2017-09-26 14:41:16 +02:00
Khoa Pham db80c7384c Add comments. Add makeLoadingIndicator 2017-09-26 14:40:46 +02:00
Khoa Pham d03d724746 Merge pull request #135 from hyperoslo/fix/imaginary
Add Imaginary
2017-09-25 16:41:08 +02:00
Khoa Pham cb583ef202 Add bootstrap scripts for Carthage 2017-09-25 16:30:20 +02:00
Khoa Pham d92b2c3e79 Add comments 2017-09-25 16:20:21 +02:00
Khoa Pham d0923f2660 Remove typealias 2017-09-25 16:15:16 +02:00
Khoa Pham 961020ea94 Update demo 2017-09-25 16:14:39 +02:00
Khoa Pham 8867836ff5 Use Imaginary to load image 2017-09-25 16:06:16 +02:00
Khoa Pham aec061594d Add Imaginary 2017-09-25 16:01:57 +02:00
Khoa Pham 45abbf66ad Disable Swift 3 @objc Inference 2017-09-25 15:40:28 +02:00
Khoa Pham 59d59bd532 Use swift 4 2017-09-25 15:39:22 +02:00
Khoa Pham 29f5e05f1b Add circle CI 2017-09-25 15:38:40 +02:00
Khoa Pham 7885828fa3 Use latest version of Hue 2017-09-25 15:36:30 +02:00
Khoa Pham a69fb3da17 Use swift 4 2017-09-25 15:35:28 +02:00
Khoa Pham 0e16f68dc1 Remove travis 2017-09-25 15:34:47 +02:00
Khoa Pham 5cd6b4b698 Merge pull request #134 from mhassanpur/master
Fixes Swift 4 errors and warnings
2017-09-25 15:32:37 +02:00
Mujtaba Hassanpur b5d86f1f79 Fixes more issues with @objc modifier on configureLayout() methods 2017-09-21 10:28:51 -07:00
Mujtaba Hassanpur 68a429be43 Fixes Swift 4 errors and warnings 2017-09-20 21:14:45 -07:00
Christoffer Winterkvist ec1200faea Merge pull request #129 from r-mckay/feature/useSwiftLint
project: use swiftlint and fix triggered warnings
2017-09-03 14:32:32 +02:00
Romain Bertozzi f0825e09d5 source: fix SwiftLint unused closure parameters
This commit fixes several warnings concerning unused closure parameters.
2017-09-02 12:23:47 -04:00
Romain Bertozzi 1e354c2675 source: fix SwiftLint option redondant init
This commit fixes a SwiftLint Option Redondant Initialization warning in
a file.
2017-09-02 12:19:36 -04:00
Romain Bertozzi eade5ac4c8 source: fix SwiftLint colon violation
This commit takes care of fixing a SwiftLint Colon Violation in a file.
2017-09-02 12:19:36 -04:00
Romain Bertozzi 8a33f9529b source: fix SwiftLint parameter alignement violation
This commit aligns parameters in a call to fix a SwiftLint warning.
2017-09-02 12:19:36 -04:00
Romain Bertozzi 4abeb93ac7 source: remove trailing spaces
This commit solves the SwiftLint warning concerning the trailing spaces.
2017-09-02 12:19:36 -04:00
Romain Bertozzi 619f84d89e project: add build phase running SwiftLint
This commit adds a build phase to the project to run SwiftLint. This new
phase follows the implementation made in the ImagePicker project [1].

This commit does not try to handle the eventual warning that could be
raised by the static code analysis.

[1] https://github.com/hyperoslo/ImagePicker
2017-09-02 12:19:36 -04:00
Christoffer Winterkvist 9531315c94 Merge pull request #123 from ShaneQi/fix_hide_status_bar_and_footer_gradient
Fixed two bugs.
2017-09-01 09:03:37 +02:00
Vadym Markov cfafbbcb14 Merge pull request #127 from r-mckay/fix/resolveWarning
lightboxController: fix warning
2017-08-27 19:40:37 +02:00
Shane Qi 6a6096e0b8 Fixed footer view gradient.
Should remove gradient layer if infoLabel's text is empty, regardless expanded state.

This is a override commit, in order to run CI again.
2017-08-26 19:54:37 -05:00
Romain Bertozzi 1480a44dfb lightboxController: fix warning
This commit fixes a warning indicating that a variable value was never
mutated and should be a constant.

To fix this warning we actually replace the 'var' by a 'let'.
2017-08-26 17:45:00 -04:00
Christoffer Winterkvist 2687d175c1 Merge pull request #128 from r-mckay/fix/continuousIntegration
project: update continuous integration setup
2017-08-26 13:51:32 +02:00
Romain Bertozzi c84682d3d9 project: update continuous integration setup
This commit updates the continuous integration setup by selecting the
Xcode 8.3 osx_image and by indicating that the project is written in
swift.
2017-08-25 16:12:33 -04:00
Shane Qi 6627936d23 Fixed status bar hidden config.
Switched from `UIApplication.shared.setStatusBarHidden` to `prefersStatusBarHidden`.
2017-07-13 18:06:38 -05:00
onmyway133 b26ee135bc Merge pull request #120 from vitalii-tym/fix/issue108
Updating the image frames while images are still being loaded
2017-06-20 15:11:00 +02:00
onmyway133 96d7da82bb Merge pull request #119 from vitalii-tym/fix/issue117
Cutting long texts quicker
2017-06-20 15:07:01 +02:00
onmyway133 9707c7cfe4 Merge pull request #122 from vitalii-tym/improvement/accessible-images
Updating the .image property of a LightboxImage instance after Lightbox has downloaded an image via URL
2017-06-20 11:31:28 +02:00
Vitaliy Tim 4968853f8c Made image property of LightBox images accessible after the image has been loaded via URL 2017-06-20 11:29:48 +03:00
Vitaliy Tim 053735d408 Properly updating the image frames while images are still being loaded, so that activity indicators are correcty shown 2017-06-20 10:59:38 +03:00
Vitaliy Tim 6052398040 Speeding up cutting process for long texts 2017-06-20 10:39:18 +03:00
onmyway133 df48ce7b85 Merge pull request #112 from danwilliams64/fix/screen_bounds
Use key window bounds instead of screen bounds
2017-06-19 12:46:00 +02:00
Dan Williams eb44646978 Use app delegate's window instead of screen bounds 2017-06-19 11:30:35 +01:00
onmyway133 6686d8f83b Merge pull request #113 from vitalii-tym/master
Preserve correct Navigation Bar after dismissal when opened from a controller with a Nav Bar
2017-06-19 11:30:30 +02:00
Vitaliy Tim 03be7479f4 Fixes an issue with Navigation Bar, which had wrong position after the lightbox has been dismissed 2017-06-19 11:50:09 +03:00
Christoffer Winterkvist 3b54e8959d Merge pull request #107 from hyperoslo/improve/dynamic-background
Fix dynamic background loading
2017-04-25 12:33:20 +02:00
Christoffer Winterkvist 69813ee7fe Fix dynamic background loading
Because `loadDynamicBackground` is called in `remoteImageDidLoad`, it
can end up flickering between all images as they are loaded from the
network. To fix this issue there is a now a small safeguard in
`remoteImageDidLoad` to evaluate if the image view is on screen,
otherwise just return early and don't switch out the background.

The `PageViewDelegate` has been slightly modified to return the image
view when loading remote images, that image view is used in the safe
guard mentioned earlier.

The `addìmageTo` now uses a weak reference to reduce the chance of
holding reference.

`addGradientLayer` now uses `@discardableResult` so that you don't have
to assign it to a variable when using the method.

The `goTo` method in `LightboxController` will no disregard the
animation if the controller is not on screen. This is done by checking
if the controller's view as a window or not.
2017-04-25 07:28:13 +02:00
Vadym Markov 4ccab620d6 Merge pull request #104 from rmnblm/master
Auto-size Close and Delete buttons
2017-04-21 09:37:55 +02:00
Roman Blum 3ea5a88e01 change 4 spaces to 2 spaces 2017-04-21 09:36:51 +02:00
Roman Blum 2b9216b1b8 auto-size Close and Delete buttons 2017-03-14 09:26:02 +01:00
Khoa Pham 48f307b003 Merge pull request #103 from rmnblm/master
Fix half-black screen after dismissal
2017-03-02 15:00:16 +01:00
Roman Blum eb44c67f69 Fix half-black screen after dismissal 2017-03-02 12:06:42 +01:00
John Sundell e6452f116e Merge pull request #94 from basecom/master
Added new protocol LightboxControllerTouchDelegate
2017-02-14 09:56:02 +01:00
Christoph Dieckmann 96c660a424 Added new protocol LightboxControllerTouchDelegate to delegate the touch event to the calling object. 2017-02-07 14:35:16 +01:00
Vadym Markov 4833dcde35 Update README.md 2016-12-21 15:17:16 +01:00
Vadym Markov 8f907c1fe9 Update README.md 2016-12-21 15:10:40 +01:00
Vadym Markov e314fea3e7 Update summary 2016-12-21 14:36:07 +01:00
Vadym Markov b4ec75ca27 Add swift version 2016-12-21 14:34:18 +01:00
28 changed files with 585 additions and 281 deletions
-4
View File
@@ -1,4 +0,0 @@
ci_service: travis_ci
coverage_service: coveralls
xcodeproj: Tests/Tests.xcodeproj
source_directory: Source
+1
View File
@@ -0,0 +1 @@
4.0
-13
View File
@@ -1,13 +0,0 @@
osx_image: xcode8
language: objective-c
before_install:
- brew update
- if brew outdated | grep -qx carthage; then brew upgrade carthage; fi
- travis_wait 35 carthage bootstrap --platform iOS
script:
- xcodebuild clean build -project Lightbox.xcodeproj -scheme "Lightbox-iOS" -sdk iphonesimulator
notifications:
email: false
+2 -1
View File
@@ -1 +1,2 @@
github "hyperoslo/Hue" "master"
github "hyperoslo/Hue" ~> 3.0
github "hyperoslo/Imaginary" ~> 3.0
+3 -1
View File
@@ -1 +1,3 @@
github "hyperoslo/Hue" "f82ffc7dd55d093d3acc6ce5b3d36ca259091fdd"
github "hyperoslo/Cache" "4.1.2"
github "hyperoslo/Hue" "3.0.0"
github "hyperoslo/Imaginary" "3.0.2"
@@ -11,20 +11,20 @@
29B4A42F1C43A4320060ED52 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29B4A42E1C43A4320060ED52 /* ViewController.swift */; };
29B4A4341C43A4320060ED52 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 29B4A4331C43A4320060ED52 /* Assets.xcassets */; };
29B4A4371C43A4320060ED52 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 29B4A4351C43A4320060ED52 /* LaunchScreen.storyboard */; };
7193005DD460E198432D8F06 /* Pods_DemoLightbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0977FB7C36F459186E043753 /* Pods_DemoLightbox.framework */; };
B89E57B7A21C44D762123511 /* Pods_DemoLightbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE4E898FD95F4D90F624B067 /* Pods_DemoLightbox.framework */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
0977FB7C36F459186E043753 /* Pods_DemoLightbox.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DemoLightbox.framework; sourceTree = BUILT_PRODUCTS_DIR; };
064155DBC618EBACF5C257C6 /* Pods-DemoLightbox.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DemoLightbox.release.xcconfig"; path = "Pods/Target Support Files/Pods-DemoLightbox/Pods-DemoLightbox.release.xcconfig"; sourceTree = "<group>"; };
29B4A4291C43A4320060ED52 /* DemoLightbox.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DemoLightbox.app; sourceTree = BUILT_PRODUCTS_DIR; };
29B4A42C1C43A4320060ED52 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
29B4A42E1C43A4320060ED52 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
29B4A4331C43A4320060ED52 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
29B4A4361C43A4320060ED52 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
29B4A4381C43A4320060ED52 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5B9CE7F93A06A0459BF452D8 /* Pods-DemoLightbox.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DemoLightbox.release.xcconfig"; path = "Pods/Target Support Files/Pods-DemoLightbox/Pods-DemoLightbox.release.xcconfig"; sourceTree = "<group>"; };
C37FDBF69CDC2A95E0E105A7 /* Pods-DemoLightbox.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DemoLightbox.debug.xcconfig"; path = "Pods/Target Support Files/Pods-DemoLightbox/Pods-DemoLightbox.debug.xcconfig"; sourceTree = "<group>"; };
6096248776155BE47C0A196A /* Pods-DemoLightbox.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DemoLightbox.debug.xcconfig"; path = "Pods/Target Support Files/Pods-DemoLightbox/Pods-DemoLightbox.debug.xcconfig"; sourceTree = "<group>"; };
DAE713340DA5D2F2EF13EA8D /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; };
EE4E898FD95F4D90F624B067 /* Pods_DemoLightbox.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DemoLightbox.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -32,20 +32,29 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
7193005DD460E198432D8F06 /* Pods_DemoLightbox.framework in Frameworks */,
B89E57B7A21C44D762123511 /* Pods_DemoLightbox.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0C8887567644E86396B8D885 /* Pods */ = {
isa = PBXGroup;
children = (
6096248776155BE47C0A196A /* Pods-DemoLightbox.debug.xcconfig */,
064155DBC618EBACF5C257C6 /* Pods-DemoLightbox.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
29B4A4201C43A4320060ED52 = {
isa = PBXGroup;
children = (
29B4A42B1C43A4320060ED52 /* DemoLightbox */,
29B4A42A1C43A4320060ED52 /* Products */,
B1B2B3DADEEC7FD14D4A9FF8 /* Frameworks */,
80F119CA8153119A6934480D /* Pods */,
0C8887567644E86396B8D885 /* Pods */,
);
sourceTree = "<group>";
};
@@ -69,20 +78,11 @@
path = DemoLightbox;
sourceTree = "<group>";
};
80F119CA8153119A6934480D /* Pods */ = {
isa = PBXGroup;
children = (
C37FDBF69CDC2A95E0E105A7 /* Pods-DemoLightbox.debug.xcconfig */,
5B9CE7F93A06A0459BF452D8 /* Pods-DemoLightbox.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
B1B2B3DADEEC7FD14D4A9FF8 /* Frameworks */ = {
isa = PBXGroup;
children = (
DAE713340DA5D2F2EF13EA8D /* Pods.framework */,
0977FB7C36F459186E043753 /* Pods_DemoLightbox.framework */,
EE4E898FD95F4D90F624B067 /* Pods_DemoLightbox.framework */,
);
name = Frameworks;
sourceTree = "<group>";
@@ -94,12 +94,12 @@
isa = PBXNativeTarget;
buildConfigurationList = 29B4A43B1C43A4320060ED52 /* Build configuration list for PBXNativeTarget "DemoLightbox" */;
buildPhases = (
2CF277B8821F7CE6E2730C9C /* [CP] Check Pods Manifest.lock */,
4DE126F6B5D0C8D6C0E7D848 /* [CP] Check Pods Manifest.lock */,
29B4A4251C43A4320060ED52 /* Sources */,
29B4A4261C43A4320060ED52 /* Frameworks */,
29B4A4271C43A4320060ED52 /* Resources */,
831C9CD301B03A92F6320AEE /* [CP] Embed Pods Frameworks */,
3BCDC27EE322C46C109D231B /* [CP] Copy Pods Resources */,
F162948C45248BBD677112BF /* [CP] Embed Pods Frameworks */,
D1AB0C213924D367899FA1A2 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
@@ -117,7 +117,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Hyper Interaktiv AS";
TargetAttributes = {
29B4A4281C43A4320060ED52 = {
@@ -158,22 +158,25 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
2CF277B8821F7CE6E2730C9C /* [CP] Check Pods Manifest.lock */ = {
4DE126F6B5D0C8D6C0E7D848 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-DemoLightbox-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
3BCDC27EE322C46C109D231B /* [CP] Copy Pods Resources */ = {
D1AB0C213924D367899FA1A2 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
@@ -188,15 +191,26 @@
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-DemoLightbox/Pods-DemoLightbox-resources.sh\"\n";
showEnvVarsInLog = 0;
};
831C9CD301B03A92F6320AEE /* [CP] Embed Pods Frameworks */ = {
F162948C45248BBD677112BF /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-DemoLightbox/Pods-DemoLightbox-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Cache/Cache.framework",
"${BUILT_PRODUCTS_DIR}/Hue/Hue.framework",
"${BUILT_PRODUCTS_DIR}/Imaginary/Imaginary.framework",
"${BUILT_PRODUCTS_DIR}/Lightbox/Lightbox.framework",
"${BUILT_PRODUCTS_DIR}/SwiftHash/SwiftHash.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cache.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Hue.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Imaginary.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Lightbox.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftHash.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -237,14 +251,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -272,7 +292,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -284,14 +304,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -312,14 +338,14 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
29B4A43C1C43A4320060ED52 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C37FDBF69CDC2A95E0E105A7 /* Pods-DemoLightbox.debug.xcconfig */;
baseConfigurationReference = 6096248776155BE47C0A196A /* Pods-DemoLightbox.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
@@ -328,13 +354,13 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.DemoLightbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
29B4A43D1C43A4320060ED52 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5B9CE7F93A06A0459BF452D8 /* Pods-DemoLightbox.release.xcconfig */;
baseConfigurationReference = 064155DBC618EBACF5C257C6 /* Pods-DemoLightbox.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
@@ -343,7 +369,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.DemoLightbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
@@ -13,11 +13,11 @@ class ViewController: UIViewController {
button.autoresizingMask = [.flexibleTopMargin, .flexibleLeftMargin, .flexibleRightMargin, .flexibleBottomMargin]
return button
}()
}()
override func viewDidLoad() {
super.viewDidLoad()
view.autoresizingMask = [.flexibleTopMargin, .flexibleLeftMargin, .flexibleRightMargin, .flexibleBottomMargin]
view.backgroundColor = UIColor.white
view.addSubview(showButton)
@@ -25,21 +25,21 @@ class ViewController: UIViewController {
// MARK: - Action methods
func showLightbox() {
@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: "Some very long lorem ipsum text. Some very long lorem ipsum text. Some very long lorem ipsum text. Some very long lorem ipsum text"
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: "",
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: "Some very long lorem ipsum text."
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."
)
]
+5 -6
View File
@@ -1,7 +1,6 @@
platform :ios, '8.0'
platform :ios, '9.0'
use_frameworks!
inhibit_all_warnings!
pod 'Lightbox', path: '../../'
target 'DemoLightbox'
target 'DemoLightbox' do
use_frameworks!
pod 'Lightbox', path: '../../'
end
+17 -8
View File
@@ -1,19 +1,28 @@
PODS:
- Hue (2.0.1)
- Lightbox (1.0.0):
- Hue
- Cache (4.0.2):
- SwiftHash (~> 2.0.0)
- Hue (3.0.0)
- Imaginary (3.0.0):
- Cache (~> 4.0)
- Lightbox (2.0.0):
- Hue (~> 3.0)
- Imaginary (~> 3.0)
- SwiftHash (2.0.0)
DEPENDENCIES:
- Lightbox (from `../../`)
EXTERNAL SOURCES:
Lightbox:
:path: "../../"
:path: ../../
SPEC CHECKSUMS:
Hue: 354caec055fdc9d38b5ef33ca2e7224721843baf
Lightbox: eb4196a846a883c4c2a52209b29b283d1bc706e1
Cache: 363b6899cee63c82ccbd291e64a6c202abc17a88
Hue: b8fe1e43eef13631331eebecb2198b68e2622f95
Imaginary: 2765d293d425cbed3b07fa11642554cbaebe913d
Lightbox: f7f1cc942d81e84d85095531208f5fe1bfd9c639
SwiftHash: d2e09b13495447178cdfb8e46e54a5c46f15f5a9
PODFILE CHECKSUM: cd88b68c201e5c39cef62070056649eaee91c71b
PODFILE CHECKSUM: 408ae3477507a1d4b7ff06ffb3f162eda443424f
COCOAPODS: 1.1.1
COCOAPODS: 1.3.1
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 290 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 296 KiB

+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
}
}
+7 -6
View File
@@ -1,19 +1,20 @@
Pod::Spec.new do |s|
s.name = "Lightbox"
s.summary = "A short description of Lightbox."
s.version = "1.0.0"
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.1"
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, '8.0'
s.platform = :ios, '9.0'
s.requires_arc = true
s.source_files = 'Source/**/*'
s.ios.resource = 'Resources/Lightbox.bundle'
s.frameworks = 'UIKit', 'AVFoundation', 'AVKit'
s.dependency 'Hue'
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '3.0' }
s.dependency 'Hue', '~> 3.0'
s.dependency 'Imaginary', '~> 3.0'
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' }
end
+181 -10
View File
@@ -8,6 +8,9 @@
/* 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 */; };
D523B0BD1C43AA8B001AD1EC /* LightboxConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = D523B0B61C43AA8A001AD1EC /* LightboxConfig.swift */; };
@@ -23,8 +26,22 @@
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>"; };
D523B0A91C43AA2A001AD1EC /* Lightbox.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Lightbox.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -43,10 +60,19 @@
/* 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;
files = (
D2A58F5E1F7943A30064F14E /* Imaginary.framework in Frameworks */,
D54DFCC21C5AAAF100ADEA0E /* Hue.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -62,6 +88,23 @@
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 = (
D2A58F5D1F7943A30064F14E /* Imaginary.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
D523B09F1C43AA2A001AD1EC = {
isa = PBXGroup;
children = (
@@ -69,7 +112,9 @@
D54DFCC01C5AAAF100ADEA0E /* Hue.framework */,
D523B0B41C43AA8A001AD1EC /* Source */,
D523B0AB1C43AA2A001AD1EC /* Lightbox */,
D229B5E21FC3123F00F04123 /* Lightbox-iOS-Tests */,
D523B0AA1C43AA2A001AD1EC /* Products */,
D2A58F5C1F7943A30064F14E /* Frameworks */,
);
sourceTree = "<group>";
};
@@ -77,6 +122,7 @@
isa = PBXGroup;
children = (
D523B0A91C43AA2A001AD1EC /* Lightbox.framework */,
D229B5E11FC3123F00F04123 /* Lightbox-iOS-Tests.xctest */,
);
name = Products;
sourceTree = "<group>";
@@ -137,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" */;
@@ -146,6 +210,7 @@
D523B0A61C43AA2A001AD1EC /* Headers */,
D523B0A71C43AA2A001AD1EC /* Resources */,
D54DFCC41C5AAAF600ADEA0E /* Copy frameworks with Carthage */,
5CF8A88D1F50B4EA00C28475 /* ShellScript */,
);
buildRules = (
);
@@ -162,12 +227,17 @@
D523B0A01C43AA2A001AD1EC /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0800;
LastSwiftUpdateCheck = 0910;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Hyper Interaktiv AS";
TargetAttributes = {
D229B5E01FC3123F00F04123 = {
CreatedOnToolsVersion = 9.1;
ProvisioningStyle = Automatic;
};
D523B0A81C43AA2A001AD1EC = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
};
};
@@ -184,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;
@@ -200,6 +278,19 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
5CF8A88D1F50B4EA00C28475 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
};
D54DFCC41C5AAAF600ADEA0E /* Copy frameworks with Carthage */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -207,6 +298,8 @@
);
inputPaths = (
"$(SRCROOT)/Carthage/Build/iOS/Hue.framework",
"$(SRCROOT)/Carthage/Build/iOS/Imaginary.framework",
"$(SRCROOT)/Carthage/Build/iOS/Cache.framework",
);
name = "Copy frameworks with Carthage";
outputPaths = (
@@ -218,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;
@@ -239,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 = {
@@ -248,14 +400,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -279,12 +437,12 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
@@ -299,14 +457,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -324,11 +488,11 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
@@ -350,12 +514,11 @@
);
INFOPLIST_FILE = Lightbox/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Lightbox;
PRODUCT_NAME = Lightbox;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
@@ -373,18 +536,26 @@
);
INFOPLIST_FILE = Lightbox/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Lightbox;
PRODUCT_NAME = Lightbox;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Release;
};
/* 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 = (
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -26,9 +26,29 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
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>
@@ -36,6 +56,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
+13 -10
View File
@@ -1,11 +1,10 @@
# Lightbox
[![Version](https://img.shields.io/cocoapods/v/Lightbox.svg?style=flat)](http://cocoadocs.org/docsets/Lightbox)
[![CI Status](http://img.shields.io/travis/hyperoslo/Lightbox.svg?style=flat)](https://travis-ci.org/hyperoslo/Lightbox)
[![CI Status](https://circleci.com/gh/hyperoslo/Lightbox.png)](https://circleci.com/gh/hyperoslo/Lightbox)
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![License](https://img.shields.io/cocoapods/l/Lightbox.svg?style=flat)](http://cocoadocs.org/docsets/Lightbox)
[![Platform](https://img.shields.io/cocoapods/p/Lightbox.svg?style=flat)](http://cocoadocs.org/docsets/Lightbox)
![Swift](https://img.shields.io/badge/%20in-swift%203.0-orange.svg)
![Swift](https://img.shields.io/badge/%20in-swift%204.0-orange.svg)
<img src="https://raw.githubusercontent.com/hyperoslo/Lightbox/master/Images/Icon.png" alt="Lightbox Icon" align="right" />
@@ -16,10 +15,16 @@ packed with all the features you expect:
- [x] Video support.
- [x] Double-tap to zoom.
- [x] Image caption.
- [x] Dynamic background.
- [x] Dynamic background based on [Hue](https://github.com/hyperoslo/Hue)
- [x] Remote image loading and caching based on [Imaginary](https://github.com/hyperoslo/Imaginary)
- [x] Interactive transition animations.
- [x] Powerful configuration.
- [x] Demo project.
- [x] [Live Demo](https://appetize.io/app/wfgwc2uvg82m9pzbt17p4rrgh4?device=iphone5s&scale=75&orientation=portrait&osVersion=9.3)
<div align="center">
<img src="Images/demo.png" height="500">
<img src="Images/demo2.png" height="500">
</div>
## Table of Contents
@@ -105,9 +110,7 @@ extension ViewController: LightboxControllerDismissalDelegate: class {
### Image loading
By default images are loaded using `sendAsynchronousRequest` method of
`NSURLConnection`. But it's easy to change this behavior using **Lightbox**
configuration.
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 = {
@@ -118,7 +121,7 @@ LightboxConfig.loadImage = {
### Video
**Lightbox** has video support out of the box. Configure video by using `videoURL`:
**Lightbox** can show and plays video using default `AVPlayerViewController`. Showning video by using `videoURL`:
```swift
LightboxImage(
@@ -156,7 +159,7 @@ LightboxConfig.DeleteButton.image = UIImage(named: ImageList.Lightbox.deleteButt
LightboxConfig.DeleteButton.textAttributes = TextAttributes.Lightbox.deleteButton
LightboxConfig.DeleteButton.text = "Delete"
LightboxConfig.InfoLabel.ellipsisText = "ShowMore"
LightboxConfig.InfoLabel.ellipsisText = "Show more"
```
## Installation
+1
View File
@@ -1,5 +1,6 @@
import UIKit
/// Used to load assets from Lightbox bundle
class AssetManager {
static func image(_ named: String) -> UIImage? {
+7 -13
View File
@@ -28,14 +28,6 @@ class LightboxTransition: UIPercentDrivenInteractiveTransition {
func transition(_ show: Bool) {
guard let controller = lightboxController else { return }
controller.headerView.transform = show
? CGAffineTransform.identity
: CGAffineTransform(translationX: 0, y: -200)
controller.footerView.transform = show
? CGAffineTransform.identity
: CGAffineTransform(translationX: 0, y: 250)
if interactive {
controller.view.backgroundColor = UIColor.black.withAlphaComponent(show ? 1 : 0)
} else {
@@ -45,7 +37,7 @@ class LightboxTransition: UIPercentDrivenInteractiveTransition {
// MARK: - Pan gesture recognizer
func handlePanGesture(_ gesture: UIPanGestureRecognizer) {
@objc func handlePanGesture(_ gesture: UIPanGestureRecognizer) {
let translation = gesture.translation(in: scrollView)
let percentage = abs(translation.y) / UIScreen.main.bounds.height / 1.5
let velocity = gesture.velocity(in: scrollView)
@@ -111,8 +103,8 @@ extension LightboxTransition: UIViewControllerAnimatedTransitioning {
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
let container = transitionContext.containerView
guard let fromView = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)?.view,
let toView = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)?.view
guard let fromView = transitionContext.view(forKey: UITransitionContextViewKey.from),
let toView = transitionContext.view(forKey: UITransitionContextViewKey.to)
else { return }
let firstView = dismissing ? toView : fromView
@@ -123,6 +115,8 @@ extension LightboxTransition: UIViewControllerAnimatedTransitioning {
container.addSubview(firstView)
container.addSubview(secondView)
toView.frame = container.bounds
let duration = transitionDuration(using: transitionContext)
UIView.animate(withDuration: duration, animations: {
@@ -145,8 +139,8 @@ extension LightboxTransition: UIViewControllerTransitioningDelegate {
}
func animationController(forPresented presented: UIViewController,
presenting: UIViewController,
source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
presenting: UIViewController,
source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
dismissing = false
return self
}
+1 -1
View File
@@ -2,7 +2,7 @@ import UIKit
extension UIView {
func addGradientLayer(_ colors: [UIColor]) -> CAGradientLayer {
@discardableResult func addGradientLayer(_ colors: [UIColor]) -> CAGradientLayer {
if let gradientLayer = gradientLayer { return gradientLayer }
let gradient = CAGradientLayer()
+45 -45
View File
@@ -2,29 +2,14 @@ import UIKit
import Hue
import AVKit
import AVFoundation
import Imaginary
open class LightboxConfig {
public class LightboxConfig {
/// Whether to show status bar while Lightbox is presented
public static var hideStatusBar = true
public typealias LoadImageCompletion = (_ error: NSError?, _ image: UIImage?) -> Void
open static var hideStatusBar = true
open static var loadImage: (_ imageView: UIImageView, _ URL: URL, _ completion: LoadImageCompletion?) -> Void = {
imageView, URL, completion in
let imageRequest: URLRequest = URLRequest(url: URL)
NSURLConnection.sendAsynchronousRequest(imageRequest,
queue: OperationQueue.main,
completionHandler: { response, data, error in
if let data = data, let image = UIImage(data: data) {
imageView.image = image
}
completion?(error as NSError?, imageView.image)
})
}
open static var handleVideo: (_ from: UIViewController, _ videoURL: URL) -> Void = { from, videoURL in
/// Provide a closure to handle selected video
public static var handleVideo: (_ from: UIViewController, _ videoURL: URL) -> Void = { from, videoURL in
let videoController = AVPlayerViewController()
videoController.player = AVPlayer(url: videoURL)
@@ -33,52 +18,71 @@ open 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)
}
})
}
/// Indicator is used to show while image is being fetched
public static var makeLoadingIndicator: () -> UIView = {
return LoadingIndicator()
}
public struct PageIndicator {
public static var enabled = true
public static var separatorColor = UIColor(hex: "3D4757")
public static var textAttributes = [
NSFontAttributeName: UIFont.systemFont(ofSize: 12),
NSForegroundColorAttributeName: UIColor(hex: "899AB8"),
NSParagraphStyleAttributeName: {
public static var textAttributes: [NSAttributedStringKey: Any] = [
.font: UIFont.systemFont(ofSize: 12),
.foregroundColor: UIColor(hex: "899AB8"),
.paragraphStyle: {
var style = NSMutableParagraphStyle()
style.alignment = .center
return style
}()
}()
]
}
public struct CloseButton {
public static var enabled = true
public static var size = CGSize(width: 60, height: 25)
public static var size: CGSize?
public static var text = NSLocalizedString("Close", comment: "")
public static var image: UIImage?
public static var textAttributes = [
NSFontAttributeName: UIFont.boldSystemFont(ofSize: 16),
NSForegroundColorAttributeName: UIColor.white,
NSParagraphStyleAttributeName: {
public static var textAttributes: [NSAttributedStringKey: Any] = [
.font: UIFont.boldSystemFont(ofSize: 16),
.foregroundColor: UIColor.white,
.paragraphStyle: {
var style = NSMutableParagraphStyle()
style.alignment = .center
return style
}()
}()
]
}
public struct DeleteButton {
public static var enabled = false
public static var size = CGSize(width: 70, height: 25)
public static var size: CGSize?
public static var text = NSLocalizedString("Delete", comment: "")
public static var image: UIImage?
public static var textAttributes = [
NSFontAttributeName: UIFont.boldSystemFont(ofSize: 16),
NSForegroundColorAttributeName: UIColor(hex: "FA2F5B"),
NSParagraphStyleAttributeName: {
public static var textAttributes: [NSAttributedStringKey: Any] = [
.font: UIFont.boldSystemFont(ofSize: 16),
.foregroundColor: UIColor(hex: "FA2F5B"),
.paragraphStyle: {
var style = NSMutableParagraphStyle()
style.alignment = .center
return style
}()
}()
]
}
@@ -88,9 +92,9 @@ open class LightboxConfig {
public static var ellipsisText = NSLocalizedString("Show more", comment: "")
public static var ellipsisColor = UIColor(hex: "899AB9")
public static var textAttributes = [
NSFontAttributeName: UIFont.systemFont(ofSize: 12),
NSForegroundColorAttributeName: UIColor(hex: "DBDBDB")
public static var textAttributes: [NSAttributedStringKey: Any] = [
.font: UIFont.systemFont(ofSize: 12),
.foregroundColor: UIColor(hex: "DBDBDB")
]
}
@@ -98,8 +102,4 @@ open class LightboxConfig {
public static var minimumScale: CGFloat = 1.0
public static var maximumScale: CGFloat = 3.0
}
public struct LoadingIndicator {
public static var configure: ((UIActivityIndicatorView) -> Void)? = nil
}
}
+58 -48
View File
@@ -11,21 +11,24 @@ public protocol LightboxControllerDismissalDelegate: class {
func lightboxControllerWillDismiss(_ controller: LightboxController)
}
public protocol LightboxControllerTouchDelegate: class {
func lightboxController(_ controller: LightboxController, didTouch image: LightboxImage, at index: Int)
}
open class LightboxController: UIViewController {
// MARK: - Internal views
lazy var scrollView: UIScrollView = { [unowned self] in
let scrollView = UIScrollView()
scrollView.frame = self.screenBounds
scrollView.isPagingEnabled = false
scrollView.delegate = self
scrollView.isUserInteractionEnabled = true
scrollView.showsHorizontalScrollIndicator = false
scrollView.decelerationRate = UIScrollViewDecelerationRateFast
return scrollView
}()
}()
lazy var overlayTapGestureRecognizer: UITapGestureRecognizer = { [unowned self] in
let gesture = UITapGestureRecognizer()
@@ -56,29 +59,25 @@ open class LightboxController: UIViewController {
view.delegate = self
return view
}()
}()
open fileprivate(set) lazy var footerView: FooterView = { [unowned self] in
let view = FooterView()
view.delegate = self
return view
}()
}()
open fileprivate(set) lazy var overlayView: UIView = { [unowned self] in
let view = UIView(frame: CGRect.zero)
let gradient = CAGradientLayer()
let colors = [UIColor(hex: "090909").alpha(0), UIColor(hex: "040404")]
_ = view.addGradientLayer(colors)
view.addGradientLayer(colors)
view.alpha = 0
return view
}()
var screenBounds: CGRect {
return UIScreen.main.bounds
}
}()
// MARK: - Properties
@@ -94,7 +93,7 @@ open class LightboxController: UIViewController {
pageDelegate?.lightboxController(self, didMoveToPage: currentPage)
if let image = pageViews[currentPage].imageView.image , dynamicBackground {
if let image = pageViews[currentPage].imageView.image, dynamicBackground {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.125) {
self.loadDynamicBackground(image)
}
@@ -122,7 +121,7 @@ open class LightboxController: UIViewController {
open var spacing: CGFloat = 20 {
didSet {
configureLayout()
configureLayout(view.bounds.size)
}
}
@@ -137,6 +136,7 @@ open class LightboxController: UIViewController {
open weak var pageDelegate: LightboxControllerPageDelegate?
open weak var dismissalDelegate: LightboxControllerDismissalDelegate?
open weak var imageTouchDelegate: LightboxControllerTouchDelegate?
open internal(set) var presented = false
open fileprivate(set) var seen = false
@@ -182,23 +182,33 @@ open class LightboxController: UIViewController {
open override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if LightboxConfig.hideStatusBar {
UIApplication.shared.setStatusBarHidden(true, with: .fade)
}
if !presented {
presented = true
configureLayout()
configureLayout(view.bounds.size)
}
}
open override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
open override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
if LightboxConfig.hideStatusBar {
UIApplication.shared.setStatusBarHidden(statusBarHidden, with: .fade)
}
scrollView.frame = view.bounds
footerView.frame = CGRect(
x: 0,
y: view.bounds.height - footerView.frame.height,
width: view.bounds.width,
height: 100
)
headerView.frame = CGRect(
x: 0,
y: 16,
width: view.bounds.width,
height: 100
)
}
open override var prefersStatusBarHidden: Bool {
return LightboxConfig.hideStatusBar
}
// MARK: - Rotation
@@ -206,9 +216,9 @@ open class LightboxController: UIViewController {
override open func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
coordinator.animate(alongsideTransition: { (UIViewControllerTransitionCoordinatorContext) -> Void in
coordinator.animate(alongsideTransition: { _ in
self.configureLayout(size)
}, completion: nil)
}, completion: nil)
}
// MARK: - Configuration
@@ -225,7 +235,7 @@ open class LightboxController: UIViewController {
pageViews.append(pageView)
}
configureLayout()
configureLayout(view.bounds.size)
}
// MARK: - Pagination
@@ -240,7 +250,9 @@ open class LightboxController: UIViewController {
var offset = scrollView.contentOffset
offset.x = CGFloat(page) * (scrollView.frame.width + spacing)
scrollView.setContentOffset(offset, animated: animated)
let shouldAnimated = view.window != nil ? animated : false
scrollView.setContentOffset(offset, animated: shouldAnimated)
}
open func next(_ animated: Bool = true) {
@@ -253,13 +265,13 @@ open class LightboxController: UIViewController {
// MARK: - Actions
func overlayViewDidTap(_ tapGestureRecognizer: UITapGestureRecognizer) {
@objc func overlayViewDidTap(_ tapGestureRecognizer: UITapGestureRecognizer) {
footerView.expand(false)
}
// MARK: - Layout
open func configureLayout(_ size: CGSize = UIScreen.main.bounds.size) {
open func configureLayout(_ size: CGSize) {
scrollView.frame.size = size
scrollView.contentSize = CGSize(
width: size.width * CGFloat(numberOfPages) + spacing * CGFloat(numberOfPages - 1),
@@ -276,18 +288,8 @@ open class LightboxController: UIViewController {
}
}
let bounds = scrollView.bounds
let headerViewHeight = headerView.closeButton.frame.height > headerView.deleteButton.frame.height
? headerView.closeButton.frame.height
: headerView.deleteButton.frame.height
headerView.frame = CGRect(x: 0, y: 16, width: bounds.width, height: headerViewHeight)
footerView.frame = CGRect(x: 0, y: 0, width: bounds.width, height: 70)
[headerView, footerView].forEach { ($0 as AnyObject).configureLayout() }
footerView.frame.origin.y = bounds.height - footerView.frame.height
overlayView.frame = scrollView.frame
overlayView.resizeGradientLayer()
}
@@ -333,7 +335,7 @@ extension LightboxController: UIScrollViewDelegate {
}
targetContentOffset.pointee.x = x
currentPage = Int(x / screenBounds.width)
currentPage = Int(x / view.bounds.width)
}
}
@@ -341,8 +343,16 @@ extension LightboxController: UIScrollViewDelegate {
extension LightboxController: PageViewDelegate {
func remoteImageDidLoad(_ image: UIImage?) {
guard let image = image , dynamicBackground else { return }
func remoteImageDidLoad(_ image: UIImage?, imageView: UIImageView) {
guard let image = image, dynamicBackground else {
return
}
let imageViewFrame = imageView.convert(imageView.frame, to: view)
guard view.frame.intersects(imageViewFrame) else {
return
}
loadDynamicBackground(image)
}
@@ -358,6 +368,8 @@ extension LightboxController: PageViewDelegate {
func pageViewDidTouch(_ pageView: PageView) {
guard !pageView.hasZoomed else { return }
imageTouchDelegate?.lightboxController(self, didTouch: images[currentPage], at: currentPage)
let visible = (headerView.alpha == 1.0)
toggleControls(pageView: pageView, visible: !visible)
}
@@ -388,8 +400,8 @@ extension LightboxController: HeaderViewDelegate {
self.pageViews.remove(at: prevIndex).removeFromSuperview()
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5) {
self.configureLayout()
self.currentPage = Int(self.scrollView.contentOffset.x / self.screenBounds.width)
self.configureLayout(self.view.bounds.size)
self.currentPage = Int(self.scrollView.contentOffset.x / self.view.bounds.width)
deleteButton.isEnabled = true
}
}
@@ -407,11 +419,9 @@ extension LightboxController: HeaderViewDelegate {
extension LightboxController: FooterViewDelegate {
public func footerView(_ footerView: FooterView, didExpand expanded: Bool) {
footerView.frame.origin.y = screenBounds.height - footerView.frame.height
UIView.animate(withDuration: 0.25, animations: {
self.overlayView.alpha = expanded ? 1.0 : 0.0
self.headerView.deleteButton.alpha = expanded ? 0.0 : 1.0
})
})
}
}
+4 -5
View File
@@ -1,4 +1,5 @@
import UIKit
import Imaginary
open class LightboxImage {
@@ -15,20 +16,18 @@ open class LightboxImage {
self.videoURL = videoURL
}
public init(imageURL: URL, text: String = "", videoURL: URL? = nil ) {
public init(imageURL: URL, text: String = "", videoURL: URL? = nil) {
self.imageURL = imageURL
self.text = text
self.videoURL = videoURL
}
open func addImageTo(_ imageView: UIImageView, completion: ((_ image: UIImage?) -> Void)? = nil) {
open func addImageTo(_ imageView: UIImageView, completion: ((UIImage?) -> Void)? = nil) {
if let image = image {
imageView.image = image
completion?(image)
} else if let imageURL = imageURL {
LightboxConfig.loadImage(imageView, imageURL) { error, image in
completion?(image)
}
LightboxConfig.loadImage(imageView, imageURL, completion)
}
}
}
+25 -14
View File
@@ -16,7 +16,7 @@ open class FooterView: UIView {
label.delegate = self
return label
}()
}()
open fileprivate(set) lazy var pageLabel: UILabel = { [unowned self] in
let label = UILabel(frame: CGRect.zero)
@@ -24,7 +24,7 @@ open class FooterView: UIView {
label.numberOfLines = 1
return label
}()
}()
open fileprivate(set) lazy var separatorView: UIView = { [unowned self] in
let view = UILabel(frame: CGRect.zero)
@@ -32,7 +32,7 @@ open class FooterView: UIView {
view.backgroundColor = LightboxConfig.PageIndicator.separatorColor
return view
}()
}()
let gradientColors = [UIColor(hex: "040404").alpha(0.1), UIColor(hex: "040404")]
open weak var delegate: FooterViewDelegate?
@@ -76,17 +76,29 @@ open class FooterView: UIView {
}
}
// MARK: - Layout
open override func layoutSubviews() {
super.layoutSubviews()
fileprivate func resetFrames() {
frame.size.height = infoLabel.frame.height + 40 + 0.5
do {
let bottomPadding: CGFloat
if #available(iOS 11, *) {
bottomPadding = safeAreaInsets.bottom
} else {
bottomPadding = 0
}
pageLabel.frame.origin = CGPoint(
x: (frame.width - pageLabel.frame.width) / 2,
y: frame.height - pageLabel.frame.height - 2)
pageLabel.frame.origin = CGPoint(
x: (frame.width - pageLabel.frame.width) / 2,
y: frame.height - pageLabel.frame.height - 2 - bottomPadding
)
}
separatorView.frame = CGRect(x: 0, y: pageLabel.frame.minY - 2.5,
width: frame.width, height: 0.5)
separatorView.frame = CGRect(
x: 0,
y: pageLabel.frame.minY - 2.5,
width: frame.width,
height: 0.5
)
infoLabel.frame.origin.y = separatorView.frame.minY - infoLabel.frame.height - 15
@@ -98,7 +110,7 @@ open class FooterView: UIView {
extension FooterView: LayoutConfigurable {
public func configureLayout() {
@objc public func configureLayout() {
infoLabel.frame = CGRect(x: 17, y: 0, width: frame.width - 17 * 2, height: 35)
infoLabel.configureLayout()
}
@@ -107,8 +119,7 @@ extension FooterView: LayoutConfigurable {
extension FooterView: InfoLabelDelegate {
public func infoLabel(_ infoLabel: InfoLabel, didExpand expanded: Bool) {
resetFrames()
_ = expanded ? removeGradientLayer() : addGradientLayer(gradientColors)
_ = (expanded || infoLabel.fullText.isEmpty) ? removeGradientLayer() : addGradientLayer(gradientColors)
delegate?.footerView(self, didExpand: expanded)
}
}
+35 -17
View File
@@ -6,13 +6,6 @@ protocol HeaderViewDelegate: class {
}
open class HeaderView: UIView {
var centerTextStyle: NSMutableParagraphStyle = {
var style = NSMutableParagraphStyle()
style.alignment = .center
return style
}()
open fileprivate(set) lazy var closeButton: UIButton = { [unowned self] in
let title = NSAttributedString(
string: LightboxConfig.CloseButton.text,
@@ -20,8 +13,14 @@ open class HeaderView: UIView {
let button = UIButton(type: .system)
button.frame.size = LightboxConfig.CloseButton.size
button.setAttributedTitle(title, for: UIControlState())
if let size = LightboxConfig.CloseButton.size {
button.frame.size = size
} else {
button.sizeToFit()
}
button.addTarget(self, action: #selector(closeButtonDidPress(_:)),
for: .touchUpInside)
@@ -32,7 +31,7 @@ open class HeaderView: UIView {
button.isHidden = !LightboxConfig.CloseButton.enabled
return button
}()
}()
open fileprivate(set) lazy var deleteButton: UIButton = { [unowned self] in
let title = NSAttributedString(
@@ -41,8 +40,14 @@ open class HeaderView: UIView {
let button = UIButton(type: .system)
button.frame.size = LightboxConfig.DeleteButton.size
button.setAttributedTitle(title, for: .normal)
if let size = LightboxConfig.DeleteButton.size {
button.frame.size = size
} else {
button.sizeToFit()
}
button.addTarget(self, action: #selector(deleteButtonDidPress(_:)),
for: .touchUpInside)
@@ -53,7 +58,7 @@ open class HeaderView: UIView {
button.isHidden = !LightboxConfig.DeleteButton.enabled
return button
}()
}()
weak var delegate: HeaderViewDelegate?
@@ -73,11 +78,11 @@ open class HeaderView: UIView {
// MARK: - Actions
func deleteButtonDidPress(_ button: UIButton) {
@objc func deleteButtonDidPress(_ button: UIButton) {
delegate?.headerView(self, didPressDeleteButton: button)
}
func closeButtonDidPress(_ button: UIButton) {
@objc func closeButtonDidPress(_ button: UIButton) {
delegate?.headerView(self, didPressCloseButton: button)
}
}
@@ -86,10 +91,23 @@ open class HeaderView: UIView {
extension HeaderView: LayoutConfigurable {
public func configureLayout() {
closeButton.frame.origin = CGPoint(
x: bounds.width - closeButton.frame.width - 17, y: 0)
@objc public func configureLayout() {
let topPadding: CGFloat
deleteButton.frame.origin = CGPoint(x: 17, y: 0)
if #available(iOS 11, *) {
topPadding = safeAreaInsets.top
} else {
topPadding = 0
}
closeButton.frame.origin = CGPoint(
x: bounds.width - closeButton.frame.width - 17,
y: topPadding
)
deleteButton.frame.origin = CGPoint(
x: 17,
y: topPadding
)
}
}
+27 -17
View File
@@ -41,22 +41,32 @@ open class InfoLabel: UILabel {
}
}
fileprivate var truncatedText: String {
var truncatedText: String {
var truncatedText = fullText
guard numberOfLines(fullText) > numberOfVisibleLines else {
return truncatedText
}
// Perform quick "rough cut"
while numberOfLines(truncatedText) > numberOfVisibleLines * 2 {
truncatedText = String(truncatedText.prefix(truncatedText.count / 2))
}
// Capture the endIndex of truncatedText before appending ellipsis
var truncatedTextCursor = truncatedText.endIndex
truncatedText += ellipsis
let start = truncatedText.characters.index(truncatedText.endIndex, offsetBy: -(ellipsis.characters.count + 1))
let end = truncatedText.characters.index(truncatedText.endIndex, offsetBy: -ellipsis.characters.count)
var range = start..<end
// Remove characters ahead of ellipsis until the text is the right number of lines
while numberOfLines(truncatedText) > numberOfVisibleLines {
truncatedText.removeSubrange(range)
range = truncatedText.index(range.lowerBound, offsetBy: -1)..<truncatedText.index(range.upperBound, offsetBy: -1)
// To avoid "Cannot decrement before startIndex"
guard truncatedTextCursor > truncatedText.startIndex else {
break
}
truncatedTextCursor = truncatedText.index(before: truncatedTextCursor)
truncatedText.remove(at: truncatedTextCursor)
}
return truncatedText
@@ -81,7 +91,7 @@ open class InfoLabel: UILabel {
// MARK: - Actions
func labelDidTap(_ tapGestureRecognizer: UITapGestureRecognizer) {
@objc func labelDidTap(_ tapGestureRecognizer: UITapGestureRecognizer) {
shortText = truncatedText
expanded ? collapse() : expand()
}
@@ -101,13 +111,13 @@ open class InfoLabel: UILabel {
}
fileprivate func updateText(_ string: String) {
let attributedString = NSMutableAttributedString(string: string,
attributes: LightboxConfig.InfoLabel.textAttributes)
let textAttributes = LightboxConfig.InfoLabel.textAttributes
let attributedString = NSMutableAttributedString(string: string, attributes: textAttributes)
if string.range(of: ellipsis) != nil {
let range = (string as NSString).range(of: ellipsis)
attributedString.addAttribute(NSForegroundColorAttributeName,
value: LightboxConfig.InfoLabel.ellipsisColor, range: range)
if let range = string.range(of: ellipsis) {
let ellipsisColor = LightboxConfig.InfoLabel.ellipsisColor
let ellipsisRange = NSRange(range, in: string)
attributedString.addAttribute(.foregroundColor, value: ellipsisColor, range: ellipsisRange)
}
attributedText = attributedString
@@ -119,12 +129,12 @@ open class InfoLabel: UILabel {
return string.boundingRect(
with: CGSize(width: bounds.size.width, height: CGFloat.greatestFiniteMagnitude),
options: [.usesLineFragmentOrigin, .usesFontLeading],
attributes: [NSFontAttributeName : font],
attributes: [NSAttributedStringKey.font: font],
context: nil).height
}
fileprivate func numberOfLines(_ string: String) -> Int {
let lineHeight = "A".size(attributes: [NSFontAttributeName: font]).height
let lineHeight = "A".size(withAttributes: [NSAttributedStringKey.font: font]).height
let totalHeight = heightForString(string)
return Int(totalHeight / lineHeight)
@@ -135,7 +145,7 @@ open class InfoLabel: UILabel {
extension InfoLabel: LayoutConfigurable {
public func configureLayout() {
@objc public func configureLayout() {
shortText = truncatedText
expanded ? expand() : collapse()
}
+22 -25
View File
@@ -3,7 +3,7 @@ import UIKit
protocol PageViewDelegate: class {
func pageViewDidZoom(_ pageView: PageView)
func remoteImageDidLoad(_ image: UIImage?)
func remoteImageDidLoad(_ image: UIImage?, imageView: UIImageView)
func pageView(_ pageView: PageView, didTouchPlayButton videoURL: URL)
func pageViewDidTouch(_ pageView: PageView)
}
@@ -33,7 +33,7 @@ class PageView: UIScrollView {
return button
}()
lazy var activityIndicator: LoadingIndicator = LoadingIndicator()
lazy var loadingIndicator: UIView = LightboxConfig.makeLoadingIndicator()
var image: LightboxImage
var contentFrame = CGRect.zero
@@ -51,14 +51,18 @@ class PageView: UIScrollView {
configure()
activityIndicator.alpha = 1
self.image.addImageTo(imageView) { image in
self.isUserInteractionEnabled = true
self.configureImageView()
self.pageViewDelegate?.remoteImageDidLoad(image)
loadingIndicator.alpha = 1
self.image.addImageTo(imageView) { [weak self] image in
guard let strongSelf = self else {
return
}
strongSelf.isUserInteractionEnabled = true
strongSelf.configureImageView()
strongSelf.pageViewDelegate?.remoteImageDidLoad(image, imageView: strongSelf.imageView)
UIView.animate(withDuration: 0.4) {
self.activityIndicator.alpha = 0
strongSelf.loadingIndicator.alpha = 0
}
}
}
@@ -76,7 +80,7 @@ class PageView: UIScrollView {
addSubview(playButton)
}
addSubview(activityIndicator)
addSubview(loadingIndicator)
delegate = self
isMultipleTouchEnabled = true
@@ -98,7 +102,7 @@ class PageView: UIScrollView {
// MARK: - Recognizers
func scrollViewDoubleTapped(_ recognizer: UITapGestureRecognizer) {
@objc func scrollViewDoubleTapped(_ recognizer: UITapGestureRecognizer) {
let pointInView = recognizer.location(in: imageView)
let newZoomScale = zoomScale > minimumZoomScale
? minimumZoomScale
@@ -114,7 +118,7 @@ class PageView: UIScrollView {
zoom(to: rectToZoomTo, animated: true)
}
func viewTapped(_ recognizer: UITapGestureRecognizer) {
@objc func viewTapped(_ recognizer: UITapGestureRecognizer) {
pageViewDelegate?.pageViewDidTouch(self)
}
@@ -123,12 +127,15 @@ class PageView: UIScrollView {
override func layoutSubviews() {
super.layoutSubviews()
activityIndicator.center = imageView.center
loadingIndicator.center = imageView.center
playButton.center = imageView.center
}
func configureImageView() {
guard let image = imageView.image else { return }
guard let image = imageView.image else {
centerImageView()
return
}
let imageViewSize = imageView.frame.size
let imageSize = image.size
@@ -170,28 +177,18 @@ class PageView: UIScrollView {
// MARK: - Action
func playButtonTouched(_ button: UIButton) {
@objc func playButtonTouched(_ button: UIButton) {
guard let videoURL = image.videoURL else { return }
pageViewDelegate?.pageView(self, didTouchPlayButton: videoURL as URL)
}
// MARK: - Controls
func makeActivityIndicator() -> UIActivityIndicatorView {
let view = UIActivityIndicatorView(activityIndicatorStyle: .white)
LightboxConfig.LoadingIndicator.configure?(view)
view.startAnimating()
return view
}
}
// MARK: - LayoutConfigurable
extension PageView: LayoutConfigurable {
func configureLayout() {
@objc func configureLayout() {
contentFrame = frame
contentSize = frame.size
imageView.frame = frame
+12
View File
@@ -0,0 +1,12 @@
machine:
xcode:
version: "9.0"
dependencies:
override:
- rm -rf Carthage
- carthage update
test:
override:
- set -o pipefail && xcodebuild -project Lightbox.xcodeproj -scheme "Lightbox-iOS" -sdk iphonesimulator clean build