Browse Source

add tipNCScanAddImage

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 years ago
parent
commit
9f4c5e991a

+ 7 - 4
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -214,7 +214,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         // TIP
         if self is NCFiles, !NCBrandOptions.shared.disable_multiaccount, !NCBrandOptions.shared.disable_manage_account, self.serverUrl == NCUtilityFileSystem.shared.getHomeServer(account: appDelegate.account), let view = self.navigationItem.leftBarButtonItem?.customView {
             if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCCollectionViewCommonAccountRequest), NCManageDatabase.shared.getAllAccountOrderAlias().count > 0 {
-                self.tipView?.show(forView: view, withinSuperview: nil)
+                self.tipView?.show(forView: view)
             }
         }
     }
@@ -719,8 +719,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                 }
 
                 // TIP
-                NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCCollectionViewCommonAccountRequest)
-                self.tipView?.dismiss()
+                self.dismissTip()
             }
         }
         navigationItem.setLeftBarButton(UIBarButtonItem(customView: button), animated: true)
@@ -1935,11 +1934,15 @@ extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout {
 
 extension NCCollectionViewCommon: EasyTipViewDelegate {
 
-    // TIP
     func easyTipViewDidTap(_ tipView: EasyTipView) {
         NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCCollectionViewCommonAccountRequest)
     }
 
     func easyTipViewDidDismiss(_ tipView: EasyTipView) { }
+
+    func dismissTip() {
+        NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCCollectionViewCommonAccountRequest)
+        self.tipView?.dismiss()
+    }
 }
 

+ 1 - 0
iOSClient/NCGlobal.swift

@@ -375,4 +375,5 @@ class NCGlobal: NSObject {
     //
     let tipNCViewerPDFThumbnail                                 = "tipncviewerpdfthumbnail"
     let tipNCCollectionViewCommonAccountRequest                 = "tipnccollectionviewcommonaccountrequest"
+    let tipNCScanAddImage                                       = "tipncscanaddimage"
 }

+ 50 - 0
iOSClient/ScanDocument/NCScan.swift

@@ -23,6 +23,7 @@
 
 import UIKit
 import Photos
+import EasyTipView
 
 @available(iOS 13.0, *)
 class NCScan: UIViewController, NCScanCellCellDelegate {
@@ -45,6 +46,8 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
 
     internal let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
 
+    private var tipView: EasyTipView?
+
     enum TypeFilter {
         case original
         case grayScale
@@ -90,12 +93,37 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
         let longPressRecognizerPlus = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPressGesture(recognizer:)))
         add.addGestureRecognizer(longPressRecognizerPlus)
 
+        // TIP
+        var preferences = EasyTipView.Preferences()
+        preferences.drawing.foregroundColor = .white
+        preferences.drawing.backgroundColor = NCBrandColor.shared.nextcloud
+        preferences.drawing.textAlignment = .left
+        preferences.drawing.arrowPosition = .top
+        preferences.drawing.cornerRadius = 10
+
+        preferences.animating.dismissTransform = CGAffineTransform(translationX: 0, y: 100)
+        preferences.animating.showInitialTransform = CGAffineTransform(translationX: 0, y: -100)
+        preferences.animating.showInitialAlpha = 0
+        preferences.animating.showDuration = 1.5
+        preferences.animating.dismissDuration = 1.5
+
+        tipView = EasyTipView(text: NSLocalizedString("_tip_addcopyimage_", comment: ""), preferences: preferences, delegate: self)
+
         collectionViewSource.reloadData()
         collectionViewDestination.reloadData()
 
         loadImage()
     }
 
+    override func viewDidAppear(_ animated: Bool) {
+        super.viewDidAppear(animated)
+
+        // TIP
+        if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCScanAddImage) {
+            self.tipView?.show(forView: add)
+        }
+    }
+
     override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
         super.traitCollectionDidChange(previousTraitCollection)
 
@@ -134,6 +162,9 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
 
     @IBAction func add(sender: UIButton) {
 
+        // TIP
+        dismissTip()
+
         NCCreateScanDocument.shared.openScannerDocument(viewController: self)
     }
 
@@ -315,6 +346,9 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
                 UIMenuController.shared.setTargetRect(recognizerView.frame, in: recognizerSuperView)
                 UIMenuController.shared.setMenuVisible(true, animated: true)
             }
+
+            // TIP
+            dismissTip()
         }
     }
 
@@ -371,3 +405,19 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
         }
     }
 }
+
+@available(iOS 13.0, *)
+extension NCScan: EasyTipViewDelegate {
+
+    // TIP
+    func easyTipViewDidTap(_ tipView: EasyTipView) {
+        NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCScanAddImage)
+    }
+
+    func easyTipViewDidDismiss(_ tipView: EasyTipView) { }
+
+    func dismissTip() {
+        NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCScanAddImage)
+        self.tipView?.dismiss()
+    }
+}

+ 1 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -901,6 +901,7 @@
 // Tip
 "_tip_pdf_thumbnails_"      = "Swipe left from the right edge of the screen to show the thumbnails.";
 "_tip_accountrequest_"      = "Touch here to change account or to add a new one";
+"_tip_addcopyimage_"        = "Long press to paste a copied image";
 
 // MARK: Accessibility