feat(image): 이미지 선택 후 크롭 편집 흐름을 안정화한다
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user