feat: 更新AppSettingView和ImagePicker组件以增强图片选择与预览体验
- 在AppSettingView中修复selectedImages的绑定,确保预览组件正确接收图片。 - 在ImagePreviewView中将images参数改为@Binding类型,提升数据流动性。 - 在ImagePickerWithPreviewView中使用.constant修饰符,优化预览逻辑。 - 在CameraPicker中添加相机控制显示和视图变换设置,提升用户体验。 - 在ImagePreviewView中添加加载状态提示,改善用户反馈。
This commit is contained in:
@@ -73,7 +73,7 @@ struct AppSettingView: View {
|
||||
}
|
||||
.fullScreenCover(isPresented: $showPreview) {
|
||||
ImagePreviewView(
|
||||
images: selectedImages,
|
||||
images: $selectedImages,
|
||||
currentIndex: .constant(0),
|
||||
onConfirm: {
|
||||
print("[LOG] 预览确认,准备上传头像")
|
||||
@@ -102,7 +102,10 @@ struct AppSettingView: View {
|
||||
if let data = try? result.get(), let uiImage = UIImage(data: data) {
|
||||
DispatchQueue.main.async {
|
||||
tempImages.append(uiImage)
|
||||
print("[LOG] 成功加载图片,当前tempImages数量: \(tempImages.count)")
|
||||
}
|
||||
} else {
|
||||
print("[LOG] 图片加载失败")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,6 +113,7 @@ struct AppSettingView: View {
|
||||
group.wait()
|
||||
DispatchQueue.main.async {
|
||||
isLoading = false
|
||||
print("[LOG] 所有图片加载完成,tempImages数量: \(tempImages.count)")
|
||||
if tempImages.isEmpty {
|
||||
errorMessage = "图片加载失败,请重试"
|
||||
// 强制关闭所有弹窗
|
||||
@@ -119,11 +123,13 @@ struct AppSettingView: View {
|
||||
showActionSheet = false
|
||||
print("[LOG] PhotosPicker图片加载失败,弹出错误提示")
|
||||
} else {
|
||||
// 先设置selectedImages,确保预览组件能接收到图片
|
||||
selectedImages = tempImages
|
||||
print("[LOG] PhotosPicker获得图片,准备延迟进入预览,图片数量: \(tempImages.count)")
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
print("[LOG] selectedImages已设置,数量: \(selectedImages.count)")
|
||||
// 确保在主线程上设置showPreview
|
||||
DispatchQueue.main.async {
|
||||
showPreview = true
|
||||
print("[LOG] PhotosPicker延迟后进入预览")
|
||||
print("[LOG] showPreview已设置为true")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user