ارفع راسك فوق انته سوري حر ... :green_heart::green_heart:

Skip to content
Snippets Groups Projects
Commit ba3e3e91 authored by Mustafa Merza's avatar Mustafa Merza
Browse files

- Added edit screen mode (cropping, signing, normal).

- Fixed back button function to discard changes and stay in the screen if it is in mode other than normal.

- Fixed images colors.

- Refactored some codes.
parent 4664c497
Branches
No related tags found
No related merge requests found
...@@ -164,6 +164,7 @@ ...@@ -164,6 +164,7 @@
6709C0602C6E0005009C3F11 /* UITertiaryButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6709C05F2C6E0005009C3F11 /* UITertiaryButton.swift */; }; 6709C0602C6E0005009C3F11 /* UITertiaryButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6709C05F2C6E0005009C3F11 /* UITertiaryButton.swift */; };
6709C0622C6E2373009C3F11 /* ZoomableScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6709C0612C6E2373009C3F11 /* ZoomableScrollView.swift */; }; 6709C0622C6E2373009C3F11 /* ZoomableScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6709C0612C6E2373009C3F11 /* ZoomableScrollView.swift */; };
6709C0642C6E2495009C3F11 /* ZoomableImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6709C0632C6E2495009C3F11 /* ZoomableImageView.swift */; }; 6709C0642C6E2495009C3F11 /* ZoomableImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6709C0632C6E2495009C3F11 /* ZoomableImageView.swift */; };
6709C0662C6E2C87009C3F11 /* EditScreenMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6709C0652C6E2C87009C3F11 /* EditScreenMode.swift */; };
67106C942C4EAC0100874BFC /* CustomTabBarLayerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67106C922C4EAC0000874BFC /* CustomTabBarLayerProtocol.swift */; }; 67106C942C4EAC0100874BFC /* CustomTabBarLayerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67106C922C4EAC0000874BFC /* CustomTabBarLayerProtocol.swift */; };
67106C952C4EAC0100874BFC /* CustomTabBarLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67106C932C4EAC0000874BFC /* CustomTabBarLayer.swift */; }; 67106C952C4EAC0100874BFC /* CustomTabBarLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67106C932C4EAC0000874BFC /* CustomTabBarLayer.swift */; };
672C46442C47B1F300497EF0 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 672C46432C47B1F300497EF0 /* Localizable.xcstrings */; }; 672C46442C47B1F300497EF0 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 672C46432C47B1F300497EF0 /* Localizable.xcstrings */; };
...@@ -498,6 +499,7 @@ ...@@ -498,6 +499,7 @@
6709C05F2C6E0005009C3F11 /* UITertiaryButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITertiaryButton.swift; sourceTree = "<group>"; }; 6709C05F2C6E0005009C3F11 /* UITertiaryButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITertiaryButton.swift; sourceTree = "<group>"; };
6709C0612C6E2373009C3F11 /* ZoomableScrollView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZoomableScrollView.swift; sourceTree = "<group>"; }; 6709C0612C6E2373009C3F11 /* ZoomableScrollView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZoomableScrollView.swift; sourceTree = "<group>"; };
6709C0632C6E2495009C3F11 /* ZoomableImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZoomableImageView.swift; sourceTree = "<group>"; }; 6709C0632C6E2495009C3F11 /* ZoomableImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZoomableImageView.swift; sourceTree = "<group>"; };
6709C0652C6E2C87009C3F11 /* EditScreenMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditScreenMode.swift; sourceTree = "<group>"; };
67106C922C4EAC0000874BFC /* CustomTabBarLayerProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomTabBarLayerProtocol.swift; sourceTree = "<group>"; }; 67106C922C4EAC0000874BFC /* CustomTabBarLayerProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomTabBarLayerProtocol.swift; sourceTree = "<group>"; };
67106C932C4EAC0000874BFC /* CustomTabBarLayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomTabBarLayer.swift; sourceTree = "<group>"; }; 67106C932C4EAC0000874BFC /* CustomTabBarLayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomTabBarLayer.swift; sourceTree = "<group>"; };
672C46432C47B1F300497EF0 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; }; 672C46432C47B1F300497EF0 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
...@@ -1026,6 +1028,7 @@ ...@@ -1026,6 +1028,7 @@
53EDED9A2C183CB600DB8DF9 /* CustomCells */, 53EDED9A2C183CB600DB8DF9 /* CustomCells */,
53BAE0EB2C15E0890072189E /* EditViewController.swift */, 53BAE0EB2C15E0890072189E /* EditViewController.swift */,
53BAE0EC2C15E0890072189E /* EditViewController.xib */, 53BAE0EC2C15E0890072189E /* EditViewController.xib */,
6709C0652C6E2C87009C3F11 /* EditScreenMode.swift */,
); );
path = EditViewController; path = EditViewController;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2096,6 +2099,7 @@ ...@@ -2096,6 +2099,7 @@
535983EB2C142B16003EB6ED /* UILabel+Extensions.swift in Sources */, 535983EB2C142B16003EB6ED /* UILabel+Extensions.swift in Sources */,
677E65E52C5A36920039E2C5 /* DeleteScanSessionUseCase.swift in Sources */, 677E65E52C5A36920039E2C5 /* DeleteScanSessionUseCase.swift in Sources */,
678BD7172C4CF1EB00833DA5 /* SettingsViewModel.swift in Sources */, 678BD7172C4CF1EB00833DA5 /* SettingsViewModel.swift in Sources */,
6709C0662C6E2C87009C3F11 /* EditScreenMode.swift in Sources */,
EC8A9B10254DC6DD00F9AF99 /* PDFManager.swift in Sources */, EC8A9B10254DC6DD00F9AF99 /* PDFManager.swift in Sources */,
677E65E72C5A36990039E2C5 /* AddScanSessionUseCase.swift in Sources */, 677E65E72C5A36990039E2C5 /* AddScanSessionUseCase.swift in Sources */,
5399964B2C26E86700671340 /* FlashButton.m in Sources */, 5399964B2C26E86700671340 /* FlashButton.m in Sources */,
......
//
// EditScreenMode.swift
// MiniScanner
//
// Created by Mustafa Merza on 8/15/24.
// Copyright © 2024 AppsNectar. All rights reserved.
//
import Foundation
enum EditScreenMode {
case normal
case cropping
case signing
}
...@@ -54,6 +54,10 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess ...@@ -54,6 +54,10 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess
@IBOutlet weak var exportTextImageView: UIImageView! @IBOutlet weak var exportTextImageView: UIImageView!
@IBOutlet weak var signatureImageView: UIImageView! @IBOutlet weak var signatureImageView: UIImageView!
@IBOutlet weak var rotateLeftImageView: UIImageView!
@IBOutlet weak var rotateRightImageView: UIImageView!
@IBOutlet weak var autoDetectionImageView: UIImageView!
@Inject var addScanSessionUseCase: AddScanSessionUseCase @Inject var addScanSessionUseCase: AddScanSessionUseCase
@Inject var updateScanSessionUseCase: UpdateScanSessionUseCase @Inject var updateScanSessionUseCase: UpdateScanSessionUseCase
...@@ -71,6 +75,13 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess ...@@ -71,6 +75,13 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess
var sharingViewController: UIViewController { self } var sharingViewController: UIViewController { self }
// MARK: - Properties // MARK: - Properties
private var screenMode: EditScreenMode = .normal {
didSet {
handleScreenMode()
}
}
private var scanSession: ScanSession! private var scanSession: ScanSession!
private var selectedIndex: Int = 0 private var selectedIndex: Int = 0
...@@ -88,28 +99,6 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess ...@@ -88,28 +99,6 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess
private var detectedRectangleFeature = CIRectangleFeature() private var detectedRectangleFeature = CIRectangleFeature()
private var sharedDetector = CDImageRectangleDetector() private var sharedDetector = CDImageRectangleDetector()
private var isSigning: Bool = false {
didSet {
if !isSigning {
banner.pagerView.isScrollEnabled = true
}
}
}
private var isCropping: Bool = false {
didSet {
banner.pagerView.isScrollEnabled = !isCropping
if isCropping {
displayCropButtons()
}
else {
hideCropButtons()
}
}
}
private var name: String = "" private var name: String = ""
lazy var activityIndicator: UIActivityIndicatorView = { lazy var activityIndicator: UIActivityIndicatorView = {
...@@ -147,6 +136,9 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess ...@@ -147,6 +136,9 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess
scanSession = .newSession() scanSession = .newSession()
fatalError("init(coder:) should not be called for this class") fatalError("init(coder:) should not be called for this class")
} }
}
extension EditViewController {
private func setupUI() { private func setupUI() {
...@@ -223,6 +215,10 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess ...@@ -223,6 +215,10 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess
editImageView.customTint(.gray600) editImageView.customTint(.gray600)
exportTextImageView.customTint(.gray600) exportTextImageView.customTint(.gray600)
signatureImageView.customTint(.gray600) signatureImageView.customTint(.gray600)
rotateLeftImageView.customTint(.gray600)
rotateRightImageView.customTint(.gray600)
autoDetectionImageView.customTint(.gray600)
} }
private func setupFonts() { private func setupFonts() {
...@@ -238,40 +234,7 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess ...@@ -238,40 +234,7 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess
cropLabel.set(font: .medium(14)) cropLabel.set(font: .medium(14))
} }
// MARK: - Methods private func configImageEditor() {
@objc func backTapped() {
if navigationItem.rightBarButtonItem == nil {
navigationController?.popViewController(animated: true)
} else {
let alertController = UIAlertController(title: .alert.localized, message: .discardChangesMsg.localized, preferredStyle: .alert)
let okAction = UIAlertAction(title: .discard.localized, style: .destructive) { [weak self] (action) in
guard let self else { return }
dismiss(animated: true) {
self.discardChanges()
self.navigationController?.popViewController(animated: true)
}
}
let cancelAction = UIAlertAction(title: .cancel.localized, style: .cancel) { [weak self] (action) in
guard let self else { return }
dismiss(animated: true)
}
alertController.addAction(okAction)
alertController.addAction(cancelAction)
present(alertController, animated: true, completion: nil)
}
}
func configImageEditor() {
ZLImageEditorConfiguration.default() ZLImageEditorConfiguration.default()
.imageStickerContainerView(ImageStickerContainerView()) .imageStickerContainerView(ImageStickerContainerView())
.fontChooserContainerView(FontChooserContainerView()) .fontChooserContainerView(FontChooserContainerView())
...@@ -284,75 +247,6 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess ...@@ -284,75 +247,6 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess
config.tools.append(.adjust) config.tools.append(.adjust)
} }
@objc func onTouchDoneButton() {
if isSigning {
isSigning = false
let items = scanSession.scannedItems
if !banner.signAllDoc {
let cell = banner.pagerView.cellForItemat(index: self.banner.pagerView.currentIndex)
cell?.prepareCellForScreenshot()
let image = cell?.contentView.TakeScreenshot()
cell?.restoreCellAfterScreenshot()
cell?.selectedStickerView1?.removeFromSuperview()
if let image {
let index = banner.pagerView.currentIndex
replacePageImage(image: image, at: index)
banner.pagerView.reloadData(at: index)
navigationItem.rightBarButtonItem = nil
}
} else {
for (index, item) in items.enumerated() {
let image = item.screenShot
if let image {
replacePageImage(image: image, at: index)
}
}
banner.pagerView.reloadData()
navigationItem.rightBarButtonItem = nil
}
} else {
isCropping = false
if let editView = banner.pagerView.cellForItem(at: banner.pagerView.currentIndex) {
editView.trashButton.isHidden = false
editView.previewButton.isHidden = false
}
if let image = overlayView.cropImage(self.originalImage) {
let index = banner.pagerView.currentIndex
replacePageImage(image: image, at: index)
banner.pagerView.reloadData(at: index)
navigationItem.rightBarButtonItem = nil
overlayView.removeFromSuperview()
}
}
}
private func getCurrentRotationAngle() -> Double{ private func getCurrentRotationAngle() -> Double{
switch self.deviceOrientationHelper.currentDeviceOrientation { switch self.deviceOrientationHelper.currentDeviceOrientation {
case .landscapeRight: case .landscapeRight:
...@@ -372,7 +266,7 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess ...@@ -372,7 +266,7 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess
print("Orientation changed: \(deviceOrientationHelper.currentDeviceOrientation.rawValue)") print("Orientation changed: \(deviceOrientationHelper.currentDeviceOrientation.rawValue)")
} }
func updatePageLabel() { private func updatePageLabel() {
pageIndex.set(text: "\(selectedIndex + 1)/\(scanSession.scannedItems.count)") pageIndex.set(text: "\(selectedIndex + 1)/\(scanSession.scannedItems.count)")
...@@ -381,6 +275,33 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess ...@@ -381,6 +275,33 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess
previousPageButton.isEnabled = selectedIndex > 0 previousPageButton.isEnabled = selectedIndex > 0
nextPageButton.isEnabled = selectedIndex < scanSession.itemsCount - 1 nextPageButton.isEnabled = selectedIndex < scanSession.itemsCount - 1
} }
}
extension EditViewController {
@objc func backTapped() {
switch screenMode {
case .normal:
handleBackInNormalMode()
case .cropping:
handleBackInCroppingMode()
case .signing:
handleBackInSigningMode()
}
}
@objc func onTouchDoneButton() {
switch screenMode {
case .normal:
handleDoneInNormalMode()
case .cropping:
handleDoneInCroppingMode()
case .signing:
handleDoneInSigningMode()
}
}
// MARK: - Actions // MARK: - Actions
@IBAction func backIndex(_ sender: UIButton) { @IBAction func backIndex(_ sender: UIButton) {
...@@ -406,34 +327,14 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess ...@@ -406,34 +327,14 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess
} }
@IBAction func continueTapped(_ sender: UIButton) { @IBAction func continueTapped(_ sender: UIButton) {
if self.navigationItem.rightBarButtonItem == nil {
displayShareSheet()
} else {
let alertController = UIAlertController(title: .alert.localized, message: .discardChangesAndContinueMsg.localized, preferredStyle: .alert)
let okAction = UIAlertAction(title: .yes.localized, style: .destructive) { [weak self] (action) in
guard let self else { return }
dismiss(animated: true) { switch screenMode {
case .normal:
self.discardChanges() handleContinueInNormalMode()
case .cropping:
self.displayShareSheet() handleContinueInCroppingMode()
} case .signing:
} handleContinueInSigningMode()
let cancelAction = UIAlertAction(title: .cancel.localized, style: .cancel) { [weak self] (action) in
guard let self else { return }
dismiss(animated: true)
}
alertController.addAction(okAction)
alertController.addAction(cancelAction)
present(alertController, animated: true, completion: nil)
} }
} }
...@@ -493,72 +394,235 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess ...@@ -493,72 +394,235 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess
// MARK: - TABBAR ACTION // MARK: - TABBAR ACTION
@IBAction func editButtonTapped(_ sender: UIButton) { @IBAction func editButtonTapped(_ sender: UIButton) {
if let img = scanSession.scannedItems[banner.pagerView.currentIndex].newRenderedImage?.retrieveImage() { displayEditImageViewController()
}
ZLEditImageViewController.showEditImageVC(parentVC: self, image: img, editModel: nil) { [weak self] resImage, editModel in @IBAction func ocrTapped(_ sender: UIButton) {
guard let self else { return } displayOCRViewController()
}
@IBAction func cropTapped(_ sender: UIButton) {
displayCropOptions()
}
@IBAction func signatureTapped(_ sender: UIButton) {
displaySignatureViewController()
}
@IBAction func saveCropButtonTapped(_ sender: Any) {
onTouchDoneButton()
}
@IBAction func rotateRightTapped(_ sender: Any) {
}
@IBAction func autoDetectionTapped(_ sender: Any) {
}
@IBAction func rotateLeftTapped(_ sender: Any) {
}
}
extension EditViewController {
private func handleScreenMode() {
switch screenMode {
case .normal:
navigationItem.rightBarButtonItem = nil
banner.pagerView.isScrollEnabled = true
hideCropButtons()
case .cropping:
banner.pagerView.isScrollEnabled = false
displayCropButtons()
case .signing:
banner.pagerView.isScrollEnabled = true
}
}
}
extension EditViewController {
private func handleDoneInNormalMode() {
}
private func handleDoneInCroppingMode() {
screenMode = .normal
if let editView = banner.pagerView.cellForItem(at: banner.pagerView.currentIndex) {
editView.trashButton.isHidden = false
editView.previewButton.isHidden = false
}
if let image = overlayView.cropImage(self.originalImage) {
let index = banner.pagerView.currentIndex let index = banner.pagerView.currentIndex
replacePageImage(image: resImage, at: index) replacePageImage(image: image, at: index)
banner.pagerView.reloadData(at: index)
overlayView.removeFromSuperview()
}
}
private func handleDoneInSigningMode() {
screenMode = .normal
let items = scanSession.scannedItems
if !banner.signAllDoc {
let cell = banner.pagerView.cellForItemat(index: self.banner.pagerView.currentIndex)
cell?.prepareCellForScreenshot()
let image = cell?.contentView.TakeScreenshot()
cell?.restoreCellAfterScreenshot()
cell?.selectedStickerView1?.removeFromSuperview()
if let image {
let index = banner.pagerView.currentIndex
replacePageImage(image: image, at: index)
banner.pagerView.reloadData(at: index) banner.pagerView.reloadData(at: index)
} }
} else {
for (index, item) in items.enumerated() {
let image = item.screenShot
if let image {
replacePageImage(image: image, at: index)
} }
} }
@IBAction func ocrTapped(_ sender: UIButton) { banner.pagerView.reloadData()
displayOCRViewController() }
}
} }
@IBAction func cropTapped(_ sender: UIButton) { extension EditViewController {
if let origImage = scanSession.scannedItems[banner.pagerView.currentIndex].newRenderedImage?.retrieveImage() { private func handleContinueInNormalMode() {
displayShareSheet()
}
originalImage = origImage private func handleContinueInCroppingMode() {
displayDiscardChangesDialog()
} }
DispatchQueue.main.async { private func handleContinueInSigningMode() {
let rect = AVMakeRect(aspectRatio: self.originalImage.size, insideRect: self.banner.bounds) displayDiscardChangesDialog()
if let editView = self.banner.pagerView.cellForItem(at: self.banner.pagerView.currentIndex) {
editView.trashButton.isHidden = true
editView.previewButton.isHidden = true
editView.contentView.frame = rect
} }
} }
extension EditViewController {
isCropping = true private func handleBackInNormalMode() {
navigationController?.popViewController(animated: true)
}
let cropButton = UIBarButtonItem(title: .crop.localized, style: .plain, target: self, action: #selector(self.onTouchDoneButton)) private func handleBackInCroppingMode() {
displayDiscardChangesDialog()
}
navigationItem.rightBarButtonItem = cropButton private func handleBackInSigningMode() {
displayDiscardChangesDialog()
}
perform(#selector(setUpCropView), with: self, afterDelay: 0.2) private func displayDiscardChangesDialog() {
let alertController = UIAlertController(title: .alert.localized, message: .discardChangesMsg.localized, preferredStyle: .alert)
let okAction = UIAlertAction(title: .discard.localized, style: .destructive) { [weak self] (action) in
guard let self else { return }
dismiss(animated: true) {
switch self.screenMode {
case .normal:
break
case .cropping:
self.discardCropChanges()
case .signing:
self.discardSignatureChanges()
} }
@IBAction func signatureTapped(_ sender: UIButton) { self.banner.pagerView.reloadData()
displaySignatureViewController()
self.navigationItem.rightBarButtonItem = nil
self.screenMode = .normal
}
} }
@IBAction func saveCropButtonTapped(_ sender: Any) { let cancelAction = UIAlertAction(title: .cancel.localized, style: .cancel) { [weak self] (action) in
onTouchDoneButton() guard let self else { return }
dismiss(animated: true)
} }
@IBAction func rotateRightTapped(_ sender: Any) { alertController.addAction(okAction)
alertController.addAction(cancelAction)
present(alertController, animated: true, completion: nil)
} }
@IBAction func autoDetectionTapped(_ sender: Any) { private func discardSignatureChanges() {
let items = scanSession.scannedItems
for item in items {
item.signtureImage = UIImage()
item.rotate = 0
item.signaturePosition = .zero
item.screenShot = UIImage()
item.size = .zero
}
} }
@IBAction func rotateLeftTapped(_ sender: Any) { private func discardCropChanges() {
overlayView.removeFromSuperview()
} }
} }
extension EditViewController { extension EditViewController {
private func displayEditImageViewController() {
if let image = scanSession.scannedItems[banner.pagerView.currentIndex].newRenderedImage?.retrieveImage() {
ZLEditImageViewController.showEditImageVC(parentVC: self, image: image, editModel: nil) { [weak self] resImage, editModel in
guard let self else { return }
let index = banner.pagerView.currentIndex
replacePageImage(image: resImage, at: index)
banner.pagerView.reloadData(at: index)
}
}
}
private func displayShareSheet() { private func displayShareSheet() {
let popup = ShareSheetViewController() let popup = ShareSheetViewController()
...@@ -590,33 +654,39 @@ extension EditViewController { ...@@ -590,33 +654,39 @@ extension EditViewController {
} }
} }
private func displayCropButtons() { private func displayCropOptions() {
editButtonsStackView.isHidden = true
cropButtonsStackView.isHidden = false if let origImage = scanSession.scannedItems[banner.pagerView.currentIndex].newRenderedImage?.retrieveImage() {
originalImage = origImage
} }
private func hideCropButtons() { DispatchQueue.main.async {
editButtonsStackView.isHidden = false let rect = AVMakeRect(aspectRatio: self.originalImage.size, insideRect: self.banner.bounds)
cropButtonsStackView.isHidden = true if let editView = self.banner.pagerView.cellForItem(at: self.banner.pagerView.currentIndex) {
editView.trashButton.isHidden = true
editView.previewButton.isHidden = true
editView.contentView.frame = rect
}
} }
private func discardChanges() { screenMode = .cropping
let items = scanSession.scannedItems let cropButton = UIBarButtonItem(title: .crop.localized, style: .plain, target: self, action: #selector(self.onTouchDoneButton))
for item in items { navigationItem.rightBarButtonItem = cropButton
item.signtureImage = UIImage()
item.rotate = 0
item.signaturePosition = .zero
item.screenShot = UIImage()
item.size = .zero
}
banner.pagerView.reloadData() perform(#selector(setUpCropView), with: self, afterDelay: 0.2)
}
navigationItem.rightBarButtonItem = nil private func displayCropButtons() {
editButtonsStackView.isHidden = true
cropButtonsStackView.isHidden = false
}
overlayView.removeFromSuperview() private func hideCropButtons() {
editButtonsStackView.isHidden = false
cropButtonsStackView.isHidden = true
} }
private func displayAddSignatureDialog(signatureImage: UIImage) { private func displayAddSignatureDialog(signatureImage: UIImage) {
...@@ -651,7 +721,8 @@ extension EditViewController { ...@@ -651,7 +721,8 @@ extension EditViewController {
let cancelAction = UIAlertAction(title: .cancel.localized, style: .cancel) { [weak self] (action) in let cancelAction = UIAlertAction(title: .cancel.localized, style: .cancel) { [weak self] (action) in
guard let self else { return } guard let self else { return }
isSigning = false screenMode = .normal
dismiss(animated: true) dismiss(animated: true)
} }
...@@ -771,9 +842,14 @@ extension EditViewController: BannerViewDelegate { ...@@ -771,9 +842,14 @@ extension EditViewController: BannerViewDelegate {
func deleteSignAt(index: Int) { func deleteSignAt(index: Int) {
scanSession.scannedItems[index].signtureImage = UIImage() scanSession.scannedItems[index].signtureImage = UIImage()
if !banner.signAllDoc { let signaturesCount = scanSession.scannedItems.filter { $0.signtureImage != nil && $0.signtureImage != UIImage() }.count
isSigning = false
print("Heha", signaturesCount)
if signaturesCount == 0 {
screenMode = .normal
} }
banner.pagerView.reloadData() banner.pagerView.reloadData()
} }
...@@ -923,7 +999,7 @@ extension EditViewController: SignatureDelegate { ...@@ -923,7 +999,7 @@ extension EditViewController: SignatureDelegate {
func epSignature(didSign signatureImage: UIImage, boundingRect: CGRect) { func epSignature(didSign signatureImage: UIImage, boundingRect: CGRect) {
isSigning = true screenMode = .signing
self.signatureImage = signatureImage self.signatureImage = signatureImage
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
<objects> <objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="EditViewController" customModule="MiniScanner" customModuleProvider="target"> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="EditViewController" customModule="MiniScanner" customModuleProvider="target">
<connections> <connections>
<outlet property="autoDetectionImageView" destination="bfY-c3-Ugi" id="XdK-E7-SFZ"/>
<outlet property="autoDetectionLabel" destination="3ua-9x-3ZE" id="3CC-Ej-ssW"/> <outlet property="autoDetectionLabel" destination="3ua-9x-3ZE" id="3CC-Ej-ssW"/>
<outlet property="banner" destination="4ep-ST-cZS" id="WFR-ov-H7F"/> <outlet property="banner" destination="4ep-ST-cZS" id="WFR-ov-H7F"/>
<outlet property="continueButton" destination="jE5-UT-fB1" id="v74-7i-T0B"/> <outlet property="continueButton" destination="jE5-UT-fB1" id="v74-7i-T0B"/>
...@@ -35,7 +36,9 @@ ...@@ -35,7 +36,9 @@
<outlet property="nextPageButton" destination="Zhd-7n-Vkh" id="Mih-BG-xEl"/> <outlet property="nextPageButton" destination="Zhd-7n-Vkh" id="Mih-BG-xEl"/>
<outlet property="pageIndex" destination="cqF-h7-7PR" id="KbK-o3-cPN"/> <outlet property="pageIndex" destination="cqF-h7-7PR" id="KbK-o3-cPN"/>
<outlet property="previousPageButton" destination="3Oy-6E-tPl" id="4Wz-tD-ueD"/> <outlet property="previousPageButton" destination="3Oy-6E-tPl" id="4Wz-tD-ueD"/>
<outlet property="rotateLeftImageView" destination="fhs-7Y-dA0" id="z2H-QK-rZ5"/>
<outlet property="rotateLeftLabel" destination="B3S-6c-OhV" id="g9B-y6-BDj"/> <outlet property="rotateLeftLabel" destination="B3S-6c-OhV" id="g9B-y6-BDj"/>
<outlet property="rotateRightImageView" destination="Kbs-wl-1Ja" id="ppp-Ii-QTA"/>
<outlet property="rotateRightLabel" destination="xlr-tI-WaL" id="Lup-R6-y2j"/> <outlet property="rotateRightLabel" destination="xlr-tI-WaL" id="Lup-R6-y2j"/>
<outlet property="saveCropButton" destination="oHb-tw-dkv" id="xUA-La-bKm"/> <outlet property="saveCropButton" destination="oHb-tw-dkv" id="xUA-La-bKm"/>
<outlet property="shareTypeButton" destination="U1b-fk-5ai" id="TCj-8k-BM3"/> <outlet property="shareTypeButton" destination="U1b-fk-5ai" id="TCj-8k-BM3"/>
...@@ -261,7 +264,7 @@ ...@@ -261,7 +264,7 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="aGp-MO-3Od"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="aGp-MO-3Od">
<rect key="frame" x="16" y="812" width="398" height="120"/> <rect key="frame" x="16" y="812" width="398" height="120"/>
<subviews> <subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="718-GQ-BuB" userLabel="Edit Buttons"> <stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="718-GQ-BuB" userLabel="Edit Buttons">
<rect key="frame" x="0.0" y="0.0" width="398" height="90"/> <rect key="frame" x="0.0" y="0.0" width="398" height="90"/>
<subviews> <subviews>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ilb-67-Nes"> <view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ilb-67-Nes">
...@@ -301,23 +304,23 @@ ...@@ -301,23 +304,23 @@
</constraints> </constraints>
</view> </view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BAt-0v-QCp"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BAt-0v-QCp">
<rect key="frame" x="0.0" y="0.0" width="99.666666666666671" height="90"/> <rect key="frame" x="0.0" y="0.0" width="50" height="90"/>
<subviews> <subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="edit-ic" translatesAutoresizingMaskIntoConstraints="NO" id="ooZ-SP-MTR"> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="edit-ic" translatesAutoresizingMaskIntoConstraints="NO" id="ooZ-SP-MTR">
<rect key="frame" x="32.333333333333336" y="12" width="35.000000000000007" height="35"/> <rect key="frame" x="7.6666666666666679" y="12" width="35" height="35"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="35" id="Kx2-wR-oZT"/> <constraint firstAttribute="width" constant="35" id="Kx2-wR-oZT"/>
<constraint firstAttribute="height" constant="35" id="O8q-pH-0fM"/> <constraint firstAttribute="height" constant="35" id="O8q-pH-0fM"/>
</constraints> </constraints>
</imageView> </imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="edit" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qsI-va-wrT"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="edit" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qsI-va-wrT">
<rect key="frame" x="0.0" y="52" width="99.666666666666671" height="20"/> <rect key="frame" x="0.0" y="52" width="50" height="20"/>
<fontDescription key="fontDescription" name="Poppins-Regular" family="Poppins" pointSize="17"/> <fontDescription key="fontDescription" name="Poppins-Regular" family="Poppins" pointSize="17"/>
<nil key="textColor"/> <nil key="textColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tYF-EJ-SgN"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tYF-EJ-SgN">
<rect key="frame" x="0.0" y="0.0" width="99.666666666666671" height="90"/> <rect key="frame" x="0.0" y="0.0" width="50" height="90"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<connections> <connections>
<action selector="editButtonTapped:" destination="-1" eventType="touchUpInside" id="fXr-i1-mQm"/> <action selector="editButtonTapped:" destination="-1" eventType="touchUpInside" id="fXr-i1-mQm"/>
...@@ -338,23 +341,23 @@ ...@@ -338,23 +341,23 @@
</constraints> </constraints>
</view> </view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BJX-OA-bae"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BJX-OA-bae">
<rect key="frame" x="99.666666666666686" y="0.0" width="99.333333333333314" height="90"/> <rect key="frame" x="76.333333333333329" y="0.0" width="82.999999999999986" height="90"/>
<subviews> <subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="scan-ic" translatesAutoresizingMaskIntoConstraints="NO" id="mvC-Zj-Plh"> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="scan-ic" translatesAutoresizingMaskIntoConstraints="NO" id="mvC-Zj-Plh">
<rect key="frame" x="31.999999999999986" y="12" width="35" height="35"/> <rect key="frame" x="24" y="12" width="35" height="35"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="35" id="9lk-jm-95U"/> <constraint firstAttribute="height" constant="35" id="9lk-jm-95U"/>
<constraint firstAttribute="width" constant="35" id="KkF-U0-Sps"/> <constraint firstAttribute="width" constant="35" id="KkF-U0-Sps"/>
</constraints> </constraints>
</imageView> </imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Export text" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7JD-iL-DeH"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Export text" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7JD-iL-DeH">
<rect key="frame" x="0.0" y="52" width="99.333333333333329" height="20.333333333333329"/> <rect key="frame" x="0.0" y="52" width="83" height="20.333333333333329"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/> <nil key="textColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="iVs-aT-KbC"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="iVs-aT-KbC">
<rect key="frame" x="0.0" y="0.0" width="99.333333333333329" height="90"/> <rect key="frame" x="0.0" y="0.0" width="83" height="90"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<connections> <connections>
<action selector="ocrTapped:" destination="-1" eventType="touchUpInside" id="jaQ-ME-HOT"/> <action selector="ocrTapped:" destination="-1" eventType="touchUpInside" id="jaQ-ME-HOT"/>
...@@ -375,23 +378,23 @@ ...@@ -375,23 +378,23 @@
</constraints> </constraints>
</view> </view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="auU-4h-Wqw"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="auU-4h-Wqw">
<rect key="frame" x="199" y="0.0" width="99.666666666666686" height="90"/> <rect key="frame" x="185.33333333333334" y="0.0" width="94.000000000000028" height="90"/>
<subviews> <subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="signature-ic" translatesAutoresizingMaskIntoConstraints="NO" id="VaC-Qb-0cF"> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="signature-ic" translatesAutoresizingMaskIntoConstraints="NO" id="VaC-Qb-0cF">
<rect key="frame" x="32.333333333333343" y="12" width="35" height="35"/> <rect key="frame" x="29.666666666666657" y="12" width="35" height="35"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="35" id="nR9-vm-iOp"/> <constraint firstAttribute="width" constant="35" id="nR9-vm-iOp"/>
<constraint firstAttribute="height" constant="35" id="uXK-LC-eo2"/> <constraint firstAttribute="height" constant="35" id="uXK-LC-eo2"/>
</constraints> </constraints>
</imageView> </imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="signature" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wyA-kN-C8j"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="signature" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wyA-kN-C8j">
<rect key="frame" x="14.333333333333343" y="52" width="71" height="20.333333333333329"/> <rect key="frame" x="11.666666666666657" y="52" width="71" height="20.333333333333329"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/> <nil key="textColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="1gC-XS-O2e"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="1gC-XS-O2e">
<rect key="frame" x="0.0" y="0.0" width="99.666666666666671" height="90"/> <rect key="frame" x="0.0" y="0.0" width="94" height="90"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<connections> <connections>
<action selector="signatureTapped:" destination="-1" eventType="touchUpInside" id="oKV-wj-LNT"/> <action selector="signatureTapped:" destination="-1" eventType="touchUpInside" id="oKV-wj-LNT"/>
...@@ -411,10 +414,10 @@ ...@@ -411,10 +414,10 @@
</constraints> </constraints>
</view> </view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bgA-NI-AzQ"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bgA-NI-AzQ">
<rect key="frame" x="298.66666666666669" y="0.0" width="99.333333333333314" height="90"/> <rect key="frame" x="305.66666666666669" y="0.0" width="92.333333333333314" height="90"/>
<subviews> <subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jE5-UT-fB1" customClass="UIPrimaryButton" customModule="MiniScanner" customModuleProvider="target"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jE5-UT-fB1" customClass="UIPrimaryButton" customModule="MiniScanner" customModuleProvider="target">
<rect key="frame" x="0.0" y="17.666666666666629" width="99.333333333333329" height="55"/> <rect key="frame" x="0.0" y="17.666666666666629" width="92.333333333333329" height="55"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="55" id="JX1-6T-Gsm"/> <constraint firstAttribute="height" constant="55" id="JX1-6T-Gsm"/>
</constraints> </constraints>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment