feat(home): 팔로잉 탭 화면을 조립한다
This commit is contained in:
@@ -3,6 +3,8 @@ import SwiftUI
|
||||
struct MainHomeFollowingView: View {
|
||||
let onTapLive: (Int) -> Void
|
||||
let onTapCreator: (Int) -> Void
|
||||
let onTapContent: (Int) -> Void
|
||||
let onTapLogin: () -> Void
|
||||
let onTapFollowingAll: () -> Void
|
||||
let onTapChatTab: () -> Void
|
||||
let onTapChatRoom: (Int) -> Void
|
||||
@@ -13,6 +15,8 @@ struct MainHomeFollowingView: View {
|
||||
init(
|
||||
onTapLive: @escaping (Int) -> Void = { _ in },
|
||||
onTapCreator: @escaping (Int) -> Void = { _ in },
|
||||
onTapContent: @escaping (Int) -> Void = { _ in },
|
||||
onTapLogin: @escaping () -> Void = {},
|
||||
onTapFollowingAll: @escaping () -> Void = {},
|
||||
onTapChatTab: @escaping () -> Void = {},
|
||||
onTapChatRoom: @escaping (Int) -> Void = { _ in },
|
||||
@@ -20,6 +24,8 @@ struct MainHomeFollowingView: View {
|
||||
) {
|
||||
self.onTapLive = onTapLive
|
||||
self.onTapCreator = onTapCreator
|
||||
self.onTapContent = onTapContent
|
||||
self.onTapLogin = onTapLogin
|
||||
self.onTapFollowingAll = onTapFollowingAll
|
||||
self.onTapChatTab = onTapChatTab
|
||||
self.onTapChatRoom = onTapChatRoom
|
||||
@@ -27,41 +33,78 @@ struct MainHomeFollowingView: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
MainHomeFollowingCreatorSection(
|
||||
followingCreators: viewModel.response?.followingCreators ?? [],
|
||||
onTapCreator: onTapCreator,
|
||||
onTapAll: onTapFollowingAll
|
||||
)
|
||||
|
||||
MainHomeFollowingLiveSection(
|
||||
onAirLives: viewModel.response?.onAirLives ?? [],
|
||||
onTapLive: onTapLive
|
||||
)
|
||||
|
||||
if let recentChats = viewModel.response?.recentChats, !recentChats.isEmpty {
|
||||
MainHomeFollowingChatSection(
|
||||
recentChats: recentChats,
|
||||
onTapTitle: onTapChatTab,
|
||||
onTapChatRoom: onTapChatRoom
|
||||
)
|
||||
}
|
||||
|
||||
if let monthlySchedules = viewModel.response?.monthlySchedules, !monthlySchedules.isEmpty {
|
||||
MainHomeFollowingScheduleSection(
|
||||
monthlySchedules: monthlySchedules,
|
||||
onTapSchedule: onTapSchedule
|
||||
)
|
||||
}
|
||||
|
||||
MainPlaceholderTabView(title: I18n.HomeFollowing.tabTitle)
|
||||
}
|
||||
content
|
||||
.onAppear {
|
||||
if viewModel.hasLoaded == false {
|
||||
viewModel.fetchFollowing()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var content: some View {
|
||||
if viewModel.isLoading {
|
||||
ProgressView()
|
||||
.tint(.white)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(Color.black)
|
||||
} else if viewModel.isLoginRequired {
|
||||
MainHomeFollowingEmptyStateView(
|
||||
message: I18n.HomeFollowing.loginRequiredMessage,
|
||||
loginAction: onTapLogin
|
||||
)
|
||||
} else if !viewModel.message.isEmpty {
|
||||
MainHomeFollowingEmptyStateView(message: viewModel.message)
|
||||
} else if let response = viewModel.response {
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
VStack(spacing: 0) {
|
||||
MainHomeFollowingCreatorSection(
|
||||
followingCreators: response.followingCreators,
|
||||
onTapCreator: onTapCreator,
|
||||
onTapAll: onTapFollowingAll
|
||||
)
|
||||
|
||||
if !response.onAirLives.isEmpty {
|
||||
MainHomeFollowingLiveSection(
|
||||
onAirLives: response.onAirLives,
|
||||
onTapLive: onTapLive
|
||||
)
|
||||
.padding(.top, 28)
|
||||
}
|
||||
|
||||
if !response.recentChats.isEmpty {
|
||||
MainHomeFollowingChatSection(
|
||||
recentChats: response.recentChats,
|
||||
onTapTitle: onTapChatTab,
|
||||
onTapChatRoom: onTapChatRoom
|
||||
)
|
||||
.padding(.top, 48)
|
||||
}
|
||||
|
||||
if !response.monthlySchedules.isEmpty {
|
||||
MainHomeFollowingScheduleSection(
|
||||
monthlySchedules: response.monthlySchedules,
|
||||
onTapSchedule: onTapSchedule
|
||||
)
|
||||
.padding(.top, 48)
|
||||
}
|
||||
|
||||
if !response.recentNews.isEmpty {
|
||||
MainHomeFollowingNewsSection(
|
||||
recentNews: response.recentNews,
|
||||
onTapCreator: onTapCreator,
|
||||
onTapContent: onTapContent
|
||||
)
|
||||
.padding(.top, 48)
|
||||
}
|
||||
}
|
||||
.padding(.bottom, SodaSpacing.s20)
|
||||
}
|
||||
.background(Color.black)
|
||||
} else {
|
||||
MainHomeFollowingEmptyStateView(message: I18n.HomeFollowing.emptyStateMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct MainHomeFollowingView_Previews: PreviewProvider {
|
||||
|
||||
Reference in New Issue
Block a user