Add CoreData
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -9,9 +9,12 @@ import SwiftUI
|
||||
|
||||
@main
|
||||
struct FirebonkApp: App {
|
||||
let persistenceController = PersistenceController.shared
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
.environment(\.managedObjectContext, persistenceController.context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user