Browse Source

coding

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 years ago
parent
commit
0befb9cca7

+ 9 - 8
Widget/Dashboard/DashboardData.swift

@@ -30,6 +30,7 @@ let dashboaardItems = 5
 struct DashboardDataEntry: TimelineEntry {
     let date: Date
     let datas: [DashboardData]
+    let tableDashboard: tableDashboardWidget?
     let isPlaceholder: Bool
     let titleImage: UIImage
     let title: String
@@ -85,11 +86,11 @@ func getDashboardDataEntry(intent: Applications, isPreview: Bool, displaySize: C
     }
     
     if isPreview {
-        return completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, titleImage: UIImage(named: "widget")!, title: "Dashboard", footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " dashboard"))
+        return completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, tableDashboard: nil, isPlaceholder: true, titleImage: UIImage(named: "widget")!, title: "Dashboard", footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " dashboard"))
     }
 
     guard let account = NCManageDatabase.shared.getActiveAccount() else {
-        return completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, titleImage: UIImage(named: "widget")!, title: "Dashboard", footerImage: "xmark.icloud", footerText: NSLocalizedString("_no_active_account_", value: "No account found", comment: "")))
+        return completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, tableDashboard: nil, isPlaceholder: true, titleImage: UIImage(named: "widget")!, title: "Dashboard", footerImage: "xmark.icloud", footerText: NSLocalizedString("_no_active_account_", value: "No account found", comment: "")))
     }
     
     // NETWORKING
@@ -119,12 +120,12 @@ func getDashboardDataEntry(intent: Applications, isPreview: Bool, displaySize: C
         NKCommon.shared.writeLog("Start \(NCBrandOptions.shared.brand) dashboard widget session with level \(levelLog) " + versionNextcloudiOS)
     }
     
-    let result = NCManageDatabase.shared.getDashboardWidget(account: account.account, id: id)
+    let tableDashboard = NCManageDatabase.shared.getDashboardWidget(account: account.account, id: id)
     let options = NKRequestOptions(queue: NKCommon.shared.backgroundQueue)
-    let title = result?.title ?? id
+    let title = tableDashboard?.title ?? id
     var titleImage = UIImage(named: "widget")!
 
-    if let fileName = result?.iconClass {
+    if let fileName = tableDashboard?.iconClass {
         let fileNamePath: String = CCUtility.getDirectoryUserData() + "/" + fileName + ".png"
         if let image = UIImage(contentsOfFile: fileNamePath) {
             titleImage = image.imageColor(NCBrandColor.shared.label)
@@ -178,11 +179,11 @@ func getDashboardDataEntry(intent: Applications, isPreview: Bool, displaySize: C
         }
         
         if error != .success {
-            completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, titleImage: titleImage, title: title, footerImage: "xmark.icloud", footerText: error.errorDescription))
+            completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, tableDashboard: tableDashboard, isPlaceholder: true, titleImage: titleImage, title: title, footerImage: "xmark.icloud", footerText: error.errorDescription))
         } else if datas.isEmpty {
-            completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, titleImage: titleImage, title: title, footerImage: "checkmark.icloud", footerText: NSLocalizedString("_no_data_available_", comment: "")))
+            completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, tableDashboard: tableDashboard, isPlaceholder: true, titleImage: titleImage, title: title, footerImage: "checkmark.icloud", footerText: NSLocalizedString("_no_data_available_", comment: "")))
         } else {
-            completion(DashboardDataEntry(date: Date(), datas: datas, isPlaceholder: false, titleImage: titleImage, title: title, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " dashboard"))
+            completion(DashboardDataEntry(date: Date(), datas: datas, tableDashboard: tableDashboard, isPlaceholder: false, titleImage: titleImage, title: title, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " dashboard"))
         }
     }
 }

+ 1 - 1
Widget/Dashboard/DashboardWidgetProvider.swift

@@ -34,7 +34,7 @@ struct DashboardWidgetProvider: IntentTimelineProvider {
         let datasPlaceholder = Array(dashboardDatasTest[0...dashboaardItems - 1])
         let title = "Dashboard"
         let titleImage = UIImage(named: "widget")!
-        return Entry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, titleImage: titleImage, title: title, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " widget")
+        return Entry(date: Date(), datas: datasPlaceholder, tableDashboard: nil, isPlaceholder: true, titleImage: titleImage, title: title, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " widget")
     }
 
     func getSnapshot(for configuration: DashboardIntent, in context: Context, completion: @escaping (DashboardDataEntry) -> Void) {

+ 1 - 1
Widget/Dashboard/DashboardWidgetView.swift

@@ -123,7 +123,7 @@ struct DashboardWidget_Previews: PreviewProvider {
         let datas = Array(dashboardDatasTest[0...dashboaardItems - 1])
         let title = "Dashboard"
         let titleImage = UIImage(named: "widget")!
-        let entry = DashboardDataEntry(date: Date(), datas: datas, isPlaceholder: false, titleImage: titleImage, title: title, footerImage: "checkmark.icloud", footerText: "Nextcloud widget")
+        let entry = DashboardDataEntry(date: Date(), datas: datas, tableDashboard: nil, isPlaceholder: false, titleImage: titleImage, title: title, footerImage: "checkmark.icloud", footerText: "Nextcloud widget")
         DashboardWidgetView(entry: entry).previewContext(WidgetPreviewContext(family: .systemLarge))
     }
 }

+ 5 - 1
Widget/Toolbar/ToolbarWidgetView.swift

@@ -34,6 +34,10 @@ struct ToolbarWidgetView: View {
 
             ZStack(alignment: .topLeading) {
 
+                // Color.init(.sRGB, red: 0.89, green: 0.89, blue: 0.89, opacity: 0.75)
+                Color(.black)
+                    .ignoresSafeArea()
+            
                 HStack(spacing: 0) {
 
                     let sizeButton: CGFloat = 65
@@ -109,7 +113,7 @@ struct ToolbarWidgetView: View {
                         .foregroundColor(entry.isPlaceholder ? placeholderColor : brandColor)
                 }
                 .frame(maxWidth: geo.size.width - 5, maxHeight: geo.size.height - 2, alignment: .bottomTrailing)
-            }.background(ContainerRelativeShape().fill(Color(.black)))
+            }
         }
     }
 }

+ 1 - 0
iOSClient/Data/NCDatabase.swift

@@ -254,6 +254,7 @@ class tableDashboardWidget: Object {
     @Persisted var iconClass: String?
     @Persisted var iconUrl: String?
     @Persisted var widgetUrl: String?
+    @Persisted var itemIconsRound: Bool = false
     let button = List<tableDashboardWidgetButton>()
 }
 

+ 2 - 1
iOSClient/Data/NCManageDatabase+DashboardWidget.swift

@@ -51,6 +51,7 @@ extension NCManageDatabase {
                     
                     let addObject = tableDashboardWidget()
                     
+                    addObject.index = account + " " + widget.id
                     addObject.account = account
                     addObject.id = widget.id
                     addObject.title = widget.title
@@ -58,7 +59,7 @@ extension NCManageDatabase {
                     addObject.iconClass = widget.iconClass
                     addObject.iconUrl = widget.iconUrl
                     addObject.widgetUrl = widget.widgetUrl
-                    addObject.index = account + " " + widget.id
+                    addObject.itemIconsRound = widget.itemIconsRound
 
                     if let buttons = widget.button {
                         for button in buttons {

+ 1 - 1
iOSClient/NCGlobal.swift

@@ -115,7 +115,7 @@ class NCGlobal: NSObject {
     // Database Realm
     //
     let databaseDefault                             = "nextcloud.realm"
-    let databaseSchemaVersion: UInt64               = 243
+    let databaseSchemaVersion: UInt64               = 244
 
     // Intro selector
     //