conversations-classic-ios/ConversationsClassic/View/SharedComponents/SharedTabBar.swift

79 lines
2.2 KiB
Swift
Raw Normal View History

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