mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-18 19:23:43 +01:00
Opens Twitter links in Twitter app if installed
This commit is contained in:
@@ -225,6 +225,28 @@ private extension SettingsViewController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func openTwitter(username: String)
|
||||||
|
{
|
||||||
|
let twitterAppURL = URL(string: "twitter://user?screen_name=" + username)!
|
||||||
|
UIApplication.shared.open(twitterAppURL, options: [:]) { (success) in
|
||||||
|
if success
|
||||||
|
{
|
||||||
|
if let selectedIndexPath = self.tableView.indexPathForSelectedRow
|
||||||
|
{
|
||||||
|
self.tableView.deselectRow(at: selectedIndexPath, animated: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
let safariURL = URL(string: "https://twitter.com/" + username)!
|
||||||
|
|
||||||
|
let safariViewController = SFSafariViewController(url: safariURL)
|
||||||
|
safariViewController.preferredControlTintColor = .altPrimary
|
||||||
|
self.present(safariViewController, animated: true, completion: nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private extension SettingsViewController
|
private extension SettingsViewController
|
||||||
@@ -344,18 +366,9 @@ extension SettingsViewController
|
|||||||
let row = CreditsRow.allCases[indexPath.row]
|
let row = CreditsRow.allCases[indexPath.row]
|
||||||
switch row
|
switch row
|
||||||
{
|
{
|
||||||
case .developer:
|
case .developer: self.openTwitter(username: "rileytestut")
|
||||||
let safariViewController = SFSafariViewController(url: URL(string: "https://twitter.com/rileytestut")!)
|
case .designer: self.openTwitter(username: "1carolinemoore")
|
||||||
safariViewController.preferredControlTintColor = .altPrimary
|
case .softwareLicenses: break
|
||||||
self.present(safariViewController, animated: true, completion: nil)
|
|
||||||
|
|
||||||
case .designer:
|
|
||||||
let safariViewController = SFSafariViewController(url: URL(string: "https://twitter.com/1carolinemoore")!)
|
|
||||||
safariViewController.preferredControlTintColor = .altPrimary
|
|
||||||
self.present(safariViewController, animated: true, completion: nil)
|
|
||||||
|
|
||||||
case .softwareLicenses:
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case .debug:
|
case .debug:
|
||||||
|
|||||||
Reference in New Issue
Block a user