Browse Source

test

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 năm trước cách đây
mục cha
commit
e9b586a22b
2 tập tin đã thay đổi với 62 bổ sung42 xóa
  1. 45 41
      Widget/Nextcloud/NextcloudWidgetView.swift
  2. 17 1
      iOSClient/AppDelegate.swift

+ 45 - 41
Widget/Nextcloud/NextcloudWidgetView.swift

@@ -73,49 +73,53 @@ struct NextcloudWidgetView: View {
 
                 HStack(spacing: 0) {
 
-                    Image("buttonAddImage")
-                        .resizable()
-                        .renderingMode(.template)
-                        .foregroundColor(Color(NCBrandColor.shared.brandText))
-                        .padding(10)
-                        .background(Color(NCBrandColor.shared.brand))
-                        .clipShape(Circle())
-                        .scaledToFit()
-                        .frame(width: geo.size.width/4, height: 50)
-                        .widgetURL(URL(string: "nextcloud://open-action?action=upload-asset")!)
+                    Link(destination: URL(string: "nextcloud://open-action?action=upload-asset")!, label: {
+                        Image("buttonAddImage")
+                            .resizable()
+                            .renderingMode(.template)
+                            .foregroundColor(Color(NCBrandColor.shared.brandText))
+                            .padding(10)
+                            .background(Color(NCBrandColor.shared.brand))
+                            .clipShape(Circle())
+                            .scaledToFit()
+                            .frame(width: geo.size.width/4, height: 50)
+                    })
 
-                    Image("buttonAddScan")
-                        .resizable()
-                        .renderingMode(.template)
-                        .foregroundColor(Color(NCBrandColor.shared.brandText))
-                        .padding(10)
-                        .background(Color(NCBrandColor.shared.brand))
-                        .clipShape(Circle())
-                        .scaledToFit()
-                        .frame(width: geo.size.width/4, height: 50)
-                        .widgetURL(URL(string: "nextcloud://open-action?action=add-scan-document")!)
+                    Link(destination: URL(string: "nextcloud://open-action?action=add-scan-document")!, label: {
+                        Image("buttonAddScan")
+                            .resizable()
+                            .renderingMode(.template)
+                            .foregroundColor(Color(NCBrandColor.shared.brandText))
+                            .padding(10)
+                            .background(Color(NCBrandColor.shared.brand))
+                            .clipShape(Circle())
+                            .scaledToFit()
+                            .frame(width: geo.size.width/4, height: 50)
+                    })
 
-                    Image("note.text")
-                        .resizable()
-                        .renderingMode(.template)
-                        .foregroundColor(Color(NCBrandColor.shared.brandText))
-                        .padding(10)
-                        .background(Color(NCBrandColor.shared.brand))
-                        .clipShape(Circle())
-                        .scaledToFit()
-                        .frame(width: geo.size.width/4, height: 50)
-                        .widgetURL(URL(string: "nextcloud://open-action?action=create-text-document")!)
+                    Link(destination: URL(string: "nextcloud://open-action?action=create-text-document")!, label: {
+                        Image("note.text")
+                            .resizable()
+                            .renderingMode(.template)
+                            .foregroundColor(Color(NCBrandColor.shared.brandText))
+                            .padding(10)
+                            .background(Color(NCBrandColor.shared.brand))
+                            .clipShape(Circle())
+                            .scaledToFit()
+                            .frame(width: geo.size.width/4, height: 50)
+                    })
 
-                    Image("microphone")
-                        .resizable()
-                        .renderingMode(.template)
-                        .foregroundColor(Color(NCBrandColor.shared.brandText))
-                        .padding(10)
-                        .background(Color(NCBrandColor.shared.brand))
-                        .clipShape(Circle())
-                        .scaledToFit()
-                        .frame(width: geo.size.width/4, height: 50)
-                        .widgetURL(URL(string: "nextcloud://open-action?action=create-voice-memo")!)
+                    Link(destination: URL(string: "nextcloud://open-action?action=create-voice-memo")!, label: {
+                        Image("microphone")
+                            .resizable()
+                            .renderingMode(.template)
+                            .foregroundColor(Color(NCBrandColor.shared.brandText))
+                            .padding(10)
+                            .background(Color(NCBrandColor.shared.brand))
+                            .clipShape(Circle())
+                            .scaledToFit()
+                            .frame(width: geo.size.width/4, height: 50)
+                    })
                 }
                 .frame(width: geo.size.width, height: geo.size.height-40, alignment: .bottomTrailing)
                 .redacted(reason: entry.isPlaceholder ? .placeholder : [])
@@ -139,7 +143,7 @@ struct NextcloudWidgetView: View {
 
 struct NextcloudWidget_Previews: PreviewProvider {
     static var previews: some View {
-        let entry = NextcloudDataEntry(date: Date(), recentDatas: recentDatasTest, isPlaceholder: true, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " widget")
+        let entry = NextcloudDataEntry(date: Date(), recentDatas: recentDatasTest, isPlaceholder: false, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " widget")
         NextcloudWidgetView(entry: entry).previewContext(WidgetPreviewContext(family: .systemLarge))
     }
 }

+ 17 - 1
iOSClient/AppDelegate.swift

@@ -834,7 +834,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         var serverUrl: String = ""
         var matchedAccount: tableAccount?
 
-
         /*
          Example:
          nextcloud://open-action?action=create-voice-memo
@@ -842,6 +841,23 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
         if scheme == "nextcloud" && action == "open-action" {
 
+            if let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) {
+                let queryItems = urlComponents.queryItems
+                guard let actionScheme = CCUtility.value(forKey: "action", fromQueryItems: queryItems) else { return false }
+                
+                switch actionScheme {
+                case "upload-asset":
+                    print("")
+                case "add-scan-document":
+                    print("")
+                case "create-text-document":
+                    print("")
+                case "create-voice-memo":
+                    print("")
+                default:
+                    print("")
+                }
+            }
         }
 
         /*