فهرست منبع

Merge pull request #2314 from nextcloud/UploadAssets

Upload assets new view
Marino Faggiana 2 سال پیش
والد
کامیت
6245e562c2

+ 3 - 2
.swiftlint.yml

@@ -13,8 +13,8 @@ cyclomatic_complexity:
   warning: 25
   warning: 25
 
 
 line_length:
 line_length:
-  warning: 250
-  error: 250
+  warning: 400
+  error: 400
 
 
 function_body_length:
 function_body_length:
    warning: 200
    warning: 200
@@ -37,6 +37,7 @@ disabled_rules:
   - function_parameter_count
   - function_parameter_count
   - multiple_closures_with_trailing_closure
   - multiple_closures_with_trailing_closure
   - for_where
   - for_where
+  - cyclomatic_complexity
   
   
 excluded:
 excluded:
   - Carthage
   - Carthage

+ 25 - 3
Nextcloud.xcodeproj/project.pbxproj

@@ -267,6 +267,9 @@
 		F769454022E9F077000A798A /* NCSharePaging.swift in Sources */ = {isa = PBXBuildFile; fileRef = F769453F22E9F077000A798A /* NCSharePaging.swift */; };
 		F769454022E9F077000A798A /* NCSharePaging.swift in Sources */ = {isa = PBXBuildFile; fileRef = F769453F22E9F077000A798A /* NCSharePaging.swift */; };
 		F769454622E9F1B0000A798A /* NCShareCommon.swift in Sources */ = {isa = PBXBuildFile; fileRef = F769454522E9F1B0000A798A /* NCShareCommon.swift */; };
 		F769454622E9F1B0000A798A /* NCShareCommon.swift in Sources */ = {isa = PBXBuildFile; fileRef = F769454522E9F1B0000A798A /* NCShareCommon.swift */; };
 		F769454822E9F20D000A798A /* NCShareNetworking.swift in Sources */ = {isa = PBXBuildFile; fileRef = F769454722E9F20D000A798A /* NCShareNetworking.swift */; };
 		F769454822E9F20D000A798A /* NCShareNetworking.swift in Sources */ = {isa = PBXBuildFile; fileRef = F769454722E9F20D000A798A /* NCShareNetworking.swift */; };
+		F769CA172965AB7C00039397 /* NCUploadAssets.swift in Sources */ = {isa = PBXBuildFile; fileRef = F769CA162965AB7C00039397 /* NCUploadAssets.swift */; };
+		F769CA192966EA3C00039397 /* ComponentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F769CA182966EA3C00039397 /* ComponentView.swift */; };
+		F769CA1A2966EA3C00039397 /* ComponentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F769CA182966EA3C00039397 /* ComponentView.swift */; };
 		F76B3CCE1EAE01BD00921AC9 /* NCBrand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */; };
 		F76B3CCE1EAE01BD00921AC9 /* NCBrand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */; };
 		F76B3CCF1EAE01BD00921AC9 /* NCBrand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */; };
 		F76B3CCF1EAE01BD00921AC9 /* NCBrand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */; };
 		F76C26A62850D3A500E42BDF /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F7F67BB81A24D27800EE80DA /* Images.xcassets */; };
 		F76C26A62850D3A500E42BDF /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F7F67BB81A24D27800EE80DA /* Images.xcassets */; };
@@ -376,6 +379,7 @@
 		F78ACD52219046DC0088454D /* NCSectionHeaderFooter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78ACD51219046DC0088454D /* NCSectionHeaderFooter.swift */; };
 		F78ACD52219046DC0088454D /* NCSectionHeaderFooter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78ACD51219046DC0088454D /* NCSectionHeaderFooter.swift */; };
 		F78ACD54219047D40088454D /* NCSectionFooter.xib in Resources */ = {isa = PBXBuildFile; fileRef = F78ACD53219047D40088454D /* NCSectionFooter.xib */; };
 		F78ACD54219047D40088454D /* NCSectionFooter.xib in Resources */ = {isa = PBXBuildFile; fileRef = F78ACD53219047D40088454D /* NCSectionFooter.xib */; };
 		F78ACD58219048040088454D /* NCSectionHeaderMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F78ACD57219048040088454D /* NCSectionHeaderMenu.xib */; };
 		F78ACD58219048040088454D /* NCSectionHeaderMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F78ACD57219048040088454D /* NCSectionHeaderMenu.xib */; };
+		F78C6FDE296D677300C952C3 /* NCContextMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78C6FDD296D677300C952C3 /* NCContextMenu.swift */; };
 		F78D0C7F2912722100D706AB /* JGProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = F78D0C7E2912722100D706AB /* JGProgressHUD */; };
 		F78D0C7F2912722100D706AB /* JGProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = F78D0C7E2912722100D706AB /* JGProgressHUD */; };
 		F78D0C812912723900D706AB /* JGProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = F78D0C802912723900D706AB /* JGProgressHUD */; };
 		F78D0C812912723900D706AB /* JGProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = F78D0C802912723900D706AB /* JGProgressHUD */; };
 		F78D0C832912724F00D706AB /* JGProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = F78D0C822912724F00D706AB /* JGProgressHUD */; };
 		F78D0C832912724F00D706AB /* JGProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = F78D0C822912724F00D706AB /* JGProgressHUD */; };
@@ -882,6 +886,8 @@
 		F769453F22E9F077000A798A /* NCSharePaging.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCSharePaging.swift; sourceTree = "<group>"; };
 		F769453F22E9F077000A798A /* NCSharePaging.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCSharePaging.swift; sourceTree = "<group>"; };
 		F769454522E9F1B0000A798A /* NCShareCommon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCShareCommon.swift; sourceTree = "<group>"; };
 		F769454522E9F1B0000A798A /* NCShareCommon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCShareCommon.swift; sourceTree = "<group>"; };
 		F769454722E9F20D000A798A /* NCShareNetworking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCShareNetworking.swift; sourceTree = "<group>"; };
 		F769454722E9F20D000A798A /* NCShareNetworking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCShareNetworking.swift; sourceTree = "<group>"; };
+		F769CA162965AB7C00039397 /* NCUploadAssets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCUploadAssets.swift; sourceTree = "<group>"; };
+		F769CA182966EA3C00039397 /* ComponentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComponentView.swift; sourceTree = "<group>"; };
 		F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCBrand.swift; sourceTree = "<group>"; };
 		F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCBrand.swift; sourceTree = "<group>"; };
 		F76D364528A4F8BF00214537 /* NCActivityIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCActivityIndicator.swift; sourceTree = "<group>"; };
 		F76D364528A4F8BF00214537 /* NCActivityIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCActivityIndicator.swift; sourceTree = "<group>"; };
 		F76D3CF02428B40E005DFA87 /* NCViewerPDFSearch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerPDFSearch.swift; sourceTree = "<group>"; };
 		F76D3CF02428B40E005DFA87 /* NCViewerPDFSearch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerPDFSearch.swift; sourceTree = "<group>"; };
@@ -958,6 +964,7 @@
 		F78ACD51219046DC0088454D /* NCSectionHeaderFooter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCSectionHeaderFooter.swift; sourceTree = "<group>"; };
 		F78ACD51219046DC0088454D /* NCSectionHeaderFooter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCSectionHeaderFooter.swift; sourceTree = "<group>"; };
 		F78ACD53219047D40088454D /* NCSectionFooter.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NCSectionFooter.xib; sourceTree = "<group>"; };
 		F78ACD53219047D40088454D /* NCSectionFooter.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NCSectionFooter.xib; sourceTree = "<group>"; };
 		F78ACD57219048040088454D /* NCSectionHeaderMenu.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NCSectionHeaderMenu.xib; sourceTree = "<group>"; };
 		F78ACD57219048040088454D /* NCSectionHeaderMenu.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NCSectionHeaderMenu.xib; sourceTree = "<group>"; };
+		F78C6FDD296D677300C952C3 /* NCContextMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCContextMenu.swift; sourceTree = "<group>"; };
 		F78D6F461F0B7CB9002F9619 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = "<group>"; };
 		F78D6F461F0B7CB9002F9619 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = "<group>"; };
 		F78D6F4D1F0B7CE4002F9619 /* nb-NO */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "nb-NO"; path = "nb-NO.lproj/Localizable.strings"; sourceTree = "<group>"; };
 		F78D6F4D1F0B7CE4002F9619 /* nb-NO */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "nb-NO"; path = "nb-NO.lproj/Localizable.strings"; sourceTree = "<group>"; };
 		F78D6F541F0B7D47002F9619 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/Localizable.strings; sourceTree = "<group>"; };
 		F78D6F541F0B7D47002F9619 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/Localizable.strings; sourceTree = "<group>"; };
@@ -1320,6 +1327,7 @@
 				F75D19E225EFE09000D74598 /* NCTrash+Menu.swift */,
 				F75D19E225EFE09000D74598 /* NCTrash+Menu.swift */,
 				AF93471127E2341B002537EE /* NCShare+Menu.swift */,
 				AF93471127E2341B002537EE /* NCShare+Menu.swift */,
 				F710D2012405826100A6033D /* NCViewer+Menu.swift */,
 				F710D2012405826100A6033D /* NCViewer+Menu.swift */,
+				F78C6FDD296D677300C952C3 /* NCContextMenu.swift */,
 			);
 			);
 			path = Menu;
 			path = Menu;
 			sourceTree = "<group>";
 			sourceTree = "<group>";
@@ -1629,6 +1637,15 @@
 			path = Recent;
 			path = Recent;
 			sourceTree = "<group>";
 			sourceTree = "<group>";
 		};
 		};
+		F769CA1B2966EF4F00039397 /* GUI */ = {
+			isa = PBXGroup;
+			children = (
+				F75CA1462962F13700B01130 /* HUDView.swift */,
+				F769CA182966EA3C00039397 /* ComponentView.swift */,
+			);
+			path = GUI;
+			sourceTree = "<group>";
+		};
 		F76D3CEF2428B3DD005DFA87 /* NCViewerPDF */ = {
 		F76D3CEF2428B3DD005DFA87 /* NCViewerPDF */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
@@ -1901,7 +1918,6 @@
 				F70968A324212C4E00ED60E5 /* NCLivePhoto.swift */,
 				F70968A324212C4E00ED60E5 /* NCLivePhoto.swift */,
 				F702F30725EE5D47008F8E80 /* NCPopupViewController.swift */,
 				F702F30725EE5D47008F8E80 /* NCPopupViewController.swift */,
 				F707C26421A2DC5200F6181E /* NCStoreReview.swift */,
 				F707C26421A2DC5200F6181E /* NCStoreReview.swift */,
-				F75CA1462962F13700B01130 /* HUDView.swift */,
 				AF817EF0274BC781009ED85B /* NCUserBaseUrl.swift */,
 				AF817EF0274BC781009ED85B /* NCUserBaseUrl.swift */,
 				F70BFC7320E0FA7C00C67599 /* NCUtility.swift */,
 				F70BFC7320E0FA7C00C67599 /* NCUtility.swift */,
 				AF93474B27E34120002537EE /* NCUtility+Image.swift */,
 				AF93474B27E34120002537EE /* NCUtility+Image.swift */,
@@ -2026,6 +2042,7 @@
 		F7DFB7E9219C5A0500680748 /* Create cloud */ = {
 		F7DFB7E9219C5A0500680748 /* Create cloud */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
+				F769CA162965AB7C00039397 /* NCUploadAssets.swift */,
 				F7DFB7EF219C5B8000680748 /* NCCreateFormUploadAssets.swift */,
 				F7DFB7EF219C5B8000680748 /* NCCreateFormUploadAssets.swift */,
 				F704B5E22430AA6F00632F5F /* NCCreateFormUploadConflict.storyboard */,
 				F704B5E22430AA6F00632F5F /* NCCreateFormUploadConflict.storyboard */,
 				F704B5E42430AA8000632F5F /* NCCreateFormUploadConflict.swift */,
 				F704B5E42430AA8000632F5F /* NCCreateFormUploadConflict.swift */,
@@ -2129,6 +2146,7 @@
 				F702F2CC25EE5B4F008F8E80 /* AppDelegate.swift */,
 				F702F2CC25EE5B4F008F8E80 /* AppDelegate.swift */,
 				F702F2CE25EE5B5C008F8E80 /* NCGlobal.swift */,
 				F702F2CE25EE5B5C008F8E80 /* NCGlobal.swift */,
 				F7F67BB81A24D27800EE80DA /* Images.xcassets */,
 				F7F67BB81A24D27800EE80DA /* Images.xcassets */,
+				F769CA1B2966EF4F00039397 /* GUI */,
 				F7C1CDD91E6DFC6F005D92BE /* Brand */,
 				F7C1CDD91E6DFC6F005D92BE /* Brand */,
 				F70211F31BAC56E9003FC03E /* Main */,
 				F70211F31BAC56E9003FC03E /* Main */,
 				F7CA213725F1372B00826ABB /* Account Request */,
 				F7CA213725F1372B00826ABB /* Account Request */,
@@ -2845,6 +2863,7 @@
 				AF4BF617275629E20081CEEF /* NCManageDatabase+Account.swift in Sources */,
 				AF4BF617275629E20081CEEF /* NCManageDatabase+Account.swift in Sources */,
 				F7BF9D872934CA21009EE9A6 /* NCManageDatabase+LayoutForView.swift in Sources */,
 				F7BF9D872934CA21009EE9A6 /* NCManageDatabase+LayoutForView.swift in Sources */,
 				D575039F27146F93008DC9DC /* String+Extension.swift in Sources */,
 				D575039F27146F93008DC9DC /* String+Extension.swift in Sources */,
+				F769CA1A2966EA3C00039397 /* ComponentView.swift in Sources */,
 				F73D5E4A246DE09200DF6467 /* NCElementsJSON.swift in Sources */,
 				F73D5E4A246DE09200DF6467 /* NCElementsJSON.swift in Sources */,
 				F79B646326CA661600838ACA /* UIControl+Extension.swift in Sources */,
 				F79B646326CA661600838ACA /* UIControl+Extension.swift in Sources */,
 				F78A10C429322E8A008499B8 /* NCManageDatabase+Directory.swift in Sources */,
 				F78A10C429322E8A008499B8 /* NCManageDatabase+Directory.swift in Sources */,
@@ -3024,6 +3043,8 @@
 			buildActionMask = 2147483647;
 			buildActionMask = 2147483647;
 			files = (
 			files = (
 				F77444F522281649000D5EB0 /* NCGridMediaCell.swift in Sources */,
 				F77444F522281649000D5EB0 /* NCGridMediaCell.swift in Sources */,
+				F78C6FDE296D677300C952C3 /* NCContextMenu.swift in Sources */,
+				F769CA172965AB7C00039397 /* NCUploadAssets.swift in Sources */,
 				F7AE00F8230E81CB007ACF8A /* NCBrowserWeb.swift in Sources */,
 				F7AE00F8230E81CB007ACF8A /* NCBrowserWeb.swift in Sources */,
 				F702F30825EE5D47008F8E80 /* NCPopupViewController.swift in Sources */,
 				F702F30825EE5D47008F8E80 /* NCPopupViewController.swift in Sources */,
 				F70A58BE24D0349500DED00D /* NCCapabilitiesViewController.swift in Sources */,
 				F70A58BE24D0349500DED00D /* NCCapabilitiesViewController.swift in Sources */,
@@ -3138,6 +3159,7 @@
 				F7581D2425EFDDDF004DC699 /* NCMedia+Menu.swift in Sources */,
 				F7581D2425EFDDDF004DC699 /* NCMedia+Menu.swift in Sources */,
 				F738D4902756740100CD1D38 /* NCLoginNavigationController.swift in Sources */,
 				F738D4902756740100CD1D38 /* NCLoginNavigationController.swift in Sources */,
 				F77B0E981D118A16002130FE /* CCManageAccount.m in Sources */,
 				F77B0E981D118A16002130FE /* CCManageAccount.m in Sources */,
+				F769CA192966EA3C00039397 /* ComponentView.swift in Sources */,
 				AF93474C27E34120002537EE /* NCUtility+Image.swift in Sources */,
 				AF93474C27E34120002537EE /* NCUtility+Image.swift in Sources */,
 				F702F30125EE5D2C008F8E80 /* NYMnemonic.m in Sources */,
 				F702F30125EE5D2C008F8E80 /* NYMnemonic.m in Sources */,
 				AF93474E27E3F212002537EE /* NCShareNewUserAddComment.swift in Sources */,
 				AF93474E27E3F212002537EE /* NCShareNewUserAddComment.swift in Sources */,
@@ -3732,7 +3754,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 3;
+				CURRENT_PROJECT_VERSION = 4;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
 				ENABLE_TESTABILITY = YES;
@@ -3795,7 +3817,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 3;
+				CURRENT_PROJECT_VERSION = 4;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
 				ENABLE_TESTABILITY = YES;

+ 58 - 0
iOSClient/GUI/ComponentView.swift

@@ -0,0 +1,58 @@
+//
+//  ComponentView.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 05/01/23.
+//  Copyright © 2023 Marino Faggiana. All rights reserved.
+//
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+import SwiftUI
+
+struct TextFieldClearButton: ViewModifier {
+
+    @Binding var text: String
+
+    func body(content: Content) -> some View {
+        HStack {
+            content
+            if !text.isEmpty {
+                Button(
+                    action: { self.text = "" },
+                    label: {
+                        Image(systemName: "xmark.circle.fill")
+                            .foregroundColor(Color(UIColor.placeholderText))
+                    }
+                ).buttonStyle(BorderlessButtonStyle())
+            }
+        }
+    }
+}
+
+struct ButtonRounded: ButtonStyle {
+
+    var disabled = false
+
+    func makeBody(configuration: Configuration) -> some View {
+        configuration.label
+            .padding(.horizontal, 40)
+            .padding(.vertical, 10)
+            .background(disabled ? Color(UIColor.placeholderText) : Color(NCBrandColor.shared.brand))
+            .foregroundColor(disabled ? Color(UIColor.placeholderText) : Color(NCBrandColor.shared.brandText))
+            .clipShape(Capsule())
+    }
+}

+ 0 - 0
iOSClient/Utility/HUDView.swift → iOSClient/GUI/HUDView.swift


+ 1 - 1
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -1366,7 +1366,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
 
 
         }, actionProvider: { _ in
         }, actionProvider: { _ in
 
 
-            return NCFunctionCenter.shared.contextMenuConfiguration(ocId: metadata.ocId, viewController: self, enableDeleteLocal: true, enableViewInFolder: false, image: image)
+            return NCContextMenu().viewMenu(ocId: metadata.ocId, viewController: self, enableDeleteLocal: true, enableViewInFolder: false, image: image)
         })
         })
     }
     }
 
 

+ 1 - 13
iOSClient/Main/Create cloud/NCCreateFormUploadAssets.swift

@@ -27,10 +27,6 @@ import NextcloudKit
 import XLForm
 import XLForm
 import Photos
 import Photos
 
 
-protocol createFormUploadAssetsDelegate: AnyObject {
-    func dismissFormUploadAssets()
-}
-
 class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
 class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
 
 
     var serverUrl: String = ""
     var serverUrl: String = ""
@@ -38,7 +34,6 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
     var assets: [PHAsset] = []
     var assets: [PHAsset] = []
     var cryptated: Bool = false
     var cryptated: Bool = false
     var session: String = ""
     var session: String = ""
-    weak var delegate: createFormUploadAssetsDelegate?
     let requestOptions = PHImageRequestOptions()
     let requestOptions = PHImageRequestOptions()
     var imagePreview: UIImage?
     var imagePreview: UIImage?
     let targetSizeImagePreview = CGSize(width: 100, height: 100)
     let targetSizeImagePreview = CGSize(width: 100, height: 100)
@@ -48,7 +43,7 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
 
 
     // MARK: - View Life Cycle
     // MARK: - View Life Cycle
 
 
-    convenience init(serverUrl: String, assets: [PHAsset], cryptated: Bool, session: String, delegate: createFormUploadAssetsDelegate?) {
+    convenience init(serverUrl: String, assets: [PHAsset], cryptated: Bool, session: String) {
 
 
         self.init()
         self.init()
 
 
@@ -66,7 +61,6 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         self.assets = assets
         self.assets = assets
         self.cryptated = cryptated
         self.cryptated = cryptated
         self.session = session
         self.session = session
-        self.delegate = delegate
 
 
         requestOptions.resizeMode = PHImageRequestOptionsResizeMode.exact
         requestOptions.resizeMode = PHImageRequestOptionsResizeMode.exact
         requestOptions.deliveryMode = PHImageRequestOptionsDeliveryMode.highQualityFormat
         requestOptions.deliveryMode = PHImageRequestOptionsDeliveryMode.highQualityFormat
@@ -98,12 +92,6 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         reloadForm()
         reloadForm()
     }
     }
 
 
-    override func viewWillDisappear(_ animated: Bool) {
-        super.viewWillDisappear(animated)
-
-        self.delegate?.dismissFormUploadAssets()
-    }
-
     // MARK: XLForm
     // MARK: XLForm
 
 
     func initializeForm() {
     func initializeForm() {

+ 39 - 14
iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift

@@ -22,19 +22,16 @@
 //
 //
 
 
 import UIKit
 import UIKit
+import SwiftUI
 import NextcloudKit
 import NextcloudKit
 import Photos
 import Photos
 import JGProgressHUD
 import JGProgressHUD
 
 
-@objc protocol NCCreateFormUploadConflictDelegate {
-    @objc func dismissCreateFormUploadConflict(metadatas: [tableMetadata]?)
+protocol NCCreateFormUploadConflictDelegate {
+    func dismissCreateFormUploadConflict(metadatas: [tableMetadata]?)
 }
 }
 
 
-extension NCCreateFormUploadConflictDelegate {
-    func dismissCreateFormUploadConflict(metadatas: [tableMetadata]?) {}
-}
-
-@objc class NCCreateFormUploadConflict: UIViewController {
+class NCCreateFormUploadConflict: UIViewController {
 
 
     @IBOutlet weak var labelTitle: UILabel!
     @IBOutlet weak var labelTitle: UILabel!
     @IBOutlet weak var labelSubTitle: UILabel!
     @IBOutlet weak var labelSubTitle: UILabel!
@@ -52,12 +49,12 @@ extension NCCreateFormUploadConflictDelegate {
     @IBOutlet weak var buttonCancel: UIButton!
     @IBOutlet weak var buttonCancel: UIButton!
     @IBOutlet weak var buttonContinue: UIButton!
     @IBOutlet weak var buttonContinue: UIButton!
 
 
-    @objc var metadatasNOConflict: [tableMetadata]
-    @objc var metadatasUploadInConflict: [tableMetadata]
-    @objc var serverUrl: String?
-    @objc weak var delegate: NCCreateFormUploadConflictDelegate?
-    @objc var alwaysNewFileNameNumber: Bool = false
-    @objc var textLabelDetailNewFile: String?
+    var metadatasNOConflict: [tableMetadata]
+    var metadatasUploadInConflict: [tableMetadata]
+    var serverUrl: String?
+    var delegate: NCCreateFormUploadConflictDelegate?
+    var alwaysNewFileNameNumber: Bool = false
+    var textLabelDetailNewFile: String?
 
 
     var metadatasConflictNewFiles: [String] = []
     var metadatasConflictNewFiles: [String] = []
     var metadatasConflictAlreadyExistingFiles: [String] = []
     var metadatasConflictAlreadyExistingFiles: [String] = []
@@ -66,7 +63,7 @@ extension NCCreateFormUploadConflictDelegate {
 
 
     // MARK: - View Life Cycle
     // MARK: - View Life Cycle
 
 
-    @objc required init?(coder aDecoder: NSCoder) {
+    required init?(coder aDecoder: NSCoder) {
         self.metadatasNOConflict = []
         self.metadatasNOConflict = []
         self.metadatasUploadInConflict = []
         self.metadatasUploadInConflict = []
         super.init(coder: aDecoder)
         super.init(coder: aDecoder)
@@ -511,3 +508,31 @@ extension NCCreateFormUploadConflict: NCCreateFormUploadConflictCellDelegate {
         }
         }
     }
     }
 }
 }
+
+// MARK: - UIViewControllerRepresentable
+
+struct UploadConflictView: UIViewControllerRepresentable {
+
+    typealias UIViewControllerType = NCCreateFormUploadConflict
+    var delegate: NCCreateFormUploadConflictDelegate
+    var serverUrl: String
+    var metadatasUploadInConflict: [tableMetadata]
+    var metadatasNOConflict: [tableMetadata]
+
+
+    func makeUIViewController(context: Context) -> UIViewControllerType {
+
+        let storyboard = UIStoryboard(name: "NCCreateFormUploadConflict", bundle: nil)
+        let viewController = storyboard.instantiateInitialViewController() as? NCCreateFormUploadConflict
+
+        viewController?.delegate = delegate
+        viewController?.textLabelDetailNewFile = NSLocalizedString("_now_", comment: "")
+        viewController?.serverUrl = serverUrl
+        viewController?.metadatasUploadInConflict = metadatasUploadInConflict
+        viewController?.metadatasNOConflict = metadatasNOConflict
+
+        return viewController!
+    }
+
+    func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) { }
+}

+ 300 - 0
iOSClient/Main/Create cloud/NCUploadAssets.swift

@@ -0,0 +1,300 @@
+//
+//  NCUploadAssets.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 04/01/23.
+//  Copyright © 2023 Marino Faggiana. All rights reserved.
+//
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+import SwiftUI
+import NextcloudKit
+
+class NCHostingUploadAssetsView: NSObject {
+
+    @objc func makeShipDetailsUI(assets: [PHAsset], serverUrl: String, userBaseUrl: NCUserBaseUrl) -> UIViewController {
+
+        let uploadAssets = NCUploadAssets(assets: assets, serverUrl: serverUrl, userBaseUrl: userBaseUrl )
+        let details = UploadAssetsView(uploadAssets: uploadAssets)
+        return UIHostingController(rootView: details)
+    }
+}
+
+// MARK: - Class
+
+class NCUploadAssets: ObservableObject, NCCreateFormUploadConflictDelegate {
+
+    @Published var serverUrl: String
+    @Published var assets: [PHAsset]
+    @Published var userBaseUrl: NCUserBaseUrl
+    @Published var dismiss = false
+
+    var metadatasNOConflict: [tableMetadata] = []
+    var metadatasUploadInConflict: [tableMetadata] = []
+
+    init(assets: [PHAsset], serverUrl: String, userBaseUrl: NCUserBaseUrl) {
+
+        self.assets = assets
+        self.serverUrl = serverUrl
+        self.userBaseUrl = userBaseUrl
+    }
+
+    func dismissCreateFormUploadConflict(metadatas: [tableMetadata]?) {
+
+        if let metadatas = metadatas {
+            NCNetworkingProcessUpload.shared.createProcessUploads(metadatas: metadatas, completion: { _ in
+                self.dismiss = true
+            })
+        } else {
+            self.dismiss = true
+        }
+    }
+}
+
+// MARK: - View
+
+struct UploadAssetsView: View {
+
+    @State private var fileName: String = CCUtility.getFileNameMask(NCGlobal.shared.keyFileNameMask)
+    @State private var isMaintainOriginalFilename: Bool = CCUtility.getOriginalFileName(NCGlobal.shared.keyFileNameOriginal)
+    @State private var isAddFilenametype: Bool = CCUtility.getFileNameType(NCGlobal.shared.keyFileNameType)
+    @State private var isPresentedSelect = false
+    @State private var isPresentedUploadConflict = false
+
+    @ObservedObject var uploadAssets: NCUploadAssets
+
+    @Environment(\.presentationMode) var presentationMode
+
+    init(uploadAssets: NCUploadAssets) {
+        self.uploadAssets = uploadAssets
+    }
+
+    func getOriginalFilename() -> String {
+
+        CCUtility.setOriginalFileName(isMaintainOriginalFilename, key: NCGlobal.shared.keyFileNameOriginal)
+
+        if let asset = uploadAssets.assets.first, let name = (asset.value(forKey: "filename") as? String) {
+            return name
+        } else {
+            return ""
+        }
+    }
+
+    func setFileNameMask(fileName: String?) -> String {
+
+        guard let asset = uploadAssets.assets.first else { return "" }
+        var preview: String = ""
+        let creationDate = asset.creationDate ?? Date()
+
+        CCUtility.setOriginalFileName(isMaintainOriginalFilename, key: NCGlobal.shared.keyFileNameOriginal)
+        CCUtility.setFileNameType(isAddFilenametype, key: NCGlobal.shared.keyFileNameType)
+
+        if let fileName = fileName {
+
+            let fileName = fileName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
+
+            if !fileName.isEmpty {
+
+                CCUtility.setFileNameMask(fileName, key: NCGlobal.shared.keyFileNameMask)
+                preview = CCUtility.createFileName(asset.value(forKey: "filename") as? String,
+                                                   fileDate: creationDate, fileType: asset.mediaType,
+                                                   keyFileName: NCGlobal.shared.keyFileNameMask,
+                                                   keyFileNameType: NCGlobal.shared.keyFileNameType,
+                                                   keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal,
+                                                   forcedNewFileName: false)
+
+            } else {
+
+                CCUtility.setFileNameMask("", key: NCGlobal.shared.keyFileNameMask)
+                preview = CCUtility.createFileName(asset.value(forKey: "filename") as? String,
+                                                   fileDate: creationDate,
+                                                   fileType: asset.mediaType,
+                                                   keyFileName: nil,
+                                                   keyFileNameType: NCGlobal.shared.keyFileNameType,
+                                                   keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal,
+                                                   forcedNewFileName: false)
+            }
+
+        } else {
+
+            CCUtility.setFileNameMask("", key: NCGlobal.shared.keyFileNameMask)
+            preview = CCUtility.createFileName(asset.value(forKey: "filename") as? String,
+                                               fileDate: creationDate,
+                                               fileType: asset.mediaType,
+                                               keyFileName: nil,
+                                               keyFileNameType: NCGlobal.shared.keyFileNameType,
+                                               keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal,
+                                               forcedNewFileName: false)
+        }
+
+        return String(format: NSLocalizedString("_preview_filename_", comment: ""), "MM, MMM, DD, YY, YYYY, HH, hh, mm, ss, ampm") + ":" + "\n\n" + preview
+    }
+
+    func save(completion: @escaping (_ metadatasNOConflict: [tableMetadata], _ metadatasUploadInConflict: [tableMetadata]) -> Void) {
+
+        var metadatasNOConflict: [tableMetadata] = []
+        var metadatasUploadInConflict: [tableMetadata] = []
+
+        for asset in uploadAssets.assets {
+
+            let serverUrl = uploadAssets.serverUrl
+            var livePhoto: Bool = false
+            let creationDate = asset.creationDate ?? Date()
+            let fileName = CCUtility.createFileName(asset.value(forKey: "filename") as? String,
+                                                    fileDate: creationDate,
+                                                    fileType: asset.mediaType,
+                                                    keyFileName: NCGlobal.shared.keyFileNameMask,
+                                                    keyFileNameType: NCGlobal.shared.keyFileNameType,
+                                                    keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal,
+                                                    forcedNewFileName: false)!
+
+            if asset.mediaSubtypes.contains(.photoLive) && CCUtility.getLivePhoto() {
+                livePhoto = true
+            }
+
+            // Check if is in upload
+            let isRecordInSessions = NCManageDatabase.shared.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileName == %@ AND session != ''", uploadAssets.userBaseUrl.account, serverUrl, fileName), sorted: "fileName", ascending: false)
+            if !isRecordInSessions.isEmpty { continue }
+
+            let metadata = NCManageDatabase.shared.createMetadata(account: uploadAssets.userBaseUrl.account, user: uploadAssets.userBaseUrl.user, userId: uploadAssets.userBaseUrl.userId, fileName: fileName, fileNameView: fileName, ocId: NSUUID().uuidString, serverUrl: serverUrl, urlBase: uploadAssets.userBaseUrl.urlBase, url: "", contentType: "", isLivePhoto: livePhoto)
+
+            metadata.assetLocalIdentifier = asset.localIdentifier
+            metadata.session = NCNetworking.shared.sessionIdentifierBackground
+            metadata.sessionSelector = NCGlobal.shared.selectorUploadFile
+            metadata.status = NCGlobal.shared.metadataStatusWaitUpload
+
+            if let result = NCManageDatabase.shared.getMetadataConflict(account: uploadAssets.userBaseUrl.account, serverUrl: serverUrl, fileNameView: fileName) {
+                metadata.fileName = result.fileName
+                metadatasUploadInConflict.append(metadata)
+            } else {
+                metadatasNOConflict.append(metadata)
+            }
+        }
+
+        // Verify if file(s) exists
+        if !metadatasUploadInConflict.isEmpty {
+            completion(metadatasNOConflict, metadatasUploadInConflict)
+        } else {
+            NCNetworkingProcessUpload.shared.createProcessUploads(metadatas: metadatasNOConflict, completion: { _ in })
+            completion(metadatasNOConflict, metadatasUploadInConflict)
+        }
+    }
+
+    var body: some View {
+        NavigationView {
+            List {
+                Section(header: Text(NSLocalizedString("_save_path_", comment: ""))) {
+
+                    HStack {
+                        Label {
+                            if NCUtilityFileSystem.shared.getHomeServer(urlBase: uploadAssets.userBaseUrl.urlBase, userId: uploadAssets.userBaseUrl.userId) == uploadAssets.serverUrl {
+                                Text("/")
+                                    .frame(maxWidth: .infinity, alignment: .trailing)
+                            } else {
+                                Text((uploadAssets.serverUrl as NSString).lastPathComponent)
+                                    .frame(maxWidth: .infinity, alignment: .trailing)
+                            }
+                        } icon: {
+                            Image("folder")
+                                .renderingMode(.template)
+                                .resizable()
+                                .scaledToFit()
+                                .foregroundColor(Color(NCBrandColor.shared.brand))
+                        }
+                    }
+                    .contentShape(Rectangle())
+                    .onTapGesture {
+                        isPresentedSelect = true
+                    }
+                }
+
+                Section(header: Text(NSLocalizedString("_mode_filename_", comment: ""))) {
+
+                    Toggle(NSLocalizedString("_maintain_original_filename_", comment: ""), isOn: $isMaintainOriginalFilename)
+                        .toggleStyle(SwitchToggleStyle(tint: Color(NCBrandColor.shared.brand)))
+
+                    if !isMaintainOriginalFilename {
+                        Toggle(NSLocalizedString("_add_filenametype_", comment: ""), isOn: $isAddFilenametype)
+                            .toggleStyle(SwitchToggleStyle(tint: Color(NCBrandColor.shared.brand)))
+                    }
+                }
+
+                Section(header: Text(NSLocalizedString("_filename_", comment: ""))) {
+
+                    HStack {
+                        Text(NSLocalizedString("_filename_", comment: ""))
+                        if isMaintainOriginalFilename {
+                            Text(getOriginalFilename())
+                                .frame(maxWidth: .infinity, alignment: .trailing)
+                        } else {
+                            TextField(NSLocalizedString("_enter_filename_", comment: ""), text: $fileName)
+                                .modifier(TextFieldClearButton(text: $fileName))
+                                .multilineTextAlignment(.trailing)
+                        }
+                    }
+                    if !isMaintainOriginalFilename {
+                        Text(setFileNameMask(fileName: fileName))
+                    }
+                }
+                .complexModifier { view in
+                    if #available(iOS 15, *) {
+                        view.listRowSeparator(.hidden)
+                    }
+                }
+
+                Button(NSLocalizedString("_save_", comment: "")) {
+                    save { metadatasNOConflict, metadatasUploadInConflict in
+                        if metadatasUploadInConflict.isEmpty {
+                            uploadAssets.dismiss = true
+                        } else {
+                            uploadAssets.metadatasNOConflict = metadatasNOConflict
+                            uploadAssets.metadatasUploadInConflict = metadatasUploadInConflict
+                            isPresentedUploadConflict = true
+                        }
+                    }
+                }
+                .frame(maxWidth: .infinity)
+                .buttonStyle(ButtonRounded(disabled: false))
+                .listRowBackground(Color(UIColor.systemGroupedBackground))
+            }
+            .navigationTitle(NSLocalizedString("_upload_photos_videos_", comment: ""))
+            .navigationBarTitleDisplayMode(.inline)
+        }
+        .sheet(isPresented: $isPresentedSelect) {
+            SelectView(serverUrl: $uploadAssets.serverUrl)
+        }
+        .sheet(isPresented: $isPresentedUploadConflict) {
+            UploadConflictView(delegate: uploadAssets, serverUrl: uploadAssets.serverUrl, metadatasUploadInConflict: uploadAssets.metadatasUploadInConflict, metadatasNOConflict: uploadAssets.metadatasNOConflict)
+        }
+        .onReceive(uploadAssets.$dismiss) { newValue in
+            if newValue {
+                presentationMode.wrappedValue.dismiss()
+            }
+        }
+    }
+}
+
+// MARK: - Preview
+
+struct UploadAssetsView_Previews: PreviewProvider {
+    static var previews: some View {
+        if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
+            let uploadAssets = NCUploadAssets(assets: [], serverUrl: "/", userBaseUrl: appDelegate)
+            UploadAssetsView(uploadAssets: uploadAssets)
+        }
+    }
+}

+ 0 - 193
iOSClient/Main/NCFunctionCenter.swift

@@ -602,199 +602,6 @@ import Photos
 
 
         appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
         appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
     }
     }
-
-    // MARK: - Context Menu Configuration
-
-    func contextMenuConfiguration(ocId: String, viewController: UIViewController, enableDeleteLocal: Bool, enableViewInFolder: Bool, image: UIImage?) -> UIMenu {
-
-        guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) else {
-            return UIMenu()
-        }
-
-        let isDirectoryE2EE = NCUtility.shared.isDirectoryE2EE(metadata: metadata)
-        var titleDeleteConfirmFile = NSLocalizedString("_delete_file_", comment: "")
-        if metadata.directory { titleDeleteConfirmFile = NSLocalizedString("_delete_folder_", comment: "") }
-        var titleSave: String = NSLocalizedString("_save_selected_files_", comment: "")
-        let metadataMOV = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata)
-        if metadataMOV != nil {
-            titleSave = NSLocalizedString("_livephoto_save_", comment: "")
-        }
-        let titleFavorite = metadata.favorite ? NSLocalizedString("_remove_favorites_", comment: "") : NSLocalizedString("_add_favorites_", comment: "")
-
-        let serverUrl = metadata.serverUrl + "/" + metadata.fileName
-        var isOffline = false
-        if metadata.directory {
-            if let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl)) {
-                isOffline = directory.offline
-            }
-        } else {
-            if let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) {
-                isOffline = localFile.offline
-            }
-        }
-        let titleOffline = isOffline ? NSLocalizedString("_remove_available_offline_", comment: "") :  NSLocalizedString("_set_available_offline_", comment: "")
-        let titleLock = metadata.lock ? NSLocalizedString("_unlock_file_", comment: "") :  NSLocalizedString("_lock_file_", comment: "")
-        let iconLock = metadata.lock ? "lock.open" : "lock"
-        let copy = UIAction(title: NSLocalizedString("_copy_file_", comment: ""), image: UIImage(systemName: "doc.on.doc")) { _ in
-            self.copyPasteboard(pasteboardOcIds: [metadata.ocId], hudView: viewController.view)
-        }
-
-        let copyPath = UIAction(title: NSLocalizedString("_copy_path_", comment: ""), image: UIImage(systemName: "doc.on.clipboard")) { _ in
-            let board = UIPasteboard.general
-            board.string = NCUtilityFileSystem.shared.getPath(path: metadata.path, user: metadata.user, fileName: metadata.fileName)
-            let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_copied_path_")
-            NCContentPresenter.shared.showInfo(error: error)
-        }
-
-        let detail = UIAction(title: NSLocalizedString("_details_", comment: ""), image: UIImage(systemName: "info")) { _ in
-            self.openShare(viewController: viewController, metadata: metadata, indexPage: .activity)
-        }
-
-        let offline = UIAction(title: titleOffline, image: UIImage(systemName: "tray.and.arrow.down")) { _ in
-            self.setMetadataAvalableOffline(metadata, isOffline: isOffline)
-            if let viewController = viewController as? NCCollectionViewCommon {
-                viewController.reloadDataSource()
-            }
-        }
-        
-        let lockUnlock = UIAction(title: titleLock, image: UIImage(systemName: iconLock)) { _ in
-            NCNetworking.shared.lockUnlockFile(metadata, shoulLock: !metadata.lock)
-        }
-        let save = UIAction(title: titleSave, image: UIImage(systemName: "square.and.arrow.down")) { _ in
-            if metadataMOV != nil {
-                self.saveLivePhoto(metadata: metadata, metadataMOV: metadataMOV!)
-            } else {
-                if CCUtility.fileProviderStorageExists(metadata) {
-                    self.saveAlbum(metadata: metadata)
-                } else {
-                    NCOperationQueue.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorSaveAlbum)
-                }
-            }
-        }
-
-        let viewInFolder = UIAction(title: NSLocalizedString("_view_in_folder_", comment: ""), image: UIImage(systemName: "arrow.forward.square")) { _ in
-            self.openFileViewInFolder(serverUrl: metadata.serverUrl, fileNameBlink: metadata.fileName, fileNameOpen: nil)
-        }
-
-        let openIn = UIAction(title: NSLocalizedString("_open_in_", comment: ""), image: UIImage(systemName: "square.and.arrow.up") ) { _ in
-            self.openDownload(metadata: metadata, selector: NCGlobal.shared.selectorOpenIn)
-        }
-
-        let print = UIAction(title: NSLocalizedString("_print_", comment: ""), image: UIImage(systemName: "printer") ) { _ in
-            self.openDownload(metadata: metadata, selector: NCGlobal.shared.selectorPrint)
-        }
-
-        let modify = UIAction(title: NSLocalizedString("_modify_", comment: ""), image: UIImage(systemName: "pencil.tip.crop.circle")) { _ in
-            self.openDownload(metadata: metadata, selector: NCGlobal.shared.selectorLoadFileQuickLook)
-        }
-
-        let saveAsScan = UIAction(title: NSLocalizedString("_save_as_scan_", comment: ""), image: UIImage(systemName: "viewfinder.circle")) { _ in
-            self.openDownload(metadata: metadata, selector: NCGlobal.shared.selectorSaveAsScan)
-        }
-
-        // let open = UIMenu(title: NSLocalizedString("_open_", comment: ""), image: UIImage(systemName: "square.and.arrow.up"), children: [openIn, openQuickLook])
-
-        let moveCopy = UIAction(title: NSLocalizedString("_move_or_copy_", comment: ""), image: UIImage(systemName: "arrow.up.right.square")) { _ in
-            self.openSelectView(items: [metadata])
-        }
-
-        let rename = UIAction(title: NSLocalizedString("_rename_", comment: ""), image: UIImage(systemName: "pencil")) { _ in
-
-            if let vcRename = UIStoryboard(name: "NCRenameFile", bundle: nil).instantiateInitialViewController() as? NCRenameFile {
-
-                vcRename.metadata = metadata
-                vcRename.imagePreview = image
-
-                let popup = NCPopupViewController(contentController: vcRename, popupWidth: vcRename.width, popupHeight: vcRename.height)
-
-                viewController.present(popup, animated: true)
-            }
-        }
-
-        let favorite = UIAction(title: titleFavorite, image: NCUtility.shared.loadImage(named: "star.fill", color: NCBrandColor.shared.yellowFavorite)) { _ in
-
-            NCNetworking.shared.favoriteMetadata(metadata) { error in
-                if error != .success {
-                    NCContentPresenter.shared.showError(error: error)
-                }
-            }
-        }
-
-        let deleteConfirmFile = UIAction(title: titleDeleteConfirmFile, image: UIImage(systemName: "trash"), attributes: .destructive) { _ in
-            NCNetworking.shared.deleteMetadata(metadata, onlyLocalCache: false) { error in
-                if error != .success {
-                    NCContentPresenter.shared.showError(error: error)
-                }
-            }
-        }
-
-        let deleteConfirmLocal = UIAction(title: NSLocalizedString("_remove_local_file_", comment: ""), image: UIImage(systemName: "trash"), attributes: .destructive) { _ in
-            NCNetworking.shared.deleteMetadata(metadata, onlyLocalCache: true) { _ in
-            }
-        }
-
-        var delete = UIMenu(title: NSLocalizedString("_delete_file_", comment: ""), image: UIImage(systemName: "trash"), options: .destructive, children: [deleteConfirmLocal, deleteConfirmFile])
-
-        if !enableDeleteLocal {
-            delete = UIMenu(title: NSLocalizedString("_delete_file_", comment: ""), image: UIImage(systemName: "trash"), options: .destructive, children: [deleteConfirmFile])
-        }
-
-        if metadata.directory {
-            delete = UIMenu(title: NSLocalizedString("_delete_folder_", comment: ""), image: UIImage(systemName: "trash"), options: .destructive, children: [deleteConfirmFile])
-        }
-
-        // ------ MENU -----
-
-        // DIR
-
-        guard !metadata.directory else {
-            let submenu = UIMenu(title: "", options: .displayInline, children: [favorite, offline, rename, moveCopy, copyPath, delete])
-            guard appDelegate.disableSharesView == false else { return submenu }
-            return UIMenu(title: "", children: [detail, submenu])
-        }
-
-        // FILE
-
-        var children: [UIMenuElement] = [offline, openIn, moveCopy, copy, copyPath]
-        
-        if !metadata.lock {
-            // Workaround: PROPPATCH doesn't work (favorite)
-            // https://github.com/nextcloud/files_lock/issues/68
-            children.insert(favorite, at: 0)
-            children.append(delete)
-            children.insert(rename, at: 3)
-        } else if enableDeleteLocal {
-            children.append(deleteConfirmLocal)
-        }
-
-        if NCManageDatabase.shared.getCapabilitiesServerInt(account: appDelegate.account, elements: NCElementsJSON.shared.capabilitiesFilesLockVersion) >= 1, metadata.canUnlock(as: appDelegate.userId) {
-            children.insert(lockUnlock, at: metadata.lock ? 0 : 1)
-        }
-
-        if (metadata.contentType != "image/svg+xml") && (metadata.classFile == NKCommon.typeClassFile.image.rawValue || metadata.classFile == NKCommon.typeClassFile.video.rawValue) {
-            children.insert(save, at: 2)
-        }
-
-        if (metadata.contentType != "image/svg+xml") && (metadata.classFile == NKCommon.typeClassFile.image.rawValue) {
-            children.insert(saveAsScan, at: 2)
-        }
-
-        if (metadata.contentType != "image/svg+xml") && (metadata.classFile == NKCommon.typeClassFile.image.rawValue || metadata.contentType == "application/pdf" || metadata.contentType == "com.adobe.pdf") {
-            children.insert(print, at: 2)
-        }
-
-        if enableViewInFolder {
-            children.insert(viewInFolder, at: children.count - 1)
-        }
-
-        if (!isDirectoryE2EE && metadata.contentType != "image/gif" && metadata.contentType != "image/svg+xml") && (metadata.contentType == "com.adobe.pdf" || metadata.contentType == "application/pdf" || metadata.classFile == NKCommon.typeClassFile.image.rawValue) {
-            children.insert(modify, at: children.count - 1)
-        }
-
-        let submenu = UIMenu(title: "", options: .displayInline, children: children)
-        guard appDelegate.disableSharesView == false else { return submenu }
-        return UIMenu(title: "", children: [detail, submenu])
-    }
 }
 }
 
 
 fileprivate extension tableMetadata {
 fileprivate extension tableMetadata {

+ 2 - 5
iOSClient/Main/NCPickerViewController.swift

@@ -47,12 +47,9 @@ class NCPhotosPickerViewController: NSObject {
         self.openPhotosPickerViewController { assets in
         self.openPhotosPickerViewController { assets in
             guard let assets = assets else { return }
             guard let assets = assets else { return }
             if assets.count > 0 {
             if assets.count > 0 {
-
-                let form = NCCreateFormUploadAssets(serverUrl: self.appDelegate.activeServerUrl, assets: assets, cryptated: false, session: NCNetworking.shared.sessionIdentifierBackground, delegate: nil)
-                let navigationController = UINavigationController(rootViewController: form)
-
+                let vc = NCHostingUploadAssetsView().makeShipDetailsUI(assets: assets, serverUrl: self.appDelegate.activeServerUrl, userBaseUrl: self.appDelegate)
                 DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) {
                 DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) {
-                    viewController.present(navigationController, animated: true, completion: nil)
+                    viewController.present(vc, animated: true, completion: nil)
                 }
                 }
             }
             }
         }
         }

+ 1 - 1
iOSClient/Media/NCMedia.swift

@@ -329,7 +329,7 @@ extension NCMedia: UICollectionViewDelegate {
         return UIContextMenuConfiguration(identifier: identifier, previewProvider: {
         return UIContextMenuConfiguration(identifier: identifier, previewProvider: {
             return NCViewerProviderContextMenu(metadata: metadata, image: image)
             return NCViewerProviderContextMenu(metadata: metadata, image: image)
         }, actionProvider: { _ in
         }, actionProvider: { _ in
-            return NCFunctionCenter.shared.contextMenuConfiguration(ocId: metadata.ocId, viewController: self, enableDeleteLocal: false, enableViewInFolder: true, image: image)
+            return NCContextMenu().viewMenu(ocId: metadata.ocId, viewController: self, enableDeleteLocal: false, enableViewInFolder: true, image: image)
         })
         })
     }
     }
 
 

+ 225 - 0
iOSClient/Menu/NCContextMenu.swift

@@ -0,0 +1,225 @@
+//
+//  NCContextMenu.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 10/01/23.
+//  Copyright © 2023 Marino Faggiana. All rights reserved.
+//
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+import Foundation
+import NextcloudKit
+
+class NCContextMenu: NSObject {
+
+    func viewMenu(ocId: String, viewController: UIViewController, enableDeleteLocal: Bool, enableViewInFolder: Bool, image: UIImage?) -> UIMenu {
+
+        let appDelegate = UIApplication.shared.delegate as? AppDelegate
+        guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) else {
+            return UIMenu()
+        }
+
+        let isDirectoryE2EE = NCUtility.shared.isDirectoryE2EE(metadata: metadata)
+        var titleDeleteConfirmFile = NSLocalizedString("_delete_file_", comment: "")
+        if metadata.directory { titleDeleteConfirmFile = NSLocalizedString("_delete_folder_", comment: "") }
+        var titleSave: String = NSLocalizedString("_save_selected_files_", comment: "")
+        let metadataMOV = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata)
+        if metadataMOV != nil {
+            titleSave = NSLocalizedString("_livephoto_save_", comment: "")
+        }
+        let titleFavorite = metadata.favorite ? NSLocalizedString("_remove_favorites_", comment: "") : NSLocalizedString("_add_favorites_", comment: "")
+
+        let serverUrl = metadata.serverUrl + "/" + metadata.fileName
+        var isOffline = false
+        if metadata.directory {
+            if let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate!.account, serverUrl)) {
+                isOffline = directory.offline
+            }
+        } else {
+            if let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) {
+                isOffline = localFile.offline
+            }
+        }
+        let titleOffline = isOffline ? NSLocalizedString("_remove_available_offline_", comment: "") : NSLocalizedString("_set_available_offline_", comment: "")
+        let titleLock = metadata.lock ? NSLocalizedString("_unlock_file_", comment: "") : NSLocalizedString("_lock_file_", comment: "")
+        let iconLock = metadata.lock ? "lock.open" : "lock"
+        let copy = UIAction(title: NSLocalizedString("_copy_file_", comment: ""), image: UIImage(systemName: "doc.on.doc")) { _ in
+            NCFunctionCenter.shared.copyPasteboard(pasteboardOcIds: [metadata.ocId], hudView: viewController.view)
+        }
+
+        let copyPath = UIAction(title: NSLocalizedString("_copy_path_", comment: ""), image: UIImage(systemName: "doc.on.clipboard")) { _ in
+            let board = UIPasteboard.general
+            board.string = NCUtilityFileSystem.shared.getPath(path: metadata.path, user: metadata.user, fileName: metadata.fileName)
+            let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_copied_path_")
+            NCContentPresenter.shared.showInfo(error: error)
+        }
+
+        let detail = UIAction(title: NSLocalizedString("_details_", comment: ""), image: UIImage(systemName: "info")) { _ in
+            NCFunctionCenter.shared.openShare(viewController: viewController, metadata: metadata, indexPage: .activity)
+        }
+
+        let offline = UIAction(title: titleOffline, image: UIImage(systemName: "tray.and.arrow.down")) { _ in
+            NCFunctionCenter.shared.setMetadataAvalableOffline(metadata, isOffline: isOffline)
+            if let viewController = viewController as? NCCollectionViewCommon {
+                viewController.reloadDataSource()
+            }
+        }
+
+        let lockUnlock = UIAction(title: titleLock, image: UIImage(systemName: iconLock)) { _ in
+            NCNetworking.shared.lockUnlockFile(metadata, shoulLock: !metadata.lock)
+        }
+        let save = UIAction(title: titleSave, image: UIImage(systemName: "square.and.arrow.down")) { _ in
+            if metadataMOV != nil {
+                NCFunctionCenter.shared.saveLivePhoto(metadata: metadata, metadataMOV: metadataMOV!)
+            } else {
+                if CCUtility.fileProviderStorageExists(metadata) {
+                    NCFunctionCenter.shared.saveAlbum(metadata: metadata)
+                } else {
+                    NCOperationQueue.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorSaveAlbum)
+                }
+            }
+        }
+
+        let viewInFolder = UIAction(title: NSLocalizedString("_view_in_folder_", comment: ""), image: UIImage(systemName: "arrow.forward.square")) { _ in
+            NCFunctionCenter.shared.openFileViewInFolder(serverUrl: metadata.serverUrl, fileNameBlink: metadata.fileName, fileNameOpen: nil)
+        }
+
+        let openIn = UIAction(title: NSLocalizedString("_open_in_", comment: ""), image: UIImage(systemName: "square.and.arrow.up") ) { _ in
+            NCFunctionCenter.shared.openDownload(metadata: metadata, selector: NCGlobal.shared.selectorOpenIn)
+        }
+
+        let print = UIAction(title: NSLocalizedString("_print_", comment: ""), image: UIImage(systemName: "printer") ) { _ in
+            NCFunctionCenter.shared.openDownload(metadata: metadata, selector: NCGlobal.shared.selectorPrint)
+        }
+
+        let modify = UIAction(title: NSLocalizedString("_modify_", comment: ""), image: UIImage(systemName: "pencil.tip.crop.circle")) { _ in
+            NCFunctionCenter.shared.openDownload(metadata: metadata, selector: NCGlobal.shared.selectorLoadFileQuickLook)
+        }
+
+        let saveAsScan = UIAction(title: NSLocalizedString("_save_as_scan_", comment: ""), image: UIImage(systemName: "viewfinder.circle")) { _ in
+            NCFunctionCenter.shared.openDownload(metadata: metadata, selector: NCGlobal.shared.selectorSaveAsScan)
+        }
+
+        // let open = UIMenu(title: NSLocalizedString("_open_", comment: ""), image: UIImage(systemName: "square.and.arrow.up"), children: [openIn, openQuickLook])
+
+        let moveCopy = UIAction(title: NSLocalizedString("_move_or_copy_", comment: ""), image: UIImage(systemName: "arrow.up.right.square")) { _ in
+            NCFunctionCenter.shared.openSelectView(items: [metadata])
+        }
+
+        let rename = UIAction(title: NSLocalizedString("_rename_", comment: ""), image: UIImage(systemName: "pencil")) { _ in
+
+            if let vcRename = UIStoryboard(name: "NCRenameFile", bundle: nil).instantiateInitialViewController() as? NCRenameFile {
+
+                vcRename.metadata = metadata
+                vcRename.imagePreview = image
+
+                let popup = NCPopupViewController(contentController: vcRename, popupWidth: vcRename.width, popupHeight: vcRename.height)
+
+                viewController.present(popup, animated: true)
+            }
+        }
+
+        let favorite = UIAction(title: titleFavorite, image: NCUtility.shared.loadImage(named: "star.fill", color: NCBrandColor.shared.yellowFavorite)) { _ in
+
+            NCNetworking.shared.favoriteMetadata(metadata) { error in
+                if error != .success {
+                    NCContentPresenter.shared.showError(error: error)
+                }
+            }
+        }
+
+        let deleteConfirmFile = UIAction(title: titleDeleteConfirmFile, image: UIImage(systemName: "trash"), attributes: .destructive) { _ in
+            NCNetworking.shared.deleteMetadata(metadata, onlyLocalCache: false) { error in
+                if error != .success {
+                    NCContentPresenter.shared.showError(error: error)
+                }
+            }
+        }
+
+        let deleteConfirmLocal = UIAction(title: NSLocalizedString("_remove_local_file_", comment: ""), image: UIImage(systemName: "trash"), attributes: .destructive) { _ in
+            NCNetworking.shared.deleteMetadata(metadata, onlyLocalCache: true) { _ in
+            }
+        }
+
+        var delete = UIMenu(title: NSLocalizedString("_delete_file_", comment: ""), image: UIImage(systemName: "trash"), options: .destructive, children: [deleteConfirmLocal, deleteConfirmFile])
+
+        if !enableDeleteLocal {
+            delete = UIMenu(title: NSLocalizedString("_delete_file_", comment: ""), image: UIImage(systemName: "trash"), options: .destructive, children: [deleteConfirmFile])
+        }
+
+        if metadata.directory {
+            delete = UIMenu(title: NSLocalizedString("_delete_folder_", comment: ""), image: UIImage(systemName: "trash"), options: .destructive, children: [deleteConfirmFile])
+        }
+
+        // ------ MENU -----
+
+        // DIR
+
+        guard !metadata.directory else {
+            var submenu = UIMenu()
+            if !isDirectoryE2EE && metadata.e2eEncrypted {
+                submenu = UIMenu(title: "", options: .displayInline, children: [favorite, offline, rename, moveCopy, copyPath])
+            } else {
+                submenu = UIMenu(title: "", options: .displayInline, children: [favorite, offline, rename, moveCopy, copyPath, delete])
+            }
+            guard appDelegate!.disableSharesView == false else { return submenu }
+            return UIMenu(title: "", children: [detail, submenu])
+        }
+
+        // FILE
+
+        var children: [UIMenuElement] = [offline, openIn, moveCopy, copy, copyPath]
+
+        if !metadata.lock {
+            // Workaround: PROPPATCH doesn't work (favorite)
+            // https://github.com/nextcloud/files_lock/issues/68
+            children.insert(favorite, at: 0)
+            children.append(delete)
+            children.insert(rename, at: 3)
+        } else if enableDeleteLocal {
+            children.append(deleteConfirmLocal)
+        }
+
+        if NCManageDatabase.shared.getCapabilitiesServerInt(account: appDelegate!.account, elements: NCElementsJSON.shared.capabilitiesFilesLockVersion) >= 1, metadata.canUnlock(as: appDelegate!.userId) {
+            children.insert(lockUnlock, at: metadata.lock ? 0 : 1)
+        }
+
+        if (metadata.contentType != "image/svg+xml") && (metadata.classFile == NKCommon.typeClassFile.image.rawValue || metadata.classFile == NKCommon.typeClassFile.video.rawValue) {
+            children.insert(save, at: 2)
+        }
+
+        if (metadata.contentType != "image/svg+xml") && (metadata.classFile == NKCommon.typeClassFile.image.rawValue) {
+            children.insert(saveAsScan, at: 2)
+        }
+
+        if (metadata.contentType != "image/svg+xml") && (metadata.classFile == NKCommon.typeClassFile.image.rawValue || metadata.contentType == "application/pdf" || metadata.contentType == "com.adobe.pdf") {
+            children.insert(print, at: 2)
+        }
+
+        if enableViewInFolder {
+            children.insert(viewInFolder, at: children.count - 1)
+        }
+
+        if (!isDirectoryE2EE && metadata.contentType != "image/gif" && metadata.contentType != "image/svg+xml") && (metadata.contentType == "com.adobe.pdf" || metadata.contentType == "application/pdf" || metadata.classFile == NKCommon.typeClassFile.image.rawValue) {
+            children.insert(modify, at: children.count - 1)
+        }
+
+        let submenu = UIMenu(title: "", options: .displayInline, children: children)
+        guard appDelegate!.disableSharesView == false else { return submenu }
+        return UIMenu(title: "", children: [detail, submenu])
+    }
+}

+ 1 - 0
iOSClient/NCGlobal.swift

@@ -375,6 +375,7 @@ class NCGlobal: NSObject {
     let notificationCenterPauseMedia                            = "pauseMedia"
     let notificationCenterPauseMedia                            = "pauseMedia"
 
 
     let notificationCenterDismissScanDocument                   = "dismissScanDocument"
     let notificationCenterDismissScanDocument                   = "dismissScanDocument"
+    let notificationCenterDismissUploadAssets                   = "dismissUploadAssets"
 
 
     // TIP
     // TIP
     //
     //

+ 8 - 82
iOSClient/Scan document/NCUploadScanDocument.swift

@@ -33,7 +33,7 @@ class NCHostingUploadScanDocumentView: NSObject {
     @objc func makeShipDetailsUI(images: [UIImage], userBaseUrl: NCUserBaseUrl, serverUrl: String) -> UIViewController {
     @objc func makeShipDetailsUI(images: [UIImage], userBaseUrl: NCUserBaseUrl, serverUrl: String) -> UIViewController {
 
 
         let uploadScanDocument = NCUploadScanDocument(images: images, userBaseUrl: userBaseUrl, serverUrl: serverUrl)
         let uploadScanDocument = NCUploadScanDocument(images: images, userBaseUrl: userBaseUrl, serverUrl: serverUrl)
-        let details = UploadScanDocumentView(uploadScanDocument)
+        let details = UploadScanDocumentView(uploadScanDocument: uploadScanDocument)
         let vc = UIHostingController(rootView: details)
         let vc = UIHostingController(rootView: details)
         vc.title = NSLocalizedString("_save_", comment: "")
         vc.title = NSLocalizedString("_save_", comment: "")
         return vc
         return vc
@@ -45,7 +45,7 @@ class NCHostingUploadScanDocumentView: NSObject {
 class NCUploadScanDocument: ObservableObject {
 class NCUploadScanDocument: ObservableObject {
 
 
     internal var userBaseUrl: NCUserBaseUrl
     internal var userBaseUrl: NCUserBaseUrl
-    internal var serverUrl: String
+
     internal var metadata = tableMetadata()
     internal var metadata = tableMetadata()
     internal var images: [UIImage]
     internal var images: [UIImage]
 
 
@@ -54,6 +54,7 @@ class NCUploadScanDocument: ObservableObject {
     internal var quality: Double = 0
     internal var quality: Double = 0
     internal var removeAllFiles: Bool = false
     internal var removeAllFiles: Bool = false
 
 
+    @Published var serverUrl: String
     @Published var showHUD: Bool = false
     @Published var showHUD: Bool = false
 
 
     init(images: [UIImage], userBaseUrl: NCUserBaseUrl, serverUrl: String) {
     init(images: [UIImage], userBaseUrl: NCUserBaseUrl, serverUrl: String) {
@@ -367,7 +368,7 @@ struct UploadScanDocumentView: View {
 
 
     @ObservedObject var uploadScanDocument: NCUploadScanDocument
     @ObservedObject var uploadScanDocument: NCUploadScanDocument
 
 
-    init(_ uploadScanDocument: NCUploadScanDocument) {
+    init(uploadScanDocument: NCUploadScanDocument) {
         self.uploadScanDocument = uploadScanDocument
         self.uploadScanDocument = uploadScanDocument
     }
     }
 
 
@@ -467,7 +468,7 @@ struct UploadScanDocumentView: View {
                                 }
                                 }
                             }
                             }
                         }
                         }
-                        .buttonStyle(ButtonUploadScanDocumenStyle(disabled: fileName.isEmpty))
+                        .buttonStyle(ButtonRounded(disabled: fileName.isEmpty))
                     }
                     }
 
 
                     Section(header: Text(NSLocalizedString("_quality_image_title_", comment: ""))) {
                     Section(header: Text(NSLocalizedString("_quality_image_title_", comment: ""))) {
@@ -496,10 +497,10 @@ struct UploadScanDocumentView: View {
         }
         }
         .background(Color(UIColor.systemGroupedBackground))
         .background(Color(UIColor.systemGroupedBackground))
         .sheet(isPresented: $isPresentedSelect) {
         .sheet(isPresented: $isPresentedSelect) {
-            NCSelectRepresentedView(uploadScanDocument: uploadScanDocument)
+            NCSelectViewControllerRepresentable(delegate: uploadScanDocument)
         }
         }
         .sheet(isPresented: $isPresentedUploadConflict) {
         .sheet(isPresented: $isPresentedUploadConflict) {
-            NCUploadConflictRepresentedView(uploadScanDocument: uploadScanDocument)
+            UploadConflictView(delegate: uploadScanDocument, serverUrl: uploadScanDocument.serverUrl, metadatasUploadInConflict: [uploadScanDocument.metadata], metadatasNOConflict: [])
         }.onTapGesture {
         }.onTapGesture {
             dismissKeyboard()
             dismissKeyboard()
         }
         }
@@ -510,83 +511,8 @@ struct UploadScanDocumentView: View {
     }
     }
 }
 }
 
 
-struct TextFieldClearButton: ViewModifier {
-    @Binding var text: String
-
-    func body(content: Content) -> some View {
-        HStack {
-            content
-            if !text.isEmpty {
-                Button(
-                    action: { self.text = "" },
-                    label: {
-                        Image(systemName: "xmark.circle.fill")
-                            .foregroundColor(Color(UIColor.placeholderText))
-                    }
-                ).buttonStyle(BorderlessButtonStyle())
-            }
-        }
-    }
-}
-
-struct ButtonUploadScanDocumenStyle: ButtonStyle {
-    var disabled = false
-    func makeBody(configuration: Configuration) -> some View {
-        configuration.label
-            .padding(.horizontal, 40)
-            .padding(.vertical, 10)
-            .background(disabled ? Color(UIColor.placeholderText) : Color(NCBrandColor.shared.brand))
-            .foregroundColor(disabled ? Color(UIColor.placeholderText) : Color(NCBrandColor.shared.brandText))
-            .clipShape(Capsule())
-    }
-}
-
 // MARK: - UIViewControllerRepresentable
 // MARK: - UIViewControllerRepresentable
 
 
-struct NCSelectRepresentedView: UIViewControllerRepresentable {
-
-    typealias UIViewControllerType = UINavigationController
-    @ObservedObject var uploadScanDocument: NCUploadScanDocument
-
-    func makeUIViewController(context: Context) -> UINavigationController {
-
-        let storyboard = UIStoryboard(name: "NCSelect", bundle: nil)
-        let navigationController = storyboard.instantiateInitialViewController() as? UINavigationController
-        let viewController = navigationController?.topViewController as? NCSelect
-
-        viewController?.delegate = uploadScanDocument
-        viewController?.typeOfCommandView = .selectCreateFolder
-        viewController?.includeDirectoryE2EEncryption = true
-
-        return navigationController!
-    }
-
-    func updateUIViewController(_ uiViewController: UINavigationController, context: Context) {
-    }
-}
-
-struct NCUploadConflictRepresentedView: UIViewControllerRepresentable {
-
-    typealias UIViewControllerType = NCCreateFormUploadConflict
-    @ObservedObject var uploadScanDocument: NCUploadScanDocument
-
-    func makeUIViewController(context: Context) -> NCCreateFormUploadConflict {
-
-        let storyboard = UIStoryboard(name: "NCCreateFormUploadConflict", bundle: nil)
-        let viewController = storyboard.instantiateInitialViewController() as? NCCreateFormUploadConflict
-
-        viewController?.delegate = uploadScanDocument
-        viewController?.textLabelDetailNewFile = NSLocalizedString("_now_", comment: "")
-        viewController?.serverUrl = uploadScanDocument.serverUrl
-        viewController?.metadatasUploadInConflict = [uploadScanDocument.metadata]
-
-        return viewController!
-    }
-
-    func updateUIViewController(_ uiViewController: NCCreateFormUploadConflict, context: Context) {
-    }
-}
-
 struct PDFKitRepresentedView: UIViewRepresentable {
 struct PDFKitRepresentedView: UIViewRepresentable {
 
 
     typealias UIView = PDFView
     typealias UIView = PDFView
@@ -617,7 +543,7 @@ struct UploadScanDocumentView_Previews: PreviewProvider {
     static var previews: some View {
     static var previews: some View {
         if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
         if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
             let uploadScanDocument = NCUploadScanDocument(images: [], userBaseUrl: appDelegate, serverUrl: "ABCD")
             let uploadScanDocument = NCUploadScanDocument(images: [], userBaseUrl: appDelegate, serverUrl: "ABCD")
-            UploadScanDocumentView(uploadScanDocument)
+            UploadScanDocumentView(uploadScanDocument: uploadScanDocument)
         }
         }
     }
     }
 }
 }

+ 67 - 0
iOSClient/Select/NCSelect.swift

@@ -22,6 +22,7 @@
 //
 //
 
 
 import UIKit
 import UIKit
+import SwiftUI
 import NextcloudKit
 import NextcloudKit
 
 
 @objc protocol NCSelectDelegate {
 @objc protocol NCSelectDelegate {
@@ -836,3 +837,69 @@ class NCSelectCommandView: UIView {
         selectView?.valueChangedSwitchOverwrite(sender)
         selectView?.valueChangedSwitchOverwrite(sender)
     }
     }
 }
 }
+
+// MARK: - UIViewControllerRepresentable
+
+struct NCSelectViewControllerRepresentable: UIViewControllerRepresentable {
+
+    typealias UIViewControllerType = UINavigationController
+    var delegate: NCSelectDelegate
+
+    func makeUIViewController(context: Context) -> UINavigationController {
+
+        let storyboard = UIStoryboard(name: "NCSelect", bundle: nil)
+        let navigationController = storyboard.instantiateInitialViewController() as? UINavigationController
+        let viewController = navigationController?.topViewController as? NCSelect
+
+        viewController?.delegate = delegate
+        viewController?.typeOfCommandView = .selectCreateFolder
+        viewController?.includeDirectoryE2EEncryption = true
+
+        return navigationController!
+    }
+
+    func updateUIViewController(_ uiViewController: UINavigationController, context: Context) { }
+}
+
+struct SelectView: UIViewControllerRepresentable {
+
+    typealias UIViewControllerType = UINavigationController
+
+    @Binding var serverUrl: String
+
+    class Coordinator: NSObject, NCSelectDelegate {
+
+        var parent: SelectView
+
+        init(_ parent: SelectView) {
+            self.parent = parent
+        }
+
+        func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], overwrite: Bool, copy: Bool, move: Bool) {
+            if let serverUrl = serverUrl {
+                self.parent.serverUrl = serverUrl
+            }
+        }
+    }
+
+    func makeUIViewController(context: Context) -> UINavigationController {
+
+        let storyboard = UIStoryboard(name: "NCSelect", bundle: nil)
+        let navigationController = storyboard.instantiateInitialViewController() as? UINavigationController
+        let viewController = navigationController?.topViewController as? NCSelect
+
+        viewController?.delegate = context.coordinator
+        viewController?.typeOfCommandView = .selectCreateFolder
+        viewController?.includeDirectoryE2EEncryption = true
+
+        return navigationController!
+    }
+
+    func updateUIViewController(_ uiViewController: UINavigationController, context: Context) { }
+
+    func makeCoordinator() -> Coordinator {
+        Coordinator(self)
+    }
+}
+
+