feat(image): 이미지 선택 후 크롭 편집 흐름을 안정화한다

This commit is contained in:
Yu Sung
2026-03-17 17:05:22 +09:00
parent 039355c088
commit 606470ae04
2 changed files with 76 additions and 11 deletions

View File

@@ -17,6 +17,10 @@ struct LiveRoomViewV2: View {
@State private var textHeight: CGFloat = .zero
@State private var menuTextHeight: CGFloat = .zero
@State private var selectedPickedImage: UIImage?
@State private var cropSourceImage: UIImage?
@State private var isShowImageCropper = false
@State private var isImageLoading = false
//
@State private var isLongPressingHeart: Bool = false
@@ -764,6 +768,10 @@ struct LiveRoomViewV2: View {
if viewModel.isV2VLoading {
LoadingView()
}
if isImageLoading {
LoadingView()
}
}
.overlay(alignment: .center) {
ZStack {
@@ -840,10 +848,47 @@ struct LiveRoomViewV2: View {
.sheet(isPresented: $viewModel.isShowPhotoPicker) {
ImagePicker(
isShowing: $viewModel.isShowPhotoPicker,
selectedImage: $viewModel.coverImage,
selectedImage: $selectedPickedImage,
sourceType: .photoLibrary
)
}
.onChange(of: selectedPickedImage, perform: { newImage in
guard let newImage else {
return
}
isImageLoading = true
DispatchQueue.global(qos: .userInitiated).async {
let normalizedImage = newImage.normalizedForCrop()
DispatchQueue.main.async {
isImageLoading = false
selectedPickedImage = nil
cropSourceImage = normalizedImage
isShowImageCropper = true
}
}
})
.onDisappear {
isImageLoading = false
}
.sheet(isPresented: $isShowImageCropper, onDismiss: {
cropSourceImage = nil
}) {
if let cropSourceImage {
ImageCropEditorView(
image: cropSourceImage,
aspectPolicy: .free,
onCancel: {
isShowImageCropper = false
},
onComplete: { croppedImage in
viewModel.coverImage = croppedImage
isShowImageCropper = false
}
)
}
}
.sheet(isPresented: $viewModel.isShowEditRoomInfoDialog) {
if let liveRoomInfo = viewModel.liveRoomInfo {
LiveRoomInfoEditDialog(