forked from zelo72/mastodon-ios
feat: add keyboard commands for discovery posts, tag. And also restore for hashtag timeline and profile scene
This commit is contained in:
parent
945241e730
commit
fe93c8b4f7
|
@ -529,6 +529,7 @@
|
||||||
DBC6462826A1736300B0E31B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DB427DDE25BAA00100D1B89D /* Assets.xcassets */; };
|
DBC6462826A1736300B0E31B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DB427DDE25BAA00100D1B89D /* Assets.xcassets */; };
|
||||||
DBC7A672260C897100E57475 /* StatusContentWarningEditorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC7A671260C897100E57475 /* StatusContentWarningEditorView.swift */; };
|
DBC7A672260C897100E57475 /* StatusContentWarningEditorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC7A671260C897100E57475 /* StatusContentWarningEditorView.swift */; };
|
||||||
DBC7A67C260DFADE00E57475 /* StatusPublishService.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC7A67B260DFADE00E57475 /* StatusPublishService.swift */; };
|
DBC7A67C260DFADE00E57475 /* StatusPublishService.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC7A67B260DFADE00E57475 /* StatusPublishService.swift */; };
|
||||||
|
DBCA0EBC282BB38A0029E2B0 /* PageboyNavigateable.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBCA0EBB282BB38A0029E2B0 /* PageboyNavigateable.swift */; };
|
||||||
DBCBCBF4267CB070000F5B51 /* Decode85.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBCBCBF3267CB070000F5B51 /* Decode85.swift */; };
|
DBCBCBF4267CB070000F5B51 /* Decode85.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBCBCBF3267CB070000F5B51 /* Decode85.swift */; };
|
||||||
DBCBCC0D2680B908000F5B51 /* HomeTimelinePreference.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBCBCC0C2680B908000F5B51 /* HomeTimelinePreference.swift */; };
|
DBCBCC0D2680B908000F5B51 /* HomeTimelinePreference.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBCBCC0C2680B908000F5B51 /* HomeTimelinePreference.swift */; };
|
||||||
DBCBED1726132DB500B49291 /* UserTimelineViewModel+Diffable.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBCBED1626132DB500B49291 /* UserTimelineViewModel+Diffable.swift */; };
|
DBCBED1726132DB500B49291 /* UserTimelineViewModel+Diffable.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBCBED1626132DB500B49291 /* UserTimelineViewModel+Diffable.swift */; };
|
||||||
|
@ -1290,6 +1291,7 @@
|
||||||
DBC6462226A1712000B0E31B /* ShareViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShareViewModel.swift; sourceTree = "<group>"; };
|
DBC6462226A1712000B0E31B /* ShareViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShareViewModel.swift; sourceTree = "<group>"; };
|
||||||
DBC7A671260C897100E57475 /* StatusContentWarningEditorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusContentWarningEditorView.swift; sourceTree = "<group>"; };
|
DBC7A671260C897100E57475 /* StatusContentWarningEditorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusContentWarningEditorView.swift; sourceTree = "<group>"; };
|
||||||
DBC7A67B260DFADE00E57475 /* StatusPublishService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusPublishService.swift; sourceTree = "<group>"; };
|
DBC7A67B260DFADE00E57475 /* StatusPublishService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusPublishService.swift; sourceTree = "<group>"; };
|
||||||
|
DBCA0EBB282BB38A0029E2B0 /* PageboyNavigateable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageboyNavigateable.swift; sourceTree = "<group>"; };
|
||||||
DBCBCBF3267CB070000F5B51 /* Decode85.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Decode85.swift; sourceTree = "<group>"; };
|
DBCBCBF3267CB070000F5B51 /* Decode85.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Decode85.swift; sourceTree = "<group>"; };
|
||||||
DBCBCC0C2680B908000F5B51 /* HomeTimelinePreference.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeTimelinePreference.swift; sourceTree = "<group>"; };
|
DBCBCC0C2680B908000F5B51 /* HomeTimelinePreference.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeTimelinePreference.swift; sourceTree = "<group>"; };
|
||||||
DBCBED1626132DB500B49291 /* UserTimelineViewModel+Diffable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserTimelineViewModel+Diffable.swift"; sourceTree = "<group>"; };
|
DBCBED1626132DB500B49291 /* UserTimelineViewModel+Diffable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserTimelineViewModel+Diffable.swift"; sourceTree = "<group>"; };
|
||||||
|
@ -1697,6 +1699,7 @@
|
||||||
DB4AA6B227BA34B6009EC082 /* CellFrameCacheContainer.swift */,
|
DB4AA6B227BA34B6009EC082 /* CellFrameCacheContainer.swift */,
|
||||||
2D38F20725CD491300561493 /* DisposeBagCollectable.swift */,
|
2D38F20725CD491300561493 /* DisposeBagCollectable.swift */,
|
||||||
DB1D84372657B275000346B3 /* SegmentedControlNavigateable.swift */,
|
DB1D84372657B275000346B3 /* SegmentedControlNavigateable.swift */,
|
||||||
|
DBCA0EBB282BB38A0029E2B0 /* PageboyNavigateable.swift */,
|
||||||
DB1D843326579931000346B3 /* TableViewControllerNavigateable.swift */,
|
DB1D843326579931000346B3 /* TableViewControllerNavigateable.swift */,
|
||||||
DB1D842D26552C4D000346B3 /* StatusTableViewControllerNavigateable.swift */,
|
DB1D842D26552C4D000346B3 /* StatusTableViewControllerNavigateable.swift */,
|
||||||
);
|
);
|
||||||
|
@ -4082,6 +4085,7 @@
|
||||||
DB1D186C25EF5BA7003F1F23 /* PollTableView.swift in Sources */,
|
DB1D186C25EF5BA7003F1F23 /* PollTableView.swift in Sources */,
|
||||||
DBA94434265CBB5300C537E1 /* ProfileFieldSection.swift in Sources */,
|
DBA94434265CBB5300C537E1 /* ProfileFieldSection.swift in Sources */,
|
||||||
DB336F28278D6EC70031E64B /* MastodonFieldContainer.swift in Sources */,
|
DB336F28278D6EC70031E64B /* MastodonFieldContainer.swift in Sources */,
|
||||||
|
DBCA0EBC282BB38A0029E2B0 /* PageboyNavigateable.swift in Sources */,
|
||||||
DBF156E42702DB3F00EC00B7 /* HandleTapAction.swift in Sources */,
|
DBF156E42702DB3F00EC00B7 /* HandleTapAction.swift in Sources */,
|
||||||
DB98EB4727B0DFAA0082E365 /* ReportViewModel+State.swift in Sources */,
|
DB98EB4727B0DFAA0082E365 /* ReportViewModel+State.swift in Sources */,
|
||||||
2D5981A125E4A593000FB903 /* MastodonConfirmEmailViewModel.swift in Sources */,
|
2D5981A125E4A593000FB903 /* MastodonConfirmEmailViewModel.swift in Sources */,
|
||||||
|
|
|
@ -16,10 +16,15 @@
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>27</integer>
|
<integer>27</integer>
|
||||||
</dict>
|
</dict>
|
||||||
|
<key>Mastodon - Profile.xcscheme_^#shared#^_</key>
|
||||||
|
<dict>
|
||||||
|
<key>orderHint</key>
|
||||||
|
<integer>19</integer>
|
||||||
|
</dict>
|
||||||
<key>Mastodon - RTL.xcscheme_^#shared#^_</key>
|
<key>Mastodon - RTL.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>6</integer>
|
<integer>5</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Mastodon - Release.xcscheme_^#shared#^_</key>
|
<key>Mastodon - Release.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
|
@ -109,7 +114,7 @@
|
||||||
<key>MastodonIntent.xcscheme_^#shared#^_</key>
|
<key>MastodonIntent.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>28</integer>
|
<integer>21</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>MastodonIntents.xcscheme_^#shared#^_</key>
|
<key>MastodonIntents.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
|
@ -124,12 +129,12 @@
|
||||||
<key>NotificationService.xcscheme_^#shared#^_</key>
|
<key>NotificationService.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>27</integer>
|
<integer>20</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>ShareActionExtension.xcscheme_^#shared#^_</key>
|
<key>ShareActionExtension.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>26</integer>
|
<integer>22</integer>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<key>SuppressBuildableAutocreation</key>
|
<key>SuppressBuildableAutocreation</key>
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
//
|
||||||
|
// PageboyNavigateable.swift
|
||||||
|
// Mastodon
|
||||||
|
//
|
||||||
|
// Created by MainasuK on 2022-5-11.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import Pageboy
|
||||||
|
import MastodonLocalization
|
||||||
|
|
||||||
|
typealias PageboyNavigateable = PageboyNavigateableCore & PageboyNavigateableRelay
|
||||||
|
|
||||||
|
protocol PageboyNavigateableCore: AnyObject {
|
||||||
|
var navigateablePageViewController: PageboyViewController { get }
|
||||||
|
var pageboyNavigateKeyCommands: [UIKeyCommand] { get }
|
||||||
|
|
||||||
|
func pageboyNavigateKeyCommandHandler(_ sender: UIKeyCommand)
|
||||||
|
func navigate(direction: PageboyNavigationDirection)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc protocol PageboyNavigateableRelay: AnyObject {
|
||||||
|
func pageboyNavigateKeyCommandHandlerRelay(_ sender: UIKeyCommand)
|
||||||
|
}
|
||||||
|
|
||||||
|
enum PageboyNavigationDirection: String, CaseIterable {
|
||||||
|
case previous
|
||||||
|
case next
|
||||||
|
|
||||||
|
var title: String {
|
||||||
|
switch self {
|
||||||
|
case .previous: return L10n.Common.Controls.Keyboard.SegmentedControl.previousSection
|
||||||
|
case .next: return L10n.Common.Controls.Keyboard.SegmentedControl.nextSection
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UIKeyCommand input
|
||||||
|
var input: String {
|
||||||
|
switch self {
|
||||||
|
case .previous: return "["
|
||||||
|
case .next: return "]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var modifierFlags: UIKeyModifierFlags {
|
||||||
|
switch self {
|
||||||
|
case .previous: return [.shift, .command]
|
||||||
|
case .next: return [.shift, .command]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var propertyList: Any {
|
||||||
|
return rawValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension PageboyNavigateableCore where Self: PageboyNavigateableRelay {
|
||||||
|
var pageboyNavigateKeyCommands: [UIKeyCommand] {
|
||||||
|
PageboyNavigationDirection.allCases.map { direction in
|
||||||
|
UIKeyCommand(
|
||||||
|
title: direction.title,
|
||||||
|
image: nil,
|
||||||
|
action: #selector(Self.pageboyNavigateKeyCommandHandlerRelay(_:)),
|
||||||
|
input: direction.input,
|
||||||
|
modifierFlags: direction.modifierFlags,
|
||||||
|
propertyList: direction.propertyList,
|
||||||
|
alternates: [],
|
||||||
|
discoverabilityTitle: nil,
|
||||||
|
attributes: [],
|
||||||
|
state: .off
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func pageboyNavigateKeyCommandHandler(_ sender: UIKeyCommand) {
|
||||||
|
guard let rawValue = sender.propertyList as? String,
|
||||||
|
let direction = PageboyNavigationDirection(rawValue: rawValue) else { return }
|
||||||
|
navigate(direction: direction)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension PageboyNavigateableCore {
|
||||||
|
func navigate(direction: PageboyNavigationDirection) {
|
||||||
|
switch direction {
|
||||||
|
case .previous:
|
||||||
|
navigateablePageViewController.scrollToPage(.previous, animated: true)
|
||||||
|
case .next:
|
||||||
|
navigateablePageViewController.scrollToPage(.next, animated: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -115,7 +115,7 @@ extension StatusTableViewControllerNavigateableCore where Self: DataSourceProvid
|
||||||
|
|
||||||
guard let provider = self as? (DataSourceProvider & MediaPreviewableViewController) else { return }
|
guard let provider = self as? (DataSourceProvider & MediaPreviewableViewController) else { return }
|
||||||
guard let indexPathForSelectedRow = tableView.indexPathForSelectedRow,
|
guard let indexPathForSelectedRow = tableView.indexPathForSelectedRow,
|
||||||
let cell = tableView.cellForRow(at: indexPathForSelectedRow) as? StatusTableViewCell
|
let cell = tableView.cellForRow(at: indexPathForSelectedRow) as? StatusViewContainerTableViewCell
|
||||||
else { return }
|
else { return }
|
||||||
|
|
||||||
guard let mediaView = cell.statusView.mediaGridContainerView.mediaViews.first else { return }
|
guard let mediaView = cell.statusView.mediaGridContainerView.mediaViews.first else { return }
|
||||||
|
|
|
@ -152,3 +152,20 @@ extension DiscoveryCommunityViewController: ScrollViewContainer {
|
||||||
tableView
|
tableView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension DiscoveryCommunityViewController {
|
||||||
|
override var keyCommands: [UIKeyCommand]? {
|
||||||
|
return navigationKeyCommands + statusNavigationKeyCommands
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - StatusTableViewControllerNavigateable
|
||||||
|
extension DiscoveryCommunityViewController: StatusTableViewControllerNavigateable {
|
||||||
|
@objc func navigateKeyCommandHandlerRelay(_ sender: UIKeyCommand) {
|
||||||
|
navigateKeyCommandHandler(sender)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func statusKeyCommandHandlerRelay(_ sender: UIKeyCommand) {
|
||||||
|
statusKeyCommandHandler(sender)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import os.log
|
||||||
import UIKit
|
import UIKit
|
||||||
import Combine
|
import Combine
|
||||||
import Tabman
|
import Tabman
|
||||||
|
import Pageboy
|
||||||
import MastodonAsset
|
import MastodonAsset
|
||||||
import MastodonUI
|
import MastodonUI
|
||||||
|
|
||||||
|
@ -126,3 +127,31 @@ extension DiscoveryViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - ScrollViewContainer
|
||||||
|
extension DiscoveryViewController: ScrollViewContainer {
|
||||||
|
var scrollView: UIScrollView? {
|
||||||
|
return (currentViewController as? ScrollViewContainer)?.scrollView
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension DiscoveryViewController {
|
||||||
|
|
||||||
|
public override var keyCommands: [UIKeyCommand]? {
|
||||||
|
return pageboyNavigateKeyCommands
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - PageboyNavigateable
|
||||||
|
extension DiscoveryViewController: PageboyNavigateable {
|
||||||
|
|
||||||
|
var navigateablePageViewController: PageboyViewController {
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func pageboyNavigateKeyCommandHandlerRelay(_ sender: UIKeyCommand) {
|
||||||
|
pageboyNavigateKeyCommandHandler(sender)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -131,3 +131,98 @@ extension DiscoveryHashtagsViewController: ScrollViewContainer {
|
||||||
tableView
|
tableView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension DiscoveryHashtagsViewController {
|
||||||
|
override var keyCommands: [UIKeyCommand]? {
|
||||||
|
return navigationKeyCommands
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - TableViewControllerNavigateable
|
||||||
|
extension DiscoveryHashtagsViewController: TableViewControllerNavigateable {
|
||||||
|
@objc func navigateKeyCommandHandlerRelay(_ sender: UIKeyCommand) {
|
||||||
|
navigateKeyCommandHandler(sender)
|
||||||
|
}
|
||||||
|
|
||||||
|
func navigate(direction: TableViewNavigationDirection) {
|
||||||
|
if let indexPathForSelectedRow = tableView.indexPathForSelectedRow {
|
||||||
|
// navigate up/down on the current selected item
|
||||||
|
navigateToTag(direction: direction, indexPath: indexPathForSelectedRow)
|
||||||
|
} else {
|
||||||
|
// set first visible item selected
|
||||||
|
navigateToFirstVisibleStatus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func navigateToTag(direction: TableViewNavigationDirection, indexPath: IndexPath) {
|
||||||
|
guard let diffableDataSource = viewModel.diffableDataSource else { return }
|
||||||
|
let items = diffableDataSource.snapshot().itemIdentifiers
|
||||||
|
guard let selectedItem = diffableDataSource.itemIdentifier(for: indexPath),
|
||||||
|
let selectedItemIndex = items.firstIndex(of: selectedItem) else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let _navigateToItem: DiscoveryItem? = {
|
||||||
|
var index = selectedItemIndex
|
||||||
|
while 0..<items.count ~= index {
|
||||||
|
index = {
|
||||||
|
switch direction {
|
||||||
|
case .up: return index - 1
|
||||||
|
case .down: return index + 1
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
guard 0..<items.count ~= index else { return nil }
|
||||||
|
let item = items[index]
|
||||||
|
|
||||||
|
guard Self.validNavigateableItem(item) else { continue }
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}()
|
||||||
|
|
||||||
|
guard let item = _navigateToItem, let indexPath = diffableDataSource.indexPath(for: item) else { return }
|
||||||
|
let scrollPosition: UITableView.ScrollPosition = overrideNavigationScrollPosition ?? Self.navigateScrollPosition(tableView: tableView, indexPath: indexPath)
|
||||||
|
tableView.selectRow(at: indexPath, animated: true, scrollPosition: scrollPosition)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func navigateToFirstVisibleStatus() {
|
||||||
|
guard let indexPathsForVisibleRows = tableView.indexPathsForVisibleRows else { return }
|
||||||
|
guard let diffableDataSource = viewModel.diffableDataSource else { return }
|
||||||
|
|
||||||
|
var visibleItems: [DiscoveryItem] = indexPathsForVisibleRows.sorted().compactMap { indexPath in
|
||||||
|
guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return nil }
|
||||||
|
guard Self.validNavigateableItem(item) else { return nil }
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
if indexPathsForVisibleRows.first?.row != 0, visibleItems.count > 1 {
|
||||||
|
// drop first when visible not the first cell of table
|
||||||
|
visibleItems.removeFirst()
|
||||||
|
}
|
||||||
|
guard let item = visibleItems.first, let indexPath = diffableDataSource.indexPath(for: item) else { return }
|
||||||
|
let scrollPosition: UITableView.ScrollPosition = overrideNavigationScrollPosition ?? Self.navigateScrollPosition(tableView: tableView, indexPath: indexPath)
|
||||||
|
tableView.selectRow(at: indexPath, animated: true, scrollPosition: scrollPosition)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func validNavigateableItem(_ item: DiscoveryItem) -> Bool {
|
||||||
|
switch item {
|
||||||
|
case .hashtag:
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func open() {
|
||||||
|
guard let indexPathForSelectedRow = tableView.indexPathForSelectedRow else { return }
|
||||||
|
guard let diffableDataSource = viewModel.diffableDataSource else { return }
|
||||||
|
guard let item = diffableDataSource.itemIdentifier(for: indexPathForSelectedRow) else { return }
|
||||||
|
|
||||||
|
guard case let .hashtag(tag) = item else { return }
|
||||||
|
let hashtagTimelineViewModel = HashtagTimelineViewModel(context: context, hashtag: tag.name)
|
||||||
|
coordinator.present(
|
||||||
|
scene: .hashtagTimeline(viewModel: hashtagTimelineViewModel),
|
||||||
|
from: self,
|
||||||
|
transition: .show
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -171,3 +171,20 @@ extension DiscoveryPostsViewController: DiscoveryIntroBannerViewDelegate {
|
||||||
UserDefaults.shared.discoveryIntroBannerNeedsHidden = true
|
UserDefaults.shared.discoveryIntroBannerNeedsHidden = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension DiscoveryPostsViewController {
|
||||||
|
override var keyCommands: [UIKeyCommand]? {
|
||||||
|
return navigationKeyCommands + statusNavigationKeyCommands
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - StatusTableViewControllerNavigateable
|
||||||
|
extension DiscoveryPostsViewController: StatusTableViewControllerNavigateable {
|
||||||
|
@objc func navigateKeyCommandHandlerRelay(_ sender: UIKeyCommand) {
|
||||||
|
navigateKeyCommandHandler(sender)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func statusKeyCommandHandlerRelay(_ sender: UIKeyCommand) {
|
||||||
|
statusKeyCommandHandler(sender)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -84,7 +84,6 @@ extension HashtagTimelineViewController {
|
||||||
])
|
])
|
||||||
|
|
||||||
tableView.delegate = self
|
tableView.delegate = self
|
||||||
// tableView.prefetchDataSource = self
|
|
||||||
viewModel.setupDiffableDataSource(
|
viewModel.setupDiffableDataSource(
|
||||||
tableView: tableView,
|
tableView: tableView,
|
||||||
statusTableViewCellDelegate: self
|
statusTableViewCellDelegate: self
|
||||||
|
@ -158,27 +157,6 @@ extension HashtagTimelineViewController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - TableViewCellHeightCacheableContainer
|
|
||||||
//extension HashtagTimelineViewController: TableViewCellHeightCacheableContainer {
|
|
||||||
// var cellFrameCache: NSCache<NSNumber, NSValue> {
|
|
||||||
// return viewModel.cellFrameCache
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//// MARK: - UIScrollViewDelegate
|
|
||||||
//extension HashtagTimelineViewController {
|
|
||||||
// func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
|
||||||
// aspectScrollViewDidScroll(scrollView)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//extension HashtagTimelineViewController: LoadMoreConfigurableTableViewContainer {
|
|
||||||
// typealias BottomLoaderTableViewCell = TimelineBottomLoaderTableViewCell
|
|
||||||
// typealias LoadingState = HashtagTimelineViewModel.LoadOldestState.Loading
|
|
||||||
// var loadMoreConfigurableTableView: UITableView { return tableView }
|
|
||||||
// var loadMoreConfigurableStateMachine: GKStateMachine { return viewModel.loadOldestStateMachine }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// MARK: - UITableViewDelegate
|
// MARK: - UITableViewDelegate
|
||||||
extension HashtagTimelineViewController: UITableViewDelegate, AutoGenerateTableViewDelegate {
|
extension HashtagTimelineViewController: UITableViewDelegate, AutoGenerateTableViewDelegate {
|
||||||
// sourcery:inline:HashtagTimelineViewController.AutoGenerateTableViewDelegate
|
// sourcery:inline:HashtagTimelineViewController.AutoGenerateTableViewDelegate
|
||||||
|
@ -206,82 +184,23 @@ extension HashtagTimelineViewController: UITableViewDelegate, AutoGenerateTableV
|
||||||
}
|
}
|
||||||
// sourcery:end
|
// sourcery:end
|
||||||
|
|
||||||
// func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
|
|
||||||
// return aspectTableView(tableView, estimatedHeightForRowAt: indexPath)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
|
|
||||||
// aspectTableView(tableView, willDisplay: cell, forRowAt: indexPath)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) {
|
|
||||||
// aspectTableView(tableView, didEndDisplaying: cell, forRowAt: indexPath)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
||||||
// aspectTableView(tableView, didSelectRowAt: indexPath)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
|
|
||||||
// return aspectTableView(tableView, contextMenuConfigurationForRowAt: indexPath, point: point)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func tableView(_ tableView: UITableView, previewForHighlightingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {
|
|
||||||
// return aspectTableView(tableView, previewForHighlightingContextMenuWithConfiguration: configuration)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func tableView(_ tableView: UITableView, previewForDismissingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {
|
|
||||||
// return aspectTableView(tableView, previewForDismissingContextMenuWithConfiguration: configuration)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func tableView(_ tableView: UITableView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) {
|
|
||||||
// aspectTableView(tableView, willPerformPreviewActionForMenuWith: configuration, animator: animator)
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - UITableViewDataSourcePrefetching
|
|
||||||
//extension HashtagTimelineViewController: UITableViewDataSourcePrefetching {
|
|
||||||
// func tableView(_ tableView: UITableView, prefetchRowsAt indexPaths: [IndexPath]) {
|
|
||||||
// aspectTableView(tableView, prefetchRowsAt: indexPaths)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// MARK: - StatusTableViewCellDelegate
|
// MARK: - StatusTableViewCellDelegate
|
||||||
extension HashtagTimelineViewController: StatusTableViewCellDelegate { }
|
extension HashtagTimelineViewController: StatusTableViewCellDelegate { }
|
||||||
|
|
||||||
// MARK: - AVPlayerViewControllerDelegate
|
extension HashtagTimelineViewController {
|
||||||
//extension HashtagTimelineViewController: AVPlayerViewControllerDelegate {
|
override var keyCommands: [UIKeyCommand]? {
|
||||||
//
|
return navigationKeyCommands + statusNavigationKeyCommands
|
||||||
// func playerViewController(_ playerViewController: AVPlayerViewController, willBeginFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator) {
|
}
|
||||||
// aspectPlayerViewController(playerViewController, willBeginFullScreenPresentationWithAnimationCoordinator: coordinator)
|
}
|
||||||
// }
|
// MARK: - StatusTableViewControllerNavigateable
|
||||||
//
|
extension HashtagTimelineViewController: StatusTableViewControllerNavigateable {
|
||||||
// func playerViewController(_ playerViewController: AVPlayerViewController, willEndFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator) {
|
@objc func navigateKeyCommandHandlerRelay(_ sender: UIKeyCommand) {
|
||||||
// aspectPlayerViewController(playerViewController, willEndFullScreenPresentationWithAnimationCoordinator: coordinator)
|
navigateKeyCommandHandler(sender)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
|
||||||
// MARK: - StatusTableViewCellDelegate
|
@objc func statusKeyCommandHandlerRelay(_ sender: UIKeyCommand) {
|
||||||
//extension HashtagTimelineViewController: StatusTableViewCellDelegate {
|
statusKeyCommandHandler(sender)
|
||||||
// weak var playerViewControllerDelegate: AVPlayerViewControllerDelegate? { return self }
|
}
|
||||||
// func parent() -> UIViewController { return self }
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
//extension HashtagTimelineViewController {
|
|
||||||
// override var keyCommands: [UIKeyCommand]? {
|
|
||||||
// return navigationKeyCommands + statusNavigationKeyCommands
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//// MARK: - StatusTableViewControllerNavigateable
|
|
||||||
//extension HashtagTimelineViewController: StatusTableViewControllerNavigateable {
|
|
||||||
// @objc func navigateKeyCommandHandlerRelay(_ sender: UIKeyCommand) {
|
|
||||||
// navigateKeyCommandHandler(sender)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @objc func statusKeyCommandHandlerRelay(_ sender: UIKeyCommand) {
|
|
||||||
// statusKeyCommandHandler(sender)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
|
@ -13,8 +13,9 @@ import MetaTextKit
|
||||||
import MastodonAsset
|
import MastodonAsset
|
||||||
import MastodonLocalization
|
import MastodonLocalization
|
||||||
import MastodonUI
|
import MastodonUI
|
||||||
import Tabman
|
|
||||||
import CoreDataStack
|
import CoreDataStack
|
||||||
|
import Tabman
|
||||||
|
import Pageboy
|
||||||
|
|
||||||
protocol ProfileViewModelEditable {
|
protocol ProfileViewModelEditable {
|
||||||
func isEdited() -> Bool
|
func isEdited() -> Bool
|
||||||
|
@ -1155,25 +1156,28 @@ extension ProfileViewController: ScrollViewContainer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//extension ProfileViewController {
|
extension ProfileViewController {
|
||||||
//
|
|
||||||
// override var keyCommands: [UIKeyCommand]? {
|
override var keyCommands: [UIKeyCommand]? {
|
||||||
// if !viewModel.isEditing.value {
|
if !viewModel.isEditing.value {
|
||||||
// return segmentedControlNavigateKeyCommands
|
return pageboyNavigateKeyCommands
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// return nil
|
return nil
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
// MARK: - PageboyNavigateable
|
||||||
|
extension ProfileViewController: PageboyNavigateable {
|
||||||
|
|
||||||
|
var navigateablePageViewController: PageboyViewController {
|
||||||
|
return profileSegmentedViewController.pagingViewController
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func pageboyNavigateKeyCommandHandlerRelay(_ sender: UIKeyCommand) {
|
||||||
|
pageboyNavigateKeyCommandHandler(sender)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - SegmentedControlNavigateable
|
|
||||||
//extension ProfileViewController: SegmentedControlNavigateable {
|
|
||||||
// var navigateableSegmentedControl: UISegmentedControl {
|
|
||||||
// profileHeaderViewController.pageSegmentedControl
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @objc func segmentedControlNavigateKeyCommandHandlerRelay(_ sender: UIKeyCommand) {
|
|
||||||
// segmentedControlNavigateKeyCommandHandler(sender)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
|
@ -77,6 +77,16 @@ extension ContentSplitViewController {
|
||||||
mainTabBarController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
mainTabBarController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
// response keyboard command tab switch
|
||||||
|
mainTabBarController.$currentTab
|
||||||
|
.sink { [weak self] tab in
|
||||||
|
guard let self = self else { return }
|
||||||
|
if tab != self.currentSupplementaryTab {
|
||||||
|
self.currentSupplementaryTab = tab
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.store(in: &disposeBag)
|
||||||
|
|
||||||
$currentSupplementaryTab
|
$currentSupplementaryTab
|
||||||
.removeDuplicates()
|
.removeDuplicates()
|
||||||
.sink(receiveValue: { [weak self] tab in
|
.sink(receiveValue: { [weak self] tab in
|
||||||
|
|
Loading…
Reference in New Issue