|
@@ -26,8 +26,6 @@ import NextcloudKit
|
|
import Queuer
|
|
import Queuer
|
|
import RealmSwift
|
|
import RealmSwift
|
|
|
|
|
|
-let dashboaardItems = 5
|
|
|
|
-
|
|
|
|
struct DashboardDataEntry: TimelineEntry {
|
|
struct DashboardDataEntry: TimelineEntry {
|
|
let date: Date
|
|
let date: Date
|
|
let datas: [DashboardData]
|
|
let datas: [DashboardData]
|
|
@@ -67,9 +65,17 @@ let dashboardDatasTest: [DashboardData] = [
|
|
.init(id: 9, title: "title9", subTitle: "subTitle-description9", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!)
|
|
.init(id: 9, title: "title9", subTitle: "subTitle-description9", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!)
|
|
]
|
|
]
|
|
|
|
|
|
|
|
+func getDashboardItems(displaySize: CGSize, withButton: Bool) -> Int {
|
|
|
|
+
|
|
|
|
+ let height = Int((displaySize.height - 55) / 50)
|
|
|
|
+ return withButton ? (height - 1) : height
|
|
|
|
+}
|
|
|
|
+
|
|
func getDashboardDataEntry(intent: Applications, isPreview: Bool, displaySize: CGSize, completion: @escaping (_ entry: DashboardDataEntry) -> Void) {
|
|
func getDashboardDataEntry(intent: Applications, isPreview: Bool, displaySize: CGSize, completion: @escaping (_ entry: DashboardDataEntry) -> Void) {
|
|
|
|
|
|
- let datasPlaceholder = Array(dashboardDatasTest[0...dashboaardItems - 1])
|
|
|
|
|
|
+ let dashboardItems = getDashboardItems(displaySize: displaySize, withButton: false)
|
|
|
|
+ let datasPlaceholder = Array(dashboardDatasTest[0...dashboardItems - 1])
|
|
|
|
+
|
|
var id = "recommendations"
|
|
var id = "recommendations"
|
|
switch intent {
|
|
switch intent {
|
|
case .unknown:
|
|
case .unknown:
|
|
@@ -128,7 +134,7 @@ func getDashboardDataEntry(intent: Applications, isPreview: Bool, displaySize: C
|
|
}
|
|
}
|
|
|
|
|
|
let (tableDashboard, tableButton) = NCManageDatabase.shared.getDashboardWidget(account: account.account, id: id)
|
|
let (tableDashboard, tableButton) = NCManageDatabase.shared.getDashboardWidget(account: account.account, id: id)
|
|
- let existsButton: Int = tableButton == nil ? 0 : 1
|
|
|
|
|
|
+ let existsButton = (tableButton?.isEmpty ?? true) ? false : true
|
|
let options = NKRequestOptions(queue: NKCommon.shared.backgroundQueue)
|
|
let options = NKRequestOptions(queue: NKCommon.shared.backgroundQueue)
|
|
let title = tableDashboard?.title ?? id
|
|
let title = tableDashboard?.title ?? id
|
|
var titleImage = UIImage(named: "widget")!
|
|
var titleImage = UIImage(named: "widget")!
|
|
@@ -148,7 +154,7 @@ func getDashboardDataEntry(intent: Applications, isPreview: Bool, displaySize: C
|
|
for result in results {
|
|
for result in results {
|
|
if let items = result.items {
|
|
if let items = result.items {
|
|
var counter: Int = 0
|
|
var counter: Int = 0
|
|
- let maxCounter = dashboaardItems - existsButton
|
|
|
|
|
|
+ let dashboardItems = getDashboardItems(displaySize: displaySize, withButton: existsButton)
|
|
for item in items {
|
|
for item in items {
|
|
counter += 1
|
|
counter += 1
|
|
let title = item.title ?? ""
|
|
let title = item.title ?? ""
|
|
@@ -181,7 +187,7 @@ func getDashboardDataEntry(intent: Applications, isPreview: Bool, displaySize: C
|
|
let data = DashboardData(id: counter, title: title, subTitle: subtitle, link: link, icon: icon)
|
|
let data = DashboardData(id: counter, title: title, subTitle: subtitle, link: link, icon: icon)
|
|
datas.append(data)
|
|
datas.append(data)
|
|
|
|
|
|
- if datas.count == maxCounter { break }
|
|
|
|
|
|
+ if datas.count == dashboardItems { break }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|