125 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			125 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
//
 | 
						|
//  SectionLiveNowView.swift
 | 
						|
//  SodaLive
 | 
						|
//
 | 
						|
//  Created by klaus on 2023/08/09.
 | 
						|
//
 | 
						|
 | 
						|
import SwiftUI
 | 
						|
 | 
						|
struct SectionLiveNowView: View {
 | 
						|
    
 | 
						|
    let items: [GetRoomListResponse]
 | 
						|
    
 | 
						|
    let onClickParticipant: (Int) -> Void
 | 
						|
    let onTapCreateLive: () -> Void
 | 
						|
    let onClickRefresh: () -> Void
 | 
						|
    
 | 
						|
    @AppStorage("token") private var token: String = UserDefaults.string(forKey: UserDefaultsKey.token)
 | 
						|
    
 | 
						|
    var body: some View {
 | 
						|
        LazyVStack(spacing: 13.3) {
 | 
						|
            HStack(spacing: 0) {
 | 
						|
                Text("지금 ")
 | 
						|
                    .font(.custom(Font.bold.rawValue, size: 18.3))
 | 
						|
                    .foregroundColor(Color(hex: "eeeeee"))
 | 
						|
                
 | 
						|
                Text("라이브중")
 | 
						|
                    .font(.custom(Font.bold.rawValue, size: 18.3))
 | 
						|
                    .foregroundColor(Color(hex: "ff5c49"))
 | 
						|
                
 | 
						|
                Spacer()
 | 
						|
                
 | 
						|
                if items.count > 0 {
 | 
						|
                    Text("전체보기")
 | 
						|
                        .font(.custom(Font.light.rawValue, size: 11.3))
 | 
						|
                        .foregroundColor(Color(hex: "bbbbbb"))
 | 
						|
                        .onTapGesture { AppState.shared.setAppStep(step: .liveNowAll(onClickParticipant: onClickParticipant)) }
 | 
						|
                }
 | 
						|
            }
 | 
						|
            .padding(.horizontal, 13.3)
 | 
						|
            .frame(width: screenSize().width)
 | 
						|
            
 | 
						|
            if items.count > 0 {
 | 
						|
                ScrollView(.horizontal, showsIndicators: false) {
 | 
						|
                    HStack(alignment: .top, spacing: 10) {
 | 
						|
                        ForEach(items, id: \.self) { item in
 | 
						|
                            LiveNowItemView(item: item)
 | 
						|
                                .contentShape(Rectangle())
 | 
						|
                                .onTapGesture {
 | 
						|
                                    if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
 | 
						|
                                        AppState.shared.setAppStep(
 | 
						|
                                            step: .liveDetail(
 | 
						|
                                                roomId: item.roomId,
 | 
						|
                                                onClickParticipant: {
 | 
						|
                                                    AppState.shared.isShowPlayer = false
 | 
						|
                                                    onClickParticipant(item.roomId)
 | 
						|
                                                },
 | 
						|
                                                onClickReservation: {},
 | 
						|
                                                onClickStart: {
 | 
						|
                                                },
 | 
						|
                                                onClickCancel: {
 | 
						|
                                                }
 | 
						|
                                            )
 | 
						|
                                        )
 | 
						|
                                    } else {
 | 
						|
                                        AppState.shared.setAppStep(step: .login)
 | 
						|
                                    }
 | 
						|
                                }
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                    .padding(.horizontal, 13.3)
 | 
						|
                }
 | 
						|
            } 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"))
 | 
						|
                        .fixedSize(horizontal: false, vertical: true)
 | 
						|
                        .multilineTextAlignment(.center)
 | 
						|
                        .lineSpacing(8)
 | 
						|
                        .padding(.vertical, 8)
 | 
						|
                }
 | 
						|
                .padding(.vertical, 16.7)
 | 
						|
                .frame(width: screenSize().width - 26.7)
 | 
						|
                .background(Color(hex: "13181b"))
 | 
						|
                .cornerRadius(4.7)
 | 
						|
            }
 | 
						|
            
 | 
						|
            HStack(spacing: 8) {
 | 
						|
                Image("ic_refresh")
 | 
						|
                
 | 
						|
                Text("새로고침")
 | 
						|
                    .font(.custom(Font.medium.rawValue, size: 14.7))
 | 
						|
                    .foregroundColor(Color.grayd2)
 | 
						|
            }
 | 
						|
            .padding(.vertical, 11)
 | 
						|
            .frame(maxWidth: .infinity)
 | 
						|
            .contentShape(Rectangle())
 | 
						|
            .overlay(
 | 
						|
                RoundedRectangle(cornerRadius: 26.7)
 | 
						|
                    .stroke(Color.gray90, lineWidth: 1)
 | 
						|
            )
 | 
						|
            .padding(.horizontal, 13.3)
 | 
						|
            .onTapGesture {
 | 
						|
                onClickRefresh()
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
struct SectionLiveNowView_Previews: PreviewProvider {
 | 
						|
    static var previews: some View {
 | 
						|
        SectionLiveNowView(
 | 
						|
            items: [],
 | 
						|
            onClickParticipant: { _ in },
 | 
						|
            onTapCreateLive: {},
 | 
						|
            onClickRefresh: {}
 | 
						|
        )
 | 
						|
    }
 | 
						|
}
 |