크리에이터 채널

- 룰렛 설정 메뉴 추가
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
var body: some View {
VStack(alignment: .leading, spacing: 26.7) {
HStack(spacing: 0) {
Text("라이브")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color(hex: "eeeeee"))
}
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)
if !liveRoom.isActive {
Rectangle()
.frame(width: 80, height: 116.7, alignment: .top)
.foregroundColor(Color(hex: "909090").opacity(0.5))
.cornerRadius(4.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)
VStack(alignment: .leading, spacing: 0) {
HStack(alignment: .top, spacing: 0) {
VStack(alignment: .leading, spacing: 0) {
Text(liveRoom.beginDateTime)
.font(.custom(Font.medium.rawValue, size: 9.3))
.foregroundColor(Color(hex: "ffd300"))
Text(liveRoom.managerNickname)
.font(.custom(Font.medium.rawValue, size: 11.3))
.foregroundColor(Color(hex: "bbbbbb"))
.padding(.top, 10)
Text(liveRoom.title)
.font(.custom(Font.medium.rawValue, size: 15.3))
.foregroundColor(Color(hex: "e2e2e2"))
.padding(.top, 6.7)
.lineLimit(1)
}
if !liveRoom.isActive {
Rectangle()
.frame(width: 80, height: 116.7, alignment: .top)
.foregroundColor(Color.gray90.opacity(0.5))
.cornerRadius(4.7)
}
}
VStack(alignment: .leading, spacing: 0) {
HStack(alignment: .top, spacing: 0) {
VStack(alignment: .leading, spacing: 0) {
Text(liveRoom.beginDateTime)
.font(.custom(Font.medium.rawValue, size: 9.3))
.foregroundColor(Color(hex: "ffd300"))
Spacer()
Text(liveRoom.managerNickname)
.font(.custom(Font.medium.rawValue, size: 11.3))
.foregroundColor(Color.graybb)
.padding(.top, 10)
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)
)
}
Text(liveRoom.title)
.font(.custom(Font.medium.rawValue, size: 15.3))
.foregroundColor(Color.graye2)
.padding(.top, 6.7)
.lineLimit(1)
}
Spacer()
if liveRoom.isActive {
if liveRoom.channelName != nil {
if liveRoom.isPaid || liveRoom.price <= 0 {
Text("지금 참여하기")
.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 {
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)
}
}
Text("Live")
.font(.custom(Font.medium.rawValue, size: 11.3))
.foregroundColor(Color.mainRed)
.padding(.horizontal, 7)
.padding(.vertical, 4)
.overlay(
RoundedRectangle(cornerRadius: 3.3)
.stroke(Color.mainRed, lineWidth: 1)
)
} else {
if liveRoom.isReservation {
Text("예약완료")
.font(.custom(Font.bold.rawValue, size: 13.3))
.foregroundColor(Color(hex: "777777"))
.frame(
width: screenSize().width - 26.7 - 100,
height: 36.7
)
.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)
}
}
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.bold.rawValue, size: 13.3))
.foregroundColor(Color(hex: "777777"))
.frame(
width: screenSize().width - 26.7 - 100,
height: 36.7
Text("종료")
.font(.custom(Font.medium.rawValue, size: 11.3))
.foregroundColor(Color.gray77)
.padding(.horizontal, 9)
.padding(.vertical, 4)
.overlay(
RoundedRectangle(cornerRadius: 3.3)
.stroke(Color.gray77, lineWidth: 1)
)
.background(Color(hex: "525252"))
.cornerRadius(5.3)
}
}
Spacer()
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(hex: "909090").opacity(0.5))
}
.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 isShowMemberProfilePopup: Bool = false
@State private var isShowFollowNotifyDialog: Bool = false
@State private var isShowRouletteSettings: Bool = false
var body: some View {
GeometryReader { proxy in
@ -131,30 +132,51 @@ struct UserProfileView: View {
.padding(.horizontal, 13.3)
}
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)
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) || creatorProfile.liveRoomList.count > 0 {
VStack(alignment: .leading, spacing: 26.7) {
Text("라이브")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(Color.grayee)
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) {
HStack(spacing: 8) {
Text("룰렛 설정")
.font(.custom(Font.bold.rawValue, size: 15))
.foregroundColor(Color.grayee)
.padding(.vertical, 17)
.frame(maxWidth: .infinity)
.background(Color.button)
.cornerRadius(5.3)
.onTapGesture { isShowRouletteSettings = true }
}
}
)
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(.horizontal, 13.3)
}
@ -339,6 +361,10 @@ struct UserProfileView: View {
}
)
}
if isShowRouletteSettings {
RouletteSettingsView(isShowing: $isShowRouletteSettings, availableActive: false) { _, _ in }
}
}
.sheet(
isPresented: $viewModel.isShowShareView,

View File

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