109 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			109 lines
		
	
	
		
			4.5 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: 13))
 | 
						|
                                .foregroundColor(Color(hex: "bbbbbb"))
 | 
						|
                                .multilineTextAlignment(.center)
 | 
						|
                                .lineSpacing(8)
 | 
						|
                                .padding(.top, 8)
 | 
						|
                        }
 | 
						|
                        .padding(.vertical, 16.7)
 | 
						|
                        .frame(width: screenSize().width - 26.7)
 | 
						|
                        .background(Color.bg)
 | 
						|
                        .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
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                )
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |