126 lines
5.4 KiB
Swift
126 lines
5.4 KiB
Swift
//
|
|
// LiveReservationAllView.swift
|
|
// SodaLive
|
|
//
|
|
// Created by klaus on 2023/08/14.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct LiveReservationAllView: View {
|
|
|
|
@ObservedObject var viewModel = LiveViewModel()
|
|
@StateObject var liveAllViewModel = LiveAllViewModel()
|
|
|
|
let onClickReservation: (Int) -> Void
|
|
let onClickStart: (Int) -> Void
|
|
let onClickCancel: () -> Void
|
|
let onTapCreateLive: () -> Void
|
|
|
|
var body: some View {
|
|
BaseView(isLoading: $viewModel.isLoading) {
|
|
GeometryReader { proxy in
|
|
VStack(spacing: 0) {
|
|
DetailNavigationBar(title: "라이브, 예약 캘린더")
|
|
|
|
WeekCalendarView { date in
|
|
viewModel.selectedDateString = date
|
|
}
|
|
.padding(.top, 20)
|
|
|
|
if viewModel.liveReservationItems.count > 0 {
|
|
ScrollView(.vertical, showsIndicators: false) {
|
|
LazyVStack(spacing: 13.3) {
|
|
ForEach(0..<viewModel.liveReservationItems.count, id: \.self) { index in
|
|
let item = viewModel.liveReservationItems[index]
|
|
|
|
LiveReservationAllItemView(item: item)
|
|
.contentShape(Rectangle())
|
|
.onTapGesture {
|
|
self.liveAllViewModel.selectedRoomId = item.roomId
|
|
withAnimation {
|
|
self.liveAllViewModel.isShowLiveDetail = true
|
|
}
|
|
}
|
|
.onAppear {
|
|
if index == viewModel.liveNowItems.count - 1 {
|
|
viewModel.getLiveReservationList()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.padding(.vertical, 16.7)
|
|
} else {
|
|
VStack(spacing: 0) {
|
|
Image("ic_no_item")
|
|
.resizable()
|
|
.frame(width: 60, height: 60)
|
|
|
|
Text("지금 예약중인 라이브가 없습니다.\n직접 라이브를 만들어 보세요!")
|
|
.font(.custom(Font.medium.rawValue, size: 10.7))
|
|
.foregroundColor(Color(hex: "bbbbbb"))
|
|
.multilineTextAlignment(.center)
|
|
.padding(.top, 8)
|
|
|
|
HStack(spacing: 0) {
|
|
Image("ic_plus_no_bg")
|
|
.resizable()
|
|
.frame(width: 33.3, height: 33.3, alignment: .center)
|
|
|
|
Text("라이브 만들기")
|
|
.font(.custom(Font.bold.rawValue, size: 13.3))
|
|
.foregroundColor(Color.white)
|
|
}
|
|
.frame(width: 200, height: 33.3, alignment: .center)
|
|
.background(Color(hex: "3bb9f1"))
|
|
.cornerRadius(4.7)
|
|
.padding(.top, 10.7)
|
|
.onTapGesture {
|
|
AppState.shared.back()
|
|
onTapCreateLive()
|
|
}
|
|
}
|
|
.padding(.vertical, 16.7)
|
|
.frame(width: screenSize().width - 26.7)
|
|
.background(Color(hex: "13181b"))
|
|
.cornerRadius(4.7)
|
|
.padding(.top, 28.3)
|
|
}
|
|
|
|
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: {},
|
|
onClickReservation: {
|
|
onClickReservation(liveAllViewModel.selectedRoomId)
|
|
},
|
|
onClickStart: {
|
|
onClickStart(liveAllViewModel.selectedRoomId)
|
|
},
|
|
onClickCancel: {
|
|
viewModel.page = 1
|
|
viewModel.isLast = false
|
|
viewModel.getLiveReservationList()
|
|
onClickCancel()
|
|
},
|
|
onClickClose: {
|
|
withAnimation {
|
|
liveAllViewModel.isShowLiveDetail = false
|
|
}
|
|
}
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|