라이브 상세 페이지 추가
This commit is contained in:
13
SodaLive/Sources/Live/Now/All/LiveAllViewModel.swift
Normal file
13
SodaLive/Sources/Live/Now/All/LiveAllViewModel.swift
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// LiveAllViewModel.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/14.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
final class LiveAllViewModel: ObservableObject {
|
||||
@Published var isShowLiveDetail = false
|
||||
@Published var selectedRoomId = 0
|
||||
}
|
117
SodaLive/Sources/Live/Now/All/LiveNowAllItemView.swift
Normal file
117
SodaLive/Sources/Live/Now/All/LiveNowAllItemView.swift
Normal file
@@ -0,0 +1,117 @@
|
||||
//
|
||||
// LiveNowAllItemView.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/14.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Kingfisher
|
||||
|
||||
struct LiveNowAllItemView: View {
|
||||
|
||||
let item: GetRoomListResponse
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 13.3) {
|
||||
HStack(spacing: 20) {
|
||||
ZStack(alignment: .topLeading) {
|
||||
KFImage(URL(string: item.coverImageUrl))
|
||||
.resizable()
|
||||
.scaledToFill()
|
||||
.frame(width: 80, height: 116.7, alignment: .top)
|
||||
.cornerRadius(4.7)
|
||||
.clipped()
|
||||
|
||||
if item.isAdult {
|
||||
Text("19")
|
||||
.font(.custom(Font.bold.rawValue, size: 11.3))
|
||||
.foregroundColor(Color.white)
|
||||
.padding(4)
|
||||
.background(Color(hex: "e53621"))
|
||||
.cornerRadius(20)
|
||||
.padding(.top, 3.3)
|
||||
.padding(.leading, 3.3)
|
||||
}
|
||||
}
|
||||
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
HStack(alignment: .top, spacing: 0) {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
Text(item.managerNickname)
|
||||
.font(.custom(Font.medium.rawValue, size: 11.3))
|
||||
.foregroundColor(Color(hex: "bbbbbb"))
|
||||
|
||||
Text(item.title)
|
||||
.font(.custom(Font.medium.rawValue, size: 15.3))
|
||||
.foregroundColor(Color(hex: "e2e2e2"))
|
||||
.lineLimit(2)
|
||||
.padding(.top, 4.3)
|
||||
.padding(.trailing, 20)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
if item.isPrivateRoom {
|
||||
Image("ic_lock")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
}
|
||||
}
|
||||
.padding(.top, 13.3)
|
||||
|
||||
Spacer()
|
||||
|
||||
HStack(spacing: 0) {
|
||||
Image("ic_avatar")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
|
||||
Text("\(item.numberOfParticipate)")
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(.white)
|
||||
.padding(.leading, 2.7)
|
||||
|
||||
Text("/\(item.numberOfPeople)")
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "555555"))
|
||||
|
||||
Text(item.numberOfPeople > item.numberOfParticipate ? "참여가능" : "Sold out")
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(
|
||||
Color(
|
||||
hex: item.numberOfPeople > item.numberOfParticipate ?
|
||||
"9970ff" :
|
||||
"ffd300"
|
||||
)
|
||||
)
|
||||
.padding(.leading, 10)
|
||||
|
||||
Spacer()
|
||||
|
||||
if item.price > 0 {
|
||||
Text("\(item.price)")
|
||||
.font(.custom(Font.bold.rawValue, size: 15.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
|
||||
Image("ic_can")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
.padding(.leading, 6.7)
|
||||
} else {
|
||||
Text("무료")
|
||||
.font(.custom(Font.bold.rawValue, size: 15.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
}
|
||||
}
|
||||
.padding(.bottom, 3.3)
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle()
|
||||
.foregroundColor(Color(hex: "909090").opacity(0.5))
|
||||
.frame(width: screenSize().width - 26.7, height: 1)
|
||||
}
|
||||
.frame(width: screenSize().width - 26.7, height: 130, alignment: .center)
|
||||
}
|
||||
}
|
83
SodaLive/Sources/Live/Now/All/LiveNowAllView.swift
Normal file
83
SodaLive/Sources/Live/Now/All/LiveNowAllView.swift
Normal file
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// 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: 0) {
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user