ソースを参照

improved widget

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 年 前
コミット
6b34ba59a8

+ 1 - 1
Widget/Assets.xcassets/AppIcon.imageset/Contents.json

@@ -1,7 +1,7 @@
 {
   "images" : [
     {
-      "filename" : "appicon.png",
+      "filename" : "nextcloud18.svg",
       "idiom" : "universal"
     }
   ],

BIN
Widget/Assets.xcassets/AppIcon.imageset/appicon.png


+ 70 - 0
Widget/Assets.xcassets/AppIcon.imageset/nextcloud18.svg

@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   inkscape:version="1.0beta2 (2b71d25, 2019-12-03)"
+   sodipodi:docname="nextcloud18.svg"
+   id="svg19"
+   xml:space="preserve"
+   viewBox="0 0 1024 1024"
+   version="1.1"
+   stroke-miterlimit="1.4142"
+   stroke-linejoin="round"
+   fill-rule="evenodd"
+   clip-rule="evenodd"><metadata
+   id="metadata23"><rdf:RDF><cc:Work
+       rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+         rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><sodipodi:namedview
+   inkscape:current-layer="svg19"
+   inkscape:window-maximized="1"
+   inkscape:window-y="23"
+   inkscape:window-x="0"
+   inkscape:cy="512"
+   inkscape:cx="512"
+   inkscape:zoom="0.67285156"
+   showgrid="false"
+   id="namedview21"
+   inkscape:window-height="855"
+   inkscape:window-width="1440"
+   inkscape:pageshadow="2"
+   inkscape:pageopacity="0"
+   guidetolerance="10"
+   gridtolerance="10"
+   objecttolerance="10"
+   borderopacity="1"
+   inkscape:document-rotation="0"
+   bordercolor="#666666"
+   pagecolor="#ffffff" /><defs
+   id="defs15"><linearGradient
+     gradientUnits="userSpaceOnUse"
+     gradientTransform="matrix(8.96 0 0 8.96 -7.8457e-5 .00019795)"
+     y2="-7.6294e-6"
+     y1="150"
+     x2="150"
+     x1="18.23"
+     id="a"><stop
+       id="stop10"
+       offset="0"
+       stop-color="#0082c9" /><stop
+       id="stop12"
+       offset="1"
+       stop-color="#1cafff" /></linearGradient></defs>
+<rect
+   id="rect17"
+   fill-rule="evenodd"
+   fill="url(#a)"
+   height="1024"
+   width="1024"
+   y=".00012207" /><path
+   inkscape:connector-curvature="0"
+   style="text-indent:0;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;text-transform:none;isolation:auto;mix-blend-mode:normal;stroke-width:3.40034"
+   fill="#fff"
+   d="m 513.20839,319.059 c -88.57887,0.0104 -162.93401,60.64524 -185.65856,142.22615 -19.83051,-43.63338 -63.48427,-74.55937 -114.21034,-74.55937 -69.04418,0.007 -125.812696,56.7753 -125.819487,125.81949 -0.01376,69.06082 56.761807,125.83981 125.819487,125.8465 50.72607,-0.007 94.35255,-30.94309 114.18337,-74.58636 22.71425,81.59089 97.10666,142.24646 185.68553,142.24646 88.08237,0.0104 162.08765,-59.98226 185.27132,-140.87616 20.15377,42.83411 63.13709,73.20937 113.27856,73.21606 69.07142,0.0148 125.8571,-56.77567 125.84673,-125.8465 -0.007,-69.0611 -56.78567,-125.83323 -125.84673,-125.81949 -50.14147,0.007 -93.15227,30.37531 -113.29925,73.20941 C 675.30294,379.04085 601.31136,319.059 513.24256,319.059 Z m 0,73.85529 c 66.51081,0 119.64472,53.11325 119.6515,119.63098 0,66.52058 -53.13031,119.65777 -119.6515,119.65089 -66.51039,0 -119.63049,-53.1373 -119.6236,-119.65089 0.007,-66.51085 53.11321,-119.62424 119.6236,-119.62424 z m -299.8689,67.66678 c 29.14065,0.007 51.95713,22.82665 51.95713,51.9642 0.007,29.14064 -22.81648,51.98411 -51.95713,51.991 -29.14097,-0.007 -51.9677,-22.85036 -51.95746,-51.991 0,-29.14098 22.81649,-51.95747 51.95746,-51.95747 z m 598.42566,0 c 29.14103,0 51.98456,22.81646 51.99132,51.9642 0,29.15101 -22.84028,51.991 -51.99132,51.991 -29.14102,-0.007 -51.96716,-22.85036 -51.95707,-51.991 0,-29.14098 22.81605,-51.95747 51.95707,-51.95747 z"
+   color="#000"
+   white-space="normal"
+   id="path18" /></svg>

+ 8 - 2
Widget/Nextcloud/NextcloudWidgetProvider.swift

@@ -35,8 +35,14 @@ struct NextcloudWidgetProvider: TimelineProvider {
     }
 
     func getSnapshot(in context: Context, completion: @escaping (Entry) -> Void) {
-        getDataEntry(isPreview: context.isPreview, displaySize: context.displaySize) { entry in
-            completion(entry)
+        if context.isPreview {
+            let num: Int = Int((context.displaySize.height - 150) / 40) - 1
+            let recentDatasPlaceholder = Array(recentDatasTest[0...num])
+            completion(Entry(date: Date(), recentDatas: recentDatasPlaceholder, isPlaceholder: true, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " widget"))
+        } else {
+            getDataEntry(isPreview: context.isPreview, displaySize: context.displaySize) { entry in
+                completion(entry)
+            }
         }
     }
 

+ 2 - 2
Widget/Nextcloud/NextcloudWidgetView.swift

@@ -58,7 +58,7 @@ struct NextcloudWidgetView: View {
                                             .fontWeight(.bold)
                                         Text(element.subTitle)
                                             .font(.system(size: CGFloat(10)))
-                                            .foregroundColor(Color(white: 0.4745))
+                                            .foregroundColor(Color(white: 0.5))
                                         Divider()
                                     }
                                     Spacer()
@@ -130,7 +130,7 @@ struct NextcloudWidgetView: View {
                         .resizable()
                         .scaledToFit()
                         .frame(width: 15, height: 15)
-                        .foregroundColor(Color(NCBrandColor.shared.brand))
+                        .foregroundColor(entry.isPlaceholder ? Color(white: 0.2) : Color(NCBrandColor.shared.brand))
                     Text(entry.footerText)
                         .font(.caption2)
                         .padding(.trailing, 13.0)