Browse Source

test

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

+ 12 - 0
DashboardWidget/Assets.xcassets/nextcloud.imageset/Contents.json

@@ -0,0 +1,12 @@
+{
+  "images" : [
+    {
+      "filename" : "nextcloud.png",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
DashboardWidget/Assets.xcassets/nextcloud.imageset/nextcloud.png


+ 1 - 1
DashboardWidget/DashboardWidget.swift

@@ -63,6 +63,6 @@ struct DashboardWidget: Widget {
 struct DashboardWidget_Previews: PreviewProvider {
     static var previews: some View {
         DashboardWidgetEntryView(entry: SimpleEntry(date: Date()))
-            .previewContext(WidgetPreviewContext(family: .systemSmall))
+            .previewContext(WidgetPreviewContext(family: .systemLarge))
     }
 }

+ 4 - 4
DashboardWidget/NCDataDashboard.swift

@@ -16,8 +16,8 @@ struct NCDataDashboard: Identifiable, Codable, Hashable {
 }
 
 let NCDataDashboardList: [NCDataDashboard] = [
-    .init(id: 1, image: "After Hours", title: "The Weeknd", subTitle: "theweeknd-after-hours"),
-    .init(id: 2, image: "Eternal Atake", title: "Lil Uzi", subTitle: "eternalatake-liluzivert"),
-    .init(id: 3, image: "bReAK mY heART", title: "Dua Lipa", subTitle: "dualipa-bReAK mY heART"),
-    .init(id: 4, image: "Jesus Is King", title: "Kanye West", subTitle: "kaynewest-jesusisking")
+    .init(id: 1, image: "nextcloud", title: "The Weeknd", subTitle: "theweeknd-after-hours"),
+    .init(id: 2, image: "nextcloud", title: "Lil Uzi", subTitle: "eternalatake-liluzivert"),
+    .init(id: 3, image: "nextcloud", title: "Dua Lipa", subTitle: "dualipa-bReAK mY heART"),
+    .init(id: 4, image: "nextcloud", title: "Kanye West", subTitle: "kaynewest-jesusisking")
 ]

+ 18 - 11
DashboardWidget/NCElementDashboard.swift

@@ -7,21 +7,21 @@
 //
 
 import SwiftUI
+import WidgetKit
 
 struct NCElementDashboard: View {
-    var data: NCDataDashboard
-
+    var dataElement: NCDataDashboard
     var body: some View {
         HStack {
-            Image(data.image)
+            Image(dataElement.image)
                 .resizable()
-                .aspectRatio(contentMode: .fill)
-                .frame(width:40, height: 40)
+                .aspectRatio(contentMode: .fit)
+                .frame(width: 40, height: 40)
                 .clipShape(Circle())
             VStack(alignment: .leading) {
-                Text(data.title)
+                Text(dataElement.title)
                     .font(.headline)
-                Text(data.subTitle)
+                Text(dataElement.subTitle)
                     .font(.subheadline)
                     .foregroundColor(.accentColor)
             }
@@ -30,15 +30,22 @@ struct NCElementDashboard: View {
         .cornerRadius(8)
         .overlay(
             RoundedRectangle(cornerRadius: 8)
-                .stroke(Color(.sRGB, red: 150/255, green: 150/255, blue: 150/255, opacity: 0.4), lineWidth: 1)
+                .stroke(Color(.sRGB, red: 150 / 255, green: 150/255, blue: 150/255, opacity: 0.4), lineWidth: 1)
         )
         .shadow(radius: 1)
     }
 }
 
-struct TopAlbumCard_Previews: PreviewProvider {
+struct NCElementDashboard_Previews: PreviewProvider {
     static var previews: some View {
-        NCElementDashboard(data: NCDataDashboardList[0])
-            .previewLayout(.fixed(width: 380, height: 75))
+
+//        ForEach(NCDataDashboardList, id: \.id) { dataDashboard in
+//            NCElementDashboard(dataElement: NCDataDashboardList[0])
+//                .previewContext(WidgetPreviewContext(family: .systemLarge))
+//        }
+
+
+        NCElementDashboard(dataElement: NCDataDashboardList[0])
+            .previewContext(WidgetPreviewContext(family: .systemLarge))
     }
 }