diff --git a/MiniScanner.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/UserInterfaceState.xcuserstate b/MiniScanner.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/UserInterfaceState.xcuserstate index bb3c8b656a67bfeb76dbf65f0b8b40fce5655144..025ca5bf75fa569a76c3f3373a7da5389b987861 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/Modules/EditViewController/EditViewController.swift b/MiniScanner/Modules/EditViewController/EditViewController.swift index 865957d5aaf3d935ac0c9e35a2c6889d207b86c2..39695a93cb1bb0ebdd0779d69c52d3d3e097988b 100644 --- a/MiniScanner/Modules/EditViewController/EditViewController.swift +++ b/MiniScanner/Modules/EditViewController/EditViewController.swift @@ -85,7 +85,7 @@ public class EditViewController: UIViewController { } else { let alertController = UIAlertController(title: "Alert", message: "Do you want to discard the changes you've made?", preferredStyle: .alert) - let okAction = UIAlertAction(title: "Yes", style: .default) { (action) in + let okAction = UIAlertAction(title: "Discard", style: .destructive) { (action) in self.dismiss(animated: true) { if let items = self.scanSession?.scannedItems { @@ -229,7 +229,7 @@ public class EditViewController: UIViewController { } else { let alertController = UIAlertController(title: "Alert", message: "Do you want to discard the changes you've made and continue?", preferredStyle: .alert) - let okAction = UIAlertAction(title: "Yes", style: .default) { (action) in + let okAction = UIAlertAction(title: "Yes", style: .destructive) { (action) in self.dismiss(animated: true) { if let items = self.scanSession?.scannedItems { @@ -583,28 +583,57 @@ extension EditViewController: EPSignatureDelegate { self.banner.donePressed = false self.banner.isEditing = true self.signatureImage = signatureImage - let alertController = UIAlertController(title: "", message: "Do you want to sign:", preferredStyle: .alert) - - let allAction = UIAlertAction(title: "All document", style: .default) { (action) in - if let items = self.scanSession?.scannedItems { - for (index, _) in items.enumerated() { - - if let initPosition = self.banner.pagerView.cellForItem(at: 0)?.contentView.center { - self.scanSession?.scannedItems[index].addSign(signature: signatureImage, position: initPosition, size: CGSize(width: 125, height: 125), rotate: 0) + if (self.scanSession?.scannedItems.count ?? 0) > 1 { + let alertController = UIAlertController(title: "", message: "Do you want to sign:", preferredStyle: .alert) + + let allAction = UIAlertAction(title: "All document", style: .default) { (action) in + if let items = self.scanSession?.scannedItems { + for (index, _) in items.enumerated() { + + if let initPosition = self.banner.pagerView.cellForItem(at: 0)?.contentView.center { + self.scanSession?.scannedItems[index].addSign(signature: signatureImage, position: initPosition, size: CGSize(width: 125, height: 125), rotate: 0) + } } + self.banner.scanSession = self.scanSession + self.banner.signAllDoc = true + self.banner.pagerView.reloadData() } - self.banner.scanSession = self.scanSession - self.banner.signAllDoc = true - self.banner.pagerView.reloadData() + + let addButton = UIBarButtonItem(title: "Add", style: .plain, target: self, action: #selector(self.onTouchDoneButton)) + + self.navigationItem.rightBarButtonItem = addButton + self.dismiss(animated: true) } - let addButton = UIBarButtonItem(title: "Add", style: .plain, target: self, action: #selector(self.onTouchDoneButton)) - - self.navigationItem.rightBarButtonItem = addButton - self.dismiss(animated: true) - } - - let currentAction = UIAlertAction(title: "Current page", style: .default) { (action) in + let currentAction = UIAlertAction(title: "Current page", style: .default) { (action) in + if let items = self.scanSession?.scannedItems { + for (index, _) in items.enumerated() { + if index == self.banner.pagerView.currentIndex { + if let initPosition = self.banner.pagerView.cellForItem(at: index)?.contentView.center { + self.scanSession?.scannedItems[index].addSign(signature: signatureImage, position: initPosition, size: CGSize(width: 125, height: 125), rotate: 0) + } + } + } + self.banner.scanSession = self.scanSession + self.banner.signAllDoc = false + self.banner.pagerView.reloadData() + } + + let addButton = UIBarButtonItem(title: "Add", style: .plain, target: self, action: #selector(self.onTouchDoneButton)) + self.navigationItem.rightBarButtonItem = addButton + self.dismiss(animated: true) + } + let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (action) in + self.banner.isEditing = false + self.dismiss(animated: true) + } + + alertController.addAction(allAction) + alertController.addAction(currentAction) + alertController.addAction(cancelAction) + self.present(alertController, animated: true, completion: nil) + + } else { if let items = self.scanSession?.scannedItems { for (index, _) in items.enumerated() { if index == self.banner.pagerView.currentIndex { @@ -622,15 +651,6 @@ extension EditViewController: EPSignatureDelegate { self.navigationItem.rightBarButtonItem = addButton self.dismiss(animated: true) } - let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (action) in - self.banner.isEditing = false - self.dismiss(animated: true) - } - - alertController.addAction(allAction) - alertController.addAction(currentAction) - alertController.addAction(cancelAction) - self.present(alertController, animated: true, completion: nil) } } } diff --git a/MiniScanner/Supporting Files/CustomWeScan/Scan/ScannerViewController.swift b/MiniScanner/Supporting Files/CustomWeScan/Scan/ScannerViewController.swift index aec3addd0463dcc4d78964d1e068bb6fb8987393..ff23add096b8dc5a5a58c909d2795d337a9f9504 100644 --- a/MiniScanner/Supporting Files/CustomWeScan/Scan/ScannerViewController.swift +++ b/MiniScanner/Supporting Files/CustomWeScan/Scan/ScannerViewController.swift @@ -527,7 +527,22 @@ extension ScannerViewController: CustomTabBarViewDelegate { } func fileManagerTapped() { - self.navigationController?.popViewController(animated: false) + if multipageSession.scannedItems.isEmpty { + self.navigationController?.popViewController(animated: false) + } else { + let alertController = UIAlertController(title: "Alert", + message: "You have captured some images, do you want to discard them?".localized, preferredStyle: .alert) + + let okAction = UIAlertAction(title: "Discard".localized, style: .destructive, handler: { [weak self] action in + guard let self = self else { return } + self.navigationController?.popViewController(animated: false) + }) + + alertController.addAction(okAction) + + alertController.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil)) + present(alertController, animated: true) + } } func editButtonTapped() { print(multipageSession.scannedItems.count)