72 lines
2.3 KiB
Swift
72 lines
2.3 KiB
Swift
import SwiftUI
|
|
|
|
struct MainHomeFollowingView: View {
|
|
let onTapLive: (Int) -> Void
|
|
let onTapCreator: (Int) -> Void
|
|
let onTapFollowingAll: () -> Void
|
|
let onTapChatTab: () -> Void
|
|
let onTapChatRoom: (Int) -> Void
|
|
let onTapSchedule: (CreatorActivityType, Int) -> Void
|
|
|
|
@StateObject private var viewModel = MainHomeFollowingViewModel()
|
|
|
|
init(
|
|
onTapLive: @escaping (Int) -> Void = { _ in },
|
|
onTapCreator: @escaping (Int) -> Void = { _ in },
|
|
onTapFollowingAll: @escaping () -> Void = {},
|
|
onTapChatTab: @escaping () -> Void = {},
|
|
onTapChatRoom: @escaping (Int) -> Void = { _ in },
|
|
onTapSchedule: @escaping (CreatorActivityType, Int) -> Void = { _, _ in }
|
|
) {
|
|
self.onTapLive = onTapLive
|
|
self.onTapCreator = onTapCreator
|
|
self.onTapFollowingAll = onTapFollowingAll
|
|
self.onTapChatTab = onTapChatTab
|
|
self.onTapChatRoom = onTapChatRoom
|
|
self.onTapSchedule = onTapSchedule
|
|
}
|
|
|
|
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)
|
|
}
|
|
.onAppear {
|
|
if viewModel.hasLoaded == false {
|
|
viewModel.fetchFollowing()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct MainHomeFollowingView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
MainHomeFollowingView()
|
|
}
|
|
}
|