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

Updated feedback feature to support both email and GitHub options #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions Ladybug.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
6CCFA67A20D11265006C9BAE /* RadarURLOpenerError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CCFA67920D11265006C9BAE /* RadarURLOpenerError.swift */; };
6CCFA67D20D113DE006C9BAE /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CCFA67C20D113DE006C9BAE /* String+Extension.swift */; };
6CCFA67F20D11C70006C9BAE /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CCFA67E20D11C70006C9BAE /* UIColor+Extension.swift */; };
EC8AF80D23B313D500A56EA6 /* SharedUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC8AF80C23B313D500A56EA6 /* SharedUtils.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -120,6 +121,7 @@
6CCFA67920D11265006C9BAE /* RadarURLOpenerError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadarURLOpenerError.swift; sourceTree = "<group>"; };
6CCFA67C20D113DE006C9BAE /* String+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extension.swift"; sourceTree = "<group>"; };
6CCFA67E20D11C70006C9BAE /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = "<group>"; };
EC8AF80C23B313D500A56EA6 /* SharedUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharedUtils.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -250,11 +252,12 @@
6C07277120CFB3B200603199 /* App */ = {
isa = PBXGroup;
children = (
6C07270B20CDC70300603199 /* AppDelegate.swift */,
6C92D74820DE4A7A0016BBA8 /* AppConstants.swift */,
6C380C6A20DB887D000EE273 /* TabBarController.swift */,
6C07270B20CDC70300603199 /* AppDelegate.swift */,
6CCFA67220D109FD006C9BAE /* RadarURLOpener.swift */,
6CCFA67920D11265006C9BAE /* RadarURLOpenerError.swift */,
EC8AF80C23B313D500A56EA6 /* SharedUtils.swift */,
6C380C6A20DB887D000EE273 /* TabBarController.swift */,
);
path = App;
sourceTree = "<group>";
Expand Down Expand Up @@ -464,6 +467,7 @@
6CCEA1E420D23FF3007FA16B /* TableViewSectionViewModel.swift in Sources */,
6C380C6B20DB887D000EE273 /* TabBarController.swift in Sources */,
6C92D74D20DE58DA0016BBA8 /* SettingsViewController+MFMailComposeViewControllerDelegate.swift in Sources */,
EC8AF80D23B313D500A56EA6 /* SharedUtils.swift in Sources */,
6C07270C20CDC70300603199 /* AppDelegate.swift in Sources */,
6CCEA1E820D24488007FA16B /* TableViewViewModel.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
1 change: 1 addition & 0 deletions Ladybug/App/AppConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ struct AppConstants {

static var appStoreURL: URL = URL(string: "https://itunes.apple.com/us/app/ladybug-handles-radar-links/id1402968134?l=zh&ls=1&mt=8&ct=Ladybug")!
static var githubURL: URL = URL(string: "https://github.com/ethanhuang13/ladybug")!
static var githubIssueURL: URL = URL(string: "https://github.com/ethanhuang13/ladybug/issues/new")!
static var developerURL: URL = URL(string: "https://twitter.com/ethanhuang13")!
}
18 changes: 18 additions & 0 deletions Ladybug/App/SharedUtils.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// SharedUtils.swift
// Ladybug
//
// Created by Jeriel Ng on 12/24/19.
// Copyright © 2019 Elaborapp Co., Ltd. All rights reserved.
//

import Foundation
import UIKit

class SharedUtils {

// Helper function inserted by Swift 4.2 migrator.
class func convertToUIApplicationOpenExternalURLOptionsKeyDictionary(_ input: [String: Any]) -> [UIApplication.OpenExternalURLOptionsKey: Any] {
return Dictionary(uniqueKeysWithValues: input.map { key, value in (UIApplication.OpenExternalURLOptionsKey(rawValue: key), value)})
}
}
7 changes: 1 addition & 6 deletions Ladybug/Extensions/OpenRadarKeychain+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension OpenRadarKeychain {
}))
alertController.addAction(UIAlertAction(title: "Get My API Key".localized(), style: .default, handler: { (_) in
let url = URL(string: "https://openradar.appspot.com/apikey")!
UIApplication.shared.open(url, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: { (success) in
UIApplication.shared.open(url, options: SharedUtils.convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: { (success) in
if success {
DispatchQueue.main.async {
vc.present(alertController, animated: true) { }
Expand Down Expand Up @@ -56,8 +56,3 @@ extension OpenRadarKeychain {
}
}
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToUIApplicationOpenExternalURLOptionsKeyDictionary(_ input: [String: Any]) -> [UIApplication.OpenExternalURLOptionsKey: Any] {
return Dictionary(uniqueKeysWithValues: input.map { key, value in (UIApplication.OpenExternalURLOptionsKey(rawValue: key), value)})
}
5 changes: 5 additions & 0 deletions Ladybug/Resources/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
"Developer" = "Developer";
"GitHub" = "GitHub";

"Select a Feedback Option" = "Select a Feedback Option";
"Send Email" = "Send Email";
"Submit GitHub Issue" = "Submit GitHub Issue";
"Cancel" = "Cancel";

"Setup iOS Mail" = "Setup iOS Mail";
"Setup iOS Mail accounts first, or..." = "Setup iOS Mail accounts first, or send email to elaborapp+ladybug@gmail.com";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ import UIKit
import MessageUI

extension SettingsViewController: MFMailComposeViewControllerDelegate {
func presentOptionsActionSheet() {
let optionsAlert = UIAlertController(title: "Select a Feedback Option".localized(), message: nil, preferredStyle: .actionSheet)
optionsAlert.addAction(UIAlertAction(title: "Send Email".localized(), style: .default, handler:
{ _ in
self.presentFeedbackMailComposer()
}))
optionsAlert.addAction(UIAlertAction(title: "Submit GitHub Issue".localized(), style: .default, handler:
{ _ in
UIApplication.shared.open(AppConstants.githubIssueURL, options: SharedUtils.convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
}))
optionsAlert.addAction(UIAlertAction(title: "Cancel".localized(), style: .cancel, handler: nil))
self.present(optionsAlert, animated: true, completion: nil)
}

func presentFeedbackMailComposer() {
guard MFMailComposeViewController.canSendMail() else {
let alertController = UIAlertController(title: "Setup iOS Mail".localized(), message: "Setup iOS Mail accounts first, or...".localized(), preferredStyle: .alert)
Expand All @@ -24,7 +38,7 @@ extension SettingsViewController: MFMailComposeViewControllerDelegate {
vc.mailComposeDelegate = self
self.present(vc, animated: true, completion: { })
}

func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
controller.dismiss(animated: true) { }
}
Expand Down
13 changes: 4 additions & 9 deletions Ladybug/Settings/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,20 +255,20 @@ extension SettingsViewController {

private var aboutSection: TableViewSectionViewModel {
let rateCellViewModel = TableViewCellViewModel(title: "App Store".localized()) {
UIApplication.shared.open(AppConstants.appStoreURL, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
UIApplication.shared.open(AppConstants.appStoreURL, options: SharedUtils.convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
}

let feedbackCellViewModel = TableViewCellViewModel(title: "Feedback".localized()) {
self.presentFeedbackMailComposer()
self.presentOptionsActionSheet()
}

let developerCellViewModel = TableViewCellViewModel(title: "Developer".localized(), subtitle: "@ethanhuang13", cellStyle: .value1) {
UIApplication.shared.open(AppConstants.developerURL, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
UIApplication.shared.open(AppConstants.developerURL, options: SharedUtils.convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
}

let githubCellViewModel = TableViewCellViewModel(title: "GitHub".localized(), subtitle: nil) {

UIApplication.shared.open(AppConstants.githubURL, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
UIApplication.shared.open(AppConstants.githubURL, options: SharedUtils.convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
}

let sectionViewModel = TableViewSectionViewModel(header: "About".localized(), footer: AppConstants.aboutString, rows: [rateCellViewModel, feedbackCellViewModel, developerCellViewModel, githubCellViewModel])
Expand Down Expand Up @@ -330,8 +330,3 @@ extension SettingsViewController: UITextFieldDelegate {
}
}
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToUIApplicationOpenExternalURLOptionsKeyDictionary(_ input: [String: Any]) -> [UIApplication.OpenExternalURLOptionsKey: Any] {
return Dictionary(uniqueKeysWithValues: input.map { key, value in (UIApplication.OpenExternalURLOptionsKey(rawValue: key), value)})
}