Add tapping mentions to show profiles
This commit is contained in:
parent
c5937acaa4
commit
089dda8e90
|
@ -1,10 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.13.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="HMn-Wn-5Ab">
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.15" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="HMn-Wn-5Ab">
|
||||||
<device id="retina4_7" orientation="portrait">
|
<device id="retina4_7" orientation="portrait">
|
||||||
<adaptation id="fullscreen"/>
|
<adaptation id="fullscreen"/>
|
||||||
</device>
|
</device>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.9"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.9"/>
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<scenes>
|
<scenes>
|
||||||
|
|
|
@ -31,11 +31,6 @@ class ProfileTableViewController: UITableViewController, PreferencesAdaptive {
|
||||||
var older: RequestRange?
|
var older: RequestRange?
|
||||||
var newer: RequestRange?
|
var newer: RequestRange?
|
||||||
|
|
||||||
func getStatuses(for range: RequestRange = .default, completion: @escaping Client.Callback<[Status]>) {
|
|
||||||
let request = Account.getStatuses(accountID, range: range, onlyMedia: false, pinned: false, excludeReplies: !Preferences.shared.showRepliesInProfiles)
|
|
||||||
MastodonController.shared.client.run(request, completion: completion)
|
|
||||||
}
|
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
@ -45,14 +40,33 @@ class ProfileTableViewController: UITableViewController, PreferencesAdaptive {
|
||||||
tableView.register(UINib(nibName: "StatusTableViewCell", bundle: nil), forCellReuseIdentifier: "statusCell")
|
tableView.register(UINib(nibName: "StatusTableViewCell", bundle: nil), forCellReuseIdentifier: "statusCell")
|
||||||
tableView.register(UINib(nibName: "ProfileHeaderTableViewCell", bundle: nil), forCellReuseIdentifier: "headerCell")
|
tableView.register(UINib(nibName: "ProfileHeaderTableViewCell", bundle: nil), forCellReuseIdentifier: "headerCell")
|
||||||
|
|
||||||
updateUIForPreferences()
|
if MastodonCache.account(for: accountID) != nil {
|
||||||
|
updateAccountUI()
|
||||||
getStatuses { response in
|
} else {
|
||||||
guard case let .success(statuses, pagination) = response else { fatalError() }
|
let activityIndicator = UIActivityIndicatorView(style: .whiteLarge)
|
||||||
MastodonCache.addAll(statuses: statuses)
|
activityIndicator.color = .darkGray
|
||||||
self.statusIDs = statuses.map { $0.id }
|
activityIndicator.startAnimating()
|
||||||
self.older = pagination?.older
|
activityIndicator.translatesAutoresizingMaskIntoConstraints = false
|
||||||
self.newer = pagination?.newer
|
view.addSubview(activityIndicator)
|
||||||
|
activityIndicator.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor)
|
||||||
|
activityIndicator.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor)
|
||||||
|
MastodonCache.account(for: accountID) { (account) in
|
||||||
|
guard account != nil else {
|
||||||
|
let alert = UIAlertController(title: "Something Went Wrong", message: "Couldn't load the selected account", preferredStyle: .alert)
|
||||||
|
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { (_) in
|
||||||
|
self.navigationController!.popViewController(animated: true)
|
||||||
|
}))
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.present(alert, animated: true)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
activityIndicator.removeFromSuperview()
|
||||||
|
self.updateAccountUI()
|
||||||
|
self.tableView.reloadData()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +78,22 @@ class ProfileTableViewController: UITableViewController, PreferencesAdaptive {
|
||||||
cell.updateUIForPreferences()
|
cell.updateUIForPreferences()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if MastodonCache.account(for: accountID) != nil {
|
||||||
|
updateUIForPreferences()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateAccountUI() {
|
||||||
updateUIForPreferences()
|
updateUIForPreferences()
|
||||||
|
|
||||||
|
getStatuses() { response in
|
||||||
|
guard case let .success(statuses, pagination) = response else { fatalError() }
|
||||||
|
MastodonCache.addAll(statuses: statuses)
|
||||||
|
self.statusIDs = statuses.map { $0.id }
|
||||||
|
self.older = pagination?.older
|
||||||
|
self.newer = pagination?.newer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateUIForPreferences() {
|
func updateUIForPreferences() {
|
||||||
|
@ -72,6 +101,11 @@ class ProfileTableViewController: UITableViewController, PreferencesAdaptive {
|
||||||
navigationItem.title = account.realDisplayName
|
navigationItem.title = account.realDisplayName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getStatuses(for range: RequestRange = .default, completion: @escaping Client.Callback<[Status]>) {
|
||||||
|
let request = Account.getStatuses(accountID, range: range, onlyMedia: false, pinned: false, excludeReplies: !Preferences.shared.showRepliesInProfiles)
|
||||||
|
MastodonController.shared.client.run(request, completion: completion)
|
||||||
|
}
|
||||||
|
|
||||||
func sendMessageMentioning() {
|
func sendMessageMentioning() {
|
||||||
guard let account = MastodonCache.account(for: accountID) else { fatalError("Missing cached account \(accountID!)") }
|
guard let account = MastodonCache.account(for: accountID) else { fatalError("Missing cached account \(accountID!)") }
|
||||||
let vc = ComposeViewController.create(mentioning: account.acct)
|
let vc = ComposeViewController.create(mentioning: account.acct)
|
||||||
|
@ -97,7 +131,7 @@ class ProfileTableViewController: UITableViewController, PreferencesAdaptive {
|
||||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||||
switch section {
|
switch section {
|
||||||
case 0:
|
case 0:
|
||||||
return 1
|
return MastodonCache.account(for: accountID) == nil ? 0 : 1
|
||||||
case 1:
|
case 1:
|
||||||
return statusIDs.count
|
return statusIDs.count
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -45,7 +45,11 @@ extension TuskerNavigationDelegate where Self: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
func selected(mention: Mention) {
|
func selected(mention: Mention) {
|
||||||
|
guard let navigationController = navigationController else {
|
||||||
|
fatalError("Can't show profile VC from mention when not in navigation controller")
|
||||||
|
}
|
||||||
|
let vc = ProfileTableViewController.create(for: mention.id)
|
||||||
|
navigationController.pushViewController(vc, animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func selected(tag: Hashtag) {
|
func selected(tag: Hashtag) {
|
||||||
|
|
Loading…
Reference in New Issue