Add share section with generic activity

To invite a friend.
This commit is contained in:
Davide De Rosa 2018-10-23 11:40:29 +02:00
parent 81c7236500
commit d781d9c8e0
3 changed files with 39 additions and 5 deletions

View File

@ -33,13 +33,16 @@ class AboutViewController: UITableViewController, TableModelHost {
let model: TableModel<SectionType, RowType> = TableModel()
model.add(.info)
model.add(.source)
model.add(.share)
model.add(.feedback)
model.setHeader(L10n.About.Sections.Info.header, for: .info)
model.setHeader(L10n.About.Sections.Source.header, for: .source)
model.setHeader(L10n.About.Sections.Share.header, for: .share)
model.setHeader(L10n.About.Sections.Feedback.header, for: .feedback)
model.set([.version, .credits, .disclaimer, .website], in: .info)
model.set([.sourcePassepartout, .sourceTunnelKit], in: .source)
model.set([.shareTwitter, .requestSupport, .writeReview], in: .feedback)
model.set([.shareTwitter, .shareGeneric], in: .share)
model.set([.requestSupport, .writeReview], in: .feedback)
return model
}()
@ -82,14 +85,21 @@ class AboutViewController: UITableViewController, TableModelHost {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
private func postSupportRequest() {
UIApplication.shared.open(AppConstants.URLs.subreddit, options: [:], completionHandler: nil)
}
private func tweetAboutApp() {
UIApplication.shared.open(AppConstants.URLs.twitterIntent, options: [:], completionHandler: nil)
}
private func inviteFriend(sender: UITableViewCell?) {
let message = "\(L10n.Share.message) \(AppConstants.URLs.website)"
let vc = UIActivityViewController(activityItems: [message], applicationActivities: nil)
vc.popoverPresentationController?.sourceView = sender
present(vc, animated: true, completion: nil)
}
private func postSupportRequest() {
UIApplication.shared.open(AppConstants.URLs.subreddit, options: [:], completionHandler: nil)
}
private func writeReview() {
let url = AppConstants.URLs.review(withId: GroupConstants.App.appId)
UIApplication.shared.open(url, options: [:], completionHandler: nil)
@ -130,6 +140,8 @@ extension AboutViewController {
case source
case share
case feedback
}
@ -148,6 +160,8 @@ extension AboutViewController {
case shareTwitter
case shareGeneric
case requestSupport
case writeReview
@ -207,6 +221,11 @@ extension AboutViewController {
cell.leftText = L10n.About.Cells.ShareTwitter.caption
return cell
case .shareGeneric:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.About.Cells.ShareGeneric.caption
return cell
case .requestSupport:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.About.Cells.RequestSupport.caption
@ -242,6 +261,9 @@ extension AboutViewController {
case .shareTwitter:
tweetAboutApp()
case .shareGeneric:
inviteFriend(sender: tableView.cellForRow(at: indexPath))
case .requestSupport:
postSupportRequest()

View File

@ -180,10 +180,12 @@
"about.title" = "About";
"about.sections.info.header" = "General";
"about.sections.source.header" = "Source code";
"about.sections.share.header" = "Share";
"about.sections.feedback.header" = "Feedback";
"about.cells.version.caption" = "Version";
"about.cells.website.caption" = "Visit website";
"about.cells.share_twitter.caption" = "Tweet about it!";
"about.cells.share_generic.caption" = "Invite a friend";
"about.cells.request_support.caption" = "Request support";
"about.cells.write_review.caption" = "Write a review";

View File

@ -19,6 +19,11 @@ internal enum L10n {
internal static let caption = L10n.tr("Localizable", "about.cells.request_support.caption")
}
internal enum ShareGeneric {
/// Invite a friend
internal static let caption = L10n.tr("Localizable", "about.cells.share_generic.caption")
}
internal enum ShareTwitter {
/// Tweet about it!
internal static let caption = L10n.tr("Localizable", "about.cells.share_twitter.caption")
@ -52,6 +57,11 @@ internal enum L10n {
internal static let header = L10n.tr("Localizable", "about.sections.info.header")
}
internal enum Share {
/// Share
internal static let header = L10n.tr("Localizable", "about.sections.share.header")
}
internal enum Source {
/// Source code
internal static let header = L10n.tr("Localizable", "about.sections.source.header")