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

Adding social links and redirects to About section content #328

Merged
merged 3 commits into from
Jun 18, 2023
Merged
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
4 changes: 4 additions & 0 deletions Scribe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
1406B7872A2DFCDD001DF45B /* AboutTableData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1406B7862A2DFCDD001DF45B /* AboutTableData.swift */; };
1406B78C2A3209CF001DF45B /* AppExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1406B78B2A3209CF001DF45B /* AppExtensions.swift */; };
147797AC2A2CD2F70044A53E /* ParentTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 147797AA2A2CD2F70044A53E /* ParentTableViewCell.swift */; };
147797AD2A2CD2F70044A53E /* ParentTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 147797AB2A2CD2F70044A53E /* ParentTableViewCell.xib */; };
147797B02A2CD3370044A53E /* InfoChildTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 147797AE2A2CD3370044A53E /* InfoChildTableViewCell.swift */; };
Expand Down Expand Up @@ -801,6 +802,7 @@

/* Begin PBXFileReference section */
1406B7862A2DFCDD001DF45B /* AboutTableData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutTableData.swift; sourceTree = "<group>"; };
1406B78B2A3209CF001DF45B /* AppExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppExtensions.swift; sourceTree = "<group>"; };
147797AA2A2CD2F70044A53E /* ParentTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParentTableViewCell.swift; sourceTree = "<group>"; };
147797AB2A2CD2F70044A53E /* ParentTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ParentTableViewCell.xib; sourceTree = "<group>"; };
147797AE2A2CD3370044A53E /* InfoChildTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoChildTableViewCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1177,6 +1179,7 @@
38BD213322D5907F00C6795D /* AppDelegate.swift */,
D17193C327AEAD7D0038660B /* AppStyling.swift */,
D1A2DCB327AD3EB50057A10D /* AppUISymbols.swift */,
1406B78B2A3209CF001DF45B /* AppExtensions.swift */,
38BD213722D5907F00C6795D /* AppScreen.storyboard */,
38BD213F22D5908100C6795D /* LaunchScreen.storyboard */,
38BD213D22D5908100C6795D /* Assets.xcassets */,
Expand Down Expand Up @@ -1968,6 +1971,7 @@
D17193F827AECC930038660B /* FRCommandVariables.swift in Sources */,
D171945827AF237C0038660B /* ScribeKey.swift in Sources */,
D17193C927AEC8F90038660B /* FR-AZERTYInterfaceVariables.swift in Sources */,
1406B78C2A3209CF001DF45B /* AppExtensions.swift in Sources */,
D1B81D4A27BBBA200085FE5E /* ITCommandVariables.swift in Sources */,
D180EC0328FDFABF0018E29B /* FRInterfaceVariables.swift in Sources */,
38BD213622D5907F00C6795D /* InstallationVC.swift in Sources */,
Expand Down
22 changes: 11 additions & 11 deletions Scribe/AboutTab/AboutTableData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ struct AboutTableData {
ParentTableCellModel(
headingTitle: "Community",
section: [
Section(sectionTitle: "See the code on GitHub", imageString: "github", hasToggle: false),
Section(sectionTitle: "Chat with the team on Matrix", imageString: "matrix", hasToggle: false),
Section(sectionTitle: "Wikimedia and Scribe", imageString: "wikimedia", hasToggle: false),
Section(sectionTitle: "Share Scribe", imageString: "square.and.arrow.up", hasToggle: false),
Section(sectionTitle: "See the code on GitHub", imageString: "github", hasToggle: false, sectionState: .github),
Section(sectionTitle: "Chat with the team on Matrix", imageString: "matrix", hasToggle: false, sectionState: .matrix),
Section(sectionTitle: "Wikimedia and Scribe", imageString: "wikimedia", hasToggle: false, sectionState: .wikimedia),
Section(sectionTitle: "Share Scribe", imageString: "square.and.arrow.up", hasToggle: false, sectionState: .shareScribe)
]
),
ParentTableCellModel(
headingTitle: "Feedback and support",
section: [
Section(sectionTitle: "Rate Scribe", imageString: "star", hasToggle: false),
Section(sectionTitle: "Report a bug", imageString: "ant", hasToggle: false),
Section(sectionTitle: "Send us an email", imageString: "envelope", hasToggle: false),
Section(sectionTitle: "Reset app hints", imageString: "lightbulb", hasToggle: false),
]
Section(sectionTitle: "Rate Scribe", imageString: "star", hasToggle: false, sectionState: .rateScribe),
Section(sectionTitle: "Report a bug", imageString: "ant", hasToggle: false, sectionState: .bugReport),
Section(sectionTitle: "Send us an email", imageString: "envelope", hasToggle: false, sectionState: .email),
// Section(sectionTitle: "Reset app hints", imageString: "lightbulb", hasToggle: false, sectionState: .appHints)
]
),
ParentTableCellModel(
headingTitle: "Legal",
section: [
Section(sectionTitle: "Privacy policy", imageString: "lock.shield", hasToggle: false),
Section(sectionTitle: "Third-party licenses", imageString: "thirdPartyLicenses", hasToggle: false),
Section(sectionTitle: "Privacy policy", imageString: "lock.shield", hasToggle: false, sectionState: .privacyPolicy),
Section(sectionTitle: "Third-party licenses", imageString: "thirdPartyLicenses", hasToggle: false, sectionState: .licenses)
]
),
]
Expand Down
28 changes: 28 additions & 0 deletions Scribe/AppExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// AppExtensions.swift
// Scribe
//
// Created by Saurabh Jamadagni on 08/06/23.
//

import UIKit

extension UIApplication {
var foregroundActiveScene: UIWindowScene? {
connectedScenes
.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene
}
}

extension UIView {
var parentViewController: UIViewController? {
var parentResponder: UIResponder? = self
while parentResponder != nil {
parentResponder = parentResponder!.next
if parentResponder is UIViewController {
return parentResponder as? UIViewController
}
}
return nil
}
}
103 changes: 102 additions & 1 deletion Scribe/Components/ParentTableViewCell/ParentTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// ParentTableViewCell.swift
//

import MessageUI
import StoreKit
import UIKit

class ParentTableViewCell: UITableViewCell {
Expand Down Expand Up @@ -68,4 +70,103 @@ extension ParentTableViewCell: UITableViewDataSource {
// MARK: UITableViewDelegate

/// Function implementation conforming to the UITableViewDelegate protocol.
extension ParentTableViewCell: UITableViewDelegate {}
extension ParentTableViewCell: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print(data?.section[indexPath.row].sectionTitle ?? "")

if let section = data?.section[indexPath.row] {
switch section.sectionState {
case .github:
openURLString(urlString: "https://github.com/scribe-org/Scribe-iOS", withEncoding: false)
case .matrix:
openURLString(urlString: "https://matrix.to/#/#scribe_community:matrix.org", withEncoding: true)
case .wikimedia:
// Push a new screen
print("Details about Wikimedia and Scribe")
case .shareScribe:
showShareSheet()
case .rateScribe:
showRateScribeUI()
case .bugReport:
openURLString(urlString: "https://github.com/scribe-org/Scribe-iOS/issues", withEncoding: false)
case .email:
showEmailUI()
// case .appHints:
// // reset functionality
// print("Resets app hints")
case .privacyPolicy:
// Push a new screen
print("Scribe privacy policy page")
case .licenses:
// Push a new screen
print("Licenses page")
case .appLang: break
case .specificLang: break
}
}

if let selectedIndexPath = tableView.indexPathForSelectedRow {
tableView.deselectRow(at: selectedIndexPath, animated: false)
}
}

func openURLString(urlString: String, withEncoding: Bool) {
if withEncoding {
let encodedString = urlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
guard let encodedURLString = encodedString, let url = URL(string: encodedURLString) else { return }
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
guard let url = URL(string: urlString) else { return }
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}

func showRateScribeUI() {
if #available(iOS 14.0, *) {
guard let scene = UIApplication.shared.foregroundActiveScene else { return }
SKStoreReviewController.requestReview(in: scene)
} else {
let alert = UIAlertController(title: "Enjoying Scribe?", message: "Rate Scribe on the App Store.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Continue", style: .default, handler: openScribeAppStore(alert:)))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
parentViewController?.present(alert, animated: true)
}
}

func openScribeAppStore(alert: UIAlertAction) {
openURLString(urlString: "itms-apps: //itunes.apple.com/app/id1596613886", withEncoding: true)
}

func showEmailUI() {
if MFMailComposeViewController.canSendMail() {
let mailComposeViewController = MFMailComposeViewController()
mailComposeViewController.mailComposeDelegate = self
mailComposeViewController.setToRecipients(["scribe.language@gmail.com"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! 👋

I noticed that it's possible to set the subject line and the message body as well like the recipients here. I'm thinking that the message body is likely fine staying blank, but would it make sense perhaps to have some default set for the subject line? Just more so thinking in terms of what would be easier or expected from the user perspective.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Will!

I did consider that. But we have separate sections for almost all the reasons a user might want to approach us. For example, to report a bug there is a section and to rate and share feedback there's the rating section. So writing an email seemed like a very ambiguous use case. That's why I didn't add a subject line in case the user wished to write an email for a completely different reason. Could be a complaint but could also be an email of appreciation 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the use case for emails is going to ambiguous 🤔 I just checked and we're still at a grand total of 0 emails 😄 With that being said, maybe something inviting to the user? Hey Scribe!, for instance?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good @andrewtavis! We can do that. Just a tiny problem. I kind of committed my changes for the privacy policy issue (#317) to the branch already. So if I push it now that'll be added to the PR too. So would it be okay if I made this change in the next PR? I am so sorry! 🙈

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100% ok, @SaurabhJamadagni 😊 No need to apologize :)


parentViewController?.present(mailComposeViewController, animated: true, completion: nil)
} else {
/// Show alert mentioning the email address
let alert = UIAlertController(title: "Send us an email?", message: "Reach out to us at scribe.language@gmail.com", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
parentViewController?.present(alert, animated: true)
}
}

func showShareSheet() {
let urlString = "itms-apps: //itunes.apple.com/app/id1596613886"
let encodedString = urlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
guard let encodedURLString = encodedString, let url = URL(string: encodedURLString) else { return }

let shareSheetVC = UIActivityViewController(activityItems: [url], applicationActivities: nil)

parentViewController?.present(shareSheetVC, animated: true, completion: nil)
}
}

// MARK: MFMailComposeViewControllerDelegate
/// Function implementation conforming to the MFMailComposeViewControllerDelegate protocol.
extension ParentTableViewCell: MFMailComposeViewControllerDelegate {
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
controller.dismiss(animated: true, completion: nil)
}
}
6 changes: 1 addition & 5 deletions Scribe/InstallationTab/InstallationVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,7 @@ class InstallationVC: UIViewController {
return
}

if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}

/// Function to change the key coloration given a touch down.
Expand Down
16 changes: 16 additions & 0 deletions Scribe/ParentTableCellModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,23 @@ struct ParentTableCellModel {
}

struct Section {
enum SectionState {
case github
case matrix
case wikimedia
case shareScribe
case rateScribe
case bugReport
case email
// case appHints
case privacyPolicy
case licenses
case appLang
case specificLang
}

let sectionTitle: String
let imageString: String
let hasToggle: Bool
let sectionState: SectionState
}
4 changes: 2 additions & 2 deletions Scribe/SettingsTab/SettingsTableData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ struct SettingsTableData {
ParentTableCellModel(
headingTitle: "App language",
section: [
Section(sectionTitle: "System language", imageString: "globe", hasToggle: false),
Section(sectionTitle: "System language", imageString: "globe", hasToggle: false, sectionState: .appLang)
]
),
ParentTableCellModel(
headingTitle: "Select installed keyboard",
section: [
Section(sectionTitle: "All keyboards", imageString: "globe", hasToggle: false),
Section(sectionTitle: "All keyboards", imageString: "globe", hasToggle: false, sectionState: .specificLang)
]
),
]
Expand Down