크리에이터 채널

- 룰렛 설정 메뉴 추가
This commit is contained in:
Yu Sung 2024-10-03 01:15:26 +09:00
parent 6d7e3a40e7
commit 2f734c22ec
4 changed files with 203 additions and 182 deletions

View File

@ -16,167 +16,158 @@ struct UserProfileLiveView: View {
let onClickReservation: (LiveRoomResponse) -> Void let onClickReservation: (LiveRoomResponse) -> Void
var body: some View { var body: some View {
VStack(alignment: .leading, spacing: 26.7) { VStack(spacing: 13.3) {
ForEach(0..<liveRoomList.count, id: \.self) {
let liveRoom = liveRoomList[$0]
VStack(spacing: 13.3) {
HStack(spacing: 20) {
ZStack(alignment: .topLeading) {
KFImage(URL(string: liveRoom.coverImageUrl))
.resizable()
.scaledToFill()
.frame(width: 80, height: 116.7, alignment: .center)
.clipped()
.cornerRadius(4.7)
HStack(spacing: 0) { if !liveRoom.isActive {
Text("라이브") Rectangle()
.font(.custom(Font.bold.rawValue, size: 16.7)) .frame(width: 80, height: 116.7, alignment: .top)
.foregroundColor(Color(hex: "eeeeee")) .foregroundColor(Color.gray90.opacity(0.5))
}
VStack(spacing: 13.3) {
ForEach(0..<liveRoomList.count, id: \.self) {
let liveRoom = liveRoomList[$0]
VStack(spacing: 13.3) {
HStack(spacing: 20) {
ZStack(alignment: .topLeading) {
KFImage(URL(string: liveRoom.coverImageUrl))
.resizable()
.scaledToFill()
.frame(width: 80, height: 116.7, alignment: .center)
.clipped()
.cornerRadius(4.7) .cornerRadius(4.7)
if !liveRoom.isActive {
Rectangle()
.frame(width: 80, height: 116.7, alignment: .top)
.foregroundColor(Color(hex: "909090").opacity(0.5))
.cornerRadius(4.7)
}
} }
}
VStack(alignment: .leading, spacing: 0) { VStack(alignment: .leading, spacing: 0) {
HStack(alignment: .top, spacing: 0) { HStack(alignment: .top, spacing: 0) {
VStack(alignment: .leading, spacing: 0) { VStack(alignment: .leading, spacing: 0) {
Text(liveRoom.beginDateTime) Text(liveRoom.beginDateTime)
.font(.custom(Font.medium.rawValue, size: 9.3)) .font(.custom(Font.medium.rawValue, size: 9.3))
.foregroundColor(Color(hex: "ffd300")) .foregroundColor(Color(hex: "ffd300"))
Text(liveRoom.managerNickname) Text(liveRoom.managerNickname)
.font(.custom(Font.medium.rawValue, size: 11.3)) .font(.custom(Font.medium.rawValue, size: 11.3))
.foregroundColor(Color(hex: "bbbbbb")) .foregroundColor(Color.graybb)
.padding(.top, 10) .padding(.top, 10)
Text(liveRoom.title) Text(liveRoom.title)
.font(.custom(Font.medium.rawValue, size: 15.3)) .font(.custom(Font.medium.rawValue, size: 15.3))
.foregroundColor(Color(hex: "e2e2e2")) .foregroundColor(Color.graye2)
.padding(.top, 6.7) .padding(.top, 6.7)
.lineLimit(1) .lineLimit(1)
}
Spacer()
if liveRoom.isActive {
if liveRoom.channelName != nil {
Text("Live")
.font(.custom(Font.medium.rawValue, size: 11.3))
.foregroundColor(Color(hex: "ff5c49"))
.padding(.horizontal, 7)
.padding(.vertical, 4)
.overlay(
RoundedRectangle(cornerRadius: 3.3)
.stroke(Color(hex: "ff5c49"), lineWidth: 1)
)
} else {
Text("예정")
.font(.custom(Font.medium.rawValue, size: 11.3))
.foregroundColor(Color(hex: "fdca2f"))
.padding(.horizontal, 9)
.padding(.vertical, 4)
.overlay(
RoundedRectangle(cornerRadius: 3.3)
.stroke(Color(hex: "fdca2f"), lineWidth: 1)
)
}
} else {
Text("종료")
.font(.custom(Font.medium.rawValue, size: 11.3))
.foregroundColor(Color(hex: "777777"))
.padding(.horizontal, 9)
.padding(.vertical, 4)
.overlay(
RoundedRectangle(cornerRadius: 3.3)
.stroke(Color(hex: "777777"), lineWidth: 1)
)
}
} }
Spacer() Spacer()
if liveRoom.isActive { if liveRoom.isActive {
if liveRoom.channelName != nil { if liveRoom.channelName != nil {
if liveRoom.isPaid || liveRoom.price <= 0 { Text("Live")
Text("지금 참여하기") .font(.custom(Font.medium.rawValue, size: 11.3))
.font(.custom(Font.bold.rawValue, size: 13.3)) .foregroundColor(Color.mainRed)
.foregroundColor(Color(hex: "ffffff")) .padding(.horizontal, 7)
.frame( .padding(.vertical, 4)
width: screenSize().width - 26.7 - 100, .overlay(
height: 36.7 RoundedRectangle(cornerRadius: 3.3)
) .stroke(Color.mainRed, lineWidth: 1)
.background(Color(hex: "dd4500")) )
.cornerRadius(5.3)
.onTapGesture {
onClickParticipant(liveRoom)
}
} else {
Text("\(liveRoom.price)캔으로 지금 참여하기")
.font(.custom(Font.bold.rawValue, size: 13.3))
.foregroundColor(Color(hex: "ffffff"))
.frame(
width: screenSize().width - 26.7 - 100,
height: 36.7
)
.background(Color(hex: "dd4500"))
.cornerRadius(5.3)
.onTapGesture {
onClickParticipant(liveRoom)
}
}
} else { } else {
if liveRoom.isReservation { Text("예정")
Text("예약완료") .font(.custom(Font.medium.rawValue, size: 11.3))
.font(.custom(Font.bold.rawValue, size: 13.3)) .foregroundColor(Color(hex: "fdca2f"))
.foregroundColor(Color(hex: "777777")) .padding(.horizontal, 9)
.frame( .padding(.vertical, 4)
width: screenSize().width - 26.7 - 100, .overlay(
height: 36.7 RoundedRectangle(cornerRadius: 3.3)
) .stroke(Color(hex: "fdca2f"), lineWidth: 1)
.background(Color(hex: "525252")) )
.cornerRadius(5.3)
} else {
Text("\(liveRoom.price > 0 ? "\(liveRoom.price)캔으로 " : "")예약하기")
.font(.custom(Font.bold.rawValue, size: 13.3))
.foregroundColor(Color(hex: "000000"))
.frame(
width: screenSize().width - 26.7 - 100,
height: 36.7
)
.background(Color(hex: "fdca2f"))
.cornerRadius(5.3)
.onTapGesture {
onClickReservation(liveRoom)
}
}
} }
} else { } else {
Text("다시듣기를 지원하지 않습니다") Text("종료")
.font(.custom(Font.bold.rawValue, size: 13.3)) .font(.custom(Font.medium.rawValue, size: 11.3))
.foregroundColor(Color(hex: "777777")) .foregroundColor(Color.gray77)
.frame( .padding(.horizontal, 9)
width: screenSize().width - 26.7 - 100, .padding(.vertical, 4)
height: 36.7 .overlay(
RoundedRectangle(cornerRadius: 3.3)
.stroke(Color.gray77, lineWidth: 1)
) )
.background(Color(hex: "525252"))
.cornerRadius(5.3)
} }
} }
}
.frame(height: 116.7)
Rectangle() Spacer()
.frame(height: 1)
.foregroundColor(Color(hex: "909090").opacity(0.5)) if liveRoom.isActive {
if liveRoom.channelName != nil {
if liveRoom.isPaid || liveRoom.price <= 0 {
Text("지금 참여하기")
.font(.custom(Font.bold.rawValue, size: 13.3))
.foregroundColor(Color.white)
.frame(
width: screenSize().width - 26.7 - 100,
height: 36.7
)
.background(Color.mainRed3)
.cornerRadius(5.3)
.onTapGesture {
onClickParticipant(liveRoom)
}
} else {
Text("\(liveRoom.price)캔으로 지금 참여하기")
.font(.custom(Font.bold.rawValue, size: 13.3))
.foregroundColor(Color.white)
.frame(
width: screenSize().width - 26.7 - 100,
height: 36.7
)
.background(Color.mainRed3)
.cornerRadius(5.3)
.onTapGesture {
onClickParticipant(liveRoom)
}
}
} else {
if liveRoom.isReservation {
Text("예약완료")
.font(.custom(Font.bold.rawValue, size: 13.3))
.foregroundColor(Color.gray77)
.frame(
width: screenSize().width - 26.7 - 100,
height: 36.7
)
.background(Color.gray52)
.cornerRadius(5.3)
} else {
Text("\(liveRoom.price > 0 ? "\(liveRoom.price)캔으로 " : "")예약하기")
.font(.custom(Font.bold.rawValue, size: 13.3))
.foregroundColor(Color.black)
.frame(
width: screenSize().width - 26.7 - 100,
height: 36.7
)
.background(Color(hex: "fdca2f"))
.cornerRadius(5.3)
.onTapGesture {
onClickReservation(liveRoom)
}
}
}
} else {
Text("다시듣기를 지원하지 않습니다")
.font(.custom(Font.bold.rawValue, size: 13.3))
.foregroundColor(Color.gray77)
.frame(
width: screenSize().width - 26.7 - 100,
height: 36.7
)
.background(Color.gray52)
.cornerRadius(5.3)
}
}
} }
.frame(height: 116.7)
Rectangle()
.frame(height: 1)
.foregroundColor(Color.gray90.opacity(0.5))
} }
} }
} }

View File

@ -15,6 +15,7 @@ struct UserProfileView: View {
@State private var memberId: Int = 0 @State private var memberId: Int = 0
@State private var isShowMemberProfilePopup: Bool = false @State private var isShowMemberProfilePopup: Bool = false
@State private var isShowFollowNotifyDialog: Bool = false @State private var isShowFollowNotifyDialog: Bool = false
@State private var isShowRouletteSettings: Bool = false
var body: some View { var body: some View {
GeometryReader { proxy in GeometryReader { proxy in
@ -131,30 +132,51 @@ struct UserProfileView: View {
.padding(.horizontal, 13.3) .padding(.horizontal, 13.3)
} }
if creatorProfile.liveRoomList.count > 0 { if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) || creatorProfile.liveRoomList.count > 0 {
UserProfileLiveView( VStack(alignment: .leading, spacing: 26.7) {
userId: userId, Text("라이브")
liveRoomList: creatorProfile.liveRoomList, .font(.custom(Font.bold.rawValue, size: 16.7))
onClickParticipant: { liveRoom in .foregroundColor(Color.grayee)
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) {
viewModel.errorMessage = "현재 라이브 중입니다." if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) {
viewModel.isShowPopup = true HStack(spacing: 8) {
} else { Text("룰렛 설정")
AppState.shared.isShowPlayer = false .font(.custom(Font.bold.rawValue, size: 15))
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { .foregroundColor(Color.grayee)
viewModel.enterLiveRoom(roomId: liveRoom.roomId) .padding(.vertical, 17)
} .frame(maxWidth: .infinity)
} .background(Color.button)
}, .cornerRadius(5.3)
onClickReservation: { liveRoom in .onTapGesture { isShowRouletteSettings = true }
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) {
viewModel.errorMessage = "내가 만든 라이브는 예약할 수 없습니다."
viewModel.isShowPopup = true
} else {
viewModel.reservationLiveRoom(roomId: liveRoom.roomId)
} }
} }
)
if creatorProfile.liveRoomList.count > 0 {
UserProfileLiveView(
userId: userId,
liveRoomList: creatorProfile.liveRoomList,
onClickParticipant: { liveRoom in
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) {
viewModel.errorMessage = "현재 라이브 중입니다."
viewModel.isShowPopup = true
} else {
AppState.shared.isShowPlayer = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
viewModel.enterLiveRoom(roomId: liveRoom.roomId)
}
}
},
onClickReservation: { liveRoom in
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) {
viewModel.errorMessage = "내가 만든 라이브는 예약할 수 없습니다."
viewModel.isShowPopup = true
} else {
viewModel.reservationLiveRoom(roomId: liveRoom.roomId)
}
}
)
}
}
.padding(.top, 26.7) .padding(.top, 26.7)
.padding(.horizontal, 13.3) .padding(.horizontal, 13.3)
} }
@ -339,6 +361,10 @@ struct UserProfileView: View {
} }
) )
} }
if isShowRouletteSettings {
RouletteSettingsView(isShowing: $isShowRouletteSettings, availableActive: false) { _, _ in }
}
} }
.sheet( .sheet(
isPresented: $viewModel.isShowShareView, isPresented: $viewModel.isShowShareView,

View File

@ -13,6 +13,8 @@ struct RouletteSettingsView: View {
@StateObject var viewModel = RouletteSettingsViewModel() @StateObject var viewModel = RouletteSettingsViewModel()
@Binding var isShowing: Bool @Binding var isShowing: Bool
let availableActive: Bool
let onComplete: (Bool, String) -> Void let onComplete: (Bool, String) -> Void
var body: some View { var body: some View {
@ -61,21 +63,23 @@ struct RouletteSettingsView: View {
} }
.padding(.top, 26.7) .padding(.top, 26.7)
HStack(spacing: 0) { if availableActive {
Text("룰렛을 활성화 하시겠습니까?") HStack(spacing: 0) {
.font(.custom(Font.bold.rawValue, size: 16)) Text("룰렛을 활성화 하시겠습니까?")
.foregroundColor(Color.grayee) .font(.custom(Font.bold.rawValue, size: 16))
.foregroundColor(Color.grayee)
Spacer() Spacer()
Image(viewModel.isActive ? "btn_toggle_on_big" : "btn_toggle_off_big") Image(viewModel.isActive ? "btn_toggle_on_big" : "btn_toggle_off_big")
.resizable() .resizable()
.frame(width: 44, height: 27) .frame(width: 44, height: 27)
.onTapGesture { .onTapGesture {
viewModel.isActive.toggle() viewModel.isActive.toggle()
} }
}
.padding(.top, 26.7)
} }
.padding(.top, 26.7)
VStack(alignment: .leading, spacing: 13.3) { VStack(alignment: .leading, spacing: 13.3) {
Text("룰렛 금액 설정") Text("룰렛 금액 설정")
@ -238,6 +242,6 @@ struct RouletteSettingsView: View {
struct RouletteSettingsView_Previews: PreviewProvider { struct RouletteSettingsView_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
RouletteSettingsView(isShowing: .constant(true)) { _, _ in } RouletteSettingsView(isShowing: .constant(true), availableActive: true) { _, _ in }
} }
} }

View File

@ -610,7 +610,7 @@ struct LiveRoomViewV2: View {
} }
if viewModel.isShowRouletteSettings { if viewModel.isShowRouletteSettings {
RouletteSettingsView(isShowing: $viewModel.isShowRouletteSettings) { isActiveRoulette, message in RouletteSettingsView(isShowing: $viewModel.isShowRouletteSettings, availableActive: true) { isActiveRoulette, message in
self.viewModel.setActiveRoulette( self.viewModel.setActiveRoulette(
isActiveRoulette: isActiveRoulette, isActiveRoulette: isActiveRoulette,
message: message message: message