Marino Faggiana 6 years ago
parent
commit
4113af0339

BIN
iOSClient/Images.xcassets/rotate.imageset/rotate.png


BIN
iOSClient/Images.xcassets/rotate.imageset/rotate@2x.png


BIN
iOSClient/Images.xcassets/rotate.imageset/rotate@3x.png


+ 2 - 2
iOSClient/Main/CCMore.swift

@@ -123,7 +123,7 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource, CCLo
             functionMenu.append(item)
         }
         
-//#if targetEnvironment(simulator)
+#if targetEnvironment(simulator)
         // ITEM : Trash
         let capabilities = NCManageDatabase.sharedInstance.getCapabilites()
         if capabilities != nil && capabilities!.versionMajor >= Int(k_trash_version_available) {
@@ -134,7 +134,7 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource, CCLo
             item.url = "segueTrash"
             functionMenu.append(item)
         }
-//#endif
+#endif
         
         // ITEM : External
         if NCBrandOptions.sharedInstance.disable_more_external_site == false {

+ 33 - 11
iOSClient/Scan/Scan.storyboard

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="bdK-eL-mz4">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="bdK-eL-mz4">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -41,16 +41,21 @@
                                                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="sam-7M-bIk">
                                                     <rect key="frame" x="20" y="20" width="100" height="100"/>
                                                 </imageView>
-                                                <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="06r-jm-ARX">
-                                                    <rect key="frame" x="0.0" y="0.0" width="25" height="25"/>
-                                                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="06r-jm-ARX">
+                                                    <rect key="frame" x="0.0" y="0.0" width="23" height="23"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="height" constant="23" id="BFu-CG-dUZ" userLabel="height = 23"/>
+                                                        <constraint firstAttribute="width" constant="23" id="ccc-Kb-48t" userLabel="width = 23"/>
+                                                    </constraints>
                                                     <state key="normal" image="deleteScan"/>
                                                 </button>
                                             </subviews>
                                         </view>
                                         <constraints>
                                             <constraint firstAttribute="trailing" secondItem="sam-7M-bIk" secondAttribute="trailing" constant="20" id="8AX-l8-Lm0"/>
+                                            <constraint firstItem="06r-jm-ARX" firstAttribute="top" secondItem="Lca-vD-NY2" secondAttribute="top" id="Wsp-Ec-BCg"/>
                                             <constraint firstItem="sam-7M-bIk" firstAttribute="top" secondItem="Lca-vD-NY2" secondAttribute="top" constant="20" id="YId-9R-Qgw"/>
+                                            <constraint firstItem="06r-jm-ARX" firstAttribute="leading" secondItem="Lca-vD-NY2" secondAttribute="leading" id="ffX-tw-upp"/>
                                             <constraint firstItem="sam-7M-bIk" firstAttribute="leading" secondItem="Lca-vD-NY2" secondAttribute="leading" constant="20" id="pbq-jr-YKl"/>
                                             <constraint firstAttribute="bottom" secondItem="sam-7M-bIk" secondAttribute="bottom" constant="20" id="zD5-jG-EEP"/>
                                         </constraints>
@@ -98,26 +103,42 @@
                                                     <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
-                                                <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wSg-Gm-0s3">
-                                                    <rect key="frame" x="0.0" y="0.0" width="25" height="25"/>
-                                                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wSg-Gm-0s3">
+                                                    <rect key="frame" x="0.0" y="0.0" width="23" height="23"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="width" constant="23" id="HRg-KR-tfA"/>
+                                                        <constraint firstAttribute="height" constant="23" id="QOj-Nj-nAA"/>
+                                                    </constraints>
                                                     <state key="normal" image="deleteScan"/>
                                                 </button>
+                                                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XEo-o0-dSF" userLabel="Rotate">
+                                                    <rect key="frame" x="98" y="0.0" width="22" height="22"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="width" constant="22" id="fQB-AX-aUH"/>
+                                                        <constraint firstAttribute="height" constant="22" id="fd5-QY-wlr"/>
+                                                    </constraints>
+                                                    <state key="normal" image="rotate"/>
+                                                </button>
                                             </subviews>
                                         </view>
                                         <constraints>
-                                            <constraint firstItem="wcM-U8-GLh" firstAttribute="leading" secondItem="Pph-tY-PGX" secondAttribute="leading" constant="20" id="EXk-95-OKd"/>
+                                            <constraint firstItem="wSg-Gm-0s3" firstAttribute="leading" secondItem="Pph-tY-PGX" secondAttribute="leading" id="0ev-wb-Tsh"/>
                                             <constraint firstItem="sdV-W7-Hkd" firstAttribute="top" secondItem="Pph-tY-PGX" secondAttribute="top" constant="20" id="G76-6T-Zpt"/>
+                                            <constraint firstItem="XEo-o0-dSF" firstAttribute="top" secondItem="Pph-tY-PGX" secondAttribute="top" id="Hax-sJ-buG"/>
+                                            <constraint firstItem="wcM-U8-GLh" firstAttribute="leading" secondItem="sdV-W7-Hkd" secondAttribute="leading" id="Ier-5Q-PmP"/>
                                             <constraint firstAttribute="trailing" secondItem="sdV-W7-Hkd" secondAttribute="trailing" constant="20" id="Jia-SE-8bu"/>
                                             <constraint firstAttribute="bottom" secondItem="sdV-W7-Hkd" secondAttribute="bottom" constant="20" id="Ljw-b9-Sp8"/>
+                                            <constraint firstItem="wSg-Gm-0s3" firstAttribute="top" secondItem="Pph-tY-PGX" secondAttribute="top" id="T23-0j-7ed"/>
+                                            <constraint firstItem="wcM-U8-GLh" firstAttribute="trailing" secondItem="sdV-W7-Hkd" secondAttribute="trailing" id="h6k-Kk-edu"/>
                                             <constraint firstItem="sdV-W7-Hkd" firstAttribute="leading" secondItem="Pph-tY-PGX" secondAttribute="leading" constant="20" id="kwQ-gl-6Bj"/>
+                                            <constraint firstAttribute="trailing" secondItem="XEo-o0-dSF" secondAttribute="trailing" id="m9Z-SN-0go"/>
                                             <constraint firstAttribute="bottom" secondItem="wcM-U8-GLh" secondAttribute="bottom" id="qat-UY-DBH"/>
-                                            <constraint firstAttribute="trailing" secondItem="wcM-U8-GLh" secondAttribute="trailing" constant="20" id="rLg-WD-x2l"/>
                                         </constraints>
                                         <connections>
                                             <outlet property="customImageView" destination="sdV-W7-Hkd" id="edM-S1-vkM"/>
                                             <outlet property="customLabel" destination="wcM-U8-GLh" id="BhF-OG-y3p"/>
                                             <outlet property="delete" destination="wSg-Gm-0s3" id="x0Y-P4-EXF"/>
+                                            <outlet property="rotate" destination="XEo-o0-dSF" id="cEY-b8-2tb"/>
                                         </connections>
                                     </collectionViewCell>
                                 </cells>
@@ -231,7 +252,8 @@
         </scene>
     </scenes>
     <resources>
-        <image name="add" width="25" height="25"/>
+        <image name="add" width="37.5" height="37.5"/>
         <image name="deleteScan" width="25" height="25"/>
+        <image name="rotate" width="25" height="25"/>
     </resources>
 </document>

+ 1 - 0
iOSClient/Scan/ScanCell.swift

@@ -28,4 +28,5 @@ class ScanCell: UICollectionViewCell {
     @IBOutlet weak var customImageView: UIImageView!
     @IBOutlet weak var customLabel: UILabel!
     @IBOutlet weak var delete: UIButton!
+    @IBOutlet weak var rotate: UIButton!
 }

+ 36 - 2
iOSClient/Scan/ScanCollectionView.swift

@@ -363,7 +363,6 @@ extension DragDropViewController : UICollectionViewDataSource {
             }
             
             cell.customImageView?.image = image
-//            cell.delete.setImage(CCGraphics.changeThemingColorImage(UIImage(named: "no_red"), multiplier:2, color: NCBrandColor.sharedInstance.icon).withRenderingMode(.alwaysOriginal), for: .normal)
             cell.delete.addTarget(self, action: #selector(deleteSource(_:)), for: .touchUpInside)
 
             return cell
@@ -384,8 +383,8 @@ extension DragDropViewController : UICollectionViewDataSource {
             
             cell.customImageView?.image = self.filter(image: image)
             cell.customLabel.text = NSLocalizedString("_scan_document_pdf_page_", comment: "") + " " + "\(indexPath.row+1)"
-//            cell.delete.setImage(CCGraphics.changeThemingColorImage(UIImage(named: "no_red"), multiplier:2, color: NCBrandColor.sharedInstance.icon).withRenderingMode(.alwaysOriginal), for: .normal)
             cell.delete.addTarget(self, action: #selector(deleteDestination(_:)), for: .touchUpInside)
+            cell.rotate.addTarget(self, action: #selector(rotateDestination(_:)), for: .touchUpInside)
             
             return cell
         }
@@ -419,6 +418,41 @@ extension DragDropViewController : UICollectionViewDataSource {
             save.isEnabled = true
         }
     }
+    
+    @objc func rotateDestination(_ sender:UIButton) {
+        
+        let buttonPosition:CGPoint =  sender.convert(.zero, to: self.collectionViewDestination)
+        let indexPath:IndexPath = self.collectionViewDestination.indexPathForItem(at: buttonPosition)!
+        
+        let image = self.imagesDestination[indexPath.row]
+        imagesDestination[indexPath.row] = image.rotate(radians: .pi/2)!
+        
+        self.collectionViewDestination.reloadData()
+    }
+}
+
+extension UIImage {
+    func rotate(radians: Float) -> UIImage? {
+        var newSize = CGRect(origin: CGPoint.zero, size: self.size).applying(CGAffineTransform(rotationAngle: CGFloat(radians))).size
+        // Trim off the extremely small float value to prevent core graphics from rounding it up
+        newSize.width = floor(newSize.width)
+        newSize.height = floor(newSize.height)
+        
+        UIGraphicsBeginImageContextWithOptions(newSize, true, self.scale)
+        let context = UIGraphicsGetCurrentContext()!
+        
+        // Move origin to middle
+        context.translateBy(x: newSize.width/2, y: newSize.height/2)
+        // Rotate around middle
+        context.rotate(by: CGFloat(radians))
+        // Draw the image at its center
+        self.draw(in: CGRect(x: -self.size.width/2, y: -self.size.height/2, width: self.size.width, height: self.size.height))
+        
+        let newImage = UIGraphicsGetImageFromCurrentImageContext()
+        UIGraphicsEndImageContext()
+        
+        return newImage
+    }
 }
 
 // MARK: - UICollectionViewDragDelegate Methods