오디션 지원 기능 추가

This commit is contained in:
Yu Sung
2025-01-07 18:32:34 +09:00
parent 36028aa108
commit 1d9964721f
14 changed files with 779 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
//
// ApplyAuditionRoleRequest.swift
// SodaLive
//
// Created by klaus on 1/7/25.
//
struct ApplyAuditionRoleRequest: Encodable {
let roleId: Int
let phoneNumber: String
}

View File

@@ -0,0 +1,108 @@
//
// ApplyMethodView.swift
// SodaLive
//
// Created by klaus on 1/7/25.
//
import SwiftUI
struct ApplyMethodView: View {
@Binding var isShowing: Bool
let onClickSelectAudioFile: () -> Void
let onClickRecording: () -> Void
var body: some View {
ZStack {
Color.black.opacity(0.7).ignoresSafeArea()
.onTapGesture {
isShowing = false
}
VStack(spacing: 0) {
HStack(spacing: 0) {
Spacer()
Image("ic_noti_stop")
.onTapGesture {
isShowing = false
}
}
Text("오디션 지원방식")
.font(.custom(Font.bold.rawValue, size: 18.3))
.foregroundColor(Color.graybb)
.padding(.top, 33.3)
HStack(spacing: 13.3) {
HStack(spacing: 3) {
Image("ic_upload")
Text("파일 업로드")
.font(.custom(Font.medium.rawValue, size: 14.7))
.foregroundColor(Color.button)
}
.padding(.vertical, 8)
.frame(maxWidth: .infinity)
.background(Color.bg)
.cornerRadius(5.3)
.overlay(
RoundedRectangle(cornerRadius: 8)
.stroke()
.foregroundColor(Color.button)
)
.contentShape(Rectangle())
.onTapGesture {
onClickSelectAudioFile()
}
HStack(spacing: 3) {
Image("ic_mic_color_button")
Text("바로 녹음")
.font(.custom(Font.medium.rawValue, size: 14.7))
.foregroundColor(Color.button)
}
.padding(.vertical, 8)
.frame(maxWidth: .infinity)
.background(Color.bg)
.cornerRadius(5.3)
.overlay(
RoundedRectangle(cornerRadius: 8)
.stroke()
.foregroundColor(Color.button)
)
.contentShape(Rectangle())
.onTapGesture {
onClickRecording()
}
}
.padding(.top, 21.3)
HStack(spacing: 0) {
Text("※ 파일은 mp3, aac만 업로드 가능")
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color.gray77)
.padding(.top, 13.3)
Spacer()
}
}
.padding(.horizontal, 16.7)
.padding(.vertical, 13.3)
.frame(maxWidth: .infinity)
.background(Color.gray22)
.cornerRadius(10.3)
.padding(.horizontal, 13.3)
}
}
}
#Preview {
ApplyMethodView(
isShowing: .constant(true),
onClickSelectAudioFile: {},
onClickRecording: {}
)
}

View File

@@ -0,0 +1,206 @@
//
// AuditionApplicantRecordingView.swift
// SodaLive
//
// Created by klaus on 1/7/25.
//
import SwiftUI
struct AuditionApplicantRecordingView: View {
@StateObject var soundManager = CreatorCommunitySoundManager()
@Binding var isShowing: Bool
@Binding var isShowPopup: Bool
@Binding var errorMessage: String
let onClickCompleteRecording: (String, Data) -> Void
@State private var tempFileName = ""
var body: some View {
ZStack {
Color.black.opacity(0.7)
.ignoresSafeArea()
GeometryReader { proxy in
VStack {
Spacer()
VStack {
VStack(spacing: 0) {
HStack(spacing: 0) {
Text("오디션 녹음")
.font(.custom(Font.bold.rawValue, size: 18.3))
.foregroundColor(.white)
Spacer()
Image("ic_close_white")
.resizable()
.frame(width: 20, height: 20)
.onTapGesture { isShowing = false }
}
.padding(.horizontal, 26.7)
.padding(.top, 26.7)
}
Text(soundManager.timeString)
.font(.custom(Font.bold.rawValue, size: 33.3))
.foregroundColor(.white)
.padding(.top, 80)
switch soundManager.recordMode {
case .RECORD:
if !soundManager.isLoading {
Image(soundManager.isRecording ? "ic_record_stop" : "ic_record")
.resizable()
.frame(width: 70, height: 70)
.padding(.vertical, 52.3)
.onTapGesture {
if !soundManager.isLoading {
if !soundManager.isRecording {
tempFileName = "voiceon_now_voice_\(Int(Date().timeIntervalSince1970 * 1000)).m4a"
soundManager.startRecording(tempFileName)
} else {
soundManager.stopRecording()
soundManager.recordMode = .PLAY
}
}
}
}
case .PLAY:
if !soundManager.isLoading {
VStack(spacing: 0) {
HStack(spacing: 0) {
Spacer()
Text("삭제")
.font(.custom(Font.medium.rawValue, size: 15.3))
.foregroundColor(Color.graybb.opacity(0))
Spacer()
Image(
!soundManager.isPlaying ?
"ic_record_play" :
"ic_record_pause"
)
.onTapGesture {
if !soundManager.isLoading {
if !soundManager.isPlaying {
soundManager.playAudio()
} else {
soundManager.stopAudio()
}
}
}
Spacer()
Text("삭제")
.font(.custom(Font.medium.rawValue, size: 15.3))
.foregroundColor(Color.graybb)
.onTapGesture {
soundManager.stopAudio()
soundManager.deleteAudioFile()
soundManager.recordMode = .RECORD
}
Spacer()
}
.padding(.vertical, 52.3)
HStack(spacing: 13.3) {
Text("다시 녹음")
.font(.custom(Font.bold.rawValue, size: 18.3))
.foregroundColor(Color.button)
.frame(width: (proxy.size.width - 40) / 3, height: 50)
.background(Color.button.opacity(0.2))
.cornerRadius(10)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color.button, lineWidth: 1.3)
)
.onTapGesture {
soundManager.stopAudio()
soundManager.deleteAudioFile()
soundManager.recordMode = .RECORD
}
Text("녹음완료")
.font(.custom(Font.bold.rawValue, size: 18.3))
.foregroundColor(.white)
.frame(width: (proxy.size.width - 40) * 2 / 3, height: 50)
.background(Color.button)
.cornerRadius(10)
.onTapGesture {
do {
let soundData = try Data(contentsOf: soundManager.getAudioFileURL())
onClickCompleteRecording(tempFileName, soundData)
} catch {
errorMessage = "녹음파일을 생성하지 못했습니다.\n다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
isShowPopup = true
}
}
}
.padding(.bottom, 40)
.padding(.horizontal, 13.3)
}
}
}
if proxy.safeAreaInsets.bottom > 0 {
Rectangle()
.foregroundColor(Color.gray22)
.frame(width: proxy.size.width, height: 15.3)
}
if soundManager.isLoading {
LoadingView()
}
}
.background(Color(hex: "222222"))
.cornerRadius(16.7, corners: [.topLeft, .topRight])
}
.edgesIgnoringSafeArea(.bottom)
.onAppear {
soundManager.prepareRecording()
}
}
}
.popup(isPresented: $soundManager.isShowPopup, type: .toast, position: .top, autohideIn: 2) {
GeometryReader { geo in
HStack {
Spacer()
Text(soundManager.errorMessage)
.padding(.vertical, 13.3)
.padding(.horizontal, 6.7)
.frame(width: screenSize().width - 66.7, alignment: .center)
.font(.custom(Font.medium.rawValue, size: 12))
.background(Color.button)
.foregroundColor(Color.white)
.multilineTextAlignment(.center)
.cornerRadius(20)
.padding(.top, 66.7)
Spacer()
}
.onDisappear {
if soundManager.onClose {
isShowing = false
}
}
}
}
}
}
#Preview {
AuditionApplicantRecordingView(
isShowing: .constant(false),
isShowPopup: .constant(false),
errorMessage: .constant(""),
onClickCompleteRecording: { _, _ in }
)
}

View File

@@ -0,0 +1,165 @@
//
// 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("오디션 지원")
.font(.custom(Font.medium.rawValue, size: 18.3))
.foregroundColor(.white)
Spacer()
Image("ic_noti_stop")
.onTapGesture {
isShowing = false
}
}
Text("녹음파일")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(.grayee)
.padding(.top, 20)
HStack(spacing: 4) {
Image("ic_note_square")
Text(filename)
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(.grayd2)
Spacer()
}
.padding(.horizontal, 13.3)
.padding(.vertical, 8)
.frame(maxWidth: .infinity)
.background(Color.bg)
.cornerRadius(5.3)
.padding(.top, 10)
Text("연락처")
.font(.custom(Font.bold.rawValue, size: 16.7))
.foregroundColor(.grayee)
.padding(.top, 15)
TextField("합격시 받을 연락처를 남겨주세요", text: $phoneNumber)
.autocapitalization(.none)
.disableAutocorrection(true)
.keyboardType(.decimalPad)
.font(.custom(Font.medium.rawValue, size: 13.3))
.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("보이스온 오디오 드라마 오디션 합격시 개인 연락을 위한 개인 정보(연락처) 수집 및 활용에 동의합니다.\n오디션 지원자는 개인정보 수집 및 활용 동의에 거부할 권리가 있으며 비동의시 오디션 지원은 취소 됩니다.")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color.grayee)
.lineSpacing(3)
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.top, 30)
.onTapGesture {
isAgree.toggle()
}
Text("오디션 지원하기")
.font(.custom(Font.bold.rawValue, size: 13.3))
.foregroundColor(Color.grayee)
.padding(.vertical, 13.3)
.frame(maxWidth: .infinity)
.background(Color.button)
.cornerRadius(8)
.padding(.top, 35)
.onTapGesture {
if !isAgree {
errorMessage = "연락처 수집 및 활용에 동의하셔야 오디션 지원이 가능합니다."
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()
}
.popup(isPresented: $isShowPopup, type: .toast, position: .top, autohideIn: 2) {
GeometryReader { geo in
HStack {
Spacer()
Text(errorMessage)
.padding(.vertical, 13.3)
.frame(width: screenSize().width - 66.7, alignment: .center)
.font(.custom(Font.medium.rawValue, size: 12))
.background(Color.button)
.foregroundColor(Color.white)
.multilineTextAlignment(.center)
.cornerRadius(20)
.padding(.top, 66.7)
Spacer()
}
}
}
.onAppear {
withAnimation {
isShow = true
}
}
}
}
#Preview {
AuditionApplyView(
isShowing: .constant(true),
phoneNumber: .constant(""),
filename: "now_voice_9292939.m4a",
onClickApply: {}
)
}