라이브 상세 페이지 추가
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()
|
||||
}
|
||||
}
|
||||
}
|
111
SodaLive/Sources/Live/Now/LiveNowItemView.swift
Normal file
111
SodaLive/Sources/Live/Now/LiveNowItemView.swift
Normal file
@@ -0,0 +1,111 @@
|
||||
//
|
||||
// LiveNowItemView.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/14.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Kingfisher
|
||||
|
||||
struct LiveNowItemView: View {
|
||||
|
||||
let item: GetRoomListResponse
|
||||
|
||||
let width: CGFloat = 133.3
|
||||
let height: CGFloat = 176.7
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
KFImage(URL(string: item.coverImageUrl))
|
||||
.resizable()
|
||||
.scaledToFill()
|
||||
.frame(width: width, height: height, alignment: .top)
|
||||
.cornerRadius(4.7)
|
||||
.clipped()
|
||||
|
||||
LinearGradient(
|
||||
colors: [Color.black.opacity(0.1), Color.black.opacity(0.8)],
|
||||
startPoint: .top,
|
||||
endPoint: .bottom
|
||||
)
|
||||
|
||||
VStack(spacing: 0) {
|
||||
HStack(spacing: 3.3) {
|
||||
Text(item.price > 0 ? "유료" : "무료")
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.foregroundColor(Color.white)
|
||||
.padding(.horizontal, 7.3)
|
||||
.padding(.vertical, 4)
|
||||
.background(Color(hex: item.price > 0 ? "881609" : "643bc8"))
|
||||
.cornerRadius(10)
|
||||
|
||||
Spacer()
|
||||
|
||||
if item.isPrivateRoom {
|
||||
Image("ic_lock")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
}
|
||||
|
||||
if item.isAdult {
|
||||
Text("19")
|
||||
.font(.custom(Font.bold.rawValue, size: 11.3))
|
||||
.foregroundColor(Color.white)
|
||||
.padding(4)
|
||||
.background(Color(hex: "e53621"))
|
||||
.clipShape(Circle())
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 3.3)
|
||||
.padding(.top, 3.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(Color.white)
|
||||
.padding(.leading, 2.7)
|
||||
|
||||
Spacer()
|
||||
|
||||
Text("\(item.managerNickname)")
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color.white)
|
||||
}
|
||||
.padding(.horizontal, 6.7)
|
||||
.padding(.bottom, 6.7)
|
||||
}
|
||||
}
|
||||
.frame(width: width, height: height)
|
||||
}
|
||||
}
|
||||
|
||||
struct LiveNowItemView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
LiveNowItemView(
|
||||
item: GetRoomListResponse(
|
||||
roomId: 99,
|
||||
title: "test",
|
||||
content: "testtest",
|
||||
beginDateTime: "2022.05.23 Mon 03:00 PM",
|
||||
numberOfParticipate: 3,
|
||||
numberOfPeople: 5,
|
||||
coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
|
||||
isAdult: true,
|
||||
price: 0,
|
||||
tags: ["팬미팅", "힐링"],
|
||||
channelName: nil,
|
||||
managerNickname: "user8",
|
||||
managerId: 19,
|
||||
isReservation: false,
|
||||
isPrivateRoom: true
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
@@ -16,6 +16,88 @@ struct SectionLiveNowView: View {
|
||||
|
||||
var body: some View {
|
||||
VStack(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(spacing: 10) {
|
||||
ForEach(items, id: \.self) { item in
|
||||
LiveNowItemView(item: item)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
AppState.shared.setAppStep(
|
||||
step: .liveDetail(
|
||||
roomId: item.roomId,
|
||||
onClickParticipant: {
|
||||
AppState.shared.isShowPlayer = false
|
||||
onClickParticipant(item.roomId)
|
||||
},
|
||||
onClickReservation: {},
|
||||
onClickStart: {
|
||||
},
|
||||
onClickCancel: {
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 13.3)
|
||||
}
|
||||
.padding(.top, 28.3)
|
||||
} 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"))
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.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: "9970ff"))
|
||||
.cornerRadius(4.7)
|
||||
.padding(.top, 10.7)
|
||||
.onTapGesture { onTapCreateLive() }
|
||||
}
|
||||
.padding(.vertical, 16.7)
|
||||
.frame(width: screenSize().width - 26.7)
|
||||
.background(Color(hex: "2b2635"))
|
||||
.cornerRadius(4.7)
|
||||
.padding(.top, 28.3)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user