2023-01-12 22:07:37 +00:00
|
|
|
//
|
|
|
|
// ContentView.swift
|
|
|
|
// Firebonk
|
|
|
|
//
|
|
|
|
// Created by Patrick Müller on 12.01.23.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct ContentView: View {
|
2023-01-13 18:12:23 +00:00
|
|
|
@State private var user: User?
|
2023-01-12 22:07:37 +00:00
|
|
|
|
|
|
|
var body: some View {
|
2023-01-13 18:12:23 +00:00
|
|
|
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()
|
2023-01-12 22:07:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-13 18:12:23 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-12 22:07:37 +00:00
|
|
|
struct ContentView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
ContentView()
|
|
|
|
.preferredColorScheme(.dark)
|
|
|
|
}
|
|
|
|
}
|