141 lines
6.7 KiB
Swift
141 lines
6.7 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: I18n.CanCoupon.title)
|
|
|
|
ScrollView(.vertical, showsIndicators: false) {
|
|
VStack(spacing: 0) {
|
|
Text(I18n.CanCoupon.inputTitle)
|
|
.appFont(size: 16.7, weight: .bold)
|
|
.foregroundColor(Color(hex: "eeeeee"))
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
|
|
TextField(I18n.CanCoupon.inputPlaceholder, text: $viewModel.couponNumber)
|
|
.autocapitalization(.allCharacters) // Force uppercase keyboard
|
|
.textContentType(.none)
|
|
.disableAutocorrection(true)
|
|
.appFont(size: 13.3, weight: .medium)
|
|
.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(I18n.CanCoupon.submit)
|
|
.appFont(size: 18.3, weight: .bold)
|
|
.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(I18n.CanCoupon.guideHeader)
|
|
.appFont(size: 13.3, weight: .bold)
|
|
.foregroundColor(.grayee)
|
|
|
|
CanCouponNoticeItemView(notice: I18n.CanCoupon.guide1)
|
|
.padding(.top, 8)
|
|
|
|
CanCouponNoticeItemView(notice: I18n.CanCoupon.guide2)
|
|
.padding(.top, 4)
|
|
|
|
CanCouponNoticeItemView(notice: I18n.CanCoupon.guide3)
|
|
.padding(.top, 4)
|
|
|
|
Rectangle()
|
|
.foregroundColor(.clear)
|
|
.frame(maxWidth: .infinity, minHeight: 1, maxHeight: 1)
|
|
.background(Color.gray55)
|
|
.padding(.vertical, 26.7)
|
|
|
|
Text(I18n.CanCoupon.cautionHeader)
|
|
.appFont(size: 13.3, weight: .bold)
|
|
.foregroundColor(.grayee)
|
|
|
|
CanCouponNoticeItemView(notice: I18n.CanCoupon.caution1)
|
|
.padding(.top, 8)
|
|
|
|
CanCouponNoticeItemView(notice: I18n.CanCoupon.caution2)
|
|
.padding(.top, 4)
|
|
|
|
CanCouponNoticeItemView(notice: I18n.CanCoupon.caution3)
|
|
.padding(.top, 4)
|
|
|
|
CanCouponNoticeItemView(notice: I18n.CanCoupon.caution4)
|
|
.padding(.top, 4)
|
|
|
|
Text(I18n.CanCoupon.contactHelp)
|
|
.appFont(size: 13.3, weight: .medium)
|
|
.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)
|
|
.appFont(size: 12, weight: .medium)
|
|
.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: {})
|
|
}
|
|
}
|