Files
sodalive-ios/SodaLive/Sources/Audition/Applicant/AuditionApplyView.swift

158 lines
5.9 KiB
Swift

//
// AuditionApplyView.swift
// SodaLive
//
// Created by klaus on 1/7/25.
//
import SwiftUI
struct AuditionApplyView: View {
@Binding var isShowing: Bool
@Binding var phoneNumber: String
let filename: String
let onClickApply: () -> Void
@State private var isShowPopup = false
@State private var errorMessage = ""
@State private var isShow: Bool = false
@State private var isAgree = false
var body: some View {
ZStack {
Color.black.opacity(0.7).ignoresSafeArea()
.onTapGesture {
isShowing = false
}
VStack(spacing: 0) {
Spacer()
if isShow {
VStack(alignment: .leading, spacing: 0) {
HStack(spacing: 0) {
Text(I18n.Audition.Apply.title)
.appFont(size: 18.3, weight: .medium)
.foregroundColor(.white)
Spacer()
Image("ic_noti_stop")
.onTapGesture {
isShowing = false
}
}
Text(I18n.Audition.Apply.recordingFile)
.appFont(size: 16.7, weight: .bold)
.foregroundColor(.grayee)
.padding(.top, 20)
HStack(spacing: 4) {
Image("ic_note_square")
Text(displayFileName)
.appFont(size: 13.3, weight: .medium)
.foregroundColor(.grayd2)
Spacer()
}
.padding(.horizontal, 13.3)
.padding(.vertical, 8)
.frame(maxWidth: .infinity)
.background(Color.bg)
.cornerRadius(5.3)
.padding(.top, 10)
Text(I18n.Audition.Apply.contact)
.appFont(size: 16.7, weight: .bold)
.foregroundColor(.grayee)
.padding(.top, 15)
TextField(I18n.Audition.Apply.contactPlaceholder, text: $phoneNumber)
.autocapitalization(.none)
.disableAutocorrection(true)
.keyboardType(.decimalPad)
.appFont(size: 13.3, weight: .medium)
.foregroundColor(.grayee)
.padding(.horizontal, 13.3)
.padding(.vertical, 17)
.frame(maxWidth: .infinity)
.background(Color.bg)
.cornerRadius(5.3)
.padding(.top, 10)
HStack(alignment: .top, spacing: 13.3) {
Image(isAgree ? "btn_select_checked" : "btn_select_normal")
.resizable()
.frame(width: 20, height: 20)
Text(I18n.Audition.Apply.privacyAgreement)
.appFont(size: 13.3, weight: .medium)
.foregroundColor(Color.grayee)
.lineSpacing(3)
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.top, 30)
.onTapGesture {
isAgree.toggle()
}
Text(I18n.Audition.Apply.submit)
.appFont(size: 13.3, weight: .bold)
.foregroundColor(Color.grayee)
.padding(.vertical, 13.3)
.frame(maxWidth: .infinity)
.background(Color.button)
.cornerRadius(8)
.padding(.top, 35)
.onTapGesture {
if !isAgree {
errorMessage = I18n.Audition.Apply.requireAgreement
isShowPopup = true
return
}
onClickApply()
}
}
.frame(maxWidth:.infinity)
.padding(.horizontal, 16)
.padding(.top, 16)
.padding(.bottom, 32)
.background(Color.gray22)
.cornerRadius(10, corners: [.topLeft, .topRight])
.transition(.move(edge: .bottom))
.animation(.easeInOut(duration: 0.5), value: isShow)
}
}
.ignoresSafeArea()
}
.sodaToast(isPresented: $isShowPopup, message: errorMessage, autohideIn: 2)
.onAppear {
withAnimation {
isShow = true
}
}
}
private var displayFileName: String {
if filename.hasPrefix("voiceon_now_voice_") {
return I18n.Audition.Apply.recordedVoiceFileName
}
return filename
}
}
#Preview {
AuditionApplyView(
isShowing: .constant(true),
phoneNumber: .constant(""),
filename: "voiceon_now_voice_9292939.m4a",
onClickApply: {}
)
}