Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace zendesk #1273

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 16 additions & 36 deletions Source/Controller/MenuViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import Analytics
import CrashReporting
import Logger
import Support
import MessageUI

class MenuViewController: UIViewController, ConnectedPeerListRouter {
class MenuViewController: UIViewController, ConnectedPeerListRouter, MFMailComposeViewControllerDelegate {

var menuWidth: CGFloat = 300

Expand Down Expand Up @@ -110,7 +111,6 @@ class MenuViewController: UIViewController, ConnectedPeerListRouter {
self.menuView.profileButton.addTarget(self, action: #selector(profileButtonTouchUpInside), for: .touchUpInside)
self.menuView.settingsButton.addTarget(self, action: #selector(settingsButtonTouchUpInside), for: .touchUpInside)
self.menuView.helpButton.addTarget(self, action: #selector(helpButtonTouchUpInside), for: .touchUpInside)
self.menuView.reportBugButton.addTarget(self, action: #selector(reportBugButtonTouchUpInside), for: .touchUpInside)
}

@objc private func closeButtonTouchUpInside() {
Expand Down Expand Up @@ -142,31 +142,18 @@ class MenuViewController: UIViewController, ConnectedPeerListRouter {

@objc private func helpButtonTouchUpInside() {
Analytics.shared.trackDidTapButton(buttonName: "support")
guard let controller = Support.shared.mainViewController() else {
AppController.shared.alert(
title: Localized.error.text,
message: Localized.Error.supportNotConfigured.text,
cancelTitle: Localized.ok.text
)
return
}
self.close {
AppController.shared.push(controller)
}
}

@objc private func reportBugButtonTouchUpInside() {
Analytics.shared.trackDidTapButton(buttonName: "report_bug")
guard let controller = Support.shared.myTicketsViewController(from: Bots.current.identity) else {
AppController.shared.alert(
title: Localized.error.text,
message: Localized.Error.supportNotConfigured.text,
cancelTitle: Localized.ok.text
)
return
}

let mailViewController = MFMailComposeViewController()
mailViewController.mailComposeDelegate = self
mailViewController.setToRecipients(["support@planetary.social"])
mailViewController.setSubject("Reporting a bug in Planetary")
mailViewController.setMessageBody(
"Hello, \n\n I have found a bug in Planetary and would like to provide feedback",
isHTML: false
)

self.close {
AppController.shared.push(controller)
AppController.shared.present(mailViewController, animated: true)
}
}

Expand Down Expand Up @@ -225,7 +212,6 @@ private class MenuView: UIView {
let profileButton = MenuButton(title: .yourProfile, image: UIImage.verse.profile)
let settingsButton = MenuButton(title: .settings, image: UIImage.verse.settings)
let helpButton = MenuButton(title: .helpAndSupport, image: UIImage.verse.help)
let reportBugButton = MenuButton(title: .reportBug, image: UIImage.verse.reportBug)

init(frame: CGRect, connectedPeersView: UIView) {

Expand Down Expand Up @@ -298,19 +284,13 @@ private class MenuView: UIView {
Layout.fillSouth(of: separator, with: self.helpButton)
self.helpButton.constrainHeight(to: 50)
self.helpButton.imageEdgeInsets = .top(2)
if !MFMailComposeViewController.canSendMail() {
self.helpButton.isEnabled = false
}

separator = Layout.separatorView(color: UIColor.menuBorderColor)
Layout.fillSouth(of: self.helpButton, with: separator)

Layout.fillSouth(of: separator, with: self.reportBugButton)
self.reportBugButton.constrainHeight(to: 50)

separator = Layout.separatorView(color: UIColor.menuBorderColor)
Layout.fillSouth(of: self.reportBugButton, with: separator)

separator = Layout.separatorView(color: UIColor.menuBorderColor)
Layout.fillSouth(of: reportBugButton, with: separator)

separator.bottomAnchor.constraint(equalTo: menuButtonContainer.bottomAnchor).isActive = true

return menuButtonContainer
Expand Down
Loading