Browse Source

dev new share view

marinofaggiana 5 years ago
parent
commit
1738094e61

+ 3 - 0
iOSClient/Share/NCShare.storyboard

@@ -108,6 +108,9 @@
                                             <constraint firstAttribute="height" constant="30" id="zc5-W6-SXG"/>
                                         </constraints>
                                         <state key="normal" image="add"/>
+                                        <connections>
+                                            <action selector="touchUpInsideAddShareLink:" destination="bgO-Rz-2M1" eventType="touchUpInside" id="hrJ-Bm-XgB"/>
+                                        </connections>
                                     </button>
                                 </subviews>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>

+ 30 - 5
iOSClient/Share/NCShare.swift

@@ -234,9 +234,16 @@ class NCShare: UIViewController {
     
     var metadata: tableMetadata?
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    var height: CGFloat = 0
     private var shareLinkMenuView: NCShareLinkMenuView?
 
+    var height: CGFloat = 0
+    
+    private let shareLinkMenuViewWidth: CGFloat = 200
+    private let shareLinkMenuViewHeight: CGFloat = 200
+
+    private let iconShare: CGFloat = 200
+
+    
     @IBOutlet weak var viewContainerConstraint: NSLayoutConstraint!
     @IBOutlet weak var searchField: UITextField!
     @IBOutlet weak var returnSearchButton: UIButton!
@@ -258,22 +265,40 @@ class NCShare: UIViewController {
         let bottomImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "circle"), width: 200, height: 200, color: NCBrandColor.sharedInstance.nextcloud)
         let topImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "sharebylink"), width: 200, height: 200, color: UIColor.white)
 
-        UIGraphicsBeginImageContextWithOptions(CGSize(width: 200, height: 200), false, 0.0)
-        bottomImage?.draw(in: CGRect(origin: CGPoint.zero, size: CGSize(width: 200, height: 200)))
-        topImage?.draw(in: CGRect(origin:  CGPoint(x: 50, y: 50), size: CGSize(width: 100, height: 100)))
+        UIGraphicsBeginImageContextWithOptions(CGSize(width: iconShare, height: iconShare), false, 0.0)
+        bottomImage?.draw(in: CGRect(origin: CGPoint.zero, size: CGSize(width: iconShare, height: iconShare)))
+        topImage?.draw(in: CGRect(origin:  CGPoint(x: iconShare/4, y: iconShare/4), size: CGSize(width: iconShare/2, height: iconShare/2)))
         
         shareLinkImage.image = UIGraphicsGetImageFromCurrentImageContext()
         UIGraphicsEndImageContext()
         
         // Menu
         shareLinkMenuView = Bundle.main.loadNibNamed("NCShareLinkMenuView", owner: self, options: nil)?.first as? NCShareLinkMenuView
-        
+        shareLinkMenuView?.frame = CGRect(x: self.view.bounds.width-shareLinkMenuViewWidth-35, y: height+80, width: shareLinkMenuViewWidth, height: height+shareLinkMenuViewHeight)
+        shareLinkMenuView?.layer.borderColor = UIColor.lightGray.cgColor
+        shareLinkMenuView?.layer.borderWidth = 1
+        shareLinkMenuView?.isHidden = true
+        self.view.addSubview(shareLinkMenuView!)
     }
 }
 
+// MARK: - AddShareLink
+
+extension NCShare {
+    
+    @IBAction func touchUpInsideAddShareLink(_ sender: Any) {
+        shareLinkMenuView?.isHidden = false
+    }
+}
+
+// MARK: - hareLinkMenuView
 
 class NCShareLinkMenuView: UIView {
     
     @IBOutlet weak var switchAllowEditing: UISwitch!
     @IBOutlet weak var labelAllowEditing: UILabel!
+    
+    override func awakeFromNib() {
+        switchAllowEditing.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
+    }
 }

+ 1 - 1
iOSClient/Share/NCShareLinkMenuView.xib

@@ -15,7 +15,7 @@
             <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
-                <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="sjf-wF-y07" userLabel="SwitchAllowEditing">
+                <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="sjf-wF-y07" userLabel="SwitchAllowEditing">
                     <rect key="frame" x="10" y="10" width="51" height="31"/>
                 </switch>
                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Allow editing" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IHP-P8-rm2">