Skip to content
Snippets Groups Projects
Commit 9bd489c3 authored by cruxfilm's avatar cruxfilm
Browse files

Merge remote-tracking branch...

Merge remote-tracking branch 'refs/remotes/origin/293-integrate-attachment-functionality-in-new-composeview'
parents 19eb4024 6e8126ff
No related branches found
No related tags found
No related merge requests found
//
// 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.
Finish editing this message first!
Please register or to comment