feat(main): 메인 탭 화면을 추가한다
This commit is contained in:
40
SodaLive/Sources/V2/Main/MainTabBarView.swift
Normal file
40
SodaLive/Sources/V2/Main/MainTabBarView.swift
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// 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)
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user