2020-12-21 19:28:01 +00:00
|
|
|
//
|
|
|
|
// ContentView.swift
|
|
|
|
// DHBW-Service
|
|
|
|
//
|
|
|
|
// Created by Patrick Müller on 20.12.20.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
import CoreData
|
|
|
|
|
|
|
|
struct ContentView: View {
|
2020-12-21 19:54:59 +00:00
|
|
|
@EnvironmentObject var settings: LocalSettings
|
2020-12-21 19:28:01 +00:00
|
|
|
@State private var selection = 0
|
|
|
|
|
|
|
|
var body: some View {
|
2020-12-21 19:54:59 +00:00
|
|
|
Group {
|
2020-12-23 16:13:55 +00:00
|
|
|
if(settings.isFirstOpening) {
|
|
|
|
FirstOpeningSettings()
|
|
|
|
} else {
|
2020-12-21 19:54:59 +00:00
|
|
|
TabView(selection: $selection) {
|
|
|
|
HomeView()
|
|
|
|
.tabItem {
|
|
|
|
VStack {
|
|
|
|
Image(systemName: "house.fill")
|
|
|
|
Text("Home")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.tag(0)
|
2021-01-30 22:05:44 +00:00
|
|
|
LecturePlanList()
|
|
|
|
.tabItem {
|
|
|
|
VStack {
|
|
|
|
Image(systemName: "calendar")
|
|
|
|
Text("Lecture Plan")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.tag(1)
|
2020-12-28 19:09:28 +00:00
|
|
|
SettingsMain()
|
2020-12-23 16:13:55 +00:00
|
|
|
.tabItem {
|
|
|
|
VStack {
|
|
|
|
Image(systemName: "gear")
|
|
|
|
Text("Settings")
|
|
|
|
}
|
|
|
|
}
|
2021-01-30 22:05:44 +00:00
|
|
|
.tag(2)
|
2020-12-21 19:28:01 +00:00
|
|
|
}
|
2020-12-21 19:54:59 +00:00
|
|
|
}
|
2020-12-21 19:28:01 +00:00
|
|
|
}
|
2021-01-30 22:05:44 +00:00
|
|
|
.onAppear{
|
|
|
|
// Called upon the opening of the app
|
2021-02-10 20:27:26 +00:00
|
|
|
RaPlaFetcher.getRaplaFileAndSaveToCoreData(from: "https://rapla.dhbw-karlsruhe.de/rapla?page=ical&user=eisenbiegler&file=TINF19B4")
|
2021-01-30 22:05:44 +00:00
|
|
|
}
|
2020-12-21 19:28:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-21 19:54:59 +00:00
|
|
|
extension ContentView{
|
|
|
|
}
|
|
|
|
|
2020-12-21 19:28:01 +00:00
|
|
|
struct ContentView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
ContentView()
|
|
|
|
.preferredColorScheme(.dark)
|
2021-02-07 14:51:01 +00:00
|
|
|
.previewDevice("iPhone 12")
|
2020-12-23 16:13:55 +00:00
|
|
|
.environmentObject(getFirstOpening())
|
|
|
|
.environment(\.managedObjectContext, PersistenceController.preview.container.viewContext)
|
2020-12-21 19:28:01 +00:00
|
|
|
}
|
2020-12-23 16:26:36 +00:00
|
|
|
|
|
|
|
static func getFirstOpening() -> LocalSettings {
|
|
|
|
let settings = LocalSettings();
|
|
|
|
settings.isFirstOpening = false;
|
|
|
|
return settings
|
|
|
|
}
|
2020-12-21 19:28:01 +00:00
|
|
|
}
|