Browse Source

fix comment

marinofaggiana 5 years ago
parent
commit
6fcceb4bb3

+ 23 - 3
iOSClient/Favorites/CCFavorites.m

@@ -250,6 +250,18 @@
     }];
 }
 
+- (void)tapActionComment:(UITapGestureRecognizer *)tapGesture
+{
+    CGPoint location = [tapGesture locationInView:self.tableView];
+    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location];
+    
+    tableMetadata *metadata = [[NCMainCommon sharedInstance] getMetadataFromSectionDataSourceIndexPath:indexPath sectionDataSource:sectionDataSource];
+    
+    if (metadata) {
+        [[NCMainCommon sharedInstance] openShareWithViewController:self metadata:metadata indexPage:1];
+    }
+}
+
 - (void)tapActionShared:(UITapGestureRecognizer *)tapGesture
 {
     CGPoint location = [tapGesture locationInView:self.tableView];
@@ -602,11 +614,19 @@
 
     if ([cell isKindOfClass:[CCCellMain class]]) {
         
+        // Comment tap
+        if (metadata.commentsUnread) {
+            UITapGestureRecognizer *tapComment = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapActionComment:)];
+            [tapComment setNumberOfTapsRequired:1];
+            ((CCCellMain *)cell).comment.userInteractionEnabled = YES;
+            [((CCCellMain *)cell).comment addGestureRecognizer:tapComment];
+        }
+        
         // Share add Tap
-        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapActionShared:)];
-        [tap setNumberOfTapsRequired:1];
+        UITapGestureRecognizer *tapShare = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapActionShared:)];
+        [tapShare setNumberOfTapsRequired:1];
         ((CCCellMain *)cell).shared.userInteractionEnabled = YES;
-        [((CCCellMain *)cell).shared addGestureRecognizer:tap];
+        [((CCCellMain *)cell).shared addGestureRecognizer:tapShare];
         
         // More
         if ([self canOpenMenuAction:metadata]) {

+ 23 - 4
iOSClient/Main/CCMain.m

@@ -1870,6 +1870,18 @@
 #pragma mark ===== Tap =====
 #pragma --------------------------------------------------------------------------------------------
 
+- (void)tapActionComment:(UITapGestureRecognizer *)tapGesture
+{
+    CGPoint location = [tapGesture locationInView:self.tableView];
+    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location];
+    
+    tableMetadata *metadata = [[NCMainCommon sharedInstance] getMetadataFromSectionDataSourceIndexPath:indexPath sectionDataSource:sectionDataSource];
+    
+    if (metadata) {
+        [[NCMainCommon sharedInstance] openShareWithViewController:self metadata:metadata indexPage:1];
+    }
+}
+
 - (void)tapActionShared:(UITapGestureRecognizer *)tapGesture
 {
     CGPoint location = [tapGesture locationInView:self.tableView];
@@ -3714,15 +3726,22 @@
     
     if ([cell isKindOfClass:[CCCellMain class]]) {
         
+        // Comment tap
+        if (metadata.commentsUnread) {
+            UITapGestureRecognizer *tapComment = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapActionComment:)];
+            [tapComment setNumberOfTapsRequired:1];
+            ((CCCellMain *)cell).comment.userInteractionEnabled = YES;
+            [((CCCellMain *)cell).comment addGestureRecognizer:tapComment];
+        }
+        
         // Share add Tap
-        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapActionShared:)];
-        [tap setNumberOfTapsRequired:1];
+        UITapGestureRecognizer *tapShare = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapActionShared:)];
+        [tapShare setNumberOfTapsRequired:1];
         ((CCCellMain *)cell).shared.userInteractionEnabled = YES;
-        [((CCCellMain *)cell).shared addGestureRecognizer:tap];
+        [((CCCellMain *)cell).shared addGestureRecognizer:tapShare];
         
         // More
         if ([self canOpenMenuAction:metadata]) {
-            
             UITapGestureRecognizer *tapMore = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(actionMore:)];
             [tapMore setNumberOfTapsRequired:1];
             ((CCCellMain *)cell).more.userInteractionEnabled = YES;

+ 2 - 0
iOSClient/Main/Cell/CCCellMain.h

@@ -37,4 +37,6 @@
 @property(nonatomic, weak) IBOutlet UILabel *labelTitle;
 @property(nonatomic, weak) IBOutlet UILabel *labelInfoFile;
 
+@property(nonatomic, weak) IBOutlet NSLayoutConstraint *labelTitleTrailingConstraint;
+
 @end

+ 1 - 0
iOSClient/Main/Cell/CCCellMain.xib

@@ -111,6 +111,7 @@
                 <outlet property="file" destination="5" id="Lfe-3W-yYr"/>
                 <outlet property="labelInfoFile" destination="p7I-KN-FVZ" id="5Yb-hH-k73"/>
                 <outlet property="labelTitle" destination="QNC-8X-DAC" id="dFX-Cb-8IE"/>
+                <outlet property="labelTitleTrailingConstraint" destination="ljw-Qp-g60" id="Iu0-wc-FFr"/>
                 <outlet property="local" destination="DQR-yN-JaH" id="LBA-Bm-Mz9"/>
                 <outlet property="more" destination="aRp-Ql-cyA" id="vbC-Za-UhD"/>
                 <outlet property="shared" destination="qhJ-el-R92" id="qXO-Vc-N0d"/>

+ 9 - 0
iOSClient/Main/NCMainCommon.swift

@@ -520,6 +520,7 @@ class NCMainCommon: NSObject, PhotoEditorDelegate, NCAudioRecorderViewController
             cell.favorite.image = nil
             cell.shared.image = nil
             cell.local.image = nil
+            cell.comment.image = nil
             cell.shared.isUserInteractionEnabled = false
             
             cell.backgroundColor = NCBrandColor.sharedInstance.backgroundView
@@ -652,6 +653,14 @@ class NCMainCommon: NSObject, PhotoEditorDelegate, NCAudioRecorderViewController
                 }
             }
             
+            // Comment
+            if metadata.commentsUnread {
+                cell.comment.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "comment"), width: 30, height: 30, color: NCBrandColor.sharedInstance.graySoft)
+                cell.labelTitleTrailingConstraint.constant = 160
+            } else {
+                cell.labelTitleTrailingConstraint.constant = 110
+            }
+            
             // More Image
             cell.more.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "more"), multiplier: 1, color: NCBrandColor.sharedInstance.optionItem)
             

+ 6 - 0
iOSClient/Share/NCShareComments.swift

@@ -241,6 +241,12 @@ extension NCShareComments: UITableViewDataSource {
             cell.labelDate.text = CCUtility.dateDiff(tableComments.creationDateTime as Date)
             // Message
             cell.labelMessage.text = tableComments.message
+            // Button Menu
+            if tableComments.actorId == appDelegate.activeUserID {
+                cell.buttonMenu.isHidden = false
+            } else {
+                cell.buttonMenu.isHidden = true
+            }
             
             return cell
         }