is it potential to develop a customized view for Retake/UsePhoto view?
Right here is the display screen of wanted part:
https://i.sstatic.internet/jtGZ7fhF.png
This preview seems instantly after the picture is taken. I can both reject the picture or use the picture I took.
I would like to vary the design of this one: substitute the buttons with different buttons, add a textual content field. How can I do that utilizing normal code?
Right here is my code:
struct ImagePicker: UIViewControllerRepresentable {
@Setting(.presentationMode) personal var presentationMode
@Binding var state: PhotoViewModel.ImageState
@Binding var selectedImage: UIImage?
let sourceType: UIImagePickerController.SourceType
init(selectedImage: Binding<UIImage?>, sourceType: UIImagePickerController.SourceType) {
self._state = .fixed(.none)
self._selectedImage = selectedImage
self.sourceType = sourceType
}
init(state: Binding<PhotoViewModel.ImageState>, sourceType: UIImagePickerController.SourceType) {
self._selectedImage = .fixed(nil)
self._state = state
self.sourceType = sourceType
}
func makeUIViewController(context: Context) -> UIImagePickerController {
let picker = UIImagePickerController()
picker.sourceType = sourceType
if sourceType == .digicam {
picker.cameraDevice = .rear
}
picker.delegate = context.coordinator
picker.allowsEditing = false
return picker
}
func updateUIViewController(_ uiViewController: UIImagePickerController, context: Context) {}
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
let guardian: ImagePicker
init(_ guardian: ImagePicker) {
self.guardian = guardian
}
func imagePickerController(
_ picker: UIImagePickerController,
didFinishPickingMediaWithInfo information: [UIImagePickerController.InfoKey: Any]
) {
if let uiImage = information[UIImagePickerController.InfoKey.originalImage] as? UIImage {
guardian.state = .picked(uiImage)
guardian.selectedImage = uiImage
guardian.presentationMode.wrappedValue.dismiss()
}
}
}
}