feat(component): 재사용 타이틀 탭 바를 추가한다

This commit is contained in:
Yu Sung
2026-05-19 20:29:37 +09:00
parent 71edcf8bf9
commit 942c581eaf
15 changed files with 607 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
//
// TextTabBar.swift
// SodaLive
//
import SwiftUI
struct TextTabBar<Item: Hashable>: View {
let items: [Item]
@Binding var selectedItem: Item
let title: (Item) -> String
var body: some View {
HStack(alignment: .center, spacing: SodaSpacing.s20) {
ForEach(items.prefix(3), id: \.self) { item in
Button {
selectedItem = item
} label: {
Text(title(item))
.appFont(.heading3)
.foregroundColor(selectedItem == item ? Color.white : Color.gray600)
.frame(height: 52, alignment: .center)
.contentShape(Rectangle())
}
.buttonStyle(.plain)
}
Spacer()
}
.padding(.horizontal, SodaSpacing.s20)
.frame(maxWidth: .infinity)
.frame(height: 52, alignment: .leading)
.background(Color.black)
}
}
struct TextTabBar_Previews: PreviewProvider {
private enum PreviewTab: String, CaseIterable {
case recommended = "추천"
case ranking = "랭킹"
case following = "팔로잉"
}
static var previews: some View {
TextTabBar(
items: PreviewTab.allCases,
selectedItem: .constant(.recommended),
title: { $0.rawValue }
)
}
}