Lightbox icon indicating copy to clipboard operation
Lightbox copied to clipboard

Download button

Open Wiwaltill opened this issue 3 years ago • 7 comments

It would be nice if there would be a download button at the Lightbox, which saves the opened image in the gallery.

Wiwaltill avatar Oct 10 '22 12:10 Wiwaltill

Hi @Wiwaltill,

Lightbox is currently in maintenance mode, no new features or additions are planned. Only bug fixes.

3lvis avatar Oct 11 '22 19:10 3lvis

Very sad. But thank you for the quick answer.

Maybe it is still possible to keep the idea in mind and include it in a possible further development.

Wiwaltill avatar Oct 11 '22 23:10 Wiwaltill

Hi, i added download + share button, do you still need this feature?

fukemy avatar Feb 21 '23 03:02 fukemy

Yes! This function would definitely still be very useful. @fukemy

Wiwaltill avatar Feb 21 '23 17:02 Wiwaltill

@Wiwaltill just create the class extend LightBoxController then override init function like this:

 public override init(images: [LightboxImage], startIndex: Int = 0) {
        
        super.init(images: images, startIndex: startIndex)
        
        self.downloadButton = RoundButton(frame: CGRect(0, 0, 36, 36))
        self.downloadButton?.setImage(UIImage(named: "ic_download"), for: .normal)
        self.downloadButton?.rounded = true
        self.downloadButton?.backgroundColor = UIColor.white.withAlphaComponent(0.5)
        self.downloadButton!.addTarget(self, action: #selector(self.saveImageToLocal), for: .touchUpInside)
        self.footerView.addSubview(self.downloadButton!)
        self.downloadButton?.applyShadow(isApply: true)
        
        var frame = self.downloadButton!.frame
        frame.origin.x = UIScreen.main.bounds.width / 2 - 18 - 36
        frame.origin.y = 5
        self.downloadButton?.frame = frame
        
        self.shareButton = RoundButton(frame: CGRect(0, 0, 36, 36))
        self.shareButton?.setImage(UIImage(named: "ic_share"), for: .normal)
        self.shareButton?.rounded = true
        self.shareButton?.backgroundColor = UIColor.white.withAlphaComponent(0.5)
        self.shareButton!.addTarget(self, action: #selector(self.share), for: .touchUpInside)
        self.shareButton?.applyShadow(isApply: true)
        self.footerView.addSubview(self.shareButton!)
        
        var shareFrame = self.shareButton!.frame
        shareFrame.origin.x = UIScreen.main.bounds.width / 2 + 18
        shareFrame.origin.y = 5
        self.shareButton?.frame = shareFrame
        
    }

fukemy avatar Feb 22 '23 02:02 fukemy

@fukemy Thank you for the code. Unfortunately, I'm having a few problems - could you send me the code for the entire Swift file? That would be very helpful.

Wiwaltill avatar Feb 22 '23 21:02 Wiwaltill

For the others. I make it work by the following code from @fukemy

`import UIKit import Lightbox

class LightBoxVC: LightboxController {

lazy var downloadButton: UIButton! = {
    let downloadButton = UIButton(frame: CGRect(x: 0, y: 0, width: 36, height: 36))
    downloadButton.backgroundColor = UIColor.white.withAlphaComponent(0.5)
    downloadButton.setImage(UIImage(named: "download"), for: .normal)
    downloadButton.addTarget(self, action: #selector(self.saveImageToLocal), for: .touchUpInside)
    return downloadButton
}()

public override init(images: [LightboxImage], startIndex: Int = 0) {
       
   super.init(images: images, startIndex: startIndex)
   
   self.footerView.addSubview(self.downloadButton!)
   
   var frame = self.downloadButton!.frame
   frame.origin.x = UIScreen.main.bounds.width / 2 - 18 - 36
   frame.origin.y = 5
   self.downloadButton?.frame = frame

}

required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

@objc func saveImageToLocal() {
    print("saveImageToLocal")
}

}`

IMG_7050

alvincrisuy avatar Apr 10 '23 01:04 alvincrisuy