💄 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,45 +14,61 @@ struct LecturePlanItem: View {
var body: some View { var body: some View {
VStack { VStack {
VStack {
Text(event.value(forKey: "summary") as! String)
.font(.title3)
.frame(maxWidth: .infinity, alignment: .leading)
HStack { HStack {
VStack(alignment: .leading) { Spacer()
Text("When") VStack {
Text("Where") Text(event.value(forKey: "summary") as! String)
} .font(.title3)
VStack(alignment: .leading) { .frame(maxWidth: .infinity, alignment: .leading)
Text(getDateAsString(date: event.value(forKey: "startDate") as! Date) ) Text(event.value(forKey: "descr") as! String)
.bold() .bold()
Text(event.value(forKey: "location") as! String) .frame(maxWidth: .infinity, alignment: .leading)
.bold() Divider()
}.frame(maxWidth: .infinity, alignment: .leading) HStack {
} VStack(alignment: .leading) {
} Text("When")
.padding() Text("Where")
.background( Text("Who")
RoundedRectangle(cornerRadius: 10) }
.fill(Color.gray) VStack(alignment: .leading) {
) Text(getDateAndTimeAsString(date: event.value(forKey: "startDate") as! Date)
Spacer() + " to "
Text(event.value(forKey: "summary") as! String) + getTimeAsString(date: event.value(forKey: "endDate") as! Date))
Button(action: { .bold()
event.setValue(!isHidden, forKey: "isHidden") Text(event.value(forKey: "location") as! String)
self.isHidden = !isHidden .bold()
PersistenceController.shared.save() Text(event.value(forKey: "location") as! String)
}){ .bold()
if(self.isHidden){ }.frame(maxWidth: .infinity, alignment: .leading)
Text("Show") }
} else { Divider()
Text("Hide") HStack {
Button(action: {
event.setValue(!isHidden, forKey: "isHidden")
self.isHidden = !isHidden
PersistenceController.shared.save()
}){
if(self.isHidden){
Text("Show")
} else {
Text("Hide")
}
}
.padding()
.foregroundColor(.white)
.background(Color.blue)
.cornerRadius(15)
Spacer()
}
} }
.padding()
.background(
RoundedRectangle(cornerRadius: 10)
.fill(Color.gray)
)
Spacer()
} }
.padding() .frame(maxWidth: .infinity)
.foregroundColor(.white)
.background(Color.blue)
.cornerRadius(15)
Spacer() Spacer()
} }
.onAppear{ .onAppear{
@ -61,9 +77,18 @@ struct LecturePlanItem: View {
} }
} }
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)
} }