conversations-classic-ios/ConversationsClassic/View/Screens/Attachments/AttachmentTabBar.swift
2024-07-02 11:56:27 +02:00

86 lines
2.3 KiB
Swift

import SwiftUI
enum AttachmentTab: Int, CaseIterable {
case media
case files
case location
case contacts
}
struct AttachmentTabBar: View {
@Binding var selectedTab: AttachmentTab
var body: some View {
VStack(spacing: 0) {
Rectangle()
.frame(maxWidth: .infinity)
.frame(height: 0.2)
.foregroundColor(.Main.separator)
HStack(spacing: 0) {
AttachmentTabBarButton(tab: .media, selected: $selectedTab)
AttachmentTabBarButton(tab: .files, selected: $selectedTab)
AttachmentTabBarButton(tab: .location, selected: $selectedTab)
AttachmentTabBarButton(tab: .contacts, selected: $selectedTab)
}
.background(Color.Main.backgroundDark)
}
.frame(height: 50)
}
}
private struct AttachmentTabBarButton: View {
let tab: AttachmentTab
@Binding var selected: AttachmentTab
var body: some View {
ZStack {
VStack(spacing: 2) {
buttonImg
.foregroundColor(selected == tab ? .Material.greenDark500 : .Main.gray)
.font(.system(size: 24, weight: .light))
.symbolRenderingMode(.hierarchical)
Text(buttonTitle)
.font(.sub1)
.foregroundColor(selected == tab ? .Main.black : .Main.gray)
}
Rectangle()
.foregroundColor(.white.opacity(0.01))
.onTapGesture {
selected = tab
}
}
}
var buttonImg: Image {
switch tab {
case .media:
return Image(systemName: "photo.on.rectangle.angled")
case .files:
return Image(systemName: "doc.on.doc")
case .location:
return Image(systemName: "location.circle")
case .contacts:
return Image(systemName: "person.crop.circle")
}
}
var buttonTitle: String {
switch tab {
case .media:
return L10n.Attachment.Tab.media
case .files:
return L10n.Attachment.Tab.files
case .location:
return L10n.Attachment.Tab.location
case .contacts:
return L10n.Attachment.Tab.contacts
}
}
}