hyperoslo / lightbox Goto Github PK
View Code? Open in Web Editor NEW:milky_way: A convenient and easy to use image viewer for your iOS app
Home Page: https://www.hyper.no
License: Other
:milky_way: A convenient and easy to use image viewer for your iOS app
Home Page: https://www.hyper.no
License: Other
Would it not be great if the library also could display a UIView as a page?
Maybe extend the LightboxImage class with the possibility to add a UIView?
On this screenshot I've almost scrolled out the first picture, but the second has not appeared yet.
If I try to swipe starting from blank space (inter-item-spacing) everything scrolls right (see the second screenshot).
I think, dynamics should be turned on only for vertical direction, but not for the horizontal, as this really interferes with the way you expect to interact with any image gallery.
Hi,
I am having a minor issue on launching the camera on ipad from landscape, the default connection video orientation is always portrait. but rotating the device fixes the issue. looking through the code it looks like the preview layer for cameraView initialization didn't start with the current device orientation. Just thought I bring this up.
This library is a pleasure to use, thanks for the great work!
i fixed it by doing the following changes in cameraView.swift if you decided to use it.
func setupPreviewLayer(_ session: AVCaptureSession) {
guard previewLayer == nil else { return }
let layer = AVCaptureVideoPreviewLayer(session: session)
layer.autoreverses = true
layer.videoGravity = .resizeAspectFill
//-----adding the following code here seems to fix the issue --------------
if let connection = layer.connection,
connection.isVideoOrientationSupported {
connection.videoOrientation = Utils.videoOrientation()
}
//-----end fix--------------
self.layer.insertSublayer(layer, at: 0)
layer.frame = self.layer.bounds
previewLayer = layer
}
Thanks for your work, it's really awesome!
Autoplay video when it's shown, and do not create separate av view controller.
When swiping not from the center, but the screen edge, sometimes I get past the next or previous picture and skip one more.
hi, plz update pod, since it's still the old one
When using Slide Over multitasking on iPad, the frames are sized for the iPad screen size instead of the actual size of the view. This results in photos being out of bounds and paging is broken.
Could you guild me how to create a custom cell for playing audio?
I want to hide the black color footer view and just show the image. Is there any way to do that?
LightboxController:261 attempts to get the size for the scroll view from UIApplication.shared.delegate?.window??.bounds.size
, which assumes that you have that implemented.
Maybe something like UIApplication.shared.keyWindow
could be used instead? I'm not sure if implementing UIApplicationDelegate.window
is a common enough convention that this issue doesn't matter, but it's definitely something I ran into! :)
Edit:
I can open a PR that uses UIApplication.shared.keyWindow
if I get the go ahead. Perhaps I can even have it use keyWindow
just as a ??
fallback.
Hi there,
I'm facing a weird issue after you do the following steps:
My code looks like this:
let lightboxController = LightboxController(images: [LightboxImage(image: image)])
LightboxConfig.PageIndicator.enabled = false
LightboxConfig.hideStatusBar = true
present(lightboxController, animated: true, completion: nil)
What happens is this:
To resolve the issue on the iPhone, you have to close the app in the Task Manager and open the app again.
Is there a way from Lightbox to open ImagePicker or Gallery? Examples in the other projects shows how to open Lightbox from them, but I want to do the other way around.
The users in my app should be able to add one or more images, view them and possibly add more in another session. So I wanted to use Lightbox as a image gallery to view images, and then ImagePicker or Gallery to add more images. But I want be able to add more images from Lightbox and I can't figure it out.
Hi,
thanks for awesome library. I have project written in Swift 3.2, deployment target iOS 9.0 and Xcode 9 and I've run into problem with Hue dependency. When I try to build project, I get error at import Hue - Module file's minimum deployment target is ios9.0 v9.0. I looked at Hue github and it is already updated to Swift 4 on master, could it be the problem?
Thanks,
Tomas
Now I've just dropped landscape mode, so it always in portrait.
@richardoti @zenangst You could try to play with it If you have some good ideas how to get it working properly in all device orientations and after zooming
Hey there,
Is there currently a way to add a custom button to the bottom of the photo viewer? I'd like to add a button (or any UIView) to allow the user to perform certain actions.
You can think of this similar to the native Photos.app on iOS. When you tap on a photo, you have a bottom bar where you can tap on the "share", "favourite" or "delete" buttons.
If this isn't possible right now, is this something you'd consider adding? This would mimic the behaviour of the native photo app and basically be underneath the current info label.
(Obviously the behaviour of those buttons would be defined by the developer and not by Lightbox. Lightbox would just provide a way to add buttons at the bottom, but the behaviour or what they do when tapped by the user, would be outside of the scope of this lib).
Is there any plan to support storing images to the Photos ?
Hi
I am using ImagePicker in iOS that uses Lightbox.
I am getting below when opened project in xcode 8. Seems Swift 3 and 2.3 are not supported yet.
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
When will this framework support Swift 3 and 2.3?
Or is there any alternative?
Cheers
Ashish
Hello! Faced the problem of checking the archive when it was published in itunes. The fact is that the policy of the apple prohibits the use of built-in frameworks. I removed the hue from the framework, hooked it up as a separate framework, and the project was tested. Make changes please.
Sorry, I'm using google translate =)
How to remove grey circle background behind ActivityIndicatorView?
Is there any way to add custom button? Or, for example, re-program existing "delete" button?
If I add a low resolution image into Lightbox, it stretches that images. Is it possible to have a feature that disables stretching of the images? Something like:
class PageView: UIScrollView {
lazy var imageView: UIImageView = {
let imageView = UIImageView()
imageView.contentMode = LightBoxConfig.imageView.contentMode
imageView.clipsToBounds = true
imageView.isUserInteractionEnabled = true
return imageView
}()
...
And if this would be configurable for each page it would be even better. A change to LightboxControllerPageDelegate like this? In that way I would be able to manipulate the page.
public func lightboxController(_ controller: LightboxController, didMoveToPage page: Page, at index: Int)
When i try to build the latest version with carthage i get the error:
Failed to read file or folder at /.../Carthage/Checkouts/Lightbox/Carthage/Build/iOS/SwiftHash.framework
I think it is because the dependency Imaginary uses Cache (https://github.com/hyperoslo/Cache) this is not pinned to a specific version. Since some days the Cache-project includes swiftHash in an other way since before.
I created a fork https://github.com/papierschiff/Lightbox which uses a pinned version to a forked Imaginary repo which ha a pinned Cache-dependency.
Stats: Xcode 9.1, Carthage 0.26.2, latest Lightbox build
Version: 2.0.1
Swift 4
The README says that you can do custom image loading which is what I need given that my assets are private in S3 and not exposed to world via HTTP.
LightboxConfig.loadImage = {
imageView, URL, completion in
// Custom image loading
}
However, I am getting a compiler error saying Type 'LightboxConfig' has no member 'loadImage'
and rightfully so as I am not seeing any mention of loadImage
in the source code.
Is this still a supported feature or are the docs outdated?
This bug is even present in the online demo:
Now the parent view has wrong dimensions. I guess the width equals height.
I have an app that is localized to Arabic which make the layouts from the right to the left
And I have a collection view with images (from right to left) as in this image
https://i.suar.me/8qoM/m
The problem is when I view the last image (the image on the most left with index = 3) with light box
it is shown as the most right image in Lightbox scroll view
Another ex:
in collection view
3 2 1 0
in Lightbox scroll view
0 1 2 3
how can I change this behavior?
LightboxControllerPageDelegate.lightboxController(_ controller: LightboxController, didMoveToPage page: Int)
gets called twice on initial presentation
the demo page shows an error with text "Streaming for this account has been temporarily disabled"
I'm setting a custom downloader for the library (alamofireimage), after the image is download and set the indicator is still visible and spinning.
Are you planning to add some Video support, so it can swipe trough videos and photos regardless the type of media?
When you have large gallery(this example is 50) and click an image, Background of first image you pick Dynamically animates to PREVIOUS(sometimes just random) image in your collection. Here is example:
(I click Albrecht Durer in 13, but in background we see pirate! )
I set page number with this code:
let controller = LightboxController.init(images: photos)
controller.dynamicBackground = true
controller.goTo(indexPath.row, animated: true)
I've also tried animated: false
and let controller = LightboxController.init(images: photos, startIndex:indexPath.row)
let lightboxImages = images.flatMap { $0.uimage(ofSize: UIScreen.main.bounds.size)}.map({ LightboxImage(image: $0 )})
This line has the following error in your demo project: Value of type 'Image' has no member 'uimage'
Please post a fix/idea for fix. Thanks.
All right fellas, so I have a question regarding the transition.
Right now it's pretty much working, but got a question about the image, right now, the image is not .ScaleAspectFill, then, it makes sense to treat the image like Slack does, like something that has life and you can carry on playing with it.
The other option is what Twitter does, the view it's like kinda sticked to the borders, and you can dismiss it going up or down.
What to you prefer, 1, 2, or both and then we'll select one with an enum or whatever?
Right now making a non-default config requires modifying a struct, which has to be done in the controller. I suggest making config to be a class, so it would be possible to keep it in one place and not overcomplicate controller class.
If config is a class, it is still possible for the library to work the same way (i.e. to be configured in the controller), but also, it is possible to subclass a default config, do some overrides and pass it with one line only:
let mySuperConfig = MySuperConfig()
let lightBox = LightboxController(imagesUI: images, config: mySuperConfig)
What do you think about this?
First off, thanks for the nice repo guys :)
So I have uncovered an issue when viewing an imageView while waiting for an image to download.
I'm presenting the lightboxController and then immediately going to the image that the user selected from my previous UI:
lightboxVC.goTo(index, animated: false)
present(lightboxVC, animated: true)
If the index is 0 (the first image) then, the activityIndicator shows up and behaves as expected, and disappears as the downloaded image is displayed. However, if I either 1) swipe to the next photo which is still being downloaded or 2) my index (above) is greater than 0, then the activity indicator doesn't appear.
It took me a while just to figure out the problem but I think I have a clear description of it and a potential solution. In short the problem is that the frames of the imageView aren't being set properly when there's not yet an image.
All of the attached screenshots are supposed to have 9 images total and I'm focused on the 5th image in each case. I used images with numbers to help us out here...
Improperly placed imageViews (before images download):
Note that the imageViews skip every other slot while their images are downloading. Again, the focus is on the 5th slot (with the black background). The activityIndicators are the gray dots.
Properly placed imageViews (after images download):
Note that the imageViews become properly placed once there's an image.
I believe the fix is to add:
centerImageView()
to the guard-else statement (near ln 134 of PageView.swift):
guard let image = imageView.image else { return }
in:
func configureImageView()
yielding:
guard let image = imageView.image else {
centerImageView()
return
}
This seems to properly place the imageViews, even when they don't have images yet.
Properly placed imageViews (during image download):
Hope this helps to quickly test this bug and fix and then get this code pushed live!
Maybe this activityIndicator code can get some attention too??
https://github.com/hyperoslo/Lightbox/tree/fix/loading_view
Great library! This is my first time posting in GitHub.
The latest updates take care of the safe area issues for the iPhone X, but I noticed that the footer view doesn't show up when the Lightbox view appears for the first time. I used this in the viewDidAppear method to display the footer at start:
if #available(iOS 11.0, *) {
configureLayout(view.safeAreaLayoutGuide.layoutFrame.size)
} else {
configureLayout(view.bounds.size)
}
Hello,
I get a weird bug when in landscape mode and swiping up or down. The view becomes messed up and layouts are wrong.
I had this issue using the hyperoslo/imagePicker as well. However, updating to the latest release solved the issue. On the other hand, trying the same with hyperoslo/Lightbox didn't do it.
Trying to to initialize LightboxConfig:
var lightboxConfig = LightboxConfig()
LightboxConfig initializer is inaccesible due to 'internal' protection level
I need access to the LightboxConfig to change the texts for the buttons
Any plans to update to Swift 4?
I am just update Lightbox to 2.0.0, but build with below compile error:
Cannot convert value of type '[NSAttributedStringKey : Any]' (aka 'Dictionary<NSString, Any>') to expected argument type '[String : Any]?'
First of all, - Sir you have done amazing work. I love Lightbox and how it looks like.
About the issue. I like dynamic background, however I don't understand following:
please see this gif:
I set startIndex like this:
let controller = LightboxController.init(images: photos, startIndex: indexPath.row)
I have also tried this( result still the same:( ):
let controller = LightboxController.init(images: photos)
controller.dynamicBackground = true
controller.goTo(indexPath.row, animated: false)
As you can see, background is animating like scrolling from the image number 0 to selected image.
It would be much better(and more logical: it is the first picture user clicked), if there was no background animation on startIndex image, or at least to have such option.
I hope you understand my idea.
STR:
Result: There are no progress indication while image is being loaded. If you wait for some time, the progress indication will blink right before the image appears.
P.S. I'll try to do a PR later if I have time.
We have got a crash on IOS 11.1.1 (15B150) iPhone SE
i have attached the logs below
Crashed: com.apple.main-thread
0 Lightbox 0x1051ddecc _TFC8Lightbox9InfoLabelgP33_AA4B35F0720B741F0D46790C8576C04C13truncatedTextSS + 2100
1 Lightbox 0x1051db4dc _TTSf4gs_n___TFC8Lightbox10FooterView10updateTextfSST_ + 252
2 Lightbox 0x1051e8a3c _TTSf4d_n___TFC8Lightbox18LightboxControllerW11currentPageSi + 536
3 Lightbox 0x1051e6c08 _TFC8Lightbox18LightboxController11viewDidLoadfT_T_ + 1704
4 Lightbox 0x1051e6cc4 _TToFC8Lightbox18LightboxController11viewDidLoadfT_T_ + 28
5 UIKit 0x18c584f08 -[UIViewController loadViewIfRequired] + 1040
6 UIKit 0x18c584ae0 -[UIViewController view] + 28
7 Lightbox 0x1051e8f50 _TTSf4d_n___TFC8Lightbox18LightboxControllerW17dynamicBackgroundSb + 80
8 Rapl 0x104967f74 specialized QuizViewController.openImagePreview(url : String, text : String) -> () (QuizViewController.swift:388)
9 Rapl 0x104968128 specialized QuizViewController.previewImage(choice : Choice) -> () (QuizViewController.swift)
10 Rapl 0x1049655b0 protocol witness for ImageChoicePreviewDelegate.previewImage(choice : Choice) -> () in conformance QuizViewController (QuizViewController.swift)
11 Rapl 0x1048de8fc ImageChoiceListView.previewImage(Any) -> () (ImageChoiceListView.swift:84)
12 Rapl 0x1048dea2c @objc ImageChoiceListView.previewImage(Any) -> () (ImageChoiceListView.swift)
13 UIKit 0x18c5b9614 -[UIApplication sendAction:to:from:forEvent:] + 96
14 UIKit 0x18c5b9594 -[UIControl sendAction:to:forEvent:] + 80
15 UIKit 0x18c5a42fc -[UIControl _sendActionsForEvents:withEvent:] + 440
16 UIKit 0x18c5b8e88 -[UIControl touchesEnded:withEvent:] + 576
17 UIKit 0x18cc0f084 _UIGestureEnvironmentSortAndSendDelayedTouches + 4280
18 UIKit 0x18cc0a634 _UIGestureEnvironmentUpdate + 1224
19 UIKit 0x18cc0a118 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 404
20 UIKit 0x18cc09274 -[UIGestureEnvironment _updateGesturesForEvent:window:] + 276
21 UIKit 0x18c5b3e5c -[UIWindow sendEvent:] + 3180
22 UIKit 0x18c585384 -[UIApplication sendEvent:] + 340
23 UIKit 0x18ced285c __dispatchPreprocessedEventFromEventQueue + 2364
24 UIKit 0x18ced4de8 __handleEventQueueInternal + 4760
25 UIKit 0x18cecdd04 __handleHIDEventFetcherDrain + 152
26 CoreFoundation 0x1830f62e8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
27 CoreFoundation 0x1830f6268 __CFRunLoopDoSource0 + 88
28 CoreFoundation 0x1830f5af0 __CFRunLoopDoSources0 + 204
29 CoreFoundation 0x1830f36c8 __CFRunLoopRun + 1048
30 CoreFoundation 0x183013fb8 CFRunLoopRunSpecific + 436
31 GraphicsServices 0x184eabf84 GSEventRunModal + 100
32 UIKit 0x18c5e82f4 UIApplicationMain + 208
33 Rapl 0x104896ee0 main (AppDelegate.swift:32)
34 libdyld.dylib 0x182b3656c start + 4
The code which i am using to invoke the light box is
let images = [
LightboxImage(imageURL: URL(string: url)!, text: text)
]
LightboxConfig.InfoLabel.ellipsisColor = UIColor.red;
LightboxConfig.PageIndicator.enabled = false;
LightboxConfig.CloseButton.enabled = false;
let controller = LightboxController(images: images)
if text == "" {
controller.footerView.isHidden = true;
}
controller.headerView.isHidden = true;
controller.dynamicBackground = true
present(controller, animated: true, completion: nil)
I have no clue why this happens, but for some reason some images will never be loaded. Here is example:
I load exact same image using another another lib(this is IDMPhotoBrowser):
This happens often with random images.
In log I see following message:
CFNetwork internal error (0xc01a:/BuildRoot/Library/Caches/com.apple.xbs/Sources/CFNetwork_Sim/CFNetwork-808.2.16/Loading/URLConnectionLoader.cpp:304)
I have already tried adding in Info.plist file this lines:
Still no success. All images in collection are being downloaded via HTTPS.
how do i prevent the navbar from moving up when i use this on a view with navbar
Hello,
Thanks for such a library, i am using it in my apps.
In one of my apps i encountered a problem. I am getting a video from the phone's gallery, appending it on my lightbox array and trying to play it, but i am unsuccessful. If i add a remote video, it is playing the video. My own video url is something like this "assets-library://asset/asset.mov?id=C006BE3C-2327-4A91-A139-7B594A99458D&ext=mov".
thanks in advance.
Here is my code:
var controller:LightboxController! = nil
var lbImages = [LightboxImage]()
override func viewDidLoad() {
super.viewDidLoad()
LightboxConfig.handleVideo = { from, videoURL in
// Custom video handling
print("playing local :")
print(videoURL)
let videoController = AVPlayerViewController()
videoController.player = AVPlayer(url: videoURL)
from.present(videoController, animated: true) {
videoController.player?.play()
}
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if let chosenImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
picker.dismiss(animated: false, completion: { () -> Void in
print("width is " + String(describing: chosenImage.size.width) + " height " + String(describing: chosenImage.size.height))
self.lbImages.append(LightboxImage(image: chosenImage))
self.mediaCollectionView.reloadData()
})
} else if let videoURL = info["UIImagePickerControllerReferenceURL"] as? NSURL {
picker.dismiss(animated: false, completion: { () -> Void in
print(videoURL)
self.lbImages.append(LightboxImage(
image: UIImage(named:"news")!,
text: "",
videoURL: videoURL as URL
//videoURL: NSURL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4") as URL?
))
self.mediaCollectionView.reloadData()
})
} else{
print("Something went wrong")
self.dismiss(animated: true, completion: nil)
}
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
controller = LightboxController(images: lbImages)
// Set delegates.
//controller.pageDelegate = self
//controller.dismissalDelegate = self
// Use dynamic background.
controller.dynamicBackground = true
// Present your controller.
controller.headerView.deleteButton.addTarget(self, action: #selector(self.deleteImage), for: .touchUpInside)
present(controller, animated: true, completion: nil)
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.