Skip to content
Snippets Groups Projects
Commit 81481ea8 authored by Aylin's avatar Aylin
Browse files

Committing ImagePicker

parent 07363316
Branches
No related tags found
1 merge request!83Resolve "Integrate attachment functionality in new ComposeView"
//
// ImagePicker.swift
// enzevalos_iphone
//
// Created by Aylin Akkus on 26.03.21.
// Copyright © 2021 fu-berlin. All rights reserved.
/// This file is a SwiftUI wrapper for UIImagePickerController
/// it can be used it to attach pictures to a mail and preview them
import SwiftUI
struct ImagePicker: UIViewControllerRepresentable {
@Environment(\.presentationMode) var presentationMode
@Binding var image: UIImage?
var xy = 3
class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
let parent: ImagePicker
init(_ parent: ImagePicker) {
self.parent = parent
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
if let uiImage = info[.originalImage] as? UIImage {
parent.image = uiImage
}
parent.presentationMode.wrappedValue.dismiss()
}
}
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
func makeUIViewController(context: UIViewControllerRepresentableContext<ImagePicker>) -> UIImagePickerController {
let picker = UIImagePickerController()
return picker
}
func updateUIViewController(_ uiViewController: UIImagePickerController, context: UIViewControllerRepresentableContext<ImagePicker>) {
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment