浏览代码

coding

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 年之前
父节点
当前提交
9b0d23bf33
共有 2 个文件被更改,包括 35 次插入1 次删除
  1. 5 1
      Widget/Dashboard/DashboardData.swift
  2. 30 0
      Widget/Dashboard/DashboardWidgetView.swift

+ 5 - 1
Widget/Dashboard/DashboardData.swift

@@ -26,7 +26,7 @@ import NextcloudKit
 import Queuer
 import RealmSwift
 
-let dashboaardItems = 5
+var dashboaardItems = 5
 
 struct DashboardDataEntry: TimelineEntry {
     let date: Date
@@ -132,6 +132,10 @@ func getDashboardDataEntry(intent: Applications, isPreview: Bool, displaySize: C
             titleImage = image.imageColor(NCBrandColor.shared.label)
         }
     }
+    
+    if tableButton?.count ?? 0 > 0 {
+        dashboaardItems -= 1
+    }
 
     NextcloudKit.shared.getDashboardWidgetsApplication(id, options: options) { account, results, data, error in
         

+ 30 - 0
Widget/Dashboard/DashboardWidgetView.swift

@@ -105,6 +105,36 @@ struct DashboardWidgetView: View {
                 .padding(.top, 40)
                 .redacted(reason: entry.isPlaceholder ? .placeholder : [])
 
+                if let tableButton = entry.tableButton, !tableButton.isEmpty {
+                    
+                    HStack(spacing: 0) {
+
+                        let sizeButton: CGFloat = 45
+                        let placeholderColor = Color(white: 0.8)
+                        let brandColor = Color(NCBrandColor.shared.brand)
+                        let brandTextColor = Color(NCBrandColor.shared.brandText)
+
+                        ForEach(tableButton, id: \.index) { element in
+                            Link(destination: entry.isPlaceholder ? NCGlobal.shared.widgetActionNoAction : NCGlobal.shared.widgetActionUploadAsset, label: {
+                                
+                                Text(element.text)
+                                    .fontWeight(.bold)
+                                    .font(.title)
+                                    .padding()
+                                    .background(Color.purple)
+                                    .foregroundColor(.white)
+                                    .padding(10)
+                                    .border(Color.purple, width: 5)
+                                    .cornerRadius(40)
+                            })
+                            
+                        }
+                    }
+                    .frame(width: geo.size.width, height: geo.size.height - 25, alignment: .bottomTrailing)
+                    .redacted(reason: entry.isPlaceholder ? .placeholder : [])
+                    
+                }
+                
                 HStack {
 
                     let placeholderColor = Color(white: 0.2)