|
@@ -32,10 +32,25 @@ struct DashboardWidgetView: View {
|
|
|
|
|
|
GeometryReader { geo in
|
|
|
|
|
|
+ if entry.isEmpty {
|
|
|
+ VStack(alignment: .center) {
|
|
|
+ Image(systemName: "checkmark")
|
|
|
+ .resizable()
|
|
|
+ .scaledToFit()
|
|
|
+ .frame(width: 50, height: 50)
|
|
|
+ Text(NSLocalizedString("_no_items_", comment: ""))
|
|
|
+ .font(.system(size: 25))
|
|
|
+ .padding()
|
|
|
+ Text(NSLocalizedString("_check_back_late_", comment: ""))
|
|
|
+ .font(.system(size: 15))
|
|
|
+ }
|
|
|
+ .frame(width: geo.size.width, height: geo.size.height)
|
|
|
+ }
|
|
|
+
|
|
|
ZStack(alignment: .topLeading) {
|
|
|
|
|
|
HStack() {
|
|
|
-
|
|
|
+
|
|
|
Image(uiImage: entry.titleImage)
|
|
|
.renderingMode(.template)
|
|
|
.resizable()
|
|
@@ -51,88 +66,91 @@ struct DashboardWidgetView: View {
|
|
|
}
|
|
|
.frame(width: geo.size.width - 20)
|
|
|
.padding([.top, .leading, .trailing], 10)
|
|
|
-
|
|
|
- VStack(alignment: .leading) {
|
|
|
-
|
|
|
- VStack(spacing: 0) {
|
|
|
-
|
|
|
- ForEach(entry.datas, id: \.id) { element in
|
|
|
-
|
|
|
- Link(destination: element.link) {
|
|
|
-
|
|
|
- HStack {
|
|
|
-
|
|
|
- let subTitleColor = Color(white: 0.5)
|
|
|
-
|
|
|
- if entry.isPlaceholder {
|
|
|
- Circle()
|
|
|
- .fill(Color(.systemGray4))
|
|
|
- .frame(width: 35, height: 35)
|
|
|
- } else if let color = element.imageColor {
|
|
|
- Image(uiImage: element.icon)
|
|
|
- .renderingMode(.template)
|
|
|
- .resizable()
|
|
|
- .frame(width: 20, height: 20)
|
|
|
- .foregroundColor(Color(color))
|
|
|
- } else if element.template {
|
|
|
- if entry.dashboard?.itemIconsRound ?? false {
|
|
|
+
|
|
|
+ if !entry.isEmpty {
|
|
|
+
|
|
|
+ VStack(alignment: .leading) {
|
|
|
+
|
|
|
+ VStack(spacing: 0) {
|
|
|
+
|
|
|
+ ForEach(entry.datas, id: \.id) { element in
|
|
|
+
|
|
|
+ Link(destination: element.link) {
|
|
|
+
|
|
|
+ HStack {
|
|
|
+
|
|
|
+ let subTitleColor = Color(white: 0.5)
|
|
|
+
|
|
|
+ if entry.isPlaceholder {
|
|
|
+ Circle()
|
|
|
+ .fill(Color(.systemGray4))
|
|
|
+ .frame(width: 35, height: 35)
|
|
|
+ } else if let color = element.imageColor {
|
|
|
Image(uiImage: element.icon)
|
|
|
.renderingMode(.template)
|
|
|
.resizable()
|
|
|
- .scaledToFill()
|
|
|
.frame(width: 20, height: 20)
|
|
|
- .foregroundColor(.white)
|
|
|
- .padding(8)
|
|
|
- .background(Color(.systemGray4))
|
|
|
- .clipShape(Circle())
|
|
|
- } else {
|
|
|
- Image(uiImage: element.icon)
|
|
|
- .renderingMode(.template)
|
|
|
- .resizable()
|
|
|
- .scaledToFill()
|
|
|
- .frame(width: 25, height: 25)
|
|
|
- .clipped()
|
|
|
- .cornerRadius(5)
|
|
|
- }
|
|
|
- } else {
|
|
|
- if entry.dashboard?.itemIconsRound ?? false || element.avatar {
|
|
|
- Image(uiImage: element.icon)
|
|
|
- .resizable()
|
|
|
- .scaledToFill()
|
|
|
- .frame(width: 35, height: 35)
|
|
|
- .clipShape(Circle())
|
|
|
+ .foregroundColor(Color(color))
|
|
|
+ } else if element.template {
|
|
|
+ if entry.dashboard?.itemIconsRound ?? false {
|
|
|
+ Image(uiImage: element.icon)
|
|
|
+ .renderingMode(.template)
|
|
|
+ .resizable()
|
|
|
+ .scaledToFill()
|
|
|
+ .frame(width: 20, height: 20)
|
|
|
+ .foregroundColor(.white)
|
|
|
+ .padding(8)
|
|
|
+ .background(Color(.systemGray4))
|
|
|
+ .clipShape(Circle())
|
|
|
+ } else {
|
|
|
+ Image(uiImage: element.icon)
|
|
|
+ .renderingMode(.template)
|
|
|
+ .resizable()
|
|
|
+ .scaledToFill()
|
|
|
+ .frame(width: 25, height: 25)
|
|
|
+ .clipped()
|
|
|
+ .cornerRadius(5)
|
|
|
+ }
|
|
|
} else {
|
|
|
- Image(uiImage: element.icon)
|
|
|
- .resizable()
|
|
|
- .scaledToFill()
|
|
|
- .frame(width: 35, height: 35)
|
|
|
- .clipped()
|
|
|
- .cornerRadius(5)
|
|
|
+ if entry.dashboard?.itemIconsRound ?? false || element.avatar {
|
|
|
+ Image(uiImage: element.icon)
|
|
|
+ .resizable()
|
|
|
+ .scaledToFill()
|
|
|
+ .frame(width: 35, height: 35)
|
|
|
+ .clipShape(Circle())
|
|
|
+ } else {
|
|
|
+ Image(uiImage: element.icon)
|
|
|
+ .resizable()
|
|
|
+ .scaledToFill()
|
|
|
+ .frame(width: 35, height: 35)
|
|
|
+ .clipped()
|
|
|
+ .cornerRadius(5)
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- VStack(alignment: .leading, spacing: 2) {
|
|
|
+ VStack(alignment: .leading, spacing: 2) {
|
|
|
|
|
|
- Text(element.title)
|
|
|
- .font(.system(size: 12))
|
|
|
- .fontWeight(.regular)
|
|
|
+ Text(element.title)
|
|
|
+ .font(.system(size: 12))
|
|
|
+ .fontWeight(.regular)
|
|
|
|
|
|
- Text(element.subTitle)
|
|
|
- .font(.system(size: CGFloat(10)))
|
|
|
- .foregroundColor(subTitleColor)
|
|
|
+ Text(element.subTitle)
|
|
|
+ .font(.system(size: CGFloat(10)))
|
|
|
+ .foregroundColor(subTitleColor)
|
|
|
+ }
|
|
|
+ Spacer()
|
|
|
}
|
|
|
- Spacer()
|
|
|
+ .padding(.leading, 10)
|
|
|
+ .frame(height: 50)
|
|
|
}
|
|
|
- .padding(.leading, 10)
|
|
|
- .frame(height: 50)
|
|
|
+ Divider()
|
|
|
+ .padding(.leading, 54)
|
|
|
}
|
|
|
- Divider()
|
|
|
- .padding(.leading, 54)
|
|
|
}
|
|
|
}
|
|
|
+ .padding(.top, 35)
|
|
|
+ .redacted(reason: entry.isPlaceholder ? .placeholder : [])
|
|
|
}
|
|
|
- .padding(.top, 35)
|
|
|
- .redacted(reason: entry.isPlaceholder ? .placeholder : [])
|
|
|
|
|
|
if let buttons = entry.buttons, !buttons.isEmpty, !entry.isPlaceholder {
|
|
|
|
|
@@ -181,7 +199,7 @@ struct DashboardWidget_Previews: PreviewProvider {
|
|
|
let datas = Array(dashboardDatasTest[0...4])
|
|
|
let title = "Dashboard"
|
|
|
let titleImage = UIImage(named: "widget")!
|
|
|
- let entry = DashboardDataEntry(date: Date(), datas: datas, dashboard: nil, buttons: nil, isPlaceholder: false, titleImage: titleImage, title: title, footerImage: "checkmark.icloud", footerText: "Nextcloud widget")
|
|
|
+ let entry = DashboardDataEntry(date: Date(), datas: datas, dashboard: nil, buttons: nil, isPlaceholder: false, isEmpty: true, titleImage: titleImage, title: title, footerImage: "checkmark.icloud", footerText: "Nextcloud widget")
|
|
|
DashboardWidgetView(entry: entry).previewContext(WidgetPreviewContext(family: .systemLarge))
|
|
|
}
|
|
|
}
|