150 lines
5.6 KiB
Swift
150 lines
5.6 KiB
Swift
import SwiftUI
|
|
|
|
struct SentGiftDetailContentView: View {
|
|
let model: SentGiftDetailDisplayModel
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: SodaSpacing.s32) {
|
|
hero
|
|
|
|
if model.status == .undeliverable {
|
|
undeliverableReason
|
|
} else if model.status != .canceled {
|
|
GiftProgressView(progress: model.progress)
|
|
}
|
|
|
|
if model.status == .received {
|
|
mailbox
|
|
}
|
|
|
|
giftInfo
|
|
sender
|
|
|
|
if model.status != .received {
|
|
mailbox
|
|
}
|
|
}
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
}
|
|
|
|
private var hero: some View {
|
|
VStack(alignment: .leading, spacing: SodaSpacing.s14) {
|
|
if let statusLabel {
|
|
Text(statusLabel)
|
|
.appFont(.caption2)
|
|
.foregroundColor(model.status == .undeliverable ? .red400 : .soda400)
|
|
.padding(.horizontal, SodaSpacing.s8)
|
|
.padding(.vertical, SodaSpacing.s4)
|
|
.background(Color.gray900)
|
|
.clipShape(RoundedRectangle(cornerRadius: SodaRadius.r4))
|
|
}
|
|
|
|
Text(heroTitle)
|
|
.appFont(.heading1)
|
|
.foregroundColor(.white)
|
|
.accessibilityAddTraits(.isHeader)
|
|
|
|
if let heroBody {
|
|
Text(heroBody)
|
|
.appFont(.body6)
|
|
.foregroundColor(.gray500)
|
|
}
|
|
}
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
}
|
|
|
|
private var statusLabel: String? {
|
|
switch model.status {
|
|
case .trackingRegistered: return "발송 확인"
|
|
case .delivered: return "전달 완료"
|
|
case .undeliverable: return "전달 불가"
|
|
case .received, .arrivedAtMailbox, .inspectionCompleted, .canceled: return nil
|
|
}
|
|
}
|
|
|
|
private var heroTitle: String {
|
|
switch model.status {
|
|
case .received: return "선물 신청 완료!"
|
|
case .trackingRegistered: return "사서함으로 이동 중이에요"
|
|
case .delivered: return "크리에이터에게 선물을 전달했어요"
|
|
case .undeliverable: return "전달할 수 없는 품목입니다"
|
|
case .arrivedAtMailbox, .inspectionCompleted, .canceled: return model.statusName
|
|
}
|
|
}
|
|
|
|
private var heroBody: String? {
|
|
switch model.status {
|
|
case .received:
|
|
return "선물이 정상적으로 접수되었어요!"
|
|
case .undeliverable:
|
|
return "보내주신 선물은 소다라이브 선물 정책에 따라 크리에이터에게 전달할 수 없는 품목으로 확인되었습니다."
|
|
case .trackingRegistered, .arrivedAtMailbox, .inspectionCompleted, .delivered, .canceled:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
private var giftInfo: some View {
|
|
GiftInfoSectionView(title: "선물 정보") {
|
|
if let nickname = model.recipientCreatorNickname {
|
|
GiftInfoRow(title: "크리에이터", value: nickname)
|
|
}
|
|
GiftInfoRow(title: "선물 사이즈", value: model.sizeName)
|
|
GiftInfoRow(title: "카테고리", value: model.categoryName)
|
|
GiftInfoRow(title: "신청번호", value: model.applicationNo)
|
|
if let paidCan = model.paidCan {
|
|
GiftInfoRow(title: "캔", value: String(paidCan))
|
|
}
|
|
if let tracking = model.tracking,
|
|
!tracking.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
|
GiftInfoRow(title: "운송장 번호", value: tracking)
|
|
}
|
|
}
|
|
}
|
|
|
|
@ViewBuilder
|
|
private var sender: some View {
|
|
if let sender = model.senderInfo {
|
|
GiftInfoSectionView(title: "보내는 사람") {
|
|
GiftInfoRow(title: "이름", value: sender.name)
|
|
GiftInfoRow(title: "휴대폰 번호", value: sender.phoneNumber)
|
|
GiftInfoRow(title: "주소", value: sender.address)
|
|
}
|
|
}
|
|
}
|
|
|
|
@ViewBuilder
|
|
private var mailbox: some View {
|
|
if let mailbox = model.mailbox {
|
|
GiftInfoSectionView(title: model.status == .received ? "보내실 주소" : "받는 사서함") {
|
|
GiftInfoRow(title: "사서함", value: mailbox.name)
|
|
GiftInfoRow(title: "주소", value: mailbox.address)
|
|
GiftInfoRow(title: "연락처", value: mailbox.phoneNumber)
|
|
}
|
|
}
|
|
}
|
|
|
|
private var undeliverableReason: some View {
|
|
GiftInfoSectionView(title: "사유") {
|
|
if let reason = model.undeliverableReason?.trimmingCharacters(in: .whitespacesAndNewlines),
|
|
!reason.isEmpty {
|
|
Text(reason)
|
|
.appFont(.body6)
|
|
.foregroundColor(.white)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
|
|
Divider()
|
|
.overlay(Color.gray800)
|
|
.accessibilityHidden(true)
|
|
}
|
|
|
|
Text("해당 선물은 보관기간(입고일 포함 최대 7일) 내에 반송 등 필요한 조치가 완료되지 않을 경우, 사전에 동의한 약관 및 폐기 등의 내용에 따라 폐기될 수 있습니다. 자세한 내용은 고객센터로 문의해 주세요.")
|
|
.appFont(.body6)
|
|
.foregroundColor(.red400)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
}
|
|
}
|
|
}
|