mirror of
https://github.com/Mueller-Patrick/DHBW-Service-App.git
synced 2024-11-01 00:43:58 +00:00
Merge remote-tracking branch 'refs/remotes/origin/main'
This commit is contained in:
commit
1d209aae42
|
@ -63,10 +63,14 @@ struct PersistenceController {
|
||||||
static var preview: PersistenceController = {
|
static var preview: PersistenceController = {
|
||||||
let result = PersistenceController(inMemory: true)
|
let result = PersistenceController(inMemory: true)
|
||||||
let viewContext = result.container.viewContext
|
let viewContext = result.container.viewContext
|
||||||
for _ in 0..<10 {
|
|
||||||
let newItem = Item(context: viewContext)
|
// set mock user
|
||||||
newItem.timestamp = Date()
|
let entity = NSEntityDescription.entity(forEntityName: "User", in: PersistenceController.shared.context)!
|
||||||
}
|
let user = NSManagedObject(entity: entity, insertInto: PersistenceController.shared.context)
|
||||||
|
user.setValue("Max Mustermann", forKey: "name")
|
||||||
|
user.setValue("TINF19B4", forKey: "course")
|
||||||
|
user.setValue("Dr. Mustermann", forKey: "director")
|
||||||
|
|
||||||
do {
|
do {
|
||||||
try viewContext.save()
|
try viewContext.save()
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
@ -14,7 +14,9 @@ struct ContentView: View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Group {
|
Group {
|
||||||
if(!settings.isFirstOpening) {
|
if(settings.isFirstOpening) {
|
||||||
|
FirstOpeningSettings()
|
||||||
|
} else {
|
||||||
TabView(selection: $selection) {
|
TabView(selection: $selection) {
|
||||||
HomeView()
|
HomeView()
|
||||||
.tabItem {
|
.tabItem {
|
||||||
|
@ -24,9 +26,15 @@ struct ContentView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.tag(0)
|
.tag(0)
|
||||||
|
HomeView()
|
||||||
|
.tabItem {
|
||||||
|
VStack {
|
||||||
|
Image(systemName: "gear")
|
||||||
|
Text("Settings")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.tag(1)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
FirstOpeningSettings()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,9 +44,17 @@ extension ContentView{
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ContentView_Previews: PreviewProvider {
|
struct ContentView_Previews: PreviewProvider {
|
||||||
|
|
||||||
|
static func getFirstOpening() -> LocalSettings {
|
||||||
|
let settings = LocalSettings();
|
||||||
|
settings.isFirstOpening = false;
|
||||||
|
return settings
|
||||||
|
}
|
||||||
|
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
ContentView()
|
ContentView()
|
||||||
.preferredColorScheme(.dark)
|
.preferredColorScheme(.dark)
|
||||||
.environmentObject(LocalSettings())
|
.environmentObject(getFirstOpening())
|
||||||
|
.environment(\.managedObjectContext, PersistenceController.preview.container.viewContext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user