conversations-classic-ios/ConversationsClassic/View/Screens/Sharing/SharingTabBar.swift
2024-07-13 15:58:38 +02:00

86 lines
2.3 KiB
Swift

import SwiftUI
enum SharingTab: Int, CaseIterable {
case media
case files
case location
case contacts
}
struct SharingTabBar: View {
@Binding var selectedTab: SharingTab
var body: some View {
VStack(spacing: 0) {
Rectangle()
.frame(maxWidth: .infinity)
.frame(height: 0.2)
.foregroundColor(.Material.Shape.separator)
HStack(spacing: 0) {
SharingTabBarButton(tab: .media, selected: $selectedTab)
SharingTabBarButton(tab: .files, selected: $selectedTab)
SharingTabBarButton(tab: .location, selected: $selectedTab)
SharingTabBarButton(tab: .contacts, selected: $selectedTab)
}
.background(Color.Material.Background.dark)
}
.frame(height: 50)
}
}
private struct SharingTabBarButton: View {
let tab: SharingTab
@Binding var selected: SharingTab
var body: some View {
ZStack {
VStack(spacing: 2) {
buttonImg
.foregroundColor(selected == tab ? .Material.Elements.active : .Material.Elements.inactive)
.font(.system(size: 24, weight: .light))
.symbolRenderingMode(.hierarchical)
Text(buttonTitle)
.font(.sub1)
.foregroundColor(selected == tab ? .Material.Text.main : .Material.Elements.inactive)
}
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
}
}
}