85 lines
3.3 KiB
Swift
85 lines
3.3 KiB
Swift
import SwiftUI
|
|
|
|
struct GiftDetailActionBar: View {
|
|
let model: SentGiftDetailDisplayModel
|
|
var onCancel: (() -> Void)? = nil
|
|
let onPolicy: () -> Void
|
|
@State private var isNavigating = false
|
|
|
|
var body: some View {
|
|
if model.trackingRequired || model.status == .received || model.status == .undeliverable {
|
|
VStack(spacing: SodaSpacing.s8) {
|
|
if model.trackingRequired {
|
|
Button {
|
|
guard !isNavigating else { return }
|
|
isNavigating = true
|
|
AppState.shared.setAppStep(step: .giftTrackingRegistration(applicationNo: model.applicationNo))
|
|
} label: {
|
|
SelectedButtonView(
|
|
title: "운송장 작성하기",
|
|
isActive: !isNavigating,
|
|
isSelected: false,
|
|
bgDefaultColor: .button,
|
|
textDefaultColor: .white
|
|
)
|
|
.multilineTextAlignment(.center)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
.frame(minHeight: SodaSpacing.s48)
|
|
.contentShape(Rectangle())
|
|
}
|
|
.disabled(isNavigating)
|
|
}
|
|
|
|
if model.status == .received {
|
|
Button {
|
|
onCancel?()
|
|
} label: {
|
|
secondaryLabel("신청 취소", isEnabled: onCancel != nil)
|
|
}
|
|
.disabled(onCancel == nil)
|
|
.accessibilityHint(onCancel == nil ? "현재 신청 취소를 이용할 수 없습니다." : "")
|
|
}
|
|
|
|
if model.status == .undeliverable {
|
|
Button {
|
|
guard !isNavigating else { return }
|
|
isNavigating = true
|
|
AppState.shared.setAppStep(step: GiftConstants.inquiryStep)
|
|
} label: {
|
|
secondaryLabel("문의하기", isEnabled: !isNavigating)
|
|
}
|
|
.disabled(isNavigating)
|
|
|
|
Button {
|
|
onPolicy()
|
|
} label: {
|
|
secondaryLabel("선물 정책 확인")
|
|
}
|
|
}
|
|
}
|
|
.buttonStyle(.plain)
|
|
.padding(.horizontal, SodaSpacing.s14)
|
|
.padding(.vertical, SodaSpacing.s12)
|
|
.frame(maxWidth: .infinity)
|
|
.background(Color.black)
|
|
.onAppear {
|
|
isNavigating = false
|
|
}
|
|
}
|
|
}
|
|
|
|
private func secondaryLabel(_ title: String, isEnabled: Bool = true) -> some View {
|
|
Text(title)
|
|
.appFont(.body2)
|
|
.foregroundColor(isEnabled ? .white : .gray500)
|
|
.multilineTextAlignment(.center)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
.padding(.horizontal, SodaSpacing.s16)
|
|
.padding(.vertical, SodaSpacing.s12)
|
|
.frame(maxWidth: .infinity, minHeight: SodaSpacing.s48)
|
|
.background(Color.gray900)
|
|
.clipShape(RoundedRectangle(cornerRadius: SodaRadius.r8))
|
|
.contentShape(Rectangle())
|
|
}
|
|
}
|