feat(home): 홈 탭 shell을 연결한다
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import SwiftUI
|
||||
|
||||
struct MainHomeFollowingView: View {
|
||||
var body: some View {
|
||||
MainPlaceholderTabView(title: "팔로잉")
|
||||
}
|
||||
}
|
||||
|
||||
struct MainHomeFollowingView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
MainHomeFollowingView()
|
||||
}
|
||||
}
|
||||
91
SodaLive/Sources/V2/Main/Home/MainHomeView.swift
Normal file
91
SodaLive/Sources/V2/Main/Home/MainHomeView.swift
Normal 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 }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import SwiftUI
|
||||
|
||||
struct MainHomeRankingView: View {
|
||||
var body: some View {
|
||||
MainPlaceholderTabView(title: "랭킹")
|
||||
}
|
||||
}
|
||||
|
||||
struct MainHomeRankingView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
MainHomeRankingView()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import SwiftUI
|
||||
|
||||
struct MainHomeRecommendationView: View {
|
||||
let onTapLive: (Int) -> Void
|
||||
let onTapCreator: (Int) -> Void
|
||||
let onTapContent: (Int) -> Void
|
||||
let onTapCharacter: (Int) -> Void
|
||||
let onTapCommunity: (Int) -> Void
|
||||
|
||||
@StateObject private var viewModel = MainHomeRecommendationViewModel()
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Color.black
|
||||
.ignoresSafeArea()
|
||||
|
||||
if viewModel.isLoading && viewModel.recommendations == nil {
|
||||
ProgressView()
|
||||
.progressViewStyle(CircularProgressViewStyle(tint: .white))
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
if viewModel.recommendations == nil {
|
||||
viewModel.fetchRecommendations()
|
||||
}
|
||||
}
|
||||
.sodaToast(
|
||||
isPresented: $viewModel.isShowPopup,
|
||||
message: viewModel.errorMessage,
|
||||
autohideIn: 2
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
struct MainHomeRecommendationView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
MainHomeRecommendationView(
|
||||
onTapLive: { _ in },
|
||||
onTapCreator: { _ in },
|
||||
onTapContent: { _ in },
|
||||
onTapCharacter: { _ in },
|
||||
onTapCommunity: { _ in }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
|
||||
final class MainHomeViewModel: ObservableObject {
|
||||
final class MainHomeRecommendationViewModel: ObservableObject {
|
||||
private let repository = MainHomeRecommendationRepository()
|
||||
private var subscription = Set<AnyCancellable>()
|
||||
|
||||
Reference in New Issue
Block a user