marinofaggiana 4 年之前
父节点
当前提交
fe5630c64c
共有 2 个文件被更改,包括 49 次插入14 次删除
  1. 31 12
      iOSClient/Media/NCMedia.swift
  2. 18 2
      iOSClient/Media/NCMediaCommandView.xib

+ 31 - 12
iOSClient/Media/NCMedia.swift

@@ -28,7 +28,7 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
     
     @IBOutlet weak var collectionView : UICollectionView!
     
-    private var mediaCommandView = NCMediaCommandView()
+    private var mediaCommandView: NCMediaCommandView?
     
     //Grid control buttons
     private var plusButton: UIBarButtonItem!
@@ -124,13 +124,13 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
         gridButton = UIBarButtonItem(image: CCGraphics.changeThemingColorImage(UIImage(named: "grid"), width: 50, height: 50, color: NCBrandColor.sharedInstance.textView), style: .plain, target: self, action: #selector(enableZoomGridButtons))
         self.navigationItem.leftBarButtonItem = gridButton
         
-        mediaCommandView = (Bundle.main.loadNibNamed("NCMediaCommandView", owner: self, options: nil)?.first as! NCMediaCommandView)
-        self.view.addSubview(mediaCommandView)
-        mediaCommandView.translatesAutoresizingMaskIntoConstraints = false
-        mediaCommandView.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true
-        mediaCommandView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true
-        mediaCommandView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive = true
-        mediaCommandView.heightAnchor.constraint(equalToConstant: 200).isActive = true
+        mediaCommandView = Bundle.main.loadNibNamed("NCMediaCommandView", owner: self, options: nil)?.first as? NCMediaCommandView
+        self.view.addSubview(mediaCommandView!)
+        mediaCommandView!.translatesAutoresizingMaskIntoConstraints = false
+        mediaCommandView!.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true
+        mediaCommandView!.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true
+        mediaCommandView!.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive = true
+        mediaCommandView!.heightAnchor.constraint(equalToConstant: 150).isActive = true
         
         reloadDataSource()
         
@@ -463,10 +463,10 @@ extension NCMedia: UICollectionViewDataSource {
         CATransaction.commit()
     }
     
-    func updateLabelDate() {
+    func mediaCommandTitle() {
         if let cell = collectionView?.visibleCells.first as? NCGridMediaCell {
             if cell.date != nil {
-                //self.dataLabel.text = CCUtility.getTitleSectionDate(cell.date)
+                mediaCommandView!.title.text = CCUtility.getTitleSectionDate(cell.date)
             }
         }
     }
@@ -612,7 +612,7 @@ extension NCMedia {
             
             DispatchQueue.main.async {
                 self.reloadDataThenPerform {
-                    self.updateLabelDate()
+                    self.mediaCommandTitle()
                 }
             }
         }
@@ -729,7 +729,7 @@ extension NCMedia: UIScrollViewDelegate {
     
     func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
         self.removeZoomGridButtons()
-        updateLabelDate()
+        mediaCommandTitle()
     }
     
     func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
@@ -755,4 +755,23 @@ extension NCMedia: UIScrollViewDelegate {
 
 class NCMediaCommandView: UIView {
     
+    @IBOutlet weak var title : UILabel!
+    
+    let gradient: CAGradientLayer = CAGradientLayer()
+    
+    override func awakeFromNib() {
+        
+        gradient.frame = bounds
+        gradient.startPoint = CGPoint(x: 0, y: 0.60)
+        gradient.endPoint = CGPoint(x: 0, y: 1)
+        gradient.colors = [UIColor.black.withAlphaComponent(0.5).cgColor , UIColor.clear.cgColor]
+        layer.insertSublayer(gradient, at: 0)
+            
+        title.text = ""
+    }
+    
+    override func layoutSublayers(of layer: CALayer) {
+        super.layoutSublayers(of: layer)
+        gradient.frame = bounds
+    }
 }

+ 18 - 2
iOSClient/Media/NCMediaCommandView.xib

@@ -10,11 +10,27 @@
     <objects>
         <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
         <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
-        <view contentMode="scaleToFill" id="iN0-l3-epB" customClass="NCMediaCommandView" customModule="Nextcloud" customModuleProvider="target">
+        <view userInteractionEnabled="NO" contentMode="scaleToFill" id="iN0-l3-epB" customClass="NCMediaCommandView" customModule="Nextcloud" customModuleProvider="target">
             <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-            <color key="backgroundColor" systemColor="systemPinkColor" red="1" green="0.1764705882" blue="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+            <subviews>
+                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IxY-xH-yZQ">
+                    <rect key="frame" x="10" y="10" width="300" height="21"/>
+                    <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
+                    <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                    <nil key="highlightedColor"/>
+                </label>
+            </subviews>
+            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+            <constraints>
+                <constraint firstItem="IxY-xH-yZQ" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="10" id="PsN-7P-gqa"/>
+                <constraint firstItem="IxY-xH-yZQ" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="10" id="VA4-zl-2Xl"/>
+                <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="IxY-xH-yZQ" secondAttribute="trailing" constant="10" id="vW0-Ix-rMW"/>
+            </constraints>
             <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
+            <connections>
+                <outlet property="title" destination="IxY-xH-yZQ" id="ZNZ-Jy-JbH"/>
+            </connections>
             <point key="canvasLocation" x="139" y="153"/>
         </view>
     </objects>