41 lines
967 B
Swift
41 lines
967 B
Swift
//
|
|
// MainTabBarView.swift
|
|
// SodaLive
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct MainTabBarView: View {
|
|
let width: CGFloat
|
|
@Binding var currentTab: MainTab
|
|
|
|
var body: some View {
|
|
HStack(spacing: 0) {
|
|
let tabWidth = width / CGFloat(MainTab.allCases.count)
|
|
|
|
ForEach(MainTab.allCases, id: \.self) { tab in
|
|
MainTabBarButton(
|
|
tab: tab,
|
|
isSelected: currentTab == tab,
|
|
width: tabWidth,
|
|
action: {
|
|
currentTab = tab
|
|
}
|
|
)
|
|
}
|
|
}
|
|
.padding(.top, 8)
|
|
.padding(.bottom, 8)
|
|
.background(Color.black.ignoresSafeArea(edges: .bottom))
|
|
}
|
|
}
|
|
|
|
struct MainTabBarView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
MainTabBarView(
|
|
width: UIScreen.main.bounds.width,
|
|
currentTab: .constant(.home)
|
|
)
|
|
}
|
|
}
|