Files
sodalive-ios/SodaLive/Sources/Main/Home/BottomTabView.swift
2026-01-23 02:45:36 +09:00

114 lines
3.1 KiB
Swift

//
// BottomTabView.swift
// SodaLive
//
// Created by klaus on 2023/08/09.
//
import SwiftUI
struct BottomTabView: View {
let width: CGFloat
@Binding var currentTab: HomeViewModel.CurrentTab
var body: some View {
HStack(spacing: 0) {
let tabWidth = width / 4
TabButton(
title: "",
action: {
if currentTab != .home {
currentTab = .home
}
},
image: {
currentTab == .home ?
"ic_home_selected" :
"ic_home"
},
fontWeight: { currentTab == .home ? .bold : .medium },
color: {
currentTab == .home ?
Color.button :
Color.graybb
},
width: tabWidth
)
TabButton(
title: "라이브",
action: {
if currentTab != .live {
currentTab = .live
}
},
image: {
currentTab == .live ?
"ic_live_selected" :
"ic_live"
},
fontWeight: { currentTab == .live ? .bold : .medium },
color: {
currentTab == .live ?
Color.button :
Color.graybb
},
width: tabWidth
)
TabButton(
title: "채팅",
action: {
if currentTab != .chat {
currentTab = .chat
}
},
image: {
currentTab == .chat ?
"ic_chat_selected" :
"ic_chat"
},
fontWeight: { currentTab == .chat ? .bold : .medium },
color: {
currentTab == .chat ?
Color.button :
Color.graybb
},
width: tabWidth
)
TabButton(
title: "마이",
action: {
if currentTab != .mypage {
currentTab = .mypage
}
},
image: {
currentTab == .mypage ?
"ic_my_selected" :
"ic_my"
},
fontWeight: { currentTab == .mypage ? .bold : .medium },
color: {
currentTab == .mypage ?
Color.button :
Color.graybb
},
width: tabWidth
)
}
.background(Color.gray11)
}
}
struct BottomTabView_Previews: PreviewProvider {
static var previews: some View {
BottomTabView(
width: UIScreen.main.bounds.width,
currentTab: .constant(.live)
)
}
}