feat(chat-room): 유료 메시지 구매 기능 추가
This commit is contained in:
@@ -64,6 +64,8 @@ struct AiMessageItemView: View {
|
||||
let message: ServerChatMessage
|
||||
let characterName: String
|
||||
|
||||
let purchaseMessage: () -> Void
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .bottom, spacing: 4) {
|
||||
// 메시지 영역
|
||||
@@ -88,7 +90,10 @@ struct AiMessageItemView: View {
|
||||
}
|
||||
|
||||
// 메시지 내용 (텍스트 또는 이미지)
|
||||
if message.messageType.lowercased() == "image", let imageUrl = message.imageUrl, !imageUrl.isEmpty {
|
||||
if message.messageType.lowercased() == "image",
|
||||
let imageUrl = message.imageUrl,
|
||||
!imageUrl.isEmpty
|
||||
{
|
||||
// 이미지 메시지
|
||||
let maxWidth = (UIScreen.main.bounds.width - 48) * 0.7
|
||||
let imageHeight = maxWidth * 5 / 4 // 4:5 비율
|
||||
@@ -97,6 +102,41 @@ struct AiMessageItemView: View {
|
||||
KFImage(URL(string: imageUrl))
|
||||
.resizable()
|
||||
.scaledToFill() // 비율 유지하며 프레임을 채움
|
||||
|
||||
Color.black.opacity(0.2)
|
||||
.frame(width: maxWidth, height: imageHeight)
|
||||
.cornerRadius(30)
|
||||
|
||||
if let price = message.price, price > 0, !message.hasAccess {
|
||||
VStack(spacing: 18) {
|
||||
HStack(spacing: 4) {
|
||||
Image("ic_can")
|
||||
.resizable()
|
||||
.frame(width: 24, height: 24)
|
||||
|
||||
Text("\(message.price ?? 5)")
|
||||
.font(.custom(Font.preBold.rawValue, size: 16))
|
||||
.foregroundColor(Color(hex: "263238"))
|
||||
}
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 3)
|
||||
.background(Color(hex: "B5E7FA"))
|
||||
.cornerRadius(30)
|
||||
.overlay {
|
||||
RoundedRectangle(cornerRadius: 30)
|
||||
.stroke(lineWidth: 1)
|
||||
.foregroundColor(.button)
|
||||
}
|
||||
|
||||
Text("눌러서 잠금해제")
|
||||
.font(.custom(Font.preBold.rawValue, size: 18))
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
.frame(width: maxWidth, height: imageHeight)
|
||||
.onTapGesture {
|
||||
purchaseMessage()
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(width: maxWidth, height: imageHeight)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous))
|
||||
@@ -189,7 +229,8 @@ struct AiMessageItemView: View {
|
||||
price: nil,
|
||||
hasAccess: true
|
||||
),
|
||||
characterName: "보라"
|
||||
characterName: "보라",
|
||||
purchaseMessage: {}
|
||||
)
|
||||
.padding()
|
||||
.background(Color.black)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
//
|
||||
// ChatMessagePurchaseRequest.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 9/4/25.
|
||||
//
|
||||
|
||||
struct ChatMessagePurchaseRequest: Encodable {
|
||||
let container: String = "ios"
|
||||
}
|
||||
Reference in New Issue
Block a user