feat(chat-room): 유료 메시지 구매 기능 추가

This commit is contained in:
Yu Sung
2025-09-04 06:34:00 +09:00
parent 6ce85a485a
commit 20801bdcfb
6 changed files with 165 additions and 5 deletions

View File

@@ -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)

View File

@@ -0,0 +1,10 @@
//
// ChatMessagePurchaseRequest.swift
// SodaLive
//
// Created by klaus on 9/4/25.
//
struct ChatMessagePurchaseRequest: Encodable {
let container: String = "ios"
}