another.im-ios/ConversationsClassic/View/SharedComponents/SharedTabBar.swift
2024-08-11 16:02:18 +02:00

79 lines
2.2 KiB
Swift

import SwiftUI
struct SharedTabBar: View {
var body: some View {
VStack(spacing: 0) {
Rectangle()
.frame(maxWidth: .infinity)
.frame(height: 0.2)
.foregroundColor(.Material.Shape.separator)
HStack(spacing: 0) {
SharedTabBarButton(buttonFlow: .main(.contacts(.list)))
SharedTabBarButton(buttonFlow: .main(.conversations))
SharedTabBarButton(buttonFlow: .main(.settings))
}
.background(Color.Material.Background.dark)
}
.frame(height: 50)
}
}
private struct SharedTabBarButton: View {
@EnvironmentObject var navigation: NavigationStore
let buttonFlow: NavigationStore.Flow
var body: some View {
ZStack {
VStack(spacing: 2) {
buttonImg
.foregroundColor(buttonFlow == navigation.flow ? .Material.Elements.active : .Material.Elements.inactive)
.font(.system(size: 24, weight: .light))
.symbolRenderingMode(.hierarchical)
Text(buttonTitle)
.font(.sub1)
.foregroundColor(buttonFlow == navigation.flow ? .Material.Text.main : .Material.Elements.inactive)
}
Rectangle()
.foregroundColor(.white.opacity(0.01))
.onTapGesture {
withAnimation {
navigation.flow = buttonFlow
}
}
}
}
var buttonImg: Image {
switch buttonFlow {
case .main(.contacts):
return Image(systemName: "person.2.fill")
case .main(.conversations):
return Image(systemName: "bubble.left.fill")
case .main(.settings):
return Image(systemName: "gearshape.fill")
default:
return Image(systemName: "questionmark.circle")
}
}
var buttonTitle: String {
switch buttonFlow {
case .main(.contacts(.list)):
return "Contacts"
case .main(.conversations):
return "Chats"
case .main(.settings):
return "Settings"
default:
return "Unknown"
}
}
}