forked from shadowfacts/Tusker
Add support link to about screen
This commit is contained in:
parent
8b546daeaa
commit
e45459e556
|
@ -122,7 +122,7 @@ class IssueReporterViewController: UIViewController {
|
||||||
Task {
|
Task {
|
||||||
let composeVC = MFMailComposeViewController()
|
let composeVC = MFMailComposeViewController()
|
||||||
composeVC.mailComposeDelegate = self
|
composeVC.mailComposeDelegate = self
|
||||||
composeVC.setToRecipients(["me@shadowfacts.net"])
|
composeVC.setToRecipients(["hello@vaccor.space"])
|
||||||
composeVC.setSubject(subject)
|
composeVC.setSubject(subject)
|
||||||
|
|
||||||
let data = reportText.data(using: .utf8)!
|
let data = reportText.data(using: .utf8)!
|
||||||
|
|
|
@ -7,8 +7,13 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import MessageUI
|
||||||
|
|
||||||
struct AboutView: View {
|
struct AboutView: View {
|
||||||
|
@State private var logData: Data?
|
||||||
|
@State private var isGettingLogData = false
|
||||||
|
@State private var isShowingMailSheet = false
|
||||||
|
|
||||||
private var version: String {
|
private var version: String {
|
||||||
let marketing = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
|
let marketing = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
|
||||||
let build = Bundle.main.infoDictionary?["CFBundleVersion"] as? String
|
let build = Bundle.main.infoDictionary?["CFBundleVersion"] as? String
|
||||||
|
@ -40,10 +45,32 @@ struct AboutView: View {
|
||||||
|
|
||||||
Section {
|
Section {
|
||||||
Link("Website", destination: URL(string: "https://vaccor.space/tusker")!)
|
Link("Website", destination: URL(string: "https://vaccor.space/tusker")!)
|
||||||
|
Button {
|
||||||
|
if MFMailComposeViewController.canSendMail() {
|
||||||
|
Task {
|
||||||
|
await showMailSheet()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
UIApplication.shared.open(URL(string: "mailto:hello@vaccor.space?subject=Tusker%20Support")!)
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
HStack {
|
||||||
|
Text("Get Support")
|
||||||
|
Spacer()
|
||||||
|
if isGettingLogData {
|
||||||
|
ProgressView()
|
||||||
|
.progressViewStyle(.circular)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.disabled(isGettingLogData)
|
||||||
Link("Source Code", destination: URL(string: "https://git.shadowfacts.net/shadowfacts/Tusker")!)
|
Link("Source Code", destination: URL(string: "https://git.shadowfacts.net/shadowfacts/Tusker")!)
|
||||||
Link("Issue Tracker", destination: URL(string: "https://git.shadowfacts.net/shadowfacts/Tusker/issues")!)
|
Link("Issue Tracker", destination: URL(string: "https://git.shadowfacts.net/shadowfacts/Tusker/issues")!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.sheet(isPresented: $isShowingMailSheet) {
|
||||||
|
MailSheet(logData: logData)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
|
@ -69,9 +96,20 @@ struct AboutView: View {
|
||||||
.font(.title2.bold())
|
.font(.title2.bold())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func showMailSheet() async {
|
||||||
|
isGettingLogData = true
|
||||||
|
logData = await withCheckedContinuation({ continuation in
|
||||||
|
DispatchQueue.global().async {
|
||||||
|
continuation.resume(returning: Logging.getLogData())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
isGettingLogData = false
|
||||||
|
isShowingMailSheet = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AppIconView: UIViewRepresentable {
|
private struct AppIconView: UIViewRepresentable {
|
||||||
func makeUIView(context: Context) -> UIImageView {
|
func makeUIView(context: Context) -> UIImageView {
|
||||||
let view = UIImageView(image: UIImage(named: "AboutIcon"))
|
let view = UIImageView(image: UIImage(named: "AboutIcon"))
|
||||||
view.contentMode = .scaleAspectFit
|
view.contentMode = .scaleAspectFit
|
||||||
|
@ -85,6 +123,45 @@ struct AppIconView: UIViewRepresentable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private struct MailSheet: UIViewControllerRepresentable {
|
||||||
|
typealias UIViewControllerType = MFMailComposeViewController
|
||||||
|
|
||||||
|
let logData: Data?
|
||||||
|
|
||||||
|
@Environment(\.dismiss) private var dismiss
|
||||||
|
|
||||||
|
func makeUIViewController(context: Context) -> MFMailComposeViewController {
|
||||||
|
let vc = MFMailComposeViewController()
|
||||||
|
vc.mailComposeDelegate = context.coordinator
|
||||||
|
vc.setToRecipients(["hello@vaccor.space"])
|
||||||
|
vc.setSubject("Tusker Support")
|
||||||
|
if let logData {
|
||||||
|
let timestamp = ISO8601DateFormatter().string(from: Date())
|
||||||
|
vc.addAttachmentData(logData, mimeType: "text/plain", fileName: "Tusker-\(timestamp).log")
|
||||||
|
}
|
||||||
|
return vc
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateUIViewController(_ uiViewController: MFMailComposeViewController, context: Context) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeCoordinator() -> Coordinator {
|
||||||
|
return Coordinator(dismiss: dismiss)
|
||||||
|
}
|
||||||
|
|
||||||
|
class Coordinator: NSObject, MFMailComposeViewControllerDelegate {
|
||||||
|
let dismiss: DismissAction
|
||||||
|
|
||||||
|
init(dismiss: DismissAction) {
|
||||||
|
self.dismiss = dismiss
|
||||||
|
}
|
||||||
|
|
||||||
|
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct AboutView_Previews: PreviewProvider {
|
struct AboutView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
AboutView()
|
AboutView()
|
||||||
|
|
Loading…
Reference in New Issue