Add CoreData

This commit is contained in:
2023-01-13 19:12:23 +01:00
parent ee03888990
commit 94bb75bef8
8 changed files with 288 additions and 20 deletions
+39 -19
View File
@@ -8,31 +8,51 @@
import SwiftUI
struct ContentView: View {
@State private var user: User?
var body: some View {
TabView {
Dashboard()
// Badge can show e.g. number of notifications or new posts
//.badge(2)
.tabItem {
Label("dashboard".localized(tableName: "General"), systemImage: "house.fill")
}
People()
.tabItem {
Label("people".localized(tableName: "General"), systemImage: "person.3.fill")
}
Spaces()
.tabItem {
Label("spaces".localized(tableName: "General"), systemImage: "circle.circle")
}
Profile()
.tabItem{
Label("profile".localized(tableName: "General"), systemImage: "person")
}
if(self.userInfoPresent()) {
TabView {
Dashboard()
// Badge can show e.g. number of notifications or new posts
//.badge(2)
.tabItem {
Label("dashboard".localized(tableName: "General"), systemImage: "house.fill")
}
People()
.tabItem {
Label("people".localized(tableName: "General"), systemImage: "person.3.fill")
}
Spaces()
.tabItem {
Label("spaces".localized(tableName: "General"), systemImage: "circle.circle")
}
Profile()
.tabItem{
Label("profile".localized(tableName: "General"), systemImage: "person")
}
}
} else {
Login()
}
}
}
extension ContentView {
func userInfoPresent() -> Bool {
let users = User.getAll()
if(users.count < 1) {
return false
}
let user: User = users[0]
print("Users: ")
print(user)
self.user = user
return true
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
+3
View File
@@ -9,9 +9,12 @@ import SwiftUI
@main
struct FirebonkApp: App {
let persistenceController = PersistenceController.shared
var body: some Scene {
WindowGroup {
ContentView()
.environment(\.managedObjectContext, persistenceController.context)
}
}
}