78 lines
3.3 KiB
Swift
78 lines
3.3 KiB
Swift
import SwiftUI
|
|
|
|
struct SodaAddressInputView: View {
|
|
@Binding var zipCode: String
|
|
@Binding var address: String
|
|
@Binding var addressDetail: String
|
|
@State private var isSearching = false
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: SodaSpacing.s4) {
|
|
Text("우편번호")
|
|
.appFont(.body5)
|
|
.foregroundColor(.grayee)
|
|
VStack(spacing: SodaSpacing.s8) {
|
|
HStack(spacing: SodaSpacing.s8) {
|
|
readonlyField(zipCode, placeholder: "우편번호를 입력해 주세요", label: "우편번호")
|
|
Button {
|
|
isSearching = true
|
|
} label: {
|
|
Text("주소 검색")
|
|
.appFont(.body5)
|
|
.foregroundColor(.white)
|
|
.padding(.horizontal, SodaSpacing.s14)
|
|
.frame(minHeight: 44)
|
|
.overlay(Capsule().stroke(Color.gray500, lineWidth: 1))
|
|
.fixedSize(horizontal: true, vertical: false)
|
|
}
|
|
.buttonStyle(.plain)
|
|
.accessibilityLabel("주소 검색")
|
|
}
|
|
VStack(alignment: .leading, spacing: SodaSpacing.s4) {
|
|
Text("주소")
|
|
.appFont(.body5)
|
|
.foregroundColor(.grayee)
|
|
readonlyField(address, placeholder: "주소를 입력해 주세요", label: "기본 주소")
|
|
}
|
|
VStack(alignment: .leading, spacing: SodaSpacing.s4) {
|
|
Text("상세주소")
|
|
.appFont(.body5)
|
|
.foregroundColor(.grayee)
|
|
TextField("", text: $addressDetail, prompt: Text("상세 주소를 입력해 주세요").foregroundColor(.gray600))
|
|
.appFont(.body3)
|
|
.foregroundColor(.white)
|
|
.textContentType(.streetAddressLine2)
|
|
.autocorrectionDisabled()
|
|
.padding(SodaSpacing.s14)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.background(Color.gray900)
|
|
.cornerRadius(SodaRadius.r14)
|
|
.accessibilityLabel("상세 주소")
|
|
}
|
|
}
|
|
}
|
|
.sheet(isPresented: $isSearching) {
|
|
KakaoPostcodeSearchView { result in
|
|
if zipCode != result.zonecode || address != result.address {
|
|
addressDetail = ""
|
|
}
|
|
zipCode = result.zonecode
|
|
address = result.address
|
|
isSearching = false
|
|
}
|
|
}
|
|
}
|
|
|
|
private func readonlyField(_ value: String, placeholder: String, label: String) -> some View {
|
|
Text(value.isEmpty ? placeholder : value)
|
|
.appFont(.body3)
|
|
.foregroundColor(value.isEmpty ? .gray600 : .white)
|
|
.padding(SodaSpacing.s14)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.background(Color.gray900)
|
|
.cornerRadius(SodaRadius.r14)
|
|
.accessibilityLabel(label)
|
|
.accessibilityValue(value)
|
|
}
|
|
}
|