add large widget
This commit is contained in:
@@ -123,9 +123,9 @@ struct FeelsWidgetEntryView : View {
|
||||
case .systemMedium:
|
||||
MediumWidgetView(entry: entry)
|
||||
case .systemLarge:
|
||||
MediumWidgetView(entry: entry)
|
||||
LargeWidgetView(entry: entry)
|
||||
case .systemExtraLarge:
|
||||
MediumWidgetView(entry: entry)
|
||||
LargeWidgetView(entry: entry)
|
||||
@unknown default:
|
||||
fatalError()
|
||||
}
|
||||
@@ -187,6 +187,49 @@ struct MediumWidgetView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct LargeWidgetView: View {
|
||||
var entry: Provider.Entry
|
||||
var timeLineView = [WatchTimelineView]()
|
||||
|
||||
init(entry: Provider.Entry) {
|
||||
self.entry = entry
|
||||
timeLineView = Array(TimeLineCreator.createViews(daysBack: 11).prefix(10))
|
||||
}
|
||||
|
||||
var firstGroup: ([WatchTimelineView], String) {
|
||||
return (Array(self.timeLineView.prefix(5)), UUID().uuidString)
|
||||
}
|
||||
|
||||
var secondGroup: ([WatchTimelineView], String) {
|
||||
return (Array(self.timeLineView.suffix(5)), UUID().uuidString)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Spacer()
|
||||
|
||||
ForEach([firstGroup, secondGroup], id: \.1) { group in
|
||||
VStack {
|
||||
Spacer()
|
||||
|
||||
TimeHeaderView(startDate: group.0.first!.date, endDate: group.0.last!.date)
|
||||
.frame(minWidth: 0, maxWidth: .infinity)
|
||||
.multilineTextAlignment(.leading)
|
||||
|
||||
TimeBodyView(group: group.0)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
|
||||
.frame(minHeight: 0, maxHeight: 55)
|
||||
.padding()
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
/**********************************************************/
|
||||
struct FeelsGraphicWidgetEntryView : View {
|
||||
@Environment(\.sizeCategory) var sizeCategory
|
||||
@@ -284,40 +327,6 @@ struct TimeBodyView: View {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//struct LargeWidgetView: View {
|
||||
// var entry: Provider.Entry
|
||||
//
|
||||
// var formatter: DateFormatter {
|
||||
// let dateFormatter = DateFormatter()
|
||||
// dateFormatter.dateStyle = .medium
|
||||
// return dateFormatter
|
||||
// }
|
||||
//
|
||||
//
|
||||
// var body: some View {
|
||||
// VStack {
|
||||
// Spacer()
|
||||
//
|
||||
// ForEach([Array(self.entry.timeLineViews.prefix(5)), Array(self.entry.timeLineViews.suffix(5))]) { group in
|
||||
//
|
||||
// TimeHeaderView(startDate: group.first!, endDate: group.last!)
|
||||
// .frame(minWidth: 0, maxWidth: .infinity)
|
||||
// .multilineTextAlignment(.leading)
|
||||
//
|
||||
// TimeBodyView(group: group)
|
||||
// .clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
|
||||
// .frame(minHeight: 0, maxHeight: 55)
|
||||
// .padding()
|
||||
//
|
||||
// Spacer()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
struct EntryCard: View {
|
||||
var timeLineView: WatchTimelineView
|
||||
|
||||
@@ -350,7 +359,7 @@ struct FeelsWidget: Widget {
|
||||
}
|
||||
.configurationDisplayName("Feels")
|
||||
.description("")
|
||||
.supportedFamilies([.systemSmall, .systemMedium])
|
||||
.supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user