feat(live-room): 채팅창 얼리기 기능을 추가한다

채팅 입력 제어와 룸 상태 동기화를 통합해 지연 입장자도 동일 상태를 적용한다.
This commit is contained in:
Yu Sung
2026-03-19 18:20:13 +09:00
parent 0a22f87acc
commit 70003af82b
14 changed files with 466 additions and 29 deletions

View File

@@ -11,16 +11,27 @@ struct LiveRoomInputChatView: View {
@State private var chatMessage = ""
let isInputDisabled: Bool
let sendMessage: (String) -> Bool
let onDisabledInputTap: () -> Void
var body: some View {
HStack(spacing: 6.7) {
ChatTextFieldView(text: $chatMessage, placeholder: "채팅을 입력하세요") {
ChatTextFieldView(text: $chatMessage, placeholder: "채팅을 입력하세요", isEnabled: !isInputDisabled) {
if sendMessage(chatMessage) {
chatMessage = ""
}
}
.allowsHitTesting(!isInputDisabled)
.overlay {
if isInputDisabled {
Color.clear
.contentShape(Rectangle())
.onTapGesture {
onDisabledInputTap()
}
}
}
.padding(.vertical, 18.3)
.fixedSize(horizontal: false, vertical: true)
.frame(maxWidth: .infinity)
@@ -28,7 +39,13 @@ struct LiveRoomInputChatView: View {
Image("btn_message_send")
.resizable()
.frame(width: 35, height: 35)
.opacity(isInputDisabled ? 0.5 : 1)
.onTapGesture {
if isInputDisabled {
onDisabledInputTap()
return
}
if sendMessage(chatMessage) {
chatMessage = ""
}
@@ -43,12 +60,18 @@ struct LiveRoomInputChatView: View {
.strokeBorder(lineWidth: 1)
.foregroundColor(.gray77)
)
.onChange(of: isInputDisabled) { isDisabled in
if isDisabled {
hideKeyboard()
chatMessage = ""
}
}
.padding(13.3)
}
}
struct LiveRoomInputChatView_Previews: PreviewProvider {
static var previews: some View {
LiveRoomInputChatView(sendMessage: { _ in return true })
LiveRoomInputChatView(isInputDisabled: false, sendMessage: { _ in return true }, onDisabledInputTap: {})
}
}