💄 Changed Lecture Item

This commit is contained in:
David Huh 2021-02-07 21:17:08 +01:00
parent a3871f87da
commit e5ecb6bb60

View File

@ -14,30 +14,35 @@ struct LecturePlanItem: View {
var body: some View { var body: some View {
VStack { VStack {
HStack {
Spacer()
VStack { VStack {
Text(event.value(forKey: "summary") as! String) Text(event.value(forKey: "summary") as! String)
.font(.title3) .font(.title3)
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
Text(event.value(forKey: "descr") as! String)
.bold()
.frame(maxWidth: .infinity, alignment: .leading)
Divider()
HStack { HStack {
VStack(alignment: .leading) { VStack(alignment: .leading) {
Text("When") Text("When")
Text("Where") Text("Where")
Text("Who")
} }
VStack(alignment: .leading) { VStack(alignment: .leading) {
Text(getDateAsString(date: event.value(forKey: "startDate") as! Date) ) Text(getDateAndTimeAsString(date: event.value(forKey: "startDate") as! Date)
+ " to "
+ getTimeAsString(date: event.value(forKey: "endDate") as! Date))
.bold()
Text(event.value(forKey: "location") as! String)
.bold() .bold()
Text(event.value(forKey: "location") as! String) Text(event.value(forKey: "location") as! String)
.bold() .bold()
}.frame(maxWidth: .infinity, alignment: .leading) }.frame(maxWidth: .infinity, alignment: .leading)
} }
} Divider()
.padding() HStack {
.background(
RoundedRectangle(cornerRadius: 10)
.fill(Color.gray)
)
Spacer()
Text(event.value(forKey: "summary") as! String)
Button(action: { Button(action: {
event.setValue(!isHidden, forKey: "isHidden") event.setValue(!isHidden, forKey: "isHidden")
self.isHidden = !isHidden self.isHidden = !isHidden
@ -55,15 +60,35 @@ struct LecturePlanItem: View {
.cornerRadius(15) .cornerRadius(15)
Spacer() Spacer()
} }
}
.padding()
.background(
RoundedRectangle(cornerRadius: 10)
.fill(Color.gray)
)
Spacer()
}
.frame(maxWidth: .infinity)
Spacer()
}
.onAppear{ .onAppear{
self.isHidden = event.value(forKey: "isHidden") as! Bool self.isHidden = event.value(forKey: "isHidden") as! Bool
} }
} }
} }
func getDateAsString(date: Date) -> String { func getDateAndTimeAsString(date: Date) -> String {
let formatter = DateFormatter() let formatter = DateFormatter()
formatter.dateStyle = .short formatter.dateStyle = .short
formatter.timeStyle = .short
return formatter.string(from: date)
}
func getTimeAsString(date: Date) -> String {
let formatter = DateFormatter()
formatter.timeStyle = .short
return formatter.string(from: date) return formatter.string(from: date)
} }