diff --git a/BsuirUI/PairView.swift b/BsuirUI/PairView.swift index 597db8b4..43ff1e60 100644 --- a/BsuirUI/PairView.swift +++ b/BsuirUI/PairView.swift @@ -28,7 +28,8 @@ public struct PairCell: View { public var body: some View { pair - .padding(.horizontal) + .padding(.leading) + .padding(.trailing, 4) .padding(.vertical, 8) .background( RoundedRectangle(cornerRadius: 8) @@ -144,7 +145,7 @@ public struct PairView: View { private var subtitle: some View { Group { if isCompact { - combineTexts(auditoryText, noteText).lineLimit(2) + combineTexts(auditoryText, noteText).lineLimit(1) } else { VStack(alignment: .leading) { auditoryText diff --git a/ScheduleWidget/ScheduleWidget.swift b/ScheduleWidget/ScheduleWidget.swift index f7f585a5..3948a450 100644 --- a/ScheduleWidget/ScheduleWidget.swift +++ b/ScheduleWidget/ScheduleWidget.swift @@ -96,7 +96,7 @@ struct ScheduleWidgetEntrySmallView : View { HStack { Image("BsuirSymbol").resizable().scaledToFit().frame(width: 20, height: 20) Text(entry.title).font(.subheadline).lineLimit(1) - Spacer() + Spacer(minLength: 0) } Text("Сегодня 24.09").font(.headline).foregroundColor(.blue) @@ -131,8 +131,9 @@ struct ScheduleWidgetEntrySmallView : View { struct ScheduleWidgetEntryMediumView : View { var entry: Provider.Entry - var pair: Provider.Entry.Pair { entry.pairs.first! } - var pairs: ArraySlice { entry.pairs.dropFirst() } + var pair: Provider.Entry.Pair { entry.pairs[0] } + var secondPair: Provider.Entry.Pair { entry.pairs[1] } + var pairs: ArraySlice { entry.pairs.dropFirst(2) } var body: some View { VStack(alignment: .leading, spacing: 2) { @@ -141,6 +142,7 @@ struct ScheduleWidgetEntryMediumView : View { Spacer() Image("BsuirSymbol").resizable().scaledToFit().frame(width: 20, height: 20) Text(entry.title).font(.subheadline).lineLimit(1) + } Spacer().frame(height: 4) @@ -161,11 +163,11 @@ struct ScheduleWidgetEntryMediumView : View { ) PairView( - from: pair.from, - to: pair.to, - subject: pair.title, + from: secondPair.from, + to: secondPair.to, + subject: secondPair.title, subgroup: "1", - auditory: pair.subtitle, + auditory: secondPair.subtitle, note: "asasasas as asas", form: .lecture, progress: PairProgress(constant: 0.5), @@ -189,6 +191,53 @@ struct ScheduleWidgetEntryMediumView : View { } } +struct ScheduleWidgetEntryLargeView : View { + var entry: Provider.Entry + + var body: some View { + VStack(alignment: .leading, spacing: 6) { + HStack { + Text("Сегодня, 24.09").font(.headline).foregroundColor(.blue) + Spacer() + Image("BsuirSymbol").resizable().scaledToFit().frame(width: 20, height: 20) + Text(entry.title).font(.subheadline).lineLimit(1) + } + + VStack(alignment: .leading, spacing: 8) { + ForEach(entry.pairs.prefix(6), id: \.title) { pair in + PairView( + from: pair.from, + to: pair.to, + subject: pair.title, + subgroup: "1", + auditory: pair.subtitle, + note: "asasasas as asa as asassaa asas as s", + form: .lecture, + progress: PairProgress(constant: 0.5), + isCompact: true + ) + .padding(.leading, 10) + .padding(.vertical, 4) + .background(ContainerRelativeShape().foregroundColor(Color(.secondarySystemBackground))) + } +// +// if !pairs.isEmpty { +// HStack { +// Text("12:00").font(.system(.footnote, design: .monospaced)) +// Circle().frame(width: 8, height: 8) +// Text(listFormatter.string(from: pairs.map { $0.title }, visibleCount: 3) ?? "") +// .font(.footnote) +// }.foregroundColor(.secondary) +// } + } + + Spacer(minLength: 0) + } + .padding() + .background(Color(.systemBackground)) + } +} + struct ScheduleWidgetEntryView: View { let entry: Provider.Entry @Environment(\.widgetFamily) var size @@ -199,6 +248,8 @@ struct ScheduleWidgetEntryView: View { ScheduleWidgetEntrySmallView(entry: entry) case .systemMedium: ScheduleWidgetEntryMediumView(entry: entry) + case .systemLarge: + ScheduleWidgetEntryLargeView(entry: entry) default: EmptyView() } @@ -230,11 +281,14 @@ struct ScheduleWidget_Previews: PreviewProvider { ScheduleWidgetEntryView(entry: entry) .previewContext(WidgetPreviewContext(family: .systemMedium)) + + ScheduleWidgetEntryView(entry: entry) + .previewContext(WidgetPreviewContext(family: .systemLarge)) } static let entry = ScheduleEntry( date: Date(), - title: "010102", + title: "Иванов А.Н.", pairs: [ .init(from: "10:00", to: "11:45", title: "Философ", subtitle: "101-2"), .init(from: "10:00", to: "11:45", title: "Миапр", subtitle: "101-2"),