mirror of
https://github.com/Mueller-Patrick/DHBW-Service-App.git
synced 2026-04-28 18:30:09 +00:00
✨ Added base for lecture plan view
This commit is contained in:
@@ -36,7 +36,7 @@ struct HomeView: View {
|
||||
|
||||
extension HomeView{
|
||||
func readFromCoreData() {
|
||||
let fetchedData = UtilityFunctions.getCoreDataObject(entity: "User")
|
||||
let fetchedData = UtilityFunctions.getCoreDataObject(entity: "User", sortDescriptors: [])
|
||||
|
||||
if(!fetchedData.isEmpty) {
|
||||
let user = fetchedData[0]
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// LecturePlanList.swift
|
||||
// DHBW-Service
|
||||
//
|
||||
// Created by Patrick Müller on 30.01.21.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import CoreData
|
||||
|
||||
struct LecturePlanList: View {
|
||||
@State private var events: [NSManagedObject] = []
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
ForEach(events, id: \.self) { event in
|
||||
HStack {
|
||||
Text(formatDate(date: event.value(forKeyPath: "startDate") as! Date))
|
||||
Text(event.value(forKeyPath: "summary") as! String)
|
||||
}
|
||||
}
|
||||
}.onAppear{
|
||||
let sectionSortDescriptor = NSSortDescriptor(key: "startDate", ascending: true)
|
||||
let sortDescriptors = [sectionSortDescriptor]
|
||||
self.events = UtilityFunctions.getCoreDataObject(entity: "RaPlaEvent", sortDescriptors: sortDescriptors)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct LecturePlanList_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
LecturePlanList()
|
||||
}
|
||||
}
|
||||
|
||||
extension LecturePlanList {
|
||||
private func formatDate(date: Date) -> String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .short
|
||||
return formatter.string(from: date)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user