62 lines
1.6 KiB
Swift
62 lines
1.6 KiB
Swift
//
|
|
// ContentView.swift
|
|
// Firebonk
|
|
//
|
|
// Created by Patrick Müller on 12.01.23.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct ContentView: View {
|
|
@State private var user: User?
|
|
|
|
var body: some View {
|
|
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()
|
|
.preferredColorScheme(.dark)
|
|
}
|
|
}
|