From 2f734c22ec33820f588b1265d4f884a6dc365c19 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Thu, 3 Oct 2024 01:15:26 +0900 Subject: [PATCH] =?UTF-8?q?=ED=81=AC=EB=A6=AC=EC=97=90=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=20=EC=B1=84=EB=84=90=20-=20=EB=A3=B0=EB=A0=9B=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EB=A9=94=EB=89=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Profile/UserProfileLiveView.swift | 279 +++++++++--------- .../Explorer/Profile/UserProfileView.swift | 70 +++-- .../Config/RouletteSettingsView.swift | 34 ++- .../Sources/Live/Room/V2/LiveRoomViewV2.swift | 2 +- 4 files changed, 203 insertions(+), 182 deletions(-) diff --git a/SodaLive/Sources/Explorer/Profile/UserProfileLiveView.swift b/SodaLive/Sources/Explorer/Profile/UserProfileLiveView.swift index fa9cf83..9e97797 100644 --- a/SodaLive/Sources/Explorer/Profile/UserProfileLiveView.swift +++ b/SodaLive/Sources/Explorer/Profile/UserProfileLiveView.swift @@ -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.. 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)) } } } diff --git a/SodaLive/Sources/Explorer/Profile/UserProfileView.swift b/SodaLive/Sources/Explorer/Profile/UserProfileView.swift index 7258be9..1913fc5 100644 --- a/SodaLive/Sources/Explorer/Profile/UserProfileView.swift +++ b/SodaLive/Sources/Explorer/Profile/UserProfileView.swift @@ -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, diff --git a/SodaLive/Sources/Live/Room/Routlette/Config/RouletteSettingsView.swift b/SodaLive/Sources/Live/Room/Routlette/Config/RouletteSettingsView.swift index 4ab5ca9..fb71756 100644 --- a/SodaLive/Sources/Live/Room/Routlette/Config/RouletteSettingsView.swift +++ b/SodaLive/Sources/Live/Room/Routlette/Config/RouletteSettingsView.swift @@ -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 } } } diff --git a/SodaLive/Sources/Live/Room/V2/LiveRoomViewV2.swift b/SodaLive/Sources/Live/Room/V2/LiveRoomViewV2.swift index 8eca721..1115e7c 100644 --- a/SodaLive/Sources/Live/Room/V2/LiveRoomViewV2.swift +++ b/SodaLive/Sources/Live/Room/V2/LiveRoomViewV2.swift @@ -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