Browse Source

Improved Dashboard

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

+ 2 - 0
Nextcloud.xcodeproj/project.pbxproj

@@ -168,6 +168,7 @@
 		F72EA95428B7BABA00C88F0C /* NextcloudWidgetProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = F72EA95328B7BABA00C88F0C /* NextcloudWidgetProvider.swift */; };
 		F72EA95828B7BC4F00C88F0C /* NextcloudData.swift in Sources */ = {isa = PBXBuildFile; fileRef = F72EA95728B7BC4F00C88F0C /* NextcloudData.swift */; };
 		F72EA95A28B7BD0D00C88F0C /* NextcloudWidgetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F72EA95928B7BD0D00C88F0C /* NextcloudWidgetView.swift */; };
+		F72EA95B28B7C1EE00C88F0C /* Custom.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F700222B1EC479840080073F /* Custom.xcassets */; };
 		F732D23327CF8AED000B0F1B /* NCPlayerToolBar.xib in Resources */ = {isa = PBXBuildFile; fileRef = F732D23227CF8AED000B0F1B /* NCPlayerToolBar.xib */; };
 		F733598125C1C188002ABA72 /* NCAskAuthorization.swift in Sources */ = {isa = PBXBuildFile; fileRef = F733598025C1C188002ABA72 /* NCAskAuthorization.swift */; };
 		F7346E1228B0EF5B006CE2D2 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F7346E1128B0EF5B006CE2D2 /* WidgetKit.framework */; };
@@ -2432,6 +2433,7 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				F72EA95B28B7C1EE00C88F0C /* Custom.xcassets in Resources */,
 				F7346E2328B0FEBA006CE2D2 /* Assets.xcassets in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;

+ 7 - 6
Widget/Dashboard/DashboardWidgetView.swift

@@ -44,7 +44,7 @@ import WidgetKit
 struct DashboardWidgetView: View {
     var entry: DashboardDataEntry
     var body: some View {
-        ZStack {
+        ZStack(alignment: .top) {
             VStack {
                 Text(entry.title)
                     .font(.title3)
@@ -74,11 +74,12 @@ struct DashboardWidgetView: View {
                 }
             }.padding(5)
                 .redacted(reason: entry.isPlaceholder ? .placeholder : [])
-            }
-        Text(entry.footerText)
-                .font(.caption2)
-                .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomTrailing)
-                .padding([.bottom, .trailing], 5.0)
+            Text(entry.footerText)
+                    .font(.caption2)
+                    .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomTrailing)
+                    .padding(.trailing, 10.0)
+                    .padding(.bottom, 5.0)
+        }
     }
 }
 

+ 1 - 2
Widget/Nextcloud/NextcloudData.swift

@@ -43,8 +43,7 @@ let nextcloudDatasTest: [NextcloudData] = [
     .init(id: 0, image: "nextcloud", title: "title 1", subTitle: "subTitle - description 1", url: URL(string: "https://nextcloud.com/")!),
     .init(id: 1, image: "nextcloud", title: "title 2", subTitle: "subTitle - description 2", url: URL(string: "https://nextcloud.com/")!),
     .init(id: 2, image: "nextcloud", title: "title 3", subTitle: "subTitle - description 3", url: URL(string: "https://nextcloud.com/")!),
-    .init(id: 3, image: "nextcloud", title: "title 4", subTitle: "subTitle - description 4", url: URL(string: "https://nextcloud.com/")!),
-    .init(id: 4, image: "nextcloud", title: "title 5", subTitle: "subTitle - description 5", url: URL(string: "https://nextcloud.com/")!)
+    .init(id: 3, image: "nextcloud", title: "title 4", subTitle: "subTitle - description 4", url: URL(string: "https://nextcloud.com/")!)
 ]
 
 func readNextcloudData(completion: @escaping (_ NextcloudDatas: [NextcloudData], _ isPlaceholder: Bool, _ footerText: String) -> Void) {

+ 22 - 13
Widget/Nextcloud/NextcloudWidgetView.swift

@@ -27,12 +27,20 @@ import WidgetKit
 struct NextcloudWidgetView: View {
     var entry: NextcloudDataEntry
     var body: some View {
-        ZStack {
-            VStack {
-                Text(NCBrandOptions.shared.brand)
-                    .font(.title3)
-                    .bold()
-                    .fixedSize(horizontal: false, vertical: true)
+        ZStack(alignment: .top) {
+            HStack(spacing: 5) {
+                Image("nextcloud")
+                    .resizable()
+                    .scaledToFit()
+                    .frame(width: 10, height: 10)
+                    .cornerRadius(3)
+                Text(NCBrandOptions.shared.brand + "k")
+                    .font(.system(size: 12))
+                    .textCase(.uppercase)
+            }
+            .padding(.leading, 5)
+            .padding(.bottom, 5)
+            VStack(alignment: .leading, spacing: 5) {
                 VStack(spacing: 5) {
                     ForEach(entry.nextcloudDatas, id: \.id) { element in
                         Link(destination: element.url) {
@@ -55,19 +63,20 @@ struct NextcloudWidgetView: View {
                         }
                     }
                 }
-            }.padding(5)
+            }.padding(.top, 5)
                 .redacted(reason: entry.isPlaceholder ? .placeholder : [])
-            }
-        Text(entry.footerText)
-                .font(.caption2)
-                .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomTrailing)
-                .padding([.bottom, .trailing], 5.0)
+            Text(entry.footerText)
+                    .font(.caption2)
+                    .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomTrailing)
+                    .padding(.trailing, 10.0)
+                    .padding(.bottom, 5.0)
+        }
     }
 }
 
 struct NextcloudWidget_Previews: PreviewProvider {
     static var previews: some View {
-        let entry = NextcloudDataEntry(date: Date(), nextcloudDatas: nextcloudDatasTest, isPlaceholder: false, footerText: "Nextcloud Dashboard")
+        let entry = NextcloudDataEntry(date: Date(), nextcloudDatas: nextcloudDatasTest, isPlaceholder: false, footerText: "Nextcloud widget")
         NextcloudWidgetView(entry: entry).previewContext(WidgetPreviewContext(family: .systemLarge))
     }
 }