141 lines
		
	
	
		
			7.3 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			141 lines
		
	
	
		
			7.3 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
//
 | 
						|
//  CanCouponView.swift
 | 
						|
//  SodaLive
 | 
						|
//
 | 
						|
//  Created by klaus on 2024/01/03.
 | 
						|
//
 | 
						|
 | 
						|
import SwiftUI
 | 
						|
 | 
						|
struct CanCouponView: View {
 | 
						|
    
 | 
						|
    @StateObject var viewModel = CanCouponViewModel()
 | 
						|
    
 | 
						|
    let refresh: () -> Void
 | 
						|
    
 | 
						|
    var body: some View {
 | 
						|
        BaseView(isLoading: $viewModel.isLoading) {
 | 
						|
            GeometryReader { proxy in
 | 
						|
                VStack(spacing: 0) {
 | 
						|
                    DetailNavigationBar(title: "쿠폰등록")
 | 
						|
                    
 | 
						|
                    ScrollView(.vertical, showsIndicators: false) {
 | 
						|
                        VStack(spacing: 0) {
 | 
						|
                            Text("쿠폰번호 입력")
 | 
						|
                                .font(.custom(Font.bold.rawValue, size: 16.7))
 | 
						|
                                .foregroundColor(Color(hex: "eeeeee"))
 | 
						|
                                .frame(maxWidth: .infinity, alignment: .leading)
 | 
						|
                            
 | 
						|
                            TextField("쿠폰번호를 입력하세요", text: $viewModel.couponNumber)
 | 
						|
                                .autocapitalization(.allCharacters) // Force uppercase keyboard
 | 
						|
                                .textContentType(.none)
 | 
						|
                                .disableAutocorrection(true)
 | 
						|
                                .font(.custom(Font.medium.rawValue, size: 13.3))
 | 
						|
                                .foregroundColor(Color(hex: "eeeeee"))
 | 
						|
                                .padding(.vertical, 16.7)
 | 
						|
                                .padding(.horizontal, 13.3)
 | 
						|
                                .background(Color(hex: "222222"))
 | 
						|
                                .cornerRadius(6.7)
 | 
						|
                                .keyboardType(.default)
 | 
						|
                                .padding(.top, 13.3)
 | 
						|
                                .onChange(of: viewModel.couponNumber) { newString in
 | 
						|
                                    let filtered = newString.filter { $0.isUppercase || $0.isNumber }
 | 
						|
                                    if filtered != newString {
 | 
						|
                                        viewModel.couponNumber = filtered
 | 
						|
                                    }
 | 
						|
                                }
 | 
						|
                            
 | 
						|
                            Text("등록하기")
 | 
						|
                                .font(.custom(Font.bold.rawValue, size: 18.3))
 | 
						|
                                .foregroundColor(.white)
 | 
						|
                                .padding(.vertical, 16)
 | 
						|
                                .frame(maxWidth: .infinity)
 | 
						|
                                .background(Color(hex: "3bb9f1"))
 | 
						|
                                .cornerRadius(10)
 | 
						|
                                .padding(.top, 21.3)
 | 
						|
                                .onTapGesture {
 | 
						|
                                    viewModel.useCoupon { refresh() }
 | 
						|
                                }
 | 
						|
                            
 | 
						|
                            VStack(alignment: .leading, spacing: 0) {
 | 
						|
                                Text("[등록 및 사용안내]")
 | 
						|
                                    .font(.custom(Font.bold.rawValue, size: 13.3))
 | 
						|
                                    .foregroundColor(.grayee)
 | 
						|
                                
 | 
						|
                                CanCouponNoticeItemView(notice: "공백없이 쿠폰번호 12자리를 입력해주세요.")
 | 
						|
                                    .padding(.top, 8)
 | 
						|
                                
 | 
						|
                                CanCouponNoticeItemView(notice: "충전된 캔 또는 포인트는 해당 충전현황에서 확인할 수 있습니다")
 | 
						|
                                    .padding(.top, 4)
 | 
						|
                                
 | 
						|
                                CanCouponNoticeItemView(notice: "쿠폰으로 충전된 캔은 사용 전까지 소멸되지 않으며, 포인트는 충전 후 72시간 이내에 사용하지 않으면 자동 소멸됩니다.")
 | 
						|
                                    .padding(.top, 4)
 | 
						|
                                
 | 
						|
                                Rectangle()
 | 
						|
                                  .foregroundColor(.clear)
 | 
						|
                                  .frame(maxWidth: .infinity, minHeight: 1, maxHeight: 1)
 | 
						|
                                  .background(Color.gray55)
 | 
						|
                                  .padding(.vertical, 26.7)
 | 
						|
                                
 | 
						|
                                Text("[주의사항]")
 | 
						|
                                    .font(.custom(Font.bold.rawValue, size: 13.3))
 | 
						|
                                    .foregroundColor(.grayee)
 | 
						|
                                
 | 
						|
                                CanCouponNoticeItemView(notice: "이벤트 쿠폰을 통해 충전한 캔이나 포인트는 환불되지 않습니다.")
 | 
						|
                                    .padding(.top, 8)
 | 
						|
                                
 | 
						|
                                CanCouponNoticeItemView(notice: "쿠폰은 상업적 용도로 사용하거나 매매할 수 없습니다.")
 | 
						|
                                    .padding(.top, 4)
 | 
						|
                                
 | 
						|
                                CanCouponNoticeItemView(notice: "한번 등록한 쿠폰은 재사용이 불가합니다.")
 | 
						|
                                    .padding(.top, 4)
 | 
						|
                                
 | 
						|
                                CanCouponNoticeItemView(notice: "연령 제한 정책에 따라 쿠폰이용은 본인인증한 회원만 이용 가능합니다.")
 | 
						|
                                    .padding(.top, 4)
 | 
						|
                                
 | 
						|
                                Text("※ 쿠폰 등록 및 이용에 문제가 발생한 경우 '고객센터'로 문의주시기 바랍니다.")
 | 
						|
                                    .font(.custom(Font.medium.rawValue, size: 13.3))
 | 
						|
                                    .foregroundColor(.grayee)
 | 
						|
                                    .fixedSize(horizontal: false, vertical: true)
 | 
						|
                                    .padding(.top, 26.7)
 | 
						|
                            }
 | 
						|
                            .padding(.horizontal, 13.3)
 | 
						|
                            .padding(.vertical, 26.7)
 | 
						|
                            .frame(maxWidth: .infinity, alignment: .leading)
 | 
						|
                            .background(Color(hex: "13181b"))
 | 
						|
                            .cornerRadius(6.7)
 | 
						|
                            .padding(.top, 21.3)
 | 
						|
                        }
 | 
						|
                        .padding(13.3)
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                .popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .top, autohideIn: 2) {
 | 
						|
                    GeometryReader { geo in
 | 
						|
                        HStack {
 | 
						|
                            Spacer()
 | 
						|
                            Text(viewModel.errorMessage)
 | 
						|
                                .padding(.vertical, 13.3)
 | 
						|
                                .padding(.horizontal, 6.7)
 | 
						|
                                .frame(width: geo.size.width - 66.7, alignment: .center)
 | 
						|
                                .font(.custom(Font.medium.rawValue, size: 12))
 | 
						|
                                .background(Color.button)
 | 
						|
                                .foregroundColor(Color.white)
 | 
						|
                                .multilineTextAlignment(.leading)
 | 
						|
                                .fixedSize(horizontal: false, vertical: true)
 | 
						|
                                .cornerRadius(20)
 | 
						|
                                .padding(.top, 66.7)
 | 
						|
                            Spacer()
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
struct CanCouponView_Previews: PreviewProvider {
 | 
						|
    static var previews: some View {
 | 
						|
        CanCouponView(refresh: {})
 | 
						|
    }
 | 
						|
}
 |