diff --git a/MiniScanner.xcodeproj/project.pbxproj b/MiniScanner.xcodeproj/project.pbxproj index f1f3419d5721af93fc5710bf5299c87380d8a9ad..97246278b364a2ed80e2d739ffeeee15beb9ad07 100644 --- a/MiniScanner.xcodeproj/project.pbxproj +++ b/MiniScanner.xcodeproj/project.pbxproj @@ -84,6 +84,7 @@ 53CD5F5E2C1505EC0010424B /* UIWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53CD5F5D2C1505EC0010424B /* UIWindow.swift */; }; 53CD5F612C15A6210010424B /* SettingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53CD5F5F2C15A6210010424B /* SettingViewController.swift */; }; 53CD5F622C15A6210010424B /* SettingViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 53CD5F602C15A6210010424B /* SettingViewController.xib */; }; + 53E3A2092C19D17100C9B95E /* PreviewImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53E3A2082C19D17100C9B95E /* PreviewImageViewController.swift */; }; 53EDED962C18387E00DB8DF9 /* TYPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 53EDED922C18387E00DB8DF9 /* TYPageControl.m */; }; 53EDED972C18387E00DB8DF9 /* TYCyclePagerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 53EDED932C18387E00DB8DF9 /* TYCyclePagerView.m */; }; 53EDED982C18387E00DB8DF9 /* TYCyclePagerTransformLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 53EDED942C18387E00DB8DF9 /* TYCyclePagerTransformLayout.m */; }; @@ -234,6 +235,7 @@ 53CD5F5D2C1505EC0010424B /* UIWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIWindow.swift; sourceTree = "<group>"; }; 53CD5F5F2C15A6210010424B /* SettingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingViewController.swift; sourceTree = "<group>"; }; 53CD5F602C15A6210010424B /* SettingViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SettingViewController.xib; sourceTree = "<group>"; }; + 53E3A2082C19D17100C9B95E /* PreviewImageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewImageViewController.swift; sourceTree = "<group>"; }; 53EDED902C18387E00DB8DF9 /* TYCyclePagerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TYCyclePagerView.h; sourceTree = "<group>"; }; 53EDED912C18387E00DB8DF9 /* TYCyclePagerTransformLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TYCyclePagerTransformLayout.h; sourceTree = "<group>"; }; 53EDED922C18387E00DB8DF9 /* TYPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TYPageControl.m; sourceTree = "<group>"; }; @@ -564,6 +566,7 @@ children = ( 53EDED9C2C183CDF00DB8DF9 /* BannerView.swift */, 53EDED9E2C183CEB00DB8DF9 /* BannerView.xib */, + 53E3A2082C19D17100C9B95E /* PreviewImageViewController.swift */, ); path = CustomViews; sourceTree = "<group>"; @@ -987,6 +990,7 @@ ECA1FAA4254DEB140081F00B /* CustomPDFView.swift in Sources */, 53014FA32C11A8E80071CE39 /* ZoomGestureController.swift in Sources */, 53EDED962C18387E00DB8DF9 /* TYPageControl.m in Sources */, + 53E3A2092C19D17100C9B95E /* PreviewImageViewController.swift in Sources */, EC70252A254E066400BE1958 /* SettingsViewController+Safari.swift in Sources */, 53014F9B2C11A8E80071CE39 /* CGAffineTransform+Utils.swift in Sources */, 53014FBC2C11A8E80071CE39 /* CaptureSession.swift in Sources */, diff --git a/MiniScanner.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/UserInterfaceState.xcuserstate b/MiniScanner.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/UserInterfaceState.xcuserstate index 5e76acd9ed654760749a676de46f250998a23f61..387a9536e33ac575f044b2b05050434edb3f0556 100644 Binary files a/MiniScanner.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/UserInterfaceState.xcuserstate and b/MiniScanner.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/MiniScanner.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/MiniScanner.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index dbea0bb448a5dc39516d91e83635a85983aa4a05..0167b414388510a5aab6edf277f4dcc76ab26854 100644 --- a/MiniScanner.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/MiniScanner.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -14,8 +14,8 @@ filePath = "MiniScanner/Modules/EditViewController/EditViewController.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "219" - endingLineNumber = "219" + startingLineNumber = "230" + endingLineNumber = "230" landmarkName = "saveFileAndShare(with:name:)" landmarkType = "7"> </BreakpointContent> diff --git a/MiniScanner/Modules/Documents/CustomViews/ShareSheet/ShareSheetViewController.swift b/MiniScanner/Modules/Documents/CustomViews/ShareSheet/ShareSheetViewController.swift index 7b6e2d763ba76f34bef285acea5af276a27b73f4..4d85546d573fea2bb8efdfc4cd0b012106e2f140 100644 --- a/MiniScanner/Modules/Documents/CustomViews/ShareSheet/ShareSheetViewController.swift +++ b/MiniScanner/Modules/Documents/CustomViews/ShareSheet/ShareSheetViewController.swift @@ -56,6 +56,9 @@ class ShareSheetViewController: UIViewController { fileNameTextField.placeholder = "File name" backgroundView.layer.cornerRadius = 30 backgroundView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] + pdfImage.layer.cornerRadius = 10 + pdfImage.clipsToBounds = true + pdfImage.contentMode = .scaleAspectFill } private func setup() { diff --git a/MiniScanner/Modules/EditViewController/CustomViews/BannerView.swift b/MiniScanner/Modules/EditViewController/CustomViews/BannerView.swift index 88022e935259921bbc259cace82e06b698a8fe3d..ce494343296135fcf145f7fc675072b1c5918587 100644 --- a/MiniScanner/Modules/EditViewController/CustomViews/BannerView.swift +++ b/MiniScanner/Modules/EditViewController/CustomViews/BannerView.swift @@ -12,6 +12,7 @@ import FSPagerView protocol BannerViewDelegate { func updateSelectedIndex(index: Int) func delete(index: Int) + func preview(index: Int) } class BannerView: UIView { @@ -134,6 +135,10 @@ extension BannerView: FSPagerViewDataSource,FSPagerViewDelegate { } extension BannerView: FSPagerViewCellDelegate { + func preview(at: Int) { + delegate?.preview(index: at) + } + func delete(at: Int) { delegate?.delete(index: at) } diff --git a/MiniScanner/Modules/EditViewController/CustomViews/PreviewImageViewController.swift b/MiniScanner/Modules/EditViewController/CustomViews/PreviewImageViewController.swift new file mode 100644 index 0000000000000000000000000000000000000000..d558e60f7d4454b90649c17b7e99e8ff15ef4e0f --- /dev/null +++ b/MiniScanner/Modules/EditViewController/CustomViews/PreviewImageViewController.swift @@ -0,0 +1,29 @@ +// +// PreviewImageViewController.swift +// MiniScanner +// +// Created by George Makhoul on 12/06/2024. +// Copyright © 2024 AppsNectar. All rights reserved. +// + +import UIKit +import WebKit + +class PreviewImageViewController: UIViewController { + var previewImage = UIImageView() + var image: UIImage? + + + override func viewDidLoad() { + super.viewDidLoad() + self.previewImage = UIImageView(frame: view.bounds) + previewImage.contentMode = .scaleAspectFill + previewImage.image = image + self.view.addSubview(previewImage) + previewImage.autoresizingMask = [.flexibleWidth, .flexibleHeight] + } +} + + + + diff --git a/MiniScanner/Modules/EditViewController/EditViewController.swift b/MiniScanner/Modules/EditViewController/EditViewController.swift index f825ff433f830646460f7a39373cb4f25e4c2660..53fc114cf0ce980e57a3ce7335726ed1711256c4 100644 --- a/MiniScanner/Modules/EditViewController/EditViewController.swift +++ b/MiniScanner/Modules/EditViewController/EditViewController.swift @@ -9,6 +9,8 @@ import UIKit import LNExtensionExecutor import NBBottomSheet +import QuickLook + public protocol EditViewControllerDelegate: NSObjectProtocol { func editViewController(_ editViewController: EditViewController, finished session: MultiPageScanSession) } @@ -28,7 +30,8 @@ public class EditViewController: UIViewController { private var sharedFolder: AppConfigurator.Folder? = AppConfigurator.Folder(name: "Shared", savedName: "shared", isSelected: true) var selectedFolder: AppConfigurator.Folder? private var localFileManager: LocalFileManager? - + private var fileURL: URL? + lazy private var activityIndicator: UIActivityIndicatorView = { let activityIndicator = UIActivityIndicatorView(style: .large) activityIndicator.color = .white @@ -175,6 +178,14 @@ public class EditViewController: UIViewController { // MARK: - BannerViewDelegate extension EditViewController: BannerViewDelegate { + func preview(index: Int) { + let previewController = PreviewImageViewController() + if let image = scanSession?.scannedItems[index].renderedImage?.retrieveImage() { + previewController.image = image + } + present(previewController, animated: true) + } + func delete(index: Int) { let alertController = UIAlertController(title: "Alert", message: "Are you sure you want to delete this image?", preferredStyle: .alert) @@ -306,3 +317,14 @@ extension EditViewController: ShareSheetViewControllerDelegate { } } } + +// MARK: - QLPreviewControllerDataSource +extension EditViewController: QLPreviewControllerDataSource { + public func numberOfPreviewItems(in controller: QLPreviewController) -> Int { + 1 + } + + public func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem { + return fileURL! as QLPreviewItem + } +} diff --git a/Pods/FSPagerView/Sources/FSPagerViewCell.swift b/Pods/FSPagerView/Sources/FSPagerViewCell.swift index 7128c938528f19d434bd629565e468b7f4d2db77..832de15a36f2a84d443ba14378d28901d5ae5aff 100644 --- a/Pods/FSPagerView/Sources/FSPagerViewCell.swift +++ b/Pods/FSPagerView/Sources/FSPagerViewCell.swift @@ -9,9 +9,12 @@ import UIKit public protocol FSPagerViewCellDelegate { func delete(at: Int) + func preview(at: Int) } open class FSPagerViewCell: UICollectionViewCell { - var topLeftButton: UIButton! + var trashButton: UIButton! + var previewButton: UIButton! + open var delegate: FSPagerViewCellDelegate? open var index: Int? @@ -44,21 +47,30 @@ open class FSPagerViewCell: UICollectionViewCell { return _imageView } let imageView = UIImageView(frame: .zero) + imageView.layer.cornerRadius = 10 + imageView.clipsToBounds = true self.contentView.addSubview(imageView) _imageView = imageView - let xPosition = ((self.contentView.bounds.width) - 50) / 2 - let yPosition = (self.contentView.bounds.height) - 70 - - topLeftButton = UIButton(frame: CGRect(x: xPosition, y: yPosition, width: 50, height: 50)) // Adjust frame as needed - self.contentView.addSubview(topLeftButton) // Add the button to the cell's contentView - topLeftButton.setImage(UIImage(systemName: "trash.fill"), for: .normal) - topLeftButton.addTarget(self, action: #selector(topLeftButtonTapped), for: .touchUpInside) // Set the button action - topLeftButton.tintColor = .red - topLeftButton.layer.cornerRadius = 25 - topLeftButton.layer.borderColor = UIColor.red.cgColor - topLeftButton.layer.borderWidth = 2 - + let xPosition = 0 + let yPosition = (self.contentView.bounds.height) - 50 + + trashButton = UIButton(frame: CGRect(x: xPosition, y: Int(yPosition), width: 50, height: 50)) // Adjust frame as needed + self.contentView.addSubview(trashButton) // Add the button to the cell's contentView + trashButton.setImage(UIImage(systemName: "trash.fill"), for: .normal) + trashButton.addTarget(self, action: #selector(topLeftButtonTapped), for: .touchUpInside) // Set the button action + trashButton.tintColor = .red + + + let previewXPosition = self.contentView.bounds.width - 50 + let previewYPosition = (self.contentView.bounds.height) - 50 + + previewButton = UIButton(frame: CGRect(x: Int(previewXPosition), y: Int(previewYPosition), width: 50, height: 50)) // Adjust frame as needed + self.contentView.addSubview(previewButton) // Add the button to the cell's contentView + previewButton.setImage(UIImage(systemName: "eye"), for: .normal) + previewButton.addTarget(self, action: #selector(imagePreview), for: .touchUpInside) // Set the button action + previewButton.tintColor = .red + return imageView } @@ -130,6 +142,10 @@ open class FSPagerViewCell: UICollectionViewCell { delegate?.delete(at: index ?? -1) } + @objc func imagePreview() { + delegate?.preview(at: index ?? -1) + } + deinit { if let textLabel = _textLabel { textLabel.removeObserver(self, forKeyPath: "font", context: kvoContext)