Browse Source

Build 13 - Widget

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 years ago
parent
commit
f0d1d4af57

+ 2 - 2
Nextcloud.xcodeproj/project.pbxproj

@@ -3501,7 +3501,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 12;
+				CURRENT_PROJECT_VERSION = 13;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
@@ -3564,7 +3564,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 12;
+				CURRENT_PROJECT_VERSION = 13;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;

+ 20 - 11
Widget/Dashboard/DashboardData.swift

@@ -43,6 +43,8 @@ struct DashboardData: Identifiable, Hashable {
     let subTitle: String
     let link: URL
     let icon: UIImage
+    let template: Bool
+    let avatar: Bool
 }
 
 struct DashboardDataButton: Hashable {
@@ -52,16 +54,16 @@ struct DashboardDataButton: Hashable {
 }
 
 let dashboardDatasTest: [DashboardData] = [
-    .init(id: 0, title: "title0", subTitle: "subTitle-description0", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!),
-    .init(id: 1, title: "title1", subTitle: "subTitle-description1", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!),
-    .init(id: 2, title: "title2", subTitle: "subTitle-description2", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!),
-    .init(id: 3, title: "title3", subTitle: "subTitle-description3", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!),
-    .init(id: 4, title: "title4", subTitle: "subTitle-description4", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!),
-    .init(id: 5, title: "title5", subTitle: "subTitle-description5", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!),
-    .init(id: 6, title: "title6", subTitle: "subTitle-description6", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!),
-    .init(id: 7, title: "title7", subTitle: "subTitle-description7", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!),
-    .init(id: 8, title: "title8", subTitle: "subTitle-description8", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!),
-    .init(id: 9, title: "title9", subTitle: "subTitle-description9", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!)
+    .init(id: 0, title: "title0", subTitle: "subTitle-description0", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false),
+    .init(id: 1, title: "title1", subTitle: "subTitle-description1", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false),
+    .init(id: 2, title: "title2", subTitle: "subTitle-description2", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false),
+    .init(id: 3, title: "title3", subTitle: "subTitle-description3", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false),
+    .init(id: 4, title: "title4", subTitle: "subTitle-description4", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false),
+    .init(id: 5, title: "title5", subTitle: "subTitle-description5", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false),
+    .init(id: 6, title: "title6", subTitle: "subTitle-description6", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false),
+    .init(id: 7, title: "title7", subTitle: "subTitle-description7", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false),
+    .init(id: 8, title: "title8", subTitle: "subTitle-description8", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false),
+    .init(id: 9, title: "title9", subTitle: "subTitle-description9", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false)
 ]
 
 func getDashboardItems(displaySize: CGSize, withButton: Bool) -> Int {
@@ -155,6 +157,8 @@ func getDashboardDataEntry(intent: Applications?, isPreview: Bool, displaySize:
                         if let entryLink = item.link, let url = URL(string: entryLink){ link = url }
                         var icon = UIImage(named: "file")!
                         var iconFileName: String?
+                        var template: Bool = false
+                        var avatar: Bool = false
 
                         if let iconUrl = item.iconUrl, let url = URL(string: iconUrl) {
                             if let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) {
@@ -163,10 +167,15 @@ func getDashboardDataEntry(intent: Applications?, isPreview: Bool, displaySize:
                                 let pathComponents = path.components(separatedBy: "/")
                                 let queryItems = urlComponents.queryItems
 
+                                if (pathComponents.last as? NSString)?.pathExtension.lowercased() == "svg" {
+                                    template = true
+                                }
+
                                 if let item = CCUtility.value(forKey: "fileId", fromQueryItems: queryItems) {
                                     iconFileName = item
                                 } else if pathComponents[1] == "avatar" {
                                     iconFileName = pathComponents[2]
+                                    avatar = true
                                 } else {
                                     iconFileName = ((path.lastPathComponent) as NSString).deletingPathExtension
                                 }
@@ -181,7 +190,7 @@ func getDashboardDataEntry(intent: Applications?, isPreview: Bool, displaySize:
                             semaphore.wait()
                         }
                         
-                        let data = DashboardData(id: counter, title: title, subTitle: subtitle, link: link, icon: icon)
+                        let data = DashboardData(id: counter, title: title, subTitle: subtitle, link: link, icon: icon, template: template, avatar: avatar)
                         datas.append(data)
                         
                         if datas.count == dashboardItems { break }

+ 35 - 16
Widget/Dashboard/DashboardWidgetView.swift

@@ -69,23 +69,42 @@ struct DashboardWidgetView: View {
                                         Circle()
                                             .fill(Color(.systemGray4))
                                             .frame(width: 35, height: 35)
-                                    } else if entry.tableDashboard?.itemIconsRound ?? false {
-                                        Image(uiImage: element.icon)
-                                            .renderingMode(.template)
-                                            .resizable()
-                                            .scaledToFill()
-                                            .frame(width: 20, height: 20)
-                                            .foregroundColor(.white)
-                                            .padding(7)
-                                            .background(Color(.systemGray4))
-                                            .clipShape(Circle())
+                                    } else if element.template {
+                                        if entry.tableDashboard?.itemIconsRound ?? false {
+                                            Image(uiImage: element.icon)
+                                                .renderingMode(.template)
+                                                .resizable()
+                                                .scaledToFill()
+                                                .frame(width: 20, height: 20)
+                                                .foregroundColor(.white)
+                                                .padding(7)
+                                                .background(Color(.systemGray4))
+                                                .clipShape(Circle())
+                                        } else {
+                                            Image(uiImage: element.icon)
+                                                .renderingMode(.template)
+                                                .resizable()
+                                                .scaledToFill()
+                                                .frame(width: 25, height: 25)
+                                                .foregroundColor(Color(.label))
+                                                .clipped()
+                                                .cornerRadius(5)
+                                        }
                                     } else {
-                                        Image(uiImage: element.icon)
-                                            .resizable()
-                                            .scaledToFill()
-                                            .frame(width: 35, height: 35)
-                                            .clipped()
-                                            .cornerRadius(5)
+                                        if entry.tableDashboard?.itemIconsRound ?? false || element.avatar {
+                                            Image(uiImage: element.icon)
+                                                .resizable()
+                                                .scaledToFill()
+                                                .frame(width: 35, height: 35)
+                                                .clipShape(Circle())
+                                        } else {
+                                            Image(uiImage: element.icon)
+                                                .resizable()
+                                                .scaledToFill()
+                                                .frame(width: 35, height: 35)
+                                                .clipped()
+                                                .cornerRadius(5)
+                                        }
                                     }
 
                                     VStack(alignment: .leading, spacing: 2) {

+ 0 - 4
iOSClient/Brand/iOSClient.plist

@@ -42,10 +42,6 @@
 	</array>
 	<key>CFBundleVersion</key>
 	<string>$(CURRENT_PROJECT_VERSION)</string>
-	<key>INIntentsSupported</key>
-	<array>
-		<string>DashboardIntent</string>
-	</array>
 	<key>ITSAppUsesNonExemptEncryption</key>
 	<true/>
 	<key>ITSEncryptionExportComplianceCode</key>