From 0a59c6f5751758ecb0074194ce61bb51e83d2ea4 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Wed, 5 Nov 2025 12:20:01 +0900 Subject: [PATCH] =?UTF-8?q?feat(live-room):=20=ED=95=98=ED=8A=B8=EB=A5=BC?= =?UTF-8?q?=20=EA=B8=B8=EA=B2=8C(2=EC=B4=88)=EA=B0=84=20=EB=88=84=EB=A5=B4?= =?UTF-8?q?=EB=A9=B4=20=ED=91=9C=EC=8B=9C=20=EB=90=98=EB=8A=94=20=EC=99=95?= =?UTF-8?q?=ED=95=98=ED=8A=B8(100=EC=BA=94)=20=EC=B6=94=EA=B0=80,=20?= =?UTF-8?q?=EC=95=A0=EB=8B=88=EB=A9=94=EC=9D=B4=EC=85=98=20=EC=A0=9C?= =?UTF-8?q?=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SodaLive/Sources/Live/LiveRepository.swift | 11 ++++++++-- .../Room/Chat/LiveRoomChatRawMessage.swift | 3 ++- .../Sources/Live/Room/LiveRoomViewModel.swift | 19 ++++++++++++------ .../Button/LiveRoomRightBottomButton.swift | 20 ++++++++++++++++++- .../Room/V2/LiveRoomLikeHeartRequest.swift | 1 + .../Sources/Live/Room/V2/LiveRoomViewV2.swift | 3 ++- 6 files changed, 46 insertions(+), 11 deletions(-) diff --git a/SodaLive/Sources/Live/LiveRepository.swift b/SodaLive/Sources/Live/LiveRepository.swift index 8dc046e..c491dd8 100644 --- a/SodaLive/Sources/Live/LiveRepository.swift +++ b/SodaLive/Sources/Live/LiveRepository.swift @@ -121,8 +121,15 @@ final class LiveRepository { return api.requestPublisher(.getAllMenuPreset(creatorId: creatorId)) } - func likeHeart(roomId: Int) -> AnyPublisher { - return api.requestPublisher(.likeHeart(request: LiveRoomLikeHeartRequest(roomId: roomId))) + func likeHeart(roomId: Int, heartCount: Int = 1) -> AnyPublisher { + return api.requestPublisher( + .likeHeart( + request: LiveRoomLikeHeartRequest( + roomId: roomId, + heartCount: heartCount + ) + ) + ) } func getTotalHeartCount(roomId: Int) -> AnyPublisher { diff --git a/SodaLive/Sources/Live/Room/Chat/LiveRoomChatRawMessage.swift b/SodaLive/Sources/Live/Room/Chat/LiveRoomChatRawMessage.swift index d7f2e1f..cf50ced 100644 --- a/SodaLive/Sources/Live/Room/Chat/LiveRoomChatRawMessage.swift +++ b/SodaLive/Sources/Live/Room/Chat/LiveRoomChatRawMessage.swift @@ -9,7 +9,8 @@ import Foundation struct LiveRoomChatRawMessage: Codable { enum LiveRoomChatRawMessageType: String, Codable { - case DONATION, SECRET_DONATION, EDIT_ROOM_INFO, SET_MANAGER, TOGGLE_ROULETTE, ROULETTE_DONATION, HEART_DONATION + case DONATION, SECRET_DONATION, EDIT_ROOM_INFO, SET_MANAGER, TOGGLE_ROULETTE, ROULETTE_DONATION + case HEART_DONATION, BIG_HEART_DONATION } let type: LiveRoomChatRawMessageType diff --git a/SodaLive/Sources/Live/Room/LiveRoomViewModel.swift b/SodaLive/Sources/Live/Room/LiveRoomViewModel.swift index ba77ac6..c25b00d 100644 --- a/SodaLive/Sources/Live/Room/LiveRoomViewModel.swift +++ b/SodaLive/Sources/Live/Room/LiveRoomViewModel.swift @@ -1897,12 +1897,15 @@ final class LiveRoomViewModel: NSObject, ObservableObject { } } - func likeHeart() { + func likeHeart( + messageType: LiveRoomChatRawMessage.LiveRoomChatRawMessageType = .HEART_DONATION, + heartCount: Int = 1 + ) { if isAvailableLikeHeart { if !isLoadingLikeHeart { isLoadingLikeHeart = true - repository.likeHeart(roomId: AppState.shared.roomId) + repository.likeHeart(roomId: AppState.shared.roomId, heartCount: heartCount) .sink { result in switch result { case .finished: @@ -1919,12 +1922,12 @@ final class LiveRoomViewModel: NSObject, ObservableObject { let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData) if decoded.success { - UserDefaults.set(UserDefaults.int(forKey: .can) - 1, forKey: .can) + UserDefaults.set(UserDefaults.int(forKey: .can) - heartCount, forKey: .can) let donationRawMessage = LiveRoomChatRawMessage( - type: .HEART_DONATION, + type: messageType, message: "", - can: 1, + can: heartCount, donationMessage: nil ) @@ -1933,7 +1936,7 @@ final class LiveRoomViewModel: NSObject, ObservableObject { let (nickname, _) = self.getUserNicknameAndProfileUrl(accountId: UserDefaults.int(forKey: .userId)) self.addHeartMessage(nickname: nickname) - totalHeartCount += 1 + totalHeartCount += heartCount addHeart() self.invalidateChat() @@ -2255,6 +2258,10 @@ extension LiveRoomViewModel: AgoraRtmClientDelegate { self.addHeartMessage(nickname: nickname) self.totalHeartCount += decoded.can self.addHeart() + } else if decoded.type == .BIG_HEART_DONATION { + self.addHeartMessage(nickname: nickname) + self.totalHeartCount += decoded.can + self.addHeart() } } catch { } diff --git a/SodaLive/Sources/Live/Room/V2/Component/Button/LiveRoomRightBottomButton.swift b/SodaLive/Sources/Live/Room/V2/Component/Button/LiveRoomRightBottomButton.swift index 5d46c7b..35ab1be 100644 --- a/SodaLive/Sources/Live/Room/V2/Component/Button/LiveRoomRightBottomButton.swift +++ b/SodaLive/Sources/Live/Room/V2/Component/Button/LiveRoomRightBottomButton.swift @@ -11,6 +11,20 @@ struct LiveRoomRightBottomButton: View { let imageName: String let onClick: () -> Void + let onLongPress: (() -> Void)? + let longPressDuration: Double + + init( + imageName: String, + onClick: @escaping () -> Void, + onLongPress: (() -> Void)? = nil, + longPressDuration: Double = 2.0 + ) { + self.imageName = imageName + self.onClick = onClick + self.onLongPress = onLongPress + self.longPressDuration = longPressDuration + } var body: some View { Image(imageName) @@ -20,6 +34,9 @@ struct LiveRoomRightBottomButton: View { .background(Color.gray52.opacity(0.6)) .cornerRadius(10) .onTapGesture { onClick() } + .onLongPressGesture(minimumDuration: longPressDuration) { + onLongPress?() + } } } @@ -27,7 +44,8 @@ struct LiveRoomRightBottomButton_Previews: PreviewProvider { static var previews: some View { LiveRoomRightBottomButton( imageName: "ic_donation", - onClick: {} + onClick: {}, + onLongPress: {} ) } } diff --git a/SodaLive/Sources/Live/Room/V2/LiveRoomLikeHeartRequest.swift b/SodaLive/Sources/Live/Room/V2/LiveRoomLikeHeartRequest.swift index df51545..c6005eb 100644 --- a/SodaLive/Sources/Live/Room/V2/LiveRoomLikeHeartRequest.swift +++ b/SodaLive/Sources/Live/Room/V2/LiveRoomLikeHeartRequest.swift @@ -7,5 +7,6 @@ struct LiveRoomLikeHeartRequest: Encodable { let roomId: Int + let heartCount: Int let container: String = "ios" } diff --git a/SodaLive/Sources/Live/Room/V2/LiveRoomViewV2.swift b/SodaLive/Sources/Live/Room/V2/LiveRoomViewV2.swift index 9ac06a3..9343389 100644 --- a/SodaLive/Sources/Live/Room/V2/LiveRoomViewV2.swift +++ b/SodaLive/Sources/Live/Room/V2/LiveRoomViewV2.swift @@ -253,7 +253,8 @@ struct LiveRoomViewV2: View { if liveRoomInfo.creatorId != UserDefaults.int(forKey: .userId) { LiveRoomRightBottomButton( imageName: "ic_heart_pink", - onClick: { viewModel.likeHeart() } + onClick: { viewModel.likeHeart() }, + onLongPress: { viewModel.likeHeart(messageType: .BIG_HEART_DONATION, heartCount: 100) } ) } }