feat(live-room): 라이브룸 채팅 삭제 기능 구현

This commit is contained in:
Yu Sung
2026-03-20 10:51:22 +09:00
parent 793b5dd95a
commit 8eca5df62b
9 changed files with 433 additions and 27 deletions

View File

@@ -30,6 +30,8 @@ struct LiveRoomViewV2: View {
@State private var wavePhase: CGFloat = 0
@State private var isShowFollowNotifyDialog: Bool = false
@State private var guestFollowButtonTypeOverride: FollowButtonImageType? = nil
@State private var selectedChatForDelete: LiveRoomNormalChat? = nil
@State private var isShowChatDeleteDialog: Bool = false
let heartWaveTimer = Timer.publish(every: 1/60, on: .main, in: .common).autoconnect()
private var appliedKeyboardHeight: CGFloat {
@@ -213,11 +215,19 @@ struct LiveRoomViewV2: View {
scrollObservableView
if !viewModel.changeIsAdult || UserDefaults.bool(forKey: .auth) {
LiveRoomChatView(messages: viewModel.messages) {
if $0 != UserDefaults.int(forKey: .userId) {
viewModel.getUserProfile(userId: $0)
LiveRoomChatView(
messages: viewModel.messages,
isCreator: liveRoomInfo.creatorId == UserDefaults.int(forKey: .userId),
getUserProfile: {
if $0 != UserDefaults.int(forKey: .userId) {
viewModel.getUserProfile(userId: $0)
}
},
onLongPressChat: { chat in
selectedChatForDelete = chat
isShowChatDeleteDialog = true
}
}
)
.frame(width: screenSize().width)
.rotationEffect(Angle(degrees: 180))
.valueChanged(value: viewModel.messageChangeFlag) { _ in
@@ -605,6 +615,24 @@ struct LiveRoomViewV2: View {
}
)
}
if isShowChatDeleteDialog, let selectedChat = selectedChatForDelete {
SodaDialog(
title: I18n.LiveRoom.chatDeleteTitle,
desc: "\(selectedChat.nickname): \(selectedChat.chat)",
confirmButtonTitle: I18n.Common.delete,
confirmButtonAction: {
viewModel.deleteChat(selectedChat)
selectedChatForDelete = nil
isShowChatDeleteDialog = false
},
cancelButtonTitle: I18n.Common.cancel,
cancelButtonAction: {
selectedChatForDelete = nil
isShowChatDeleteDialog = false
}
)
}
}
ZStack {
@@ -979,6 +1007,11 @@ struct LiveRoomViewV2: View {
guestFollowButtonTypeOverride = nil
}
}
.onChange(of: isShowChatDeleteDialog) { isShowing in
if isShowing {
hideKeyboard()
}
}
}
private func estimatedHeight(for text: String, width: CGFloat) -> CGFloat {