Browse Source

Fix user image load + add to comment cell

Testing...

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 3 years ago
parent
commit
9867e6ff74

+ 7 - 0
iOSClient/Activity/NCActivity.swift

@@ -433,6 +433,13 @@ extension NCActivity {
 }
 
 extension NCActivity: NCShareCommentsCellDelegate {
+    func showProfile(with tableComment: tableComments?, sender: Any) {
+        guard let tableComment = tableComment else {
+            return
+        }
+        self.showProfileMenu(userId: tableComment.actorId)
+    }
+
     func tapMenu(with tableComments: tableComments?, sender: Any) {
         toggleMenu(with: tableComments)
     }

+ 4 - 4
iOSClient/Menu/NCCollectionViewCommon+Menu.swift

@@ -50,21 +50,21 @@ extension UIViewController {
         }
     }
     
-    func showProfileMenu(userId: String, image: UIImage?) {
+    func showProfileMenu(userId: String) {
 
         NCCommunication.shared.getHovercard(for: userId) { (card, errCode, err) in
             guard let card = card else {
                 return
             }
-            
+            let appDelegate = UIApplication.shared.delegate as! AppDelegate
             let personHeader = NCMenuAction(
                 title: card.displayName,
-                icon: image ?? NCUtility.shared.loadImage(named: "person.crop.circle"),
+                icon: NCUtility.shared.loadUserImage(for: userId, displayName: card.displayName, urlBase: appDelegate.urlBase),
                 action: nil)
             
             let actions = card.actions.map { action -> NCMenuAction in
                 var image = UIImage()
-                if let url = action.hyperlinkUrl, let loadedImage = try? UIImage(data: Data(contentsOf: url)) {
+                if let url = URL(string: action.icon), let loadedImage = try? UIImage(data: Data(contentsOf: url)) {
                     image = loadedImage
                 }
                 return NCMenuAction(

+ 8 - 0
iOSClient/Share/NCShareCommentsCell.swift

@@ -62,8 +62,15 @@ class NCShareCommentsCell: UITableViewCell, NCCellProtocol {
         super.awakeFromNib()
         
         buttonMenu.setImage(UIImage.init(named: "shareMenu")!.image(color: .lightGray, size: 50), for: .normal)
+        imageItem.backgroundColor = .red
+        let tapGesture = UITapGestureRecognizer(target: self, action: #selector(tapAvatarImage))
+        imageItem?.addGestureRecognizer(tapGesture)
     }
     
+    @objc func tapAvatarImage(_ sender: UITapGestureRecognizer) {
+        self.delegate?.showProfile(with: tableComments, sender: sender)
+    }
+
     @IBAction func touchUpInsideMenu(_ sender: Any) {
         delegate?.tapMenu(with: tableComments, sender: sender)
     }
@@ -71,4 +78,5 @@ class NCShareCommentsCell: UITableViewCell, NCCellProtocol {
 
 protocol NCShareCommentsCellDelegate {
     func tapMenu(with tableComments: tableComments?, sender: Any)
+    func showProfile(with tableComment: tableComments?, sender: Any)
 }

+ 3 - 3
iOSClient/Share/NCShareCommentsCell.xib

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -16,7 +16,7 @@
                 <rect key="frame" x="0.0" y="0.0" width="600" height="122"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
-                    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" translatesAutoresizingMaskIntoConstraints="NO" id="qDs-UG-Mn7" userLabel="ImageItem">
+                    <imageView clipsSubviews="YES" contentMode="scaleAspectFill" translatesAutoresizingMaskIntoConstraints="NO" id="qDs-UG-Mn7" userLabel="ImageItem">
                         <rect key="frame" x="5" y="15" width="40" height="40"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="40" id="8et-YH-T1D"/>