라이브 중 전체보기

- 그리드 아이템 사이 간격 수정
This commit is contained in:
Yu Sung 2024-03-15 16:45:09 +09:00
parent 1f35c4585d
commit 7b24b50582
2 changed files with 113 additions and 55 deletions

View File

@ -11,33 +11,39 @@ import Kingfisher
struct LiveNowAllItemView: View { struct LiveNowAllItemView: View {
let item: GetRoomListResponse let item: GetRoomListResponse
let itemWidth: CGFloat
var body: some View { var body: some View {
VStack(spacing: 13.3) { VStack(alignment: .leading, spacing: 8) {
HStack(spacing: 20) { ZStack {
ZStack(alignment: .topLeading) { KFImage(URL(string: item.coverImageUrl))
KFImage(URL(string: item.coverImageUrl)) .resizable()
.resizable() .scaledToFill()
.scaledToFill() .frame(width: itemWidth, height: itemWidth * 144 / 102, alignment: .center)
.frame(width: 80, height: 116.7, alignment: .top) .cornerRadius(4.7)
.cornerRadius(4.7) .clipped()
.clipped()
}
VStack(alignment: .leading, spacing: 0) { LinearGradient(
HStack(alignment: .top, spacing: 0) { colors: [Color.black.opacity(0.1), Color.black.opacity(0.8)],
VStack(alignment: .leading, spacing: 0) { startPoint: .top,
Text(item.creatorNickname) endPoint: .bottom
.font(.custom(Font.medium.rawValue, size: 11.3)) )
.foregroundColor(Color(hex: "bbbbbb"))
VStack(alignment: .trailing, spacing: 0) {
HStack(spacing: 0) {
HStack(spacing: 1) {
if item.price > 0 {
Image("ic_can_white")
}
Text(item.title) Text(item.price > 0 ? "\(item.price)" : "무료")
.font(.custom(Font.medium.rawValue, size: 15.3)) .font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color(hex: "e2e2e2")) .foregroundColor(Color.white)
.lineLimit(2)
.padding(.top, 4.3)
.padding(.trailing, 20)
} }
.padding(.horizontal, 7.3)
.padding(.vertical, 4)
.background(item.price > 0 ? Color.mainRed3 : Color.gray11)
.cornerRadius(13.3)
Spacer() Spacer()
@ -45,48 +51,92 @@ struct LiveNowAllItemView: View {
Image("ic_lock") Image("ic_lock")
.resizable() .resizable()
.frame(width: 20, height: 20) .frame(width: 20, height: 20)
.padding(2.7)
.background(Color.gray33.opacity(0.7))
.clipShape(Circle())
} }
} }
.padding(.top, 13.3) .padding(.horizontal, 3.3)
.padding(.top, 3.3)
Spacer() Spacer()
HStack(spacing: 0) { if item.numberOfPeople - item.numberOfParticipate < 3 {
Text(item.numberOfPeople > item.numberOfParticipate ? "참여가능" : "Sold out") HStack(spacing: 0) {
.font(.custom(Font.medium.rawValue, size: 13.3)) Spacer()
.foregroundColor(
Color(
hex: item.numberOfPeople > item.numberOfParticipate ?
"3bb9f1" :
"ffd300"
)
)
Spacer()
if item.price > 0 {
Text("\(item.price)")
.font(.custom(Font.bold.rawValue, size: 15.3))
.foregroundColor(Color(hex: "eeeeee"))
Image("ic_can") HStack(spacing: 2) {
.resizable() Text("잔여")
.frame(width: 20, height: 20) .font(.custom(Font.medium.rawValue, size: 12))
.padding(.leading, 6.7) .foregroundColor(Color.grayee)
} else {
Text("무료") Text("\(item.numberOfPeople - item.numberOfParticipate)")
.font(.custom(Font.bold.rawValue, size: 15.3)) .font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color(hex: "eeeeee")) .foregroundColor(Color.button)
}
.padding(.horizontal, 4)
.padding(.vertical, 3)
.background(Color.gray33.opacity(0.7))
.cornerRadius(13.3)
} }
.padding(.horizontal, 3.3)
.padding(.bottom, 3.3)
} }
.padding(.bottom, 3.3)
} }
} }
.frame(width: itemWidth, height: itemWidth * 144 / 102)
Rectangle() Text("\(item.title)")
.foregroundColor(Color(hex: "909090").opacity(0.5)) .font(.custom(Font.medium.rawValue, size: 12))
.frame(width: screenSize().width - 26.7, height: 1) .foregroundColor(Color(hex: "eeeeee"))
.lineLimit(2)
.fixedSize(horizontal: false, vertical: true)
if item.tags.count > 0 {
Text("\(item.tags.map { "#\($0)" }.joined(separator: " "))")
.font(.custom(Font.medium.rawValue, size: 11))
.foregroundColor(Color.button)
}
HStack(spacing: 5.3) {
KFImage(URL(string: item.creatorProfileImage))
.resizable()
.scaledToFill()
.frame(width: 21.3, height: 21.3, alignment: .center)
.clipShape(Circle())
Text("\(item.creatorNickname)")
.font(.custom(Font.medium.rawValue, size: 10))
.foregroundColor(Color.gray77)
}
} }
.frame(width: screenSize().width - 26.7, height: 130, alignment: .center) .frame(width: itemWidth)
} }
} }
struct LiveNowAllItemView_Previews: PreviewProvider {
static var previews: some View {
LiveNowAllItemView(
item: GetRoomListResponse(
roomId: 99,
title: "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttest",
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: 20,
tags: ["팬미팅", "힐링"],
channelName: nil,
creatorProfileImage: "https://test-cf.sodalive.net/profile/default-profile.png",
creatorNickname: "user8",
creatorId: 19,
isReservation: false,
isPrivateRoom: true
),
itemWidth: 102
)
}
}

View File

@ -13,6 +13,14 @@ struct LiveNowAllView: View {
@StateObject var viewModel = LiveViewModel() @StateObject var viewModel = LiveViewModel()
@StateObject var liveAllViewModel = LiveAllViewModel() @StateObject var liveAllViewModel = LiveAllViewModel()
let columns = [
GridItem(.flexible(), alignment: .top),
GridItem(.flexible(), alignment: .top),
GridItem(.flexible(), alignment: .top)
]
let spacing: CGFloat = 13.3
let onClickParticipant: (Int) -> Void let onClickParticipant: (Int) -> Void
var body: some View { var body: some View {
@ -29,11 +37,11 @@ struct LiveNowAllView: View {
viewModel.getLiveNowList() viewModel.getLiveNowList()
}, },
content: { content: {
VStack(spacing: 13.3) { LazyVGrid(columns: columns, spacing: spacing) {
ForEach(0..<viewModel.liveNowItems.count, id: \.self) { index in ForEach(0..<viewModel.liveNowItems.count, id: \.self) { index in
let item = viewModel.liveNowItems[index] let item = viewModel.liveNowItems[index]
LiveNowAllItemView(item: item) LiveNowAllItemView(item: item, itemWidth: (screenSize().width - (spacing * (CGFloat(columns.count + 1)))) / 3)
.contentShape(Rectangle()) .contentShape(Rectangle())
.onTapGesture { .onTapGesture {
self.liveAllViewModel.selectedRoomId = item.roomId self.liveAllViewModel.selectedRoomId = item.roomId