feat(home): 홈 탭 shell을 연결한다

This commit is contained in:
Yu Sung
2026-06-27 00:09:04 +09:00
parent 5757705b12
commit 394e7ebc34
8 changed files with 354 additions and 13 deletions

View File

@@ -0,0 +1,91 @@
import SwiftUI
struct MainHomeView: View {
let onTapCanCharge: () -> Void
let onTapSearch: () -> Void
let onTapNotificationList: () -> Void
let onTapLive: (Int) -> Void
let onTapCreator: (Int) -> Void
let onTapContent: (Int) -> Void
let onTapCharacter: (Int) -> Void
let onTapCommunity: (Int) -> Void
@State private var selectedTab: MainHomeTab = .recommendation
var body: some View {
VStack(spacing: 0) {
HomeTitleBar {
HStack(spacing: 14) {
Image("ic_bar_cash")
.onTapGesture { onTapCanCharge() }
Image("ic_bar_search")
.onTapGesture { onTapSearch() }
Image("ic_bar_bell")
.onTapGesture { onTapNotificationList() }
}
}
TextTabBar(
items: MainHomeTab.allCases,
selectedItem: $selectedTab,
title: { $0.title }
)
tabContent
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.background(Color.black.ignoresSafeArea())
}
@ViewBuilder
private var tabContent: some View {
switch selectedTab {
case .recommendation:
MainHomeRecommendationView(
onTapLive: onTapLive,
onTapCreator: onTapCreator,
onTapContent: onTapContent,
onTapCharacter: onTapCharacter,
onTapCommunity: onTapCommunity
)
case .ranking:
MainHomeRankingView()
case .following:
MainHomeFollowingView()
}
}
}
private enum MainHomeTab: CaseIterable, Hashable {
case recommendation
case ranking
case following
var title: String {
switch self {
case .recommendation:
return "추천"
case .ranking:
return "랭킹"
case .following:
return "팔로잉"
}
}
}
struct MainHomeView_Previews: PreviewProvider {
static var previews: some View {
MainHomeView(
onTapCanCharge: {},
onTapSearch: {},
onTapNotificationList: {},
onTapLive: { _ in },
onTapCreator: { _ in },
onTapContent: { _ in },
onTapCharacter: { _ in },
onTapCommunity: { _ in }
)
}
}