Browse Source

new view share

marinofaggiana 5 years ago
parent
commit
a7f822342d

+ 5 - 5
iOSClient/Favorites/CCFavorites.m

@@ -258,7 +258,7 @@
     tableMetadata *metadata = [[NCMainCommon sharedInstance] getMetadataFromSectionDataSourceIndexPath:indexPath sectionDataSource:sectionDataSource];
     
     if (metadata) {
-        [appDelegate.activeMain openShareWithMetadata:metadata indexPage:2];
+        [[NCMainCommon sharedInstance] openShareWithViewController:self metadata:metadata indexPage:2];
     }
 }
 
@@ -458,7 +458,7 @@
     } else {
         
         if (metadata.directory)
-            iconHeader = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"folder"] multiplier:2 color:[NCBrandColor sharedInstance].brandElement];
+            iconHeader = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"folder"] multiplier:2 color:[NCBrandColor sharedInstance].icon];
         else
             iconHeader = [UIImage imageNamed:metadata.iconName];
     }
@@ -479,15 +479,15 @@
     }
     
     // Share
-    [actionSheet addButtonWithTitle:NSLocalizedString(@"_share_", nil) image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"share"] multiplier:2 color:[NCBrandColor sharedInstance].brandElement] backgroundColor:[NCBrandColor sharedInstance].backgroundView height: 50.0 type:AHKActionSheetButtonTypeDefault handler:^(AHKActionSheet *as) {
+    [actionSheet addButtonWithTitle:NSLocalizedString(@"_details_", nil) image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"details"] width:50 height:50 color:[NCBrandColor sharedInstance].icon] backgroundColor:[NCBrandColor sharedInstance].backgroundView height: 50.0 type:AHKActionSheetButtonTypeDefault handler:^(AHKActionSheet *as) {
         
-        [appDelegate.activeMain openShareWithMetadata:metadata indexPage:2];
+        [[NCMainCommon sharedInstance] openShareWithViewController:self metadata:metadata indexPage:0];
     }];
     
     // NO Directory
     if (metadata.directory == NO && [NCBrandOptions sharedInstance].disable_openin_file == NO) {
         
-        [actionSheet addButtonWithTitle:NSLocalizedString(@"_open_in_", nil) image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"openFile"] multiplier:2 color:[NCBrandColor sharedInstance].brandElement] backgroundColor:[NCBrandColor sharedInstance].backgroundView height: 50.0 type:AHKActionSheetButtonTypeDefault handler:^(AHKActionSheet *as) {
+        [actionSheet addButtonWithTitle:NSLocalizedString(@"_open_in_", nil) image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"openFile"] multiplier:2 color:[NCBrandColor sharedInstance].icon] backgroundColor:[NCBrandColor sharedInstance].backgroundView height: 50.0 type:AHKActionSheetButtonTypeDefault handler:^(AHKActionSheet *as) {
             [self.tableView setEditing:NO animated:YES];
             
             [[NCMainCommon sharedInstance] downloadOpenInMetadata:metadata];

+ 2 - 2
iOSClient/Main/CCDetail.m

@@ -589,7 +589,7 @@
 - (void)photoBrowser:(MWPhotoBrowser *)photoBrowser shareButtonPressedForPhotoAtIndex:(NSUInteger)index
 {
     tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
-    [appDelegate.activeMain openShareWithMetadata:metadata indexPage:2];
+    [[NCMainCommon sharedInstance] openShareWithViewController:self metadata:metadata indexPage:2];
 }
 
 - (void)photoBrowser:(MWPhotoBrowser *)photoBrowser deleteButtonPressedForPhotoAtIndex:(NSUInteger)index deleteButton:(UIBarButtonItem *)deleteButton
@@ -986,7 +986,7 @@
 
 - (void)shareButtonPressed:(UIBarButtonItem *)sender
 {
-    [appDelegate.activeMain openShareWithMetadata:self.metadataDetail indexPage:2];
+    [[NCMainCommon sharedInstance] openShareWithViewController:self metadata:self.metadataDetail indexPage:2];
 }
 
 - (void)deleteButtonPressed:(UIBarButtonItem *)sender

+ 0 - 2
iOSClient/Main/CCMain.h

@@ -78,8 +78,6 @@
 
 - (void)reloadDatasource:(NSString *)serverUrl ocId:(NSString *)ocId action:(NSInteger)action;
 
-- (void)openShareWithMetadata:(tableMetadata *)metadata indexPage:(NSInteger)indexPage;
-
 - (void)clearDateReadDataSource:(NSNotification *)notification;
 - (void)cancelSearchBar;
 

+ 8 - 19
iOSClient/Main/CCMain.m

@@ -1870,20 +1870,9 @@
 }
 
 #pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== Shared =====
+#pragma mark ===== Tap =====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)openShareWithMetadata:(tableMetadata *)metadata indexPage:(NSInteger)indexPage
-{
-    UINavigationController *shareNavigationController = [[UIStoryboard storyboardWithName:@"NCShare" bundle:nil] instantiateInitialViewController];
-    NCSharePaging *shareViewController = (NCSharePaging *)shareNavigationController.topViewController;
-    shareViewController.metadata = metadata;
-    shareViewController.indexPage = indexPage;
-    
-    [shareNavigationController setModalPresentationStyle:UIModalPresentationFormSheet];
-    [self presentViewController:shareNavigationController animated:YES completion:nil];
-}
-
 - (void)tapActionShared:(UITapGestureRecognizer *)tapGesture
 {
     CGPoint location = [tapGesture locationInView:self.tableView];
@@ -1892,7 +1881,7 @@
     tableMetadata *metadata = [[NCMainCommon sharedInstance] getMetadataFromSectionDataSourceIndexPath:indexPath sectionDataSource:sectionDataSource];
     
     if (metadata) {
-        [self openShareWithMetadata:metadata indexPage:2];
+        [[NCMainCommon sharedInstance] openShareWithViewController:self metadata:metadata indexPage:2];
     }
 }
 
@@ -3018,13 +3007,13 @@
         
         if (!lockDirectory && !isFolderEncrypted) {
             
-            [actionSheet addButtonWithTitle:NSLocalizedString(@"_share_", nil)
-                                      image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"share"] multiplier:2 color:[NCBrandColor sharedInstance].icon]
+            [actionSheet addButtonWithTitle:NSLocalizedString(@"_details_", nil)
+                                      image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"details"] width:50 height:50 color:[NCBrandColor sharedInstance].icon]
                             backgroundColor:[NCBrandColor sharedInstance].backgroundView
                                      height:50.0
                                        type:AHKActionSheetButtonTypeDefault
                                     handler:^(AHKActionSheet *as) {
-                                        [self openShareWithMetadata:self.metadata indexPage:2];
+                                        [[NCMainCommon sharedInstance] openShareWithViewController:self metadata:self.metadata indexPage:0];
                                     }];
         }
         
@@ -3207,13 +3196,13 @@
         
         if (!_metadataFolder.e2eEncrypted) {
 
-            [actionSheet addButtonWithTitle:NSLocalizedString(@"_share_", nil)
-                                      image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"share"] multiplier:2 color:[NCBrandColor sharedInstance].icon]
+            [actionSheet addButtonWithTitle:NSLocalizedString(@"_details_", nil)
+                                      image:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"details"] width:50 height:50 color:[NCBrandColor sharedInstance].icon]
                                 backgroundColor:[NCBrandColor sharedInstance].backgroundView
                                         height: 50.0
                                         type:AHKActionSheetButtonTypeDefault
                                         handler:^(AHKActionSheet *as) {
-                                            [self openShareWithMetadata:self.metadata indexPage:2];
+                                            [[NCMainCommon sharedInstance] openShareWithViewController:self metadata:self.metadata indexPage:0];
                                         }];
         }
         

+ 13 - 0
iOSClient/Main/NCMainCommon.swift

@@ -1062,6 +1062,19 @@ class NCMainCommon: NSObject, PhotoEditorDelegate, NCAudioRecorderViewController
         docController?.presentOptionsMenu(from: frame, in: view, animated: true)
     }
     
+    //MARK: - OpenShare
+    @objc func openShare(ViewController: UIViewController, metadata: tableMetadata, indexPage: Int) {
+        
+        let shareNavigationController = UIStoryboard(name: "NCShare", bundle: nil).instantiateInitialViewController() as! UINavigationController
+        let shareViewController = shareNavigationController.topViewController as! NCSharePaging
+        
+        shareViewController.metadata = metadata
+        shareViewController.indexPage = indexPage
+        
+        shareNavigationController.modalPresentationStyle = .formSheet
+        ViewController.present(shareNavigationController, animated: true, completion: nil)
+    }
+    
     //MARK: - NCAudioRecorder
     
     func startAudioRecorder() {

+ 1 - 1
iOSClient/Offline/NCOffline.swift

@@ -338,7 +338,7 @@ class NCOffline: UIViewController, UIGestureRecognizerDelegate, NCListCellDelega
                     }
                     self.loadDatasource()
                 }
-                if item.value as? Int == 1 { self.appDelegate.activeMain.openShare(with: metadata, indexPage: 2) }
+                if item.value as? Int == 1 { NCMainCommon.sharedInstance.openShare(ViewController: self, metadata: metadata, indexPage: 2) }
                 if item.value as? Int == 2 { self.deleteItem(with: metadata, sender: sender) }
                 if item is ActionSheetCancelButton { print("Cancel buttons has the value `true`") }
             }

+ 3 - 3
iOSClient/PeekPop/CCPeekPop.m

@@ -70,15 +70,15 @@
     NSMutableArray *items = [NSMutableArray new];
  
     if (self.showOpenIn && !self.metadata.directory) {
-        UIPreviewAction *openIn = [UIPreviewAction actionWithTitle:NSLocalizedString(@"_open_in_", nil) style:UIPreviewActionStyleDefault handler:^(UIPreviewAction *action,  UIViewController *previewViewController){
+        UIPreviewAction *openIn = [UIPreviewAction actionWithTitle:NSLocalizedString(@"_open_in_", nil) style:UIPreviewActionStyleDefault handler:^(UIPreviewAction *action,  UIViewController *previewViewController) {
             [[NCMainCommon sharedInstance] downloadOpenInMetadata:self.metadata];
         }];
         [items addObject:openIn];
     }
     
     if (self.showShare) {
-        UIPreviewAction *share = [UIPreviewAction actionWithTitle:NSLocalizedString(@"_share_", nil) style:UIPreviewActionStyleDefault handler:^(UIPreviewAction *action,  UIViewController *previewViewController){
-            [appDelegate.activeMain openShareWithMetadata:self.metadata indexPage:2];
+        UIPreviewAction *share = [UIPreviewAction actionWithTitle:NSLocalizedString(@"_share_", nil) style:UIPreviewActionStyleDefault handler:^(UIPreviewAction *action,  UIViewController *previewViewController) {
+            [[NCMainCommon sharedInstance] openShareWithViewController:self metadata:self.metadata indexPage:2];
         }];
         [items addObject:share];
     }

+ 1 - 1
iOSClient/Share/NCShare.swift

@@ -96,7 +96,7 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
                     }
                 })
             }
-        }
+        } 
         
         reloadData()
         

+ 1 - 1
iOSClient/Share/NCSharePaging.swift

@@ -68,7 +68,7 @@ class NCSharePaging: UIViewController {
             ])
         
         pagingViewController.dataSource = self        
-        pagingViewController.select(index: 2)
+        pagingViewController.select(index: indexPage)
     }
     
     @objc func exitTapped() {

+ 1 - 1
iOSClient/Shares/NCShares.m

@@ -338,7 +338,7 @@
         
         metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND fileName == %@", appDelegate.activeAccount, table.serverUrl, table.fileName]];
         if (metadata) {
-            [appDelegate.activeMain openShareWithMetadata:metadata indexPage:2];
+            [[NCMainCommon sharedInstance] openShareWithViewController:self metadata:metadata indexPage:2];
         }
     }
 }

+ 1 - 1
iOSClient/Viewer/NCViewerRichdocument.swift

@@ -111,7 +111,7 @@ class NCViewerRichdocument: WKWebView, WKNavigationDelegate, WKScriptMessageHand
             }
             
             if message.body as? String == "share" {
-                appDelegate.activeMain.openShare(with: metadata, indexPage: 2)
+                NCMainCommon.sharedInstance.openShare(ViewController: detail, metadata: metadata, indexPage: 2)
             }
             
             if let param = message.body as? Dictionary<AnyHashable,Any> {