// // SectionLiveNowView.swift // SodaLive // // Created by klaus on 2023/08/09. // import SwiftUI struct SectionLiveNowView: View { let items: [GetRoomListResponse] let onClickParticipant: (Int) -> Void let onTapItem: (GetRoomListResponse) -> Void let onTapCreateLive: () -> Void let onClickRefresh: () -> Void var body: some View { LazyVStack(spacing: 13.3) { HStack(spacing: 0) { Text(I18n.LiveNow.sectionTitle) .appFont(size: 24, weight: .bold) .foregroundColor(.white) Spacer() if items.count > 0 { Text(I18n.Common.viewAll) .appFont(size: 14, weight: .regular) .foregroundColor(Color(hex: "78909C")) .onTapGesture { AppState.shared.setAppStep(step: .liveNowAll(onClickParticipant: onClickParticipant)) } } } .padding(.horizontal, 24) .frame(maxWidth: .infinity) if items.count > 0 { ScrollView(.horizontal, showsIndicators: false) { LazyHStack(alignment: .top, spacing: 16) { ForEach(items, id: \.self) { item in LiveNowItemView(item: item, itemWidth: nil) .contentShape(Rectangle()) .onTapGesture { onTapItem(item) } } } .padding(.horizontal, 24) } } else { VStack(spacing: 0) { Image("ic_no_item") .resizable() .frame(width: 60, height: 60) Text(I18n.LiveNow.emptyStateMessage) .appFont(size: 13, weight: .medium) .foregroundColor(Color(hex: "bbbbbb")) .fixedSize(horizontal: false, vertical: true) .multilineTextAlignment(.center) .lineSpacing(8) .padding(.vertical, 8) } .padding(.vertical, 16.7) .frame(maxWidth: .infinity) .background(Color(hex: "13181b")) .padding(.horizontal, 24) .cornerRadius(4.7) } HStack(spacing: 8) { Image("ic_refresh") Text(I18n.LiveNow.refreshButton) .appFont(size: 14.7, weight: .medium) .foregroundColor(Color.grayd2) } .padding(.vertical, 11) .frame(maxWidth: .infinity) .contentShape(Rectangle()) .overlay( RoundedRectangle(cornerRadius: 26.7) .stroke(Color.gray90, lineWidth: 1) ) .padding(.horizontal, 24) .onTapGesture { onClickRefresh() } } } } struct SectionLiveNowView_Previews: PreviewProvider { static var previews: some View { SectionLiveNowView( items: [], onClickParticipant: { _ in }, onTapItem: { _ in }, onTapCreateLive: {}, onClickRefresh: {} ) } }