mirror of
https://github.com/NinjaCheetah/RIT-Dining.git
synced 2026-03-05 05:25:29 -05:00
Add feedback submission sheet
Also fixed a bug where locations with overlapping close and open times would show "Closing Soon" for 30 minutes just to then switch to "Open" when it rolled over.
This commit is contained in:
56
TigerDine/Views/Fragments/MailView.swift
Normal file
56
TigerDine/Views/Fragments/MailView.swift
Normal file
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// MailView.swift
|
||||
// TigerDine
|
||||
//
|
||||
// Created by Campbell on 2/16/26.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import MessageUI
|
||||
|
||||
// More gross yucky UIKit code :(
|
||||
// Unfortunately there's no native SwiftUI MailView.
|
||||
struct MailView: UIViewControllerRepresentable {
|
||||
@Environment(\.dismiss) var dismiss
|
||||
@Binding var result: Result<MFMailComposeResult, Error>?
|
||||
|
||||
class Coordinator: NSObject, MFMailComposeViewControllerDelegate {
|
||||
var parent: MailView
|
||||
|
||||
init(_ parent: MailView) {
|
||||
self.parent = parent
|
||||
}
|
||||
|
||||
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
|
||||
defer {
|
||||
parent.dismiss()
|
||||
}
|
||||
if let error = error {
|
||||
parent.result = .failure(error)
|
||||
} else {
|
||||
parent.result = .success(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
Coordinator(self)
|
||||
}
|
||||
|
||||
func makeUIViewController(context: Context) -> MFMailComposeViewController {
|
||||
let vc = MFMailComposeViewController()
|
||||
vc.mailComposeDelegate = context.coordinator
|
||||
vc.setToRecipients(["58050615+NinjaCheetah@users.noreply.github.com"])
|
||||
vc.setSubject("TigerDine Feedback")
|
||||
//vc.setMessageBody("", isHTML: false)
|
||||
return vc
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: MFMailComposeViewController, context: Context) {
|
||||
|
||||
}
|
||||
|
||||
static func canSendMail() -> Bool {
|
||||
return MFMailComposeViewController.canSendMail()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user