feat(chat): 채팅 쿼터 광고 충전을 추가한다

This commit is contained in:
Yu Sung
2026-04-30 14:23:15 +09:00
parent 714ad459b0
commit 5823f6ddb2
10 changed files with 423 additions and 133 deletions

View File

@@ -9,57 +9,79 @@ import SwiftUI
struct ChatQuotaNoticeItemView: View {
let remainingTime: String
let purchase: () -> Void
let onSelectAd: () -> Void
let onSelectCan10: () -> Void
let onSelectCan20: () -> Void
var body: some View {
VStack(spacing: 10) {
VStack(spacing: 8) {
Image("ic_time")
.resizable()
.frame(width: 30, height: 30)
Text(remainingTime)
Button {
onSelectAd()
} label: {
Text(I18n.Chat.Room.quotaAdAction(chatCount: 5))
.appFont(size: 18, weight: .bold)
.foregroundColor(.white)
Text(I18n.Chat.Room.quotaWaitForFreeNotice)
.appFont(size: 18, weight: .bold)
.foregroundColor(.white)
.foregroundColor(Color(hex: "263238"))
.frame(maxWidth: .infinity)
.padding(.vertical, 14)
}
.frame(maxWidth: .infinity)
.padding(.vertical, 15)
.background(Color(hex: "EC8280"))
.cornerRadius(10)
HStack(spacing: 4) {
Image("ic_can")
Text("10")
.appFont(size: 24, weight: .bold)
.foregroundColor(Color(hex: "263238"))
Text(I18n.Chat.Room.quotaPurchaseAction(chatCount: 12))
.appFont(size: 24, weight: .bold)
.foregroundColor(Color(hex: "263238"))
.padding(.leading, 4)
}
.frame(maxWidth: .infinity)
.padding(.vertical, 12)
.background(Color(hex: "B5E7FA"))
.background(Color(hex: "FEF8E3"))
.cornerRadius(30)
.overlay {
RoundedRectangle(cornerRadius: 30)
.stroke(lineWidth: 1)
.foregroundColor(Color.button)
.foregroundColor(Color(hex: "F7CB50"))
}
.onTapGesture {
purchase()
.buttonStyle(.plain)
HStack(spacing: 8) {
Button {
onSelectCan10()
} label: {
canButtonLabel(can: 10, chatCount: 15)
}
.buttonStyle(.plain)
Button {
onSelectCan20()
} label: {
canButtonLabel(can: 20, chatCount: 40)
}
.buttonStyle(.plain)
}
}
}
private func canButtonLabel(can: Int, chatCount: Int) -> some View {
HStack(spacing: 4) {
Image("ic_can")
HStack(spacing: 0) {
Text("\(can)")
.appFont(size: 20, weight: .bold)
.foregroundColor(Color(hex: "263238"))
Text(" / \(I18n.Chat.Room.quotaChatCount(chatCount))")
.appFont(size: 20, weight: .medium)
.foregroundColor(Color(hex: "263238"))
}
}
.frame(maxWidth: .infinity)
.padding(.vertical, 12)
.background(Color(hex: "B5E7FA"))
.cornerRadius(30)
.overlay {
RoundedRectangle(cornerRadius: 30)
.stroke(lineWidth: 1)
.foregroundColor(Color.button)
}
}
}
#Preview {
ChatQuotaNoticeItemView(remainingTime: "05:59:55") {}
ChatQuotaNoticeItemView(
onSelectAd: {},
onSelectCan10: {},
onSelectCan20: {}
)
}

View File

@@ -7,4 +7,42 @@
struct ChatQuotaPurchaseRequest: Encodable {
let container: String = "ios"
let chargeType: ChatRoomQuotaChargeType
let canOption: ChatRoomQuotaCanOption?
init(
chargeType: ChatRoomQuotaChargeType = .can,
canOption: ChatRoomQuotaCanOption? = nil
) {
self.chargeType = chargeType
self.canOption = canOption
}
}
enum ChatRoomQuotaChargeType: String, Encodable {
case can = "CAN"
case ad = "AD"
}
enum ChatRoomQuotaCanOption: String, Encodable {
case can10 = "CAN_10"
case can20 = "CAN_20"
var needCan: Int {
switch self {
case .can10:
return 10
case .can20:
return 20
}
}
var quota: Int {
switch self {
case .can10:
return 15
case .can20:
return 40
}
}
}