Эх сурвалжийг харах

restore menu swipe on favorite

Marino Faggiana 8 жил өмнө
parent
commit
8b75779bff

+ 42 - 22
iOSClient/Favorites/CCFavorites.m

@@ -33,7 +33,7 @@
 
 @interface CCFavorites () <CCActionsDeleteDelegate, CCActionsSettingFavoriteDelegate>
 {
-    NSArray *dataSource;
+    NSArray *_dataSource;
     BOOL _reloadDataSource;
 }
 @end
@@ -61,7 +61,7 @@
     [self.tableView registerNib:[UINib nibWithNibName:@"CCFavoritesCell" bundle:nil] forCellReuseIdentifier:@"Cell"];
 
     // dataSource
-    dataSource = [NSMutableArray new];
+    _dataSource = [NSMutableArray new];
     
     // Metadata
     _metadata = [CCMetadata new];
@@ -70,7 +70,7 @@
     self.tableView.separatorColor = COLOR_SEPARATOR_TABLE;
     self.tableView.emptyDataSetDelegate = self;
     self.tableView.emptyDataSetSource = self;
-    self.tableView.allowsMultipleSelectionDuringEditing = NO;
+    self.tableView.delegate = self;
     
     // calculate _serverUrl
     if (!_serverUrl)
@@ -336,14 +336,11 @@
     [self presentViewController:alertController animated:YES completion:nil];
 }
 
--(void)cellButtonDownWasTapped:(id)sender
+- (void)requestMoreMetadata:(CCMetadata *)metadata indexPath:(NSIndexPath *)indexPath
 {
-    CGPoint touchPoint = [sender convertPoint:CGPointZero toView:self.tableView];
-    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:touchPoint];
-    CCMetadata *metadata = [CCMetadata new];
     UIImage *iconHeader;
     
-    metadata = [dataSource objectAtIndex:indexPath.row];
+    metadata = [_dataSource objectAtIndex:indexPath.row];
     
     AHKActionSheet *actionSheet = [[AHKActionSheet alloc] initWithView:self.view title:nil];
     
@@ -417,15 +414,41 @@
         }];
     }
     
-    [actionSheet addButtonWithTitle:NSLocalizedString(@"_delete_", nil) image:[UIImage imageNamed:image_delete] backgroundColor:[UIColor whiteColor] height: 50.0 type:AHKActionSheetButtonTypeDestructive handler:^(AHKActionSheet *as) {
-        
-        [self requestDeleteMetadata:metadata indexPath:indexPath];
-    }];
-
-    
     [actionSheet show];
 }
 
+#pragma mark -
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark ===== Swipe Tablet -> menu =====
+#pragma --------------------------------------------------------------------------------------------
+
+- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+    return UITableViewCellEditingStyleDelete;
+}
+
+- (NSString *)tableView:(UITableView *)tableView titleForSwipeAccessoryButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
+    return NSLocalizedString(@"_more_", nil);
+}
+
+- (void)tableView:(UITableView *)tableView swipeAccessoryButtonPushedForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+    [self requestMoreMetadata:[_dataSource objectAtIndex:indexPath.row] indexPath:indexPath];
+}
+
+- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+    return NSLocalizedString(@"_delete_", nil);
+}
+
+- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
+{
+    if (editingStyle == UITableViewCellEditingStyleDelete) {
+                
+        [self requestDeleteMetadata:[_dataSource objectAtIndex:indexPath.row] indexPath:indexPath];
+    }
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ==== Table ====
 #pragma --------------------------------------------------------------------------------------------
@@ -434,7 +457,7 @@
 {
     CCMetadata *metadata;
     
-    NSManagedObject *record = [dataSource objectAtIndex:indexPath.row];
+    NSManagedObject *record = [_dataSource objectAtIndex:indexPath.row];
     metadata = [CCCoreData getMetadataWithPreficate:[NSPredicate predicateWithFormat:@"(fileID == %@) AND (account == %@)", [record valueForKey:@"fileID"], app.activeAccount] context:nil];
 
     return metadata;
@@ -466,7 +489,7 @@
     for (NSString *fileID in fileIDs)
         [metadatas addObject:[sectionDataSource.allRecordsDataSource objectForKey:fileID]];
         
-    dataSource = [NSArray arrayWithArray:metadatas];
+    _dataSource = [NSArray arrayWithArray:metadatas];
     
     [self.tableView reloadData];
 }
@@ -483,7 +506,7 @@
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 {
-    return [dataSource count];
+    return [_dataSource count];
 }
 
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
@@ -503,7 +526,7 @@
     selectionColor.backgroundColor = COLOR_SELECT_BACKGROUND;
     cell.selectedBackgroundView = selectionColor;
     
-    metadata = [dataSource objectAtIndex:indexPath.row];
+    metadata = [_dataSource objectAtIndex:indexPath.row];
         
     cell.fileImageView.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadata.fileID]];
         
@@ -513,9 +536,6 @@
     if (cell.fileImageView.image == nil && metadata.thumbnailExists)
         [[CCActions sharedInstance] downloadTumbnail:metadata delegate:self];
     
-    // ButtonDown Tapped
-    [cell.buttonDown addTarget:self action:@selector(cellButtonDownWasTapped:) forControlEvents:UIControlEventTouchUpInside];
-    
     // encrypted color
     if (metadata.cryptated) {
         cell.labelTitle.textColor = COLOR_CRYPTOCLOUD;
@@ -653,7 +673,7 @@
     
     NSMutableArray *allRecordsDataSourceImagesVideos = [NSMutableArray new];
     
-    for (CCMetadata *metadata in dataSource) {
+    for (CCMetadata *metadata in _dataSource) {
         if ([metadata.typeFile isEqualToString: k_metadataTypeFile_image] || [metadata.typeFile isEqualToString: k_metadataTypeFile_video])
             [allRecordsDataSourceImagesVideos addObject:metadata];
     }

+ 0 - 2
iOSClient/Favorites/CCFavoritesCell.h

@@ -32,8 +32,6 @@
 @property(nonatomic, weak) IBOutlet UILabel *labelTitle;
 @property(nonatomic, weak) IBOutlet UILabel *labelInfoFile;
 
-@property(nonatomic, weak) IBOutlet UIButton *buttonDown;
-
 @property (strong, nonatomic) IBOutletCollection(NSLayoutConstraint) NSArray *constraints;
 
 //Last position of the scroll of the swipe

+ 1 - 15
iOSClient/Favorites/CCFavoritesCell.xib

@@ -16,7 +16,7 @@
             <rect key="frame" x="0.0" y="0.0" width="600" height="60"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxY="YES"/>
             <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="2" id="sQq-jC-UEV">
-                <rect key="frame" x="0.0" y="0.0" width="600" height="60"/>
+                <rect key="frame" x="0.0" y="0.0" width="600" height="59.5"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <view alpha="0.10000000149011612" contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hzp-7C-oyF" userLabel="Gray">
@@ -57,14 +57,6 @@
                             <constraint firstAttribute="height" constant="15" id="aQq-XY-pNM"/>
                         </constraints>
                     </imageView>
-                    <button opaque="NO" alpha="0.40000000000000002" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6B9-Jc-esJ" userLabel="buttonDown">
-                        <rect key="frame" x="540" y="0.0" width="60" height="60.5"/>
-                        <constraints>
-                            <constraint firstAttribute="height" constant="60" id="PcN-jN-71v"/>
-                            <constraint firstAttribute="width" constant="60" id="bAG-EX-HKe"/>
-                        </constraints>
-                        <state key="normal" image="buttonDown"/>
-                    </button>
                 </subviews>
                 <constraints>
                     <constraint firstItem="DQR-yN-JaH" firstAttribute="top" secondItem="dhG-hb-z3n" secondAttribute="top" id="0XU-Ho-ald"/>
@@ -73,18 +65,15 @@
                     <constraint firstItem="dhG-hb-z3n" firstAttribute="top" secondItem="sQq-jC-UEV" secondAttribute="topMargin" constant="32" id="4Zy-SY-nfT"/>
                     <constraint firstItem="QNC-8X-DAC" firstAttribute="trailing" secondItem="sQq-jC-UEV" secondAttribute="trailingMargin" constant="-59" id="7zt-c0-CsI"/>
                     <constraint firstAttribute="centerY" secondItem="5" secondAttribute="centerY" id="FQP-wg-vPF"/>
-                    <constraint firstAttribute="trailingMargin" secondItem="6B9-Jc-esJ" secondAttribute="trailing" constant="-8" id="Ht3-dh-Pl8"/>
                     <constraint firstItem="DQR-yN-JaH" firstAttribute="top" secondItem="p7I-KN-FVZ" secondAttribute="top" constant="6.5" id="K6B-gJ-8Fp"/>
                     <constraint firstItem="p7I-KN-FVZ" firstAttribute="leading" secondItem="5" secondAttribute="trailing" constant="18" id="K7G-0u-f8E"/>
                     <constraint firstItem="QNC-8X-DAC" firstAttribute="leading" secondItem="5" secondAttribute="trailing" constant="18" id="UYc-Al-a4h"/>
                     <constraint firstItem="p7I-KN-FVZ" firstAttribute="top" secondItem="QNC-8X-DAC" secondAttribute="bottom" id="cJT-LE-kot"/>
                     <constraint firstItem="dhG-hb-z3n" firstAttribute="leading" secondItem="sQq-jC-UEV" secondAttribute="leadingMargin" constant="-4" id="dNM-6x-zkx"/>
                     <constraint firstItem="p7I-KN-FVZ" firstAttribute="trailing" secondItem="sQq-jC-UEV" secondAttribute="trailingMargin" constant="-59" id="kaB-WS-bDl"/>
-                    <constraint firstItem="6B9-Jc-esJ" firstAttribute="centerY" secondItem="sQq-jC-UEV" secondAttribute="centerY" id="quA-ue-XsG"/>
                 </constraints>
             </tableViewCellContentView>
             <connections>
-                <outlet property="buttonDown" destination="6B9-Jc-esJ" id="tb8-y2-OM0"/>
                 <outlet property="fileImageView" destination="5" id="6"/>
                 <outlet property="labelInfoFile" destination="p7I-KN-FVZ" id="5Yb-hH-k73"/>
                 <outlet property="labelTitle" destination="QNC-8X-DAC" id="dFX-Cb-8IE"/>
@@ -94,9 +83,6 @@
             <point key="canvasLocation" x="256" y="19"/>
         </tableViewCell>
     </objects>
-    <resources>
-        <image name="buttonDown" width="25" height="25"/>
-    </resources>
     <simulatedMetricsContainer key="defaultSimulatedMetrics">
         <simulatedStatusBarMetrics key="statusBar"/>
         <simulatedOrientationMetrics key="orientation"/>

+ 1 - 3
iOSClient/Main/CCMain.m

@@ -5612,9 +5612,7 @@
         if (cryptated)
             myURL = [[NSBundle mainBundle] URLForResource: @"synchronizedcrypto" withExtension:@"gif"];
         else
-            myURL = [[NSBundle mainBundle] URLForResource: @"synchronized" withExtension:@"gif"];
-        
-        //cell.synchronizedImageView.image = [UIImage animatedImageWithAnimatedGIFURL:myURL];
+            myURL = [[NSBundle mainBundle] URLForResource: @"synchronized" withExtension:@"gif"];        
         
     } else {