iOS 2.5.1 - Fixed Camera Rotation
This commit is contained in:
@@ -26,19 +26,19 @@ struct AddAttemptView: View {
|
||||
|
||||
enum SheetType: Identifiable {
|
||||
case photoOptions
|
||||
case camera
|
||||
|
||||
var id: Int {
|
||||
switch self {
|
||||
case .photoOptions: return 0
|
||||
case .camera: return 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@State private var activeSheet: SheetType?
|
||||
@State private var showCamera = false
|
||||
@State private var showPhotoPicker = false
|
||||
@State private var isPhotoPickerActionPending = false
|
||||
@State private var isCameraActionPending = false
|
||||
|
||||
private var activeProblems: [Problem] {
|
||||
dataManager.activeProblems(forGym: gym.id)
|
||||
@@ -110,6 +110,11 @@ struct AddAttemptView: View {
|
||||
.sheet(
|
||||
item: $activeSheet,
|
||||
onDismiss: {
|
||||
if isCameraActionPending {
|
||||
showCamera = true
|
||||
isCameraActionPending = false
|
||||
return
|
||||
}
|
||||
if isPhotoPickerActionPending {
|
||||
showPhotoPicker = true
|
||||
isPhotoPickerActionPending = false
|
||||
@@ -123,7 +128,8 @@ struct AddAttemptView: View {
|
||||
imageData: $imageData,
|
||||
maxImages: 5,
|
||||
onCameraSelected: {
|
||||
activeSheet = .camera
|
||||
isCameraActionPending = true
|
||||
activeSheet = nil
|
||||
},
|
||||
onPhotoLibrarySelected: {
|
||||
isPhotoPickerActionPending = true
|
||||
@@ -132,16 +138,12 @@ struct AddAttemptView: View {
|
||||
activeSheet = nil
|
||||
}
|
||||
)
|
||||
case .camera:
|
||||
CameraImagePicker(
|
||||
isPresented: Binding(
|
||||
get: { activeSheet == .camera },
|
||||
set: { if !$0 { activeSheet = nil } }
|
||||
)
|
||||
) { capturedImage in
|
||||
if let jpegData = capturedImage.jpegData(compressionQuality: 0.8) {
|
||||
imageData.append(jpegData)
|
||||
}
|
||||
}
|
||||
}
|
||||
.fullScreenCover(isPresented: $showCamera) {
|
||||
CameraImagePicker { capturedImage in
|
||||
if let jpegData = capturedImage.jpegData(compressionQuality: 0.8) {
|
||||
imageData.append(jpegData)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -778,19 +780,19 @@ struct EditAttemptView: View {
|
||||
|
||||
enum SheetType: Identifiable {
|
||||
case photoOptions
|
||||
case camera
|
||||
|
||||
var id: Int {
|
||||
switch self {
|
||||
case .photoOptions: return 0
|
||||
case .camera: return 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@State private var activeSheet: SheetType?
|
||||
@State private var showCamera = false
|
||||
@State private var showPhotoPicker = false
|
||||
@State private var isPhotoPickerActionPending = false
|
||||
@State private var isCameraActionPending = false
|
||||
|
||||
private var availableProblems: [Problem] {
|
||||
guard let session = dataManager.session(withId: attempt.sessionId) else {
|
||||
@@ -883,6 +885,11 @@ struct EditAttemptView: View {
|
||||
.sheet(
|
||||
item: $activeSheet,
|
||||
onDismiss: {
|
||||
if isCameraActionPending {
|
||||
showCamera = true
|
||||
isCameraActionPending = false
|
||||
return
|
||||
}
|
||||
if isPhotoPickerActionPending {
|
||||
showPhotoPicker = true
|
||||
isPhotoPickerActionPending = false
|
||||
@@ -896,7 +903,8 @@ struct EditAttemptView: View {
|
||||
imageData: $imageData,
|
||||
maxImages: 5,
|
||||
onCameraSelected: {
|
||||
activeSheet = .camera
|
||||
isCameraActionPending = true
|
||||
activeSheet = nil
|
||||
},
|
||||
onPhotoLibrarySelected: {
|
||||
isPhotoPickerActionPending = true
|
||||
@@ -905,16 +913,12 @@ struct EditAttemptView: View {
|
||||
activeSheet = nil
|
||||
}
|
||||
)
|
||||
case .camera:
|
||||
CameraImagePicker(
|
||||
isPresented: Binding(
|
||||
get: { activeSheet == .camera },
|
||||
set: { if !$0 { activeSheet = nil } }
|
||||
)
|
||||
) { capturedImage in
|
||||
if let jpegData = capturedImage.jpegData(compressionQuality: 0.8) {
|
||||
imageData.append(jpegData)
|
||||
}
|
||||
}
|
||||
}
|
||||
.fullScreenCover(isPresented: $showCamera) {
|
||||
CameraImagePicker { capturedImage in
|
||||
if let jpegData = capturedImage.jpegData(compressionQuality: 0.8) {
|
||||
imageData.append(jpegData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user