오디션 지원 기능 추가

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

@@ -13,6 +13,12 @@ struct AuditionRoleDetailView: View {
let roleId: Int
@StateObject var viewModel = AuditionRoleDetailViewModel()
@StateObject var keyboardHandler = KeyboardHandler()
@State private var isShowApplyMethodView = false
@State private var isShowSelectAudioView = false
@State private var isShowRecordingView = false
@State private var isShowApplyView = false
var body: some View {
BaseView(isLoading: $viewModel.isLoading) {
@@ -83,6 +89,14 @@ struct AuditionRoleDetailView: View {
AuditionApplicantItemView(item: applicant)
.padding(.bottom, $0 == viewModel.applicantList.count - 1 ? 33 : 0)
if $0 == viewModel.applicantList.count - 1 {
Color.clear
.frame(height: 0)
.onAppear {
viewModel.getAuditionApplicantList()
}
}
}
}
}
@@ -119,8 +133,96 @@ struct AuditionRoleDetailView: View {
.cornerRadius(44)
.padding(.trailing, 19)
.padding(.bottom, 19)
.onTapGesture {
isShowApplyMethodView = true
}
}
}
.fileImporter(
isPresented: $isShowSelectAudioView,
allowedContentTypes: [.audio],
allowsMultipleSelection: false
) { result in
handleFileImport(result: result)
}
if isShowApplyMethodView {
ApplyMethodView(
isShowing: $isShowApplyMethodView,
onClickSelectAudioFile: {
isShowApplyMethodView = false
isShowSelectAudioView = true
},
onClickRecording: {
isShowApplyMethodView = false
isShowRecordingView = true
}
)
}
if isShowRecordingView {
AuditionApplicantRecordingView(
isShowing: $isShowRecordingView,
isShowPopup: $viewModel.isShowPopup,
errorMessage: $viewModel.errorMessage,
onClickCompleteRecording: { fileName, soundData in
viewModel.fileName = fileName
viewModel.soundData = soundData
isShowRecordingView = false
isShowApplyView = true
}
)
}
if isShowApplyView {
AuditionApplyView(
isShowing: $isShowApplyView,
phoneNumber: $viewModel.phoneNumber,
filename: viewModel.fileName,
onClickApply: {
viewModel.applyAudition {
isShowApplyView = false
isShowRecordingView = false
}
}
)
.offset(y: 0 - (keyboardHandler.keyboardHeight / 10))
.onDisappear {
viewModel.soundData = nil
viewModel.fileName = ""
viewModel.deleteAllRecordingFilesWithNamePrefix("voiceon_now_voice")
}
}
}
}
private func handleFileImport(result: Result<[URL], Error>) {
switch result {
case .success(let url):
let fileUrl = url[0]
if fileUrl.startAccessingSecurityScopedResource() {
defer {
fileUrl.stopAccessingSecurityScopedResource()
}
if let data = try? Data(contentsOf: fileUrl) {
viewModel.soundData = data
viewModel.fileName = fileUrl.lastPathComponent
isShowApplyView = true
} else {
viewModel.errorMessage = "콘텐츠 파일을 불러오지 못했습니다.\n다시 선택해 주세요"
viewModel.isShowPopup = true
}
} else {
viewModel.errorMessage = "콘텐츠 파일을 불러오지 못했습니다.\n다시 선택해 주세요"
viewModel.isShowPopup = true
}
case .failure(let error):
DEBUG_LOG("error: \(error.localizedDescription)")
viewModel.errorMessage = "콘텐츠 파일을 불러오지 못했습니다.\n다시 선택해 주세요"
viewModel.isShowPopup = true
}
}
}