Skip to content

Commit

Permalink
Merge pull request #384 from damien-rivet/feature/330-add-settings-op…
Browse files Browse the repository at this point in the history
…tions-information-tooltips

[#330] Add description texts to cells
  • Loading branch information
andrewtavis committed Jan 13, 2024
2 parents 28462e2 + ac0979f commit 5087842
Show file tree
Hide file tree
Showing 21 changed files with 908 additions and 598 deletions.
99 changes: 69 additions & 30 deletions Scribe.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Scribe/AboutTab/AboutTableData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ struct AboutTableData {
ParentTableCellModel(
headingTitle: "Community",
section: [
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),
Section(sectionTitle: "See the code on GitHub", imageString: "github", sectionState: .github),
Section(sectionTitle: "Chat with the team on Matrix", imageString: "matrix", sectionState: .matrix),
Section(sectionTitle: "Wikimedia and Scribe", imageString: "wikimedia", sectionState: .wikimedia),
Section(sectionTitle: "Share Scribe", imageString: "square.and.arrow.up", sectionState: .shareScribe),
],
hasDynamicData: nil
),
ParentTableCellModel(
headingTitle: "Feedback and support",
section: [
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)
Section(sectionTitle: "Rate Scribe", imageString: "star", sectionState: .rateScribe),
Section(sectionTitle: "Report a bug", imageString: "ant", sectionState: .bugReport),
Section(sectionTitle: "Send us an email", imageString: "envelope", sectionState: .email),
// Section(sectionTitle: "Reset app hints", imageString: "lightbulb", sectionState: .appHints)
],
hasDynamicData: nil
),
ParentTableCellModel(
headingTitle: "Legal",
section: [
Section(sectionTitle: "Privacy policy", imageString: "lock.shield", hasToggle: false, sectionState: .privacyPolicy),
Section(sectionTitle: "Third-party licenses", imageString: "thirdPartyLicenses", hasToggle: false, sectionState: .licenses),
Section(sectionTitle: "Privacy policy", imageString: "lock.shield", hasNestedNavigation: true, sectionState: .privacyPolicy),
Section(sectionTitle: "Third-party licenses", imageString: "thirdPartyLicenses", hasNestedNavigation: true, sectionState: .licenses),
],
hasDynamicData: nil
),
Expand Down
170 changes: 145 additions & 25 deletions Scribe/AboutTab/AboutViewController.swift
Original file line number Diff line number Diff line change
@@ -1,51 +1,171 @@
//
// AboutViewController.swift
// Copyright (C) 2023 Scribe
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

import UIKit
import MessageUI
import StoreKit

class AboutViewController: UIViewController {
@IBOutlet var outerTable: UITableView!
final class AboutViewController: BaseTableViewController {

let tableData = AboutTableData.aboutTableData
override var dataSet: [ParentTableCellModel] {
AboutTableData.aboutTableData
}

override func viewDidLoad() {
super.viewDidLoad()

title = "About"
title = NSLocalizedString("about.title", comment: "The title of the about tab")

tableView.register(UINib(nibName: "AboutTableViewCell", bundle: nil), forCellReuseIdentifier: AboutTableViewCell.reuseIdentifier)
}
}

// MARK: UITableViewDataSource

extension AboutViewController {

let nib = UINib(nibName: "ParentTableViewCell", bundle: nil)
outerTable.register(nib, forCellReuseIdentifier: "ParentTableViewCell")
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: AboutTableViewCell.reuseIdentifier, for: indexPath) as! AboutTableViewCell

outerTable.dataSource = self
outerTable.delegate = self
cell.configureCell(for: dataSet[indexPath.section].section[indexPath.row])

outerTable.separatorStyle = .none
outerTable.backgroundColor = .clear
return cell
}
}

// MARK: UITableViewDataSource
// MARK: UITableViewDelegate

extension AboutViewController {

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let tableSection = dataSet[indexPath.section]
let section = tableSection.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:
if let viewController = storyboard?.instantiateViewController(identifier: "InformationScreenVC") as? InformationScreenVC {
navigationController?.pushViewController(viewController, animated: true)
viewController.section = .wikimedia
}

case .shareScribe:
showShareSheet()

/// Function implementation conforming to the UITableViewDataSource protocol.
extension AboutViewController: UITableViewDataSource {
func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int {
return tableData.count
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:
if let viewController = storyboard?.instantiateViewController(identifier: "InformationScreenVC") as? InformationScreenVC {
navigationController?.pushViewController(viewController, animated: true)
viewController.section = .privacyPolicy
}

case .licenses:
if let viewController = storyboard?.instantiateViewController(identifier: "InformationScreenVC") as? InformationScreenVC {
navigationController?.pushViewController(viewController, animated: true)
viewController.section = .licenses
}

case .appLang: break
case .none: break
case .specificLang(_): break
}


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

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "ParentTableViewCell", for: indexPath) as! ParentTableViewCell
private 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)
}
}

cell.configureCell(for: tableData[indexPath.row])
private 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))
present(alert, animated: true)
}
}

cell.backgroundColor = .clear
cell.selectionStyle = .none
private func openScribeAppStore(alert _: UIAlertAction) {
openURLString(urlString: "itms-apps: //itunes.apple.com/app/id1596613886", withEncoding: true)
}

return cell
private func showEmailUI() {
if MFMailComposeViewController.canSendMail() {
let mailComposeViewController = MFMailComposeViewController()
mailComposeViewController.mailComposeDelegate = self
mailComposeViewController.setToRecipients(["team@scri.be"])
mailComposeViewController.setSubject("Hey Scribe!")

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 team@scri.be", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
present(alert, animated: true)
}
}

private 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)

present(shareSheetVC, animated: true, completion: nil)
}
}

// MARK: UITableViewDelegate
// MARK: - MFMailComposeViewControllerDelegate

extension AboutViewController: MFMailComposeViewControllerDelegate {

/// Function implementation conforming to the UITableViewDelegate protocol.
extension AboutViewController: UITableViewDelegate {}
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith _: MFMailComposeResult, error _: Error?) {
controller.dismiss(animated: true, completion: nil)
}
}
1 change: 0 additions & 1 deletion Scribe/AboutTab/InformationScreenVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class InformationScreenVC: UIViewController {
@IBOutlet var iconImageView: UIImageView!

var text: String = ""
var screenTitle: String = ""
var section: SectionState = .privacyPolicy

override func viewDidLoad() {
Expand Down
Loading

0 comments on commit 5087842

Please sign in to comment.