forked from shadowfacts/Tusker
New timeline key commands
This commit is contained in:
parent
18ee621489
commit
817ef0c2cc
@ -12,7 +12,7 @@ import Combine
|
||||
|
||||
// TODO: gonna need a thing to replicate all of EnhancedTableViewController
|
||||
|
||||
class TimelineViewController: UIViewController, TimelineLikeCollectionViewController {
|
||||
class TimelineViewController: UIViewController, TimelineLikeCollectionViewController, RefreshableViewController {
|
||||
let timeline: Timeline
|
||||
weak var mastodonController: MastodonController!
|
||||
|
||||
@ -35,6 +35,8 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
||||
self.controller = TimelineLikeController(delegate: self)
|
||||
|
||||
addKeyCommand(MenuController.refreshCommand(discoverabilityTitle: "Refresh Timeline"))
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
@ -76,20 +78,13 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
||||
applyInitialSnapshot()
|
||||
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
let refreshControl = UIRefreshControl(frame: .zero, primaryAction: UIAction(handler: { [unowned self] _ in
|
||||
Task {
|
||||
await self.controller.loadNewer()
|
||||
self.collectionView.refreshControl!.endRefreshing()
|
||||
}
|
||||
}))
|
||||
collectionView.refreshControl = refreshControl
|
||||
collectionView.refreshControl = UIRefreshControl()
|
||||
collectionView.refreshControl!.addTarget(self, action: #selector(refresh), for: .valueChanged)
|
||||
#endif
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// TODO: refresh key command
|
||||
}
|
||||
|
||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||
@ -157,6 +152,15 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
||||
isShowingTimelineDescription = false
|
||||
}
|
||||
|
||||
@objc func refresh() {
|
||||
Task {
|
||||
await controller.loadNewer()
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
collectionView.refreshControl?.endRefreshing()
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension TimelineViewController {
|
||||
|
Loading…
x
Reference in New Issue
Block a user