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:
@@ -26,6 +26,14 @@ struct ContentView: View {
|
||||
}
|
||||
}
|
||||
.tag(0)
|
||||
LecturePlanList()
|
||||
.tabItem {
|
||||
VStack {
|
||||
Image(systemName: "calendar")
|
||||
Text("Lecture Plan")
|
||||
}
|
||||
}
|
||||
.tag(1)
|
||||
SettingsMain()
|
||||
.tabItem {
|
||||
VStack {
|
||||
@@ -33,10 +41,14 @@ struct ContentView: View {
|
||||
Text("Settings")
|
||||
}
|
||||
}
|
||||
.tag(1)
|
||||
.tag(2)
|
||||
}
|
||||
}
|
||||
}
|
||||
.onAppear{
|
||||
// Called upon the opening of the app
|
||||
RaPlaFetcher.getRaplaFileAndSaveToCoreData(from: "https://rapla.dhbw-karlsruhe.de/rapla?page=ical&user=eisenbiegler&file=TINF19B4")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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