sodalive-ios/SodaLive/Sources/Live/Now/All/LiveNowAllView.swift

84 lines
3.1 KiB
Swift

//
// LiveNowAllView.swift
// SodaLive
//
// Created by klaus on 2023/08/14.
//
import SwiftUI
import RefreshableScrollView
struct LiveNowAllView: View {
@StateObject var viewModel = LiveViewModel()
@StateObject var liveAllViewModel = LiveAllViewModel()
let onClickParticipant: (Int) -> Void
var body: some View {
BaseView(isLoading: $viewModel.isLoading) {
GeometryReader { proxy in
VStack(spacing: 0) {
DetailNavigationBar(title: "지금 라이브 중 전체보기")
RefreshableScrollView(
refreshing: $viewModel.isRefresh,
action: {
viewModel.getLiveNowList()
},
content: {
VStack(spacing: 13.3) {
ForEach(0..<viewModel.liveNowItems.count, id: \.self) { index in
let item = viewModel.liveNowItems[index]
LiveNowAllItemView(item: item)
.contentShape(Rectangle())
.onTapGesture {
self.liveAllViewModel.selectedRoomId = item.roomId
withAnimation {
self.liveAllViewModel.isShowLiveDetail = true
}
}
.onAppear {
if index == viewModel.liveNowItems.count - 1 {
viewModel.getLiveNowList()
}
}
}
}
}
)
if proxy.safeAreaInsets.bottom > 0 {
Rectangle()
.foregroundColor(Color.black.opacity(0))
.frame(width: screenSize().width, height: 15.3)
}
}
.edgesIgnoringSafeArea(.bottom)
}
if liveAllViewModel.isShowLiveDetail {
LiveDetailView(
roomId: liveAllViewModel.selectedRoomId,
onClickParticipant: {
AppState.shared.isShowPlayer = false
onClickParticipant(liveAllViewModel.selectedRoomId)
},
onClickReservation: {},
onClickStart: {},
onClickCancel: {},
onClickClose: {
withAnimation {
liveAllViewModel.isShowLiveDetail = false
}
}
)
}
}
.onAppear {
viewModel.getLiveNowList()
}
}
}