//Made by Lumaa import SwiftUI import UIKit import MessageUI struct MailView: UIViewControllerRepresentable { @Environment(\.presentationMode) var presentation @Binding var result: Result? class Coordinator: NSObject, MFMailComposeViewControllerDelegate { @Binding var presentation: PresentationMode @Binding var result: Result? init(presentation: Binding, result: Binding?>) { _presentation = presentation _result = result } func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) { defer { $presentation.wrappedValue.dismiss() } guard error == nil else { self.result = .failure(error!) return } self.result = .success(result) } } func makeCoordinator() -> Coordinator { return Coordinator(presentation: presentation, result: $result) } func makeUIViewController(context: UIViewControllerRepresentableContext) -> MFMailComposeViewController { let vc = MFMailComposeViewController() vc.mailComposeDelegate = context.coordinator vc.setSubject(String(localized: "support.mail.subject")) vc.setToRecipients(["lumaa@lumaa.fr"]) return vc } func updateUIViewController(_ uiViewController: MFMailComposeViewController, context: UIViewControllerRepresentableContext) { } }