131 lines
6.4 KiB
Swift
131 lines
6.4 KiB
Swift
//
|
|
// AuditionRoleDetailView.swift
|
|
// SodaLive
|
|
//
|
|
// Created by klaus on 1/6/25.
|
|
//
|
|
|
|
import SwiftUI
|
|
import Kingfisher
|
|
|
|
struct AuditionRoleDetailView: View {
|
|
|
|
let roleId: Int
|
|
|
|
@StateObject var viewModel = AuditionRoleDetailViewModel()
|
|
|
|
var body: some View {
|
|
BaseView(isLoading: $viewModel.isLoading) {
|
|
ZStack(alignment: .bottomTrailing) {
|
|
VStack(spacing: 0) {
|
|
DetailNavigationBar(title: viewModel.name)
|
|
|
|
ScrollView(.vertical, showsIndicators: false) {
|
|
LazyVStack(spacing: 15) {
|
|
if let roleDetail = viewModel.auditionRoleDetail {
|
|
KFImage(URL(string: roleDetail.imageUrl))
|
|
.cancelOnDisappear(true)
|
|
.downsampling(size: CGSize(width: 1000, height: 350))
|
|
.resizable()
|
|
.aspectRatio(1000/350, contentMode: .fit)
|
|
.frame(maxWidth: .infinity)
|
|
.cornerRadius(6.7)
|
|
.padding(.top, 3)
|
|
|
|
HStack(spacing: 14) {
|
|
if let url = URL(string: roleDetail.originalWorkUrl), UIApplication.shared.canOpenURL(url) {
|
|
Text("원작 보러가기")
|
|
.font(.custom(Font.bold.rawValue, size: 16))
|
|
.foregroundColor(Color.button)
|
|
.padding(.vertical, 12)
|
|
.frame(maxWidth: .infinity)
|
|
.overlay(
|
|
RoundedRectangle(cornerRadius: 10)
|
|
.stroke(Color.button, lineWidth: 1)
|
|
)
|
|
.contentShape(Rectangle())
|
|
.onTapGesture { UIApplication.shared.open(url) }
|
|
}
|
|
|
|
if let url = URL(string: roleDetail.auditionScriptUrl), UIApplication.shared.canOpenURL(url) {
|
|
Text("오디션 대본 확인")
|
|
.font(.custom(Font.bold.rawValue, size: 16))
|
|
.foregroundColor(Color.button)
|
|
.padding(.vertical, 12)
|
|
.frame(maxWidth: .infinity)
|
|
.overlay(
|
|
RoundedRectangle(cornerRadius: 10)
|
|
.stroke(Color.button, lineWidth: 1)
|
|
)
|
|
.contentShape(Rectangle())
|
|
.onTapGesture { UIApplication.shared.open(url) }
|
|
}
|
|
}
|
|
|
|
VStack(alignment: .leading, spacing: 13.3) {
|
|
Text("오디션 캐릭터 정보")
|
|
.font(.custom(Font.bold.rawValue, size: 14.7))
|
|
.foregroundColor(Color.grayee)
|
|
|
|
ExpandableTextView(text: roleDetail.information)
|
|
}
|
|
}
|
|
|
|
if viewModel.applicantList.isEmpty {
|
|
Text("지원자가 없습니다.")
|
|
.font(.custom(Font.medium.rawValue, size: 13))
|
|
.foregroundColor(Color.grayee)
|
|
.padding(.top, 15)
|
|
} else {
|
|
VStack(spacing: 5.3) {
|
|
ForEach(0..<viewModel.applicantList.count, id: \.self) {
|
|
let applicant = viewModel.applicantList[$0]
|
|
|
|
AuditionApplicantItemView(item: applicant)
|
|
.padding(.bottom, $0 == viewModel.applicantList.count - 1 ? 33 : 0)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.padding(.horizontal, 13.3)
|
|
}
|
|
}
|
|
.popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .bottom, autohideIn: 2) {
|
|
HStack {
|
|
Spacer()
|
|
Text(viewModel.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(.leading)
|
|
.cornerRadius(20)
|
|
.padding(.bottom, 66.7)
|
|
Spacer()
|
|
}
|
|
}
|
|
.onAppear {
|
|
viewModel.onFailure = { AppState.shared.back() }
|
|
viewModel.auditionRoleId = roleId
|
|
}
|
|
|
|
if let roleDetail = viewModel.auditionRoleDetail {
|
|
Text(roleDetail.isAlreadyApplicant ? "오디션 재지원" : "오디션 지원")
|
|
.font(.custom(Font.bold.rawValue, size: 15.3))
|
|
.foregroundColor(Color.white)
|
|
.padding(14)
|
|
.background(Color.button)
|
|
.cornerRadius(44)
|
|
.padding(.trailing, 19)
|
|
.padding(.bottom, 19)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
AuditionRoleDetailView(roleId: 1)
|
|
}
|