Browse Source

test

Signed-off-by: marinofaggiana <marino.faggiana@nextcloud.com>
marinofaggiana 2 years ago
parent
commit
0c81287eef

+ 21 - 0
DashboardWidget/DashboardNetworking.swift

@@ -0,0 +1,21 @@
+//
+//  DashboardNetworking.swift
+//  DashboardWidgetExtension
+//
+//  Created by Marino Faggiana on 22/08/22.
+//  Copyright © 2022 Marino Faggiana. All rights reserved.
+//
+
+import Foundation
+
+let dashboardDatasTest: [DashboardData] = [
+    .init(id: 0, image: "nextcloud", title: "title 1", subTitle: "subTitle 1", url: URL(string: "https://nextcloud.com/")!),
+    .init(id: 1, image: "nextcloud", title: "title 2", subTitle: "subTitle 2", url: URL(string: "https://nextcloud.com/")!),
+    .init(id: 2, image: "nextcloud", title: "title 3", subTitle: "subTitle 3", url: URL(string: "https://nextcloud.com/")!),
+    .init(id: 3, image: "nextcloud", title: "title 4", subTitle: "subTitle 4", url: URL(string: "https://nextcloud.com/")!),
+    .init(id: 4, image: "nextcloud", title: "title 5", subTitle: "subTitle 5", url: URL(string: "https://nextcloud.com/")!)
+]
+
+func readDashboard(completion: @escaping (_ dashboardData: [DashboardData]) -> Void) {
+    completion(dashboardDatasTest)
+}

+ 9 - 9
DashboardWidget/DashboardWidget.swift

@@ -18,18 +18,18 @@ struct Provider: TimelineProvider {
     }
 
     func getSnapshot(in context: Context, completion: @escaping (Entry) -> Void) {
-        completion(Entry(date: Date(), dashboardDatas: dashboardDatasTest))
-//        if context.isPreview {
-//        } else {
-//        }
+        readDashboard { dashboardDatas in
+            completion(Entry(date: Date(), dashboardDatas: dashboardDatas))
+        }
     }
 
     func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> Void) {
-        let components = DateComponents(minute: 10)
+        let components = DateComponents(minute: 5)
         let futureDate = Calendar.current.date(byAdding: components, to: Date())!
-        let datas = dashboardDatasTest
-        let timeLine = Timeline(entries: [Entry(date: Date(), dashboardDatas: datas)], policy: .after(futureDate))
-        completion(timeLine)
+        readDashboard { dashboardDatas in
+            let timeLine = Timeline(entries: [Entry(date: Date(), dashboardDatas: dashboardDatas)], policy: .after(futureDate))
+            completion(timeLine)
+        }
     }
 }
 
@@ -43,7 +43,7 @@ struct DashboardWidget: Widget {
         }
         .supportedFamilies([.systemLarge])
         .configurationDisplayName("Nextcloud Dashboard")
-        .description("subtitle.")
+        .description(NSLocalizedString("_subtitle_dashboard_", comment: ""))
     }
 }
 

+ 0 - 8
DashboardWidget/Entries/DashboardData.swift

@@ -15,11 +15,3 @@ struct DashboardData: Identifiable, Codable, Hashable {
     var subTitle: String
     var url: URL
 }
-
-let dashboardDatasTest: [DashboardData] = [
-    .init(id: 0, image: "nextcloud", title: "title 1", subTitle: "subTitle 1", url: URL(string: "https://nextcloud.com/")!),
-    .init(id: 1, image: "nextcloud", title: "title 2", subTitle: "subTitle 2", url: URL(string: "https://nextcloud.com/")!),
-    .init(id: 2, image: "nextcloud", title: "title 3", subTitle: "subTitle 3", url: URL(string: "https://nextcloud.com/")!),
-    .init(id: 3, image: "nextcloud", title: "title 4", subTitle: "subTitle 4", url: URL(string: "https://nextcloud.com/")!),
-    .init(id: 4, image: "nextcloud", title: "title 5", subTitle: "subTitle 5", url: URL(string: "https://nextcloud.com/")!)
-]

+ 4 - 0
Nextcloud.xcodeproj/project.pbxproj

@@ -193,6 +193,7 @@
 		F73D5E4A246DE09200DF6467 /* NCElementsJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = F73D5E46246DE09200DF6467 /* NCElementsJSON.swift */; };
 		F73F537F1E929C8500F8678D /* NCMore.swift in Sources */ = {isa = PBXBuildFile; fileRef = F73F537E1E929C8500F8678D /* NCMore.swift */; };
 		F741F3B428B3BC950045394D /* DashboardListEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = F741F3B328B3BC950045394D /* DashboardListEntry.swift */; };
+		F741F3B628B3D5720045394D /* DashboardNetworking.swift in Sources */ = {isa = PBXBuildFile; fileRef = F741F3B528B3D5720045394D /* DashboardNetworking.swift */; };
 		F7434B3420E23FD700417916 /* NCDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BAADB41ED5A87C00B7EAD4 /* NCDatabase.swift */; };
 		F7434B3620E23FE000417916 /* NCManageDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BAADB51ED5A87C00B7EAD4 /* NCManageDatabase.swift */; };
 		F7434B3820E2400600417916 /* NCBrand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */; };
@@ -710,6 +711,7 @@
 		F73D5E46246DE09200DF6467 /* NCElementsJSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCElementsJSON.swift; sourceTree = "<group>"; };
 		F73F537E1E929C8500F8678D /* NCMore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCMore.swift; sourceTree = "<group>"; };
 		F741F3B328B3BC950045394D /* DashboardListEntry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardListEntry.swift; sourceTree = "<group>"; };
+		F741F3B528B3D5720045394D /* DashboardNetworking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardNetworking.swift; sourceTree = "<group>"; };
 		F7421EAE2294044B00C4B7C1 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; };
 		F7434B5F20E2440600417916 /* FileProviderExtension-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "FileProviderExtension-Bridging-Header.h"; sourceTree = "<group>"; };
 		F745B250222D871800346520 /* QRCodeReader.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QRCodeReader.framework; path = Carthage/Build/iOS/QRCodeReader.framework; sourceTree = "<group>"; };
@@ -1306,6 +1308,7 @@
 				F741F3B028B3BBB70045394D /* Entries */,
 				F7346E2228B0FEBA006CE2D2 /* Assets.xcassets */,
 				F72A17D728B221E300F3F159 /* DashBoardList.swift */,
+				F741F3B528B3D5720045394D /* DashboardNetworking.swift */,
 				F7346E1528B0EF5C006CE2D2 /* DashboardWidget.swift */,
 				F7346E2028B0FA3A006CE2D2 /* DashboardWidget-Brinding-header.h */,
 			);
@@ -2593,6 +2596,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				F7E0710128B13BB00001B882 /* DashboardData.swift in Sources */,
+				F741F3B628B3D5720045394D /* DashboardNetworking.swift in Sources */,
 				F741F3B428B3BC950045394D /* DashboardListEntry.swift in Sources */,
 				F7346E1628B0EF5C006CE2D2 /* DashboardWidget.swift in Sources */,
 				F72A17D828B221E300F3F159 /* DashBoardList.swift in Sources */,