Merge branch 'tabbarnav' into develop

This commit is contained in:
Shadowfacts 2024-08-21 17:53:08 -04:00
commit 3a21983b98
29 changed files with 1015 additions and 461 deletions

View File

@ -131,6 +131,8 @@
D646DCDC2A081CF10059ECEB /* StatusUpdatedNotificationCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D646DCDB2A081CF10059ECEB /* StatusUpdatedNotificationCollectionViewCell.swift */; };
D64A50462C739DC0009D7193 /* NewMainTabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D64A50452C739DC0009D7193 /* NewMainTabBarViewController.swift */; };
D64A50482C739DEA009D7193 /* BaseMainTabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D64A50472C739DEA009D7193 /* BaseMainTabBarViewController.swift */; };
D64A50BC2C74F8F4009D7193 /* FindInstanceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D64A50BB2C74F8F4009D7193 /* FindInstanceViewController.swift */; };
D64A50BE2C752247009D7193 /* AdaptableNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D64A50BD2C752247009D7193 /* AdaptableNavigationController.swift */; };
D64AAE9126C80DC600FC57FB /* ToastView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D64AAE9026C80DC600FC57FB /* ToastView.swift */; };
D64AAE9526C88C5000FC57FB /* ToastableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D64AAE9426C88C5000FC57FB /* ToastableViewController.swift */; };
D64AAE9726C88DC400FC57FB /* ToastConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = D64AAE9626C88DC400FC57FB /* ToastConfiguration.swift */; };
@ -217,15 +219,12 @@
D6934F402BAA19EC002B1C8D /* VideoActivityItemSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6934F3F2BAA19EC002B1C8D /* VideoActivityItemSource.swift */; };
D6934F422BAC7D6E002B1C8D /* VideoControlsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6934F412BAC7D6E002B1C8D /* VideoControlsViewController.swift */; };
D693A72825CF282E003A14E2 /* TrendingHashtagsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D693A72725CF282E003A14E2 /* TrendingHashtagsViewController.swift */; };
D693A72F25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D693A72D25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.swift */; };
D693A73025CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D693A72E25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.xib */; };
D693DE5723FE1A6A0061E07D /* EnhancedNavigationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D693DE5623FE1A6A0061E07D /* EnhancedNavigationViewController.swift */; };
D693DE5923FE24310061E07D /* InteractivePushTransition.swift in Sources */ = {isa = PBXBuildFile; fileRef = D693DE5823FE24300061E07D /* InteractivePushTransition.swift */; };
D6945C2F23AC47C3005C403C /* SavedDataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6945C2E23AC47C3005C403C /* SavedDataManager.swift */; };
D6945C3223AC4D36005C403C /* HashtagTimelineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6945C3123AC4D36005C403C /* HashtagTimelineViewController.swift */; };
D6945C3423AC6431005C403C /* AddSavedHashtagViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6945C3323AC6431005C403C /* AddSavedHashtagViewController.swift */; };
D6945C3823AC739F005C403C /* InstanceTimelineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6945C3723AC739F005C403C /* InstanceTimelineViewController.swift */; };
D6945C3A23AC75E2005C403C /* FindInstanceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6945C3923AC75E2005C403C /* FindInstanceViewController.swift */; };
D6958F3D2AA383D90062FE52 /* WidescreenNavigationPrefsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6958F3C2AA383D90062FE52 /* WidescreenNavigationPrefsView.swift */; };
D69693F42585941A00F4E116 /* UIWindowSceneDelegate+Close.swift in Sources */ = {isa = PBXBuildFile; fileRef = D69693F32585941A00F4E116 /* UIWindowSceneDelegate+Close.swift */; };
D69693FA25859A8000F4E116 /* ComposeSceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D69693F925859A8000F4E116 /* ComposeSceneDelegate.swift */; };
@ -564,6 +563,8 @@
D646DCDB2A081CF10059ECEB /* StatusUpdatedNotificationCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusUpdatedNotificationCollectionViewCell.swift; sourceTree = "<group>"; };
D64A50452C739DC0009D7193 /* NewMainTabBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewMainTabBarViewController.swift; sourceTree = "<group>"; };
D64A50472C739DEA009D7193 /* BaseMainTabBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseMainTabBarViewController.swift; sourceTree = "<group>"; };
D64A50BB2C74F8F4009D7193 /* FindInstanceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindInstanceViewController.swift; sourceTree = "<group>"; };
D64A50BD2C752247009D7193 /* AdaptableNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdaptableNavigationController.swift; sourceTree = "<group>"; };
D64AAE9026C80DC600FC57FB /* ToastView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToastView.swift; sourceTree = "<group>"; };
D64AAE9426C88C5000FC57FB /* ToastableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToastableViewController.swift; sourceTree = "<group>"; };
D64AAE9626C88DC400FC57FB /* ToastConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToastConfiguration.swift; sourceTree = "<group>"; };
@ -653,15 +654,12 @@
D6934F3F2BAA19EC002B1C8D /* VideoActivityItemSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoActivityItemSource.swift; sourceTree = "<group>"; };
D6934F412BAC7D6E002B1C8D /* VideoControlsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoControlsViewController.swift; sourceTree = "<group>"; };
D693A72725CF282E003A14E2 /* TrendingHashtagsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrendingHashtagsViewController.swift; sourceTree = "<group>"; };
D693A72D25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeaturedProfileCollectionViewCell.swift; sourceTree = "<group>"; };
D693A72E25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FeaturedProfileCollectionViewCell.xib; sourceTree = "<group>"; };
D693DE5623FE1A6A0061E07D /* EnhancedNavigationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnhancedNavigationViewController.swift; sourceTree = "<group>"; };
D693DE5823FE24300061E07D /* InteractivePushTransition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InteractivePushTransition.swift; sourceTree = "<group>"; };
D6945C2E23AC47C3005C403C /* SavedDataManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SavedDataManager.swift; sourceTree = "<group>"; };
D6945C3123AC4D36005C403C /* HashtagTimelineViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HashtagTimelineViewController.swift; sourceTree = "<group>"; };
D6945C3323AC6431005C403C /* AddSavedHashtagViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddSavedHashtagViewController.swift; sourceTree = "<group>"; };
D6945C3723AC739F005C403C /* InstanceTimelineViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstanceTimelineViewController.swift; sourceTree = "<group>"; };
D6945C3923AC75E2005C403C /* FindInstanceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = FindInstanceViewController.swift; path = Tusker/Screens/FindInstanceViewController.swift; sourceTree = SOURCE_ROOT; };
D6958F3C2AA383D90062FE52 /* WidescreenNavigationPrefsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidescreenNavigationPrefsView.swift; sourceTree = "<group>"; };
D69693F32585941A00F4E116 /* UIWindowSceneDelegate+Close.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIWindowSceneDelegate+Close.swift"; sourceTree = "<group>"; };
D69693F925859A8000F4E116 /* ComposeSceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeSceneDelegate.swift; sourceTree = "<group>"; };
@ -981,7 +979,7 @@
D68E525C24A3E8F00054355A /* InlineTrendsViewController.swift */,
D6945C3323AC6431005C403C /* AddSavedHashtagViewController.swift */,
D6093F9A25BDD4B9004811E6 /* HashtagSearchResultsViewController.swift */,
D6945C3923AC75E2005C403C /* FindInstanceViewController.swift */,
D64A50BB2C74F8F4009D7193 /* FindInstanceViewController.swift */,
D6114E0C27F7FEB30080E273 /* TrendingStatusesViewController.swift */,
D693A72725CF282E003A14E2 /* TrendingHashtagsViewController.swift */,
D6114E1027F899B30080E273 /* TrendingLinksViewController.swift */,
@ -991,8 +989,6 @@
D601FA81297EEC3F00A8E8B5 /* SuggestedProfileCardCollectionViewCell.swift */,
D601FA82297EEC3F00A8E8B5 /* SuggestedProfileCardCollectionViewCell.xib */,
D6BC74852AFC4772000DD603 /* SuggestedProfileCardView.swift */,
D693A72D25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.swift */,
D693A72E25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.xib */,
D6C3F4FA299035650009FCFF /* TrendsViewController.swift */,
D68329EE299540050026EB24 /* MoreTrendsFooterCollectionViewCell.swift */,
D6DD996A2998611A0015C962 /* SuggestedProfilesViewController.swift */,
@ -1562,6 +1558,7 @@
D6B8DB332182A59300424AF7 /* UIAlertController+Visibility.swift */,
D6C693FD2162FEEA007D6A6D /* UIViewController+Children.swift */,
D61F759129365C6C00C0B37F /* CollectionViewController.swift */,
D64A50BD2C752247009D7193 /* AdaptableNavigationController.swift */,
);
path = Utilities;
sourceTree = "<group>";
@ -2020,7 +2017,6 @@
buildActionMask = 2147483647;
files = (
D6E77D0D286E6B7300D8B732 /* TrendingLinkCardCollectionViewCell.xib in Resources */,
D693A73025CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.xib in Resources */,
D61AC1D9232EA42D00C54D2D /* InstanceTableViewCell.xib in Resources */,
D691296E2BA75ADF005C58ED /* PrivacyInfo.xcprivacy in Resources */,
D6412B0B24B0D4C600F5412E /* ProfileHeaderView.xib in Resources */,
@ -2241,6 +2237,7 @@
D691772E29AA5D420054D7EF /* UserActivityHandlingContext.swift in Sources */,
04ED00B121481ED800567C53 /* SteppedProgressView.swift in Sources */,
D6A6C11B25B63CEE00298D0F /* MemoryCache.swift in Sources */,
D64A50BC2C74F8F4009D7193 /* FindInstanceViewController.swift in Sources */,
D6114E0D27F7FEB30080E273 /* TrendingStatusesViewController.swift in Sources */,
D6BC9DDA232D8BE5002CA326 /* SearchResultsViewController.swift in Sources */,
D698F4672BD079800054DB14 /* AnnouncementsHostingController.swift in Sources */,
@ -2260,7 +2257,6 @@
D61DC84D28F500D200B82C6E /* ProfileViewController.swift in Sources */,
D6187BED2BFA840B00B3A281 /* FollowRequestNotificationViewController.swift in Sources */,
D600891F29848DE2005B4D00 /* AddInstancePinnedTimelineView.swift in Sources */,
D693A72F25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.swift in Sources */,
D627943223A5466600D38C68 /* SelectableTableViewCell.swift in Sources */,
D64B96812BC3279D002C8990 /* PrefsAccountView.swift in Sources */,
D6EAE0DB2550CC8A002DB0AC /* FocusableTextField.swift in Sources */,
@ -2280,7 +2276,6 @@
D63CC7102911F1E4000E19DE /* UIScrollView+Top.swift in Sources */,
D6F6A557291F4F1600F496A8 /* MuteAccountView.swift in Sources */,
D65B4B8B297879E900DABDFB /* AccountFollowsViewController.swift in Sources */,
D6945C3A23AC75E2005C403C /* FindInstanceViewController.swift in Sources */,
D65B4B6429771EFF00DABDFB /* ConversationViewController.swift in Sources */,
D68E6F59253C9969001A1B4C /* MultiSourceEmojiLabel.swift in Sources */,
D6EBF01523C55C0900AE061B /* UIApplication+Scenes.swift in Sources */,
@ -2349,6 +2344,7 @@
D6C693FE2162FEEA007D6A6D /* UIViewController+Children.swift in Sources */,
D61A45EA28DF51EE002BE511 /* TimelineLikeCollectionViewController.swift in Sources */,
D64D0AB12128D9AE005A6F37 /* OnboardingViewController.swift in Sources */,
D64A50BE2C752247009D7193 /* AdaptableNavigationController.swift in Sources */,
D6934F302BA7AF91002B1C8D /* ImageGalleryContentViewController.swift in Sources */,
D6934F3E2BAA19D5002B1C8D /* ImageActivityItemSource.swift in Sources */,
D67C1795266D57D10070F250 /* FastAccountSwitcherIndicatorView.swift in Sources */,

View File

@ -9,10 +9,14 @@
import Foundation
@propertyWrapper
class Box<Value> {
final class Box<Value> {
var wrappedValue: Value
init(wrappedValue: Value) {
self.wrappedValue = wrappedValue
}
var projectedValue: Box<Value> {
self
}
}

View File

@ -17,9 +17,7 @@ class AccountFollowsListViewController: UIViewController, CollectionViewControll
let mastodonController: MastodonController
let mode: AccountFollowsViewController.Mode
var collectionView: UICollectionView! {
view as? UICollectionView
}
private(set) var collectionView: UICollectionView!
private var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
private var state: State = .unloaded
@ -40,7 +38,11 @@ class AccountFollowsListViewController: UIViewController, CollectionViewControll
fatalError("init(coder:) has not been implemented")
}
override func loadView() {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .appGroupedBackground
var config = UICollectionLayoutListConfiguration(appearance: .plain)
config.backgroundColor = .appBackground
config.itemSeparatorHandler = { [unowned self] indexPath, sectionConfig in
@ -65,10 +67,19 @@ class AccountFollowsListViewController: UIViewController, CollectionViewControll
section.readableContentInset(in: environment)
return section
}
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.delegate = self
collectionView.dragDelegate = self
collectionView.allowsFocus = true
collectionView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(collectionView)
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
dataSource = createDataSource()
}

View File

@ -14,9 +14,7 @@ class AccountListViewController: UIViewController, CollectionViewController {
private let mastodonController: MastodonController
private let accountIDs: [String]
var collectionView: UICollectionView! {
view as? UICollectionView
}
private(set) var collectionView: UICollectionView!
private var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
init(accountIDs: [String], mastodonController: MastodonController) {
@ -30,7 +28,11 @@ class AccountListViewController: UIViewController, CollectionViewController {
fatalError("init(coder:) has not been implemented")
}
override func loadView() {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .appGroupedBackground
var config = UICollectionLayoutListConfiguration(appearance: .grouped)
config.backgroundColor = .appGroupedBackground
config.separatorConfiguration.topSeparatorInsets = TimelineStatusCollectionViewCell.separatorInsets
@ -40,11 +42,25 @@ class AccountListViewController: UIViewController, CollectionViewController {
section.readableContentInset(in: environment)
return section
}
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.delegate = self
collectionView.dragDelegate = self
collectionView.allowsFocus = true
collectionView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(collectionView)
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
dataSource = createDataSource()
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
snapshot.appendSections([.accounts])
snapshot.appendItems(accountIDs)
dataSource.apply(snapshot, animatingDifferences: false)
}
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
@ -56,16 +72,7 @@ class AccountListViewController: UIViewController, CollectionViewController {
return collectionView.dequeueConfiguredReusableCell(using: accountCell, for: indexPath, item: itemIdentifier)
}
}
override func viewDidLoad() {
super.viewDidLoad()
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
snapshot.appendSections([.accounts])
snapshot.appendItems(accountIDs)
dataSource.apply(snapshot, animatingDifferences: false)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

View File

@ -19,9 +19,7 @@ class ConversationCollectionViewController: UIViewController, CollectionViewCont
var statusIDToScrollToOnLoad: String
var showStatusesAutomatically = false
var collectionView: UICollectionView! {
view as? UICollectionView
}
private(set) var collectionView: UICollectionView!
private var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
init(for mainStatusID: String, state: CollapseState, conversationViewController: ConversationViewController) {
@ -38,7 +36,9 @@ class ConversationCollectionViewController: UIViewController, CollectionViewCont
fatalError("init(coder:) has not been implemented")
}
override func loadView() {
override func viewDidLoad() {
super.viewDidLoad()
var config = UICollectionLayoutListConfiguration(appearance: .plain)
config.backgroundColor = .appSecondaryBackground
config.leadingSwipeActionsConfigurationProvider = { [unowned self] in
@ -66,13 +66,19 @@ class ConversationCollectionViewController: UIViewController, CollectionViewCont
return section
}
viewRespectsSystemMinimumLayoutMargins = false
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
// something about the autoresizing mask breaks resizing the vc
view.translatesAutoresizingMaskIntoConstraints = false
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.delegate = self
collectionView.dragDelegate = self
collectionView.allowsFocus = true
collectionView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(collectionView)
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
#if !targetEnvironment(macCatalyst)
collectionView.refreshControl = UIRefreshControl()
collectionView.refreshControl!.addTarget(self, action: #selector(refresh), for: .valueChanged)

View File

@ -48,12 +48,18 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
configuration.headerMode = .supplementary
let layout = UICollectionViewCompositionalLayout.list(using: configuration)
collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: layout)
collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
collectionView.delegate = self
collectionView.dragDelegate = self
collectionView.allowsFocus = true
collectionView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(collectionView)
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
dataSource = createDataSource()
applyInitialSnapshot()

View File

@ -1,152 +0,0 @@
//
// FeaturedProfileCollectionViewCell.swift
// Tusker
//
// Created by Shadowfacts on 2/6/21.
// Copyright © 2021 Shadowfacts. All rights reserved.
//
import UIKit
import Pachyderm
class FeaturedProfileCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var clippingView: UIView!
@IBOutlet weak var headerImageView: UIImageView!
@IBOutlet weak var avatarContainerView: UIView!
@IBOutlet weak var avatarImageView: UIImageView!
@IBOutlet weak var displayNameLabel: AccountDisplayNameLabel!
@IBOutlet weak var noteTextView: StatusContentTextView!
var account: Account?
private var accountImagesTask: Task<Void, Never>?
deinit {
accountImagesTask?.cancel()
}
override func awakeFromNib() {
super.awakeFromNib()
avatarContainerView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarContainerView)
avatarContainerView.layer.cornerCurve = .continuous
avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarImageView)
avatarImageView.layer.cornerCurve = .continuous
displayNameLabel.font = UIFontMetrics(forTextStyle: .title1).scaledFont(for: .systemFont(ofSize: 20, weight: .semibold))
displayNameLabel.adjustsFontForContentSizeCategory = true
noteTextView.adjustsFontForContentSizeCategory = true
noteTextView.textContainer.lineBreakMode = .byTruncatingTail
noteTextView.textContainerInset = UIEdgeInsets(top: 16, left: 4, bottom: 16, right: 4)
backgroundColor = .clear
clippingView.backgroundColor = .appBackground
clippingView.layer.cornerRadius = 5
clippingView.layer.cornerCurve = .continuous
clippingView.layer.borderWidth = 1
clippingView.layer.masksToBounds = true
layer.shadowOpacity = 0.2
layer.shadowRadius = 8
layer.shadowOffset = .zero
layer.masksToBounds = false
updateLayerColors()
NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil)
}
func updateUI(account: Account) {
self.account = account
displayNameLabel.updateForAccountDisplayName(account: account)
noteTextView.setBodyTextFromHTML(account.note)
noteTextView.setEmojis(account.emojis, identifier: account.id)
avatarImageView.image = nil
headerImageView.image = nil
accountImagesTask?.cancel()
accountImagesTask = Task {
await updateImages(account: account)
}
}
private nonisolated func updateImages(account: Account) async {
await withTaskGroup(of: Void.self) { group in
group.addTask {
guard let avatar = account.avatar,
let image = await ImageCache.avatars.get(avatar).1 else {
return
}
await MainActor.run {
self.avatarImageView.image = image
}
}
group.addTask {
guard let header = account.header,
let image = await ImageCache.headers.get(header).1 else {
return
}
await MainActor.run {
self.headerImageView.image = image
}
}
await group.waitForAll()
}
}
private func updateLayerColors() {
if traitCollection.userInterfaceStyle == .dark {
clippingView.layer.borderColor = UIColor.darkGray.withAlphaComponent(0.5).cgColor
layer.shadowColor = UIColor.darkGray.cgColor
} else {
clippingView.layer.borderColor = UIColor.lightGray.withAlphaComponent(0.5).cgColor
layer.shadowColor = UIColor.black.cgColor
}
}
// Unneeded on visionOS because there is no light/dark mode
#if !os(visionOS)
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
updateLayerColors()
}
#endif
override func layoutSubviews() {
super.layoutSubviews()
layer.shadowPath = CGPath(roundedRect: bounds, cornerWidth: 5, cornerHeight: 5, transform: nil)
}
@objc private func preferencesChanged() {
avatarContainerView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarContainerView)
avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarImageView)
if let account = account {
displayNameLabel.updateForAccountDisplayName(account: account)
}
}
// MARK: Accessibility
override var isAccessibilityElement: Bool {
get { true }
set {}
}
override var accessibilityAttributedLabel: NSAttributedString? {
get {
guard let account else {
return nil
}
let s = NSMutableAttributedString(string: "\(account.displayNameWithoutCustomEmoji), ")
s.append(noteTextView.attributedText)
return s
}
set {}
}
}

View File

@ -1,113 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="FeaturedProfileCollectionViewCell" customModule="Tusker" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="400" height="200"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="400" height="200"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YkJ-rV-f3C">
<rect key="frame" x="0.0" y="0.0" width="400" height="200"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="bo4-Sd-caI">
<rect key="frame" x="0.0" y="0.0" width="400" height="66"/>
<color key="backgroundColor" systemColor="systemGray5Color"/>
<constraints>
<constraint firstAttribute="height" constant="66" id="9Aa-Up-chJ"/>
</constraints>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RQe-uE-TEv">
<rect key="frame" x="8" y="34" width="64" height="64"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="4wd-wq-Sh2">
<rect key="frame" x="2" y="2" width="60" height="60"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="Xyl-Ry-J3r"/>
<constraint firstAttribute="width" secondItem="4wd-wq-Sh2" secondAttribute="height" multiplier="1:1" id="YEc-fT-FRB"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="width" secondItem="RQe-uE-TEv" secondAttribute="height" multiplier="1:1" id="4vR-IF-yS8"/>
<constraint firstAttribute="width" secondItem="4wd-wq-Sh2" secondAttribute="width" constant="4" id="52Q-zq-k28"/>
<constraint firstItem="4wd-wq-Sh2" firstAttribute="centerY" secondItem="RQe-uE-TEv" secondAttribute="centerY" id="Ped-H7-QtP"/>
<constraint firstItem="4wd-wq-Sh2" firstAttribute="centerX" secondItem="RQe-uE-TEv" secondAttribute="centerX" id="bRk-uJ-JGg"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Display name" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="10" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="voW-Is-1b2" customClass="AccountDisplayNameLabel" customModule="Tusker" customModuleProvider="target">
<rect key="frame" x="76" y="72" width="316" height="24"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="20"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="scaleToFill" verticalCompressionResistancePriority="749" scrollEnabled="NO" editable="NO" textAlignment="natural" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bvj-F0-ggC" customClass="StatusContentTextView" customModule="Tusker" customModuleProvider="target">
<rect key="frame" x="8" y="102" width="384" height="98"/>
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
<color key="textColor" systemColor="labelColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="bvj-F0-ggC" secondAttribute="trailing" constant="8" id="1sd-Df-jR1"/>
<constraint firstItem="bvj-F0-ggC" firstAttribute="leading" secondItem="YkJ-rV-f3C" secondAttribute="leading" constant="8" id="35h-Wh-fvk"/>
<constraint firstItem="voW-Is-1b2" firstAttribute="top" relation="greaterThanOrEqual" secondItem="bo4-Sd-caI" secondAttribute="bottom" id="39l-yo-g8V"/>
<constraint firstItem="bo4-Sd-caI" firstAttribute="leading" secondItem="YkJ-rV-f3C" secondAttribute="leading" id="3lQ-uN-93N"/>
<constraint firstAttribute="trailing" secondItem="voW-Is-1b2" secondAttribute="trailing" constant="8" id="Ckp-Bq-lB5"/>
<constraint firstItem="bo4-Sd-caI" firstAttribute="top" secondItem="YkJ-rV-f3C" secondAttribute="top" id="DWh-S5-PLQ"/>
<constraint firstAttribute="bottom" secondItem="bvj-F0-ggC" secondAttribute="bottom" id="MH3-7E-THx"/>
<constraint firstItem="RQe-uE-TEv" firstAttribute="leading" secondItem="YkJ-rV-f3C" secondAttribute="leading" constant="8" id="Tzo-aN-Bxq"/>
<constraint firstItem="voW-Is-1b2" firstAttribute="bottom" secondItem="4wd-wq-Sh2" secondAttribute="bottom" id="Wk6-u2-azz"/>
<constraint firstItem="RQe-uE-TEv" firstAttribute="centerY" secondItem="bo4-Sd-caI" secondAttribute="bottom" id="bon-bj-qnk"/>
<constraint firstItem="bvj-F0-ggC" firstAttribute="top" secondItem="RQe-uE-TEv" secondAttribute="bottom" constant="4" id="dyg-LN-BDn"/>
<constraint firstItem="voW-Is-1b2" firstAttribute="leading" secondItem="RQe-uE-TEv" secondAttribute="trailing" constant="4" id="shC-67-vC2"/>
<constraint firstAttribute="trailing" secondItem="bo4-Sd-caI" secondAttribute="trailing" id="wZn-gO-zue"/>
</constraints>
</view>
</subviews>
</view>
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="YkJ-rV-f3C" secondAttribute="trailing" id="Dy3-h1-zfM"/>
<constraint firstItem="YkJ-rV-f3C" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="Gld-3x-oE0"/>
<constraint firstItem="YkJ-rV-f3C" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="NIV-n8-4Rl"/>
<constraint firstAttribute="bottom" secondItem="YkJ-rV-f3C" secondAttribute="bottom" id="zNw-2z-Hlx"/>
</constraints>
<connections>
<outlet property="avatarContainerView" destination="RQe-uE-TEv" id="tBI-fT-26P"/>
<outlet property="avatarImageView" destination="4wd-wq-Sh2" id="rba-cv-8fb"/>
<outlet property="clippingView" destination="YkJ-rV-f3C" id="hLI-4z-yIc"/>
<outlet property="displayNameLabel" destination="voW-Is-1b2" id="XVS-4d-PKx"/>
<outlet property="headerImageView" destination="bo4-Sd-caI" id="YkL-Wi-BXb"/>
<outlet property="noteTextView" destination="bvj-F0-ggC" id="Bbm-ai-bu1"/>
</connections>
<point key="canvasLocation" x="535" y="428"/>
</collectionViewCell>
</objects>
<resources>
<systemColor name="labelColor">
<color red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemGray5Color">
<color red="0.89803921568627454" green="0.89803921568627454" blue="0.91764705882352937" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>

View File

@ -46,8 +46,8 @@ class SuggestedProfilesViewController: UIViewController, CollectionViewControlle
collectionView.allowsFocus = true
view.addSubview(collectionView)
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])

View File

@ -53,12 +53,18 @@ class TrendingHashtagsViewController: UIViewController, CollectionViewController
}
let layout = UICollectionViewCompositionalLayout.list(using: config)
collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: layout)
collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
collectionView.delegate = self
collectionView.dragDelegate = self
collectionView.allowsFocus = true
collectionView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(collectionView)
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, itemIdentifier in
cell.indicator.startAnimating()
}

View File

@ -40,6 +40,8 @@ class TrendingLinksViewController: UIViewController, CollectionViewController {
title = NSLocalizedString("Trending Links", comment: "trending links screen title")
view.backgroundColor = .appGroupedBackground
let layout = UICollectionViewCompositionalLayout { [unowned self] sectionIndex, environment in
switch dataSource.sectionIdentifier(for: sectionIndex) {
case nil:
@ -80,8 +82,8 @@ class TrendingLinksViewController: UIViewController, CollectionViewController {
collectionView.allowsFocus = true
view.addSubview(collectionView)
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])

View File

@ -14,9 +14,7 @@ class TrendingStatusesViewController: UIViewController, CollectionViewController
private let mastodonController: MastodonController
let filterer: Filterer
var collectionView: UICollectionView! {
view as? UICollectionView
}
private(set) var collectionView: UICollectionView!
private var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
private var loaded = false
@ -34,7 +32,9 @@ class TrendingStatusesViewController: UIViewController, CollectionViewController
fatalError("init(coder:) has not been implemented")
}
override func loadView() {
override func viewDidLoad() {
super.viewDidLoad()
var config = UICollectionLayoutListConfiguration(appearance: .plain)
config.leadingSwipeActionsConfigurationProvider = { [unowned self] in
(collectionView.cellForItem(at: $0) as? TimelineStatusCollectionViewCell)?.leadingSwipeActions()
@ -62,12 +62,22 @@ class TrendingStatusesViewController: UIViewController, CollectionViewController
section.readableContentInset(in: environment)
return section
}
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.delegate = self
collectionView.dragDelegate = self
collectionView.allowsFocus = true
collectionView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(collectionView)
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
dataSource = createDataSource()
NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: mastodonController)
}
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
@ -96,12 +106,6 @@ class TrendingStatusesViewController: UIViewController, CollectionViewController
}
}
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: mastodonController)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

View File

@ -44,6 +44,8 @@ class TrendsViewController: UIViewController, CollectionViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .appGroupedBackground
let layout = UICollectionViewCompositionalLayout { [unowned self] sectionIndex, environment in
let sectionIdentifier = self.dataSource.snapshot().sectionIdentifiers[sectionIndex]
@ -114,13 +116,19 @@ class TrendsViewController: UIViewController, CollectionViewController {
}
}
collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: layout)
collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
collectionView.delegate = self
collectionView.dragDelegate = self
collectionView.backgroundColor = .appGroupedBackground
collectionView.allowsFocus = true
collectionView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(collectionView)
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
dataSource = createDataSource()
NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil)

View File

@ -11,6 +11,7 @@ import UserAccounts
@MainActor
protocol FastAccountSwitcherViewControllerDelegate: AnyObject {
func fastAccountSwitcherItemOrientation(_ fastAccountSwitcher: FastAccountSwitcherViewController) -> FastAccountSwitcherViewController.ItemOrientation
func fastAccountSwitcherAddToViewHierarchy(_ fastAccountSwitcher: FastAccountSwitcherViewController)
/// - Parameter point: In the coordinate space of the view to which the pan gesture recognizer is attached.
func fastAccountSwitcher(_ fastAccountSwitcher: FastAccountSwitcherViewController, triggerZoneContains point: CGPoint) -> Bool
@ -31,7 +32,7 @@ class FastAccountSwitcherViewController: UIViewController {
#endif
private var touchBeganFeedbackWorkItem: DispatchWorkItem?
var itemOrientation: ItemOrientation = .iconsTrailing
private var itemOrientation: ItemOrientation = .iconsTrailing
init() {
super.init(nibName: "FastAccountSwitcherViewController", bundle: .main)
@ -60,6 +61,9 @@ class FastAccountSwitcherViewController: UIViewController {
}
func show() {
if let delegate {
itemOrientation = delegate.fastAccountSwitcherItemOrientation(self)
}
createAccountViews()
// add after creating account views so that the presenter can align based on them
delegate?.fastAccountSwitcherAddToViewHierarchy(self)

View File

@ -19,9 +19,7 @@ class LocalPredicateStatusesViewController: UIViewController, CollectionViewCont
private let predicateTitle: String
private let request: (RequestRange) -> Request<[TryDecode<Status>]>
var collectionView: UICollectionView! {
view as? UICollectionView
}
private(set) var collectionView: UICollectionView!
private var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
private var state = State.unloaded
@ -43,7 +41,9 @@ class LocalPredicateStatusesViewController: UIViewController, CollectionViewCont
fatalError("init(coder:) has not been implemented")
}
override func loadView() {
override func viewDidLoad() {
super.viewDidLoad()
var config = UICollectionLayoutListConfiguration(appearance: .plain)
config.backgroundColor = .appBackground
config.leadingSwipeActionsConfigurationProvider = { [unowned self] in
@ -71,12 +71,30 @@ class LocalPredicateStatusesViewController: UIViewController, CollectionViewCont
section.readableContentInset(in: environment)
return section
}
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.delegate = self
collectionView.dragDelegate = self
collectionView.allowsFocus = true
collectionView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(collectionView)
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
dataSource = createDataSource()
#if !targetEnvironment(macCatalyst)
collectionView.refreshControl = UIRefreshControl()
collectionView.refreshControl!.addTarget(self, action: #selector(refresh), for: .valueChanged)
#endif
addKeyCommand(MenuController.refreshCommand(discoverabilityTitle: "Refresh \(predicateTitle)"))
NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: mastodonController)
NotificationCenter.default.addObserver(self, selector: #selector(managedObjectsDidChange), name: .NSManagedObjectContextObjectsDidChange, object: mastodonController.persistentContainer.viewContext)
}
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
@ -97,20 +115,6 @@ class LocalPredicateStatusesViewController: UIViewController, CollectionViewCont
}
}
override func viewDidLoad() {
super.viewDidLoad()
#if !targetEnvironment(macCatalyst)
collectionView.refreshControl = UIRefreshControl()
collectionView.refreshControl!.addTarget(self, action: #selector(refresh), for: .valueChanged)
#endif
addKeyCommand(MenuController.refreshCommand(discoverabilityTitle: "Refresh \(predicateTitle)"))
NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: mastodonController)
NotificationCenter.default.addObserver(self, selector: #selector(managedObjectsDidChange), name: .NSManagedObjectContextObjectsDidChange, object: mastodonController.persistentContainer.viewContext)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

View File

@ -39,7 +39,16 @@ class AccountSwitchingContainerViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
embedChild(root)
addChild(root)
root.view.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(root.view)
NSLayoutConstraint.activate([
root.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
root.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
root.view.topAnchor.constraint(equalTo: view.topAnchor),
root.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
root.didMove(toParent: self)
}
override func didReceiveMemoryWarning() {

View File

@ -8,7 +8,7 @@
import UIKit
class BaseMainTabBarViewController: UITabBarController {
class BaseMainTabBarViewController: UITabBarController, FastAccountSwitcherViewControllerDelegate {
let mastodonController: MastodonController
@ -71,11 +71,12 @@ class BaseMainTabBarViewController: UITabBarController {
private func repositionFastSwitcherIndicator() {
guard let myProfileButton = findMyProfileTabBarButton(),
myProfileButton.window != nil else {
myProfileButton.window != nil,
let fastSwitcherIndicator else {
fastSwitcherIndicator?.isHidden = true
return
}
fastSwitcherIndicator?.isHidden = false
fastSwitcherIndicator.isHidden = false
NSLayoutConstraint.deactivate(fastSwitcherConstraints)
let isPortrait = view.bounds.width < view.bounds.height
if traitCollection.horizontalSizeClass == .compact && isPortrait {
@ -113,12 +114,15 @@ class BaseMainTabBarViewController: UITabBarController {
fastAccountSwitcher.hide()
}
#endif // !os(visionOS)
}
#if !os(visionOS)
extension BaseMainTabBarViewController: FastAccountSwitcherViewControllerDelegate {
// MARK: FastAccountSwitcherViewControllerDelegate
func fastAccountSwitcherItemOrientation(_ fastAccountSwitcher: FastAccountSwitcherViewController) -> FastAccountSwitcherViewController.ItemOrientation {
return .iconsTrailing
}
func fastAccountSwitcherAddToViewHierarchy(_ fastAccountSwitcher: FastAccountSwitcherViewController) {
#if !os(visionOS)
fastAccountSwitcher.view.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(fastAccountSwitcher.view)
NSLayoutConstraint.activate([
@ -133,17 +137,21 @@ extension BaseMainTabBarViewController: FastAccountSwitcherViewControllerDelegat
fastAccountSwitcher.view.safeAreaLayoutGuide.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
fastAccountSwitcher.view.safeAreaLayoutGuide.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
])
#endif // !os(visionOS)
}
func fastAccountSwitcher(_ fastAccountSwitcher: FastAccountSwitcherViewController, triggerZoneContains point: CGPoint) -> Bool {
#if !os(visionOS)
guard let myProfileButton = findMyProfileTabBarButton() else {
return false
}
let locationInButton = myProfileButton.convert(point, from: tabBar)
return myProfileButton.bounds.contains(locationInButton)
#else
return false
#endif // !os(visionOS)
}
}
#endif // !os(visionOS)
extension BaseMainTabBarViewController: TuskerNavigationDelegate {
var apiController: MastodonController! { mastodonController }
@ -156,7 +164,7 @@ extension BaseMainTabBarViewController: StateRestorableViewController {
let compose = presentedNav.viewControllers.first as? ComposeHostingController {
let draft = compose.controller.draft
activity = UserActivityManager.editDraftActivity(id: draft.id, accountID: draft.accountID)
} else if let vc = (selectedViewController as! UINavigationController).topViewController as? StateRestorableViewController {
} else if let vc = (selectedViewController as? any NavigationControllerProtocol)?.topViewController as? StateRestorableViewController {
activity = vc.stateRestorationActivity()
}
if activity == nil {

View File

@ -11,14 +11,14 @@ import UserAccounts
class MainSidebarMyProfileCollectionViewCell: UICollectionViewListCell {
private var verticalImageInset: CGFloat {
static var verticalImageInset: CGFloat {
if UIDevice.current.userInterfaceIdiom == .mac {
return (28 - avatarImageSize) / 2
} else {
return (44 - avatarImageSize) / 2
}
}
private var avatarImageSize: CGFloat {
static var avatarImageSize: CGFloat {
if UIDevice.current.userInterfaceIdiom == .mac {
return 20
} else {
@ -72,11 +72,11 @@ class MainSidebarMyProfileCollectionViewCell: UICollectionViewListCell {
return
}
config.image = image
config.directionalLayoutMargins.top = self.verticalImageInset
config.directionalLayoutMargins.bottom = self.verticalImageInset
config.imageProperties.maximumSize = CGSize(width: self.avatarImageSize, height: self.avatarImageSize)
config.directionalLayoutMargins.top = MainSidebarMyProfileCollectionViewCell.verticalImageInset
config.directionalLayoutMargins.bottom = MainSidebarMyProfileCollectionViewCell.verticalImageInset
config.imageProperties.maximumSize = CGSize(width: MainSidebarMyProfileCollectionViewCell.avatarImageSize, height: MainSidebarMyProfileCollectionViewCell.avatarImageSize)
config.imageProperties.reservedLayoutSize = CGSize(width: UIListContentConfiguration.ImageProperties.standardDimension, height: 0)
config.imageProperties.cornerRadius = Preferences.shared.avatarStyle.cornerRadiusFraction * self.avatarImageSize
config.imageProperties.cornerRadius = Preferences.shared.avatarStyle.cornerRadiusFraction * MainSidebarMyProfileCollectionViewCell.avatarImageSize
self.contentConfiguration = config
}
}
@ -86,7 +86,7 @@ class MainSidebarMyProfileCollectionViewCell: UICollectionViewListCell {
guard var config = self.contentConfiguration as? UIListContentConfiguration else {
return
}
config.imageProperties.cornerRadius = Preferences.shared.avatarStyle.cornerRadiusFraction * avatarImageSize
config.imageProperties.cornerRadius = Preferences.shared.avatarStyle.cornerRadiusFraction * MainSidebarMyProfileCollectionViewCell.avatarImageSize
self.contentConfiguration = config
}

View File

@ -269,8 +269,9 @@ class MainSidebarViewController: UIViewController {
}
private func showAddList() {
let service = CreateListService(mastodonController: mastodonController, present: { self.present($0, animated: true
) }) { list in
let service = CreateListService(mastodonController: mastodonController, present: {
self.present($0, animated: true)
}) { list in
let oldItem = self.selectedItem
self.select(item: .list(list), animated: false)
let list = ListTimelineViewController(for: list, mastodonController: self.mastodonController)
@ -370,7 +371,7 @@ extension MainSidebarViewController {
case let .savedInstance(url):
return url.host!
case .addSavedInstance:
return "Find An Instance..."
return "Find an Instance..."
}
}

View File

@ -93,7 +93,6 @@ class MainSplitViewController: UISplitViewController {
if UIDevice.current.userInterfaceIdiom != .mac {
let switcher = FastAccountSwitcherViewController()
fastAccountSwitcher = switcher
switcher.itemOrientation = .iconsLeading
switcher.view.translatesAutoresizingMaskIntoConstraints = false
switcher.delegate = self
// accessing .view unconditionally loads the view, which we don't want to happen
@ -664,6 +663,10 @@ extension MainSplitViewController: BackgroundableViewController {
}
extension MainSplitViewController: FastAccountSwitcherViewControllerDelegate {
func fastAccountSwitcherItemOrientation(_ fastAccountSwitcher: FastAccountSwitcherViewController) -> FastAccountSwitcherViewController.ItemOrientation {
return .iconsLeading
}
func fastAccountSwitcherAddToViewHierarchy(_ fastAccountSwitcher: FastAccountSwitcherViewController) {
view.addSubview(fastAccountSwitcher.view)
let currentAccount = fastAccountSwitcher.accountViews.first(where: \.isCurrent)!
@ -677,6 +680,7 @@ extension MainSplitViewController: FastAccountSwitcherViewControllerDelegate {
fastAccountSwitcher.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
}
func fastAccountSwitcher(_ fastAccountSwitcher: FastAccountSwitcherViewController, triggerZoneContains point: CGPoint) -> Bool {
guard !isCollapsed,
let cell = sidebar.myProfileCell() else {

View File

@ -7,11 +7,32 @@
//
import UIKit
import Combine
import Pachyderm
import TuskerPreferences
@available(iOS 18.0, *)
class NewMainTabBarViewController: BaseMainTabBarViewController {
final class NewMainTabBarViewController: BaseMainTabBarViewController {
private let composePlaceholder = UIViewController()
private var homeTab: UITab!
private var notificationsTab: UITab!
private var composeTab: UITab!
private var exploreTab: UITab!
private var bookmarksTab: UITab!
private var favoritesTab: UITab!
private var myProfileTab: UITab!
private var listsGroup: UITabGroup!
private var hashtagsGroup: UITabGroup!
private var instancesGroup: UITabGroup!
private var cancellables = Set<AnyCancellable>()
private var navigationStacks = [String: [UIViewController]]()
private var isCompact: Bool?
@Box fileprivate var myProfileCell: UIView?
private var sidebarTapRecognizer: UITapGestureRecognizer?
override func viewDidLoad() {
super.viewDidLoad()
@ -26,21 +47,168 @@ class NewMainTabBarViewController: BaseMainTabBarViewController {
self.makeViewController(for: tab)
}
let topLevelTabs = [
Tab.home,
.notifications,
.compose,
.explore,
.myProfile
].map {
UITab(title: $0.title, image: UIImage(systemName: $0.imageName), identifier: $0.rawValue, viewControllerProvider: viewControllerProvider)
homeTab = UITab(title: "Home", image: UIImage(systemName: "house"), identifier: Tab.home.rawValue, viewControllerProvider: viewControllerProvider)
notificationsTab = UITab(title: "Notifications", image: UIImage(systemName: "bell"), identifier: Tab.notifications.rawValue, viewControllerProvider: viewControllerProvider)
composeTab = UITab(title: "Compose", image: UIImage(systemName: "pencil"), identifier: Tab.compose.rawValue, viewControllerProvider: viewControllerProvider)
exploreTab = UITab(title: "Explore", image: UIImage(systemName: "magnifyingglass"), identifier: Tab.explore.rawValue, viewControllerProvider: viewControllerProvider)
bookmarksTab = UITab(title: "Bookmarks", image: UIImage(systemName: "bookmark"), identifier: Tab.bookmarks.rawValue, viewControllerProvider: viewControllerProvider)
bookmarksTab.preferredPlacement = .optional
favoritesTab = UITab(title: "Favorites", image: UIImage(systemName: "star"), identifier: Tab.favorites.rawValue, viewControllerProvider: viewControllerProvider)
favoritesTab.preferredPlacement = .optional
myProfileTab = MyProfileTab(mastodonController: mastodonController, viewControllerProvider: viewControllerProvider)
listsGroup = UITabGroup(title: "Lists", image: nil, identifier: Tab.lists.rawValue, children: []) { _ in
// this closure is necessary to prevent UIKit from crashing (FB14860961)
return AdaptableNavigationController()
}
listsGroup.preferredPlacement = .sidebarOnly
listsGroup.sidebarActions = [
UIAction(title: "New List…", image: UIImage(systemName: "plus"), handler: { [unowned self] _ in
self.showAddList()
})
]
reloadLists(mastodonController.lists)
hashtagsGroup = UITabGroup(title: "Hashtags", image: nil, identifier: Tab.hashtags.rawValue, children: []) { _ in
return AdaptableNavigationController()
}
hashtagsGroup.preferredPlacement = .sidebarOnly
hashtagsGroup.sidebarActions = [
UIAction(title: "Add Hashtag…", image: UIImage(systemName: "plus"), handler: { [unowned self] _ in
self.showAddSavedHashtag()
})
]
reloadHashtags()
instancesGroup = UITabGroup(title: "Instance Timelines", image: nil, identifier: Tab.instances.rawValue, children: []) { _ in
return AdaptableNavigationController()
}
instancesGroup.preferredPlacement = .sidebarOnly
instancesGroup.sidebarActions = [
UIAction(title: "Find an Instance…", image: UIImage(systemName: "plus"), handler: { [unowned self] _ in
self.showAddSavedInstance()
})
]
reloadSavedInstances()
if UIDevice.current.userInterfaceIdiom == .phone {
self.tabs = [
homeTab,
notificationsTab,
composeTab,
exploreTab,
myProfileTab,
]
} else {
self.updatePadTabs()
registerForTraitChanges([UITraitHorizontalSizeClass.self]) { (self: NewMainTabBarViewController, previousTraitCollection) in
self.updatePadTabs()
let vcToUpdate = self.selectedTab!.parent?.viewController ?? self.selectedTab!.viewController!
self.updateViewControllerSafeAreaInsets(vcToUpdate)
}
mastodonController.$lists
.sink { [unowned self] in self.reloadLists($0) }
.store(in: &cancellables)
mastodonController.$followedHashtags
.map { _ in () }
.merge(with: NotificationCenter.default.publisher(for: .savedHashtagsChanged).map { _ in () })
.sink { [unowned self] in self.reloadHashtags() }
.store(in: &cancellables)
NotificationCenter.default.addObserver(self, selector: #selector(reloadSavedInstances), name: .savedInstancesChanged, object: nil)
}
self.tabs = topLevelTabs
setupFastAccountSwitcher()
}
private func updatePadTabs() {
let wasCompact = isCompact
if self.traitCollection.horizontalSizeClass == .compact {
isCompact = true
var exploreNavStack: [UIViewController]? = nil
if let parent = selectedTab?.parent,
parent === listsGroup || parent === hashtagsGroup || parent === instancesGroup {
let nav = parent.viewController as! any NavigationControllerProtocol
exploreNavStack = nav.viewControllers
nav.viewControllers = []
}
self.tabs = [
homeTab,
notificationsTab,
composeTab,
exploreTab,
myProfileTab,
]
if let exploreNavStack {
selectedTab = exploreTab
let nav = exploreTab.viewController as! any NavigationControllerProtocol
nav.viewControllers = exploreNavStack
}
} else {
isCompact = false
var newTabAndNavigationStack: (UITab, [UIViewController])? = nil
if wasCompact == true,
selectedTab == exploreTab {
let nav = exploreTab.viewController as! any NavigationControllerProtocol
// skip over the ExploreViewController
if nav.viewControllers.count > 1 {
var newTab: UITab?
switch nav.viewControllers[1] {
case let listVC as ListTimelineViewController:
if let tab = listsGroup.tab(forIdentifier: ListTab.identifier(for: listVC.list)) {
newTab = tab
}
case let hashtagVC as HashtagTimelineViewController:
if let tab = hashtagsGroup.tab(forIdentifier: HashtagTab.identifier(for: hashtagVC.hashtagName)) {
newTab = tab
}
default:
break
}
if let newTab {
newTabAndNavigationStack = (newTab, Array(nav.viewControllers[1...]))
nav.viewControllers = [
nav.viewControllers[0], // leave the ExploreVC in place
InlineTrendsViewController(mastodonController: mastodonController), // re-insert an InlineTrendsVC
]
}
}
}
self.tabs = [
homeTab,
notificationsTab,
exploreTab,
bookmarksTab,
favoritesTab,
myProfileTab,
composeTab,
listsGroup,
hashtagsGroup,
instancesGroup,
]
if let (tab, navStack) = newTabAndNavigationStack {
let nav = tab.parent!.viewController as! any NavigationControllerProtocol
nav.viewControllers = navStack
// Setting the tab now seems to be clobbered by the UITabBarController itself updating in response
// to the size class change. So wait until it finishes to do so.
DispatchQueue.main.async {
self.selectedTab = tab
}
}
}
}
private func makeViewController(for tab: UITab) -> UIViewController {
guard let tab = Tab(rawValue: tab.identifier) else {
fatalError("unreachable")
@ -54,37 +222,183 @@ class NewMainTabBarViewController: BaseMainTabBarViewController {
case .compose:
return composePlaceholder
case .explore:
root = ExploreViewController(mastodonController: mastodonController)
if UIDevice.current.userInterfaceIdiom == .phone {
root = ExploreViewController(mastodonController: mastodonController)
} else {
let nav = AdaptableNavigationController(viewControllersToPrependInCompact: [
ExploreViewController(mastodonController: mastodonController)
])
nav.viewControllers = [InlineTrendsViewController(mastodonController: mastodonController)]
return nav
}
case .bookmarks:
root = BookmarksViewController(mastodonController: mastodonController)
case .favorites:
root = FavoritesViewController(mastodonController: mastodonController)
case .myProfile:
root = MyProfileViewController(mastodonController: mastodonController)
case .lists, .hashtags, .instances:
fatalError("unreachable")
}
let nav: any NavigationControllerProtocol
if UIDevice.current.userInterfaceIdiom == .phone {
nav = EnhancedNavigationViewController()
} else {
// TODO: need to figure out how to update the navigation controller if the pref changes
switch Preferences.shared.widescreenNavigationMode {
case .stack:
nav = EnhancedNavigationViewController()
case .splitScreen:
nav = SplitNavigationController()
case .multiColumn:
nav = MultiColumnNavigationController()
}
}
nav.viewControllers = [root]
return embedInNavigationController(root)
}
private func embedInNavigationController(_ vc: UIViewController) -> UIViewController {
let nav = AdaptableNavigationController()
nav.viewControllers = [vc]
return nav
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if sidebarTapRecognizer == nil,
let sidebarView = findSidebarView() {
sidebarTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(sidebarTapped))
sidebarTapRecognizer!.cancelsTouchesInView = false
sidebarView.addGestureRecognizer(sidebarTapRecognizer!)
}
}
private func reloadLists(_ lists: [List]) {
let viewControllerProvider = { [unowned self] (tab: UITab) in
let tab = tab as! ListTab
return ListTimelineViewController(for: tab.list, mastodonController: self.mastodonController)
}
listsGroup.children = lists.map { list in
ListTab(list: list, viewControllerProvider: viewControllerProvider)
}
}
private func reloadHashtags() {
let viewControllerProvider = { [unowned self] (tab: UITab) in
let tab = tab as! HashtagTab
return HashtagTimelineViewController(forNamed: tab.hashtagName, mastodonController: self.mastodonController)
}
var seenTags: Set<String> = []
var tabs: [UITab] = []
let savedReq = SavedHashtag.fetchRequest(account: mastodonController.accountInfo!)
let saved = (try? mastodonController.persistentContainer.viewContext.fetch(savedReq)) ?? []
for hashtag in saved {
seenTags.insert(hashtag.name)
tabs.append(HashtagTab(hashtagName: hashtag.name, viewControllerProvider: viewControllerProvider))
}
let followedReq = FollowedHashtag.fetchRequest()
let followed = (try? mastodonController.persistentContainer.viewContext.fetch(followedReq)) ?? []
for hashtag in followed where !seenTags.contains(hashtag.name) {
tabs.append(HashtagTab(hashtagName: hashtag.name, viewControllerProvider: viewControllerProvider))
}
tabs.sort(using: SemiCaseSensitiveComparator.keyPath(\.title))
hashtagsGroup.children = tabs
}
@objc private func reloadSavedInstances() {
let viewControllerProvider = { [unowned self] (tab: UITab) in
let tab = tab as! InstanceTab
return InstanceTimelineViewController(for: tab.instance.url, parentMastodonController: self.mastodonController)
}
let req = SavedInstance.fetchRequest(account: mastodonController.accountInfo!)
req.sortDescriptors = [NSSortDescriptor(key: "url.host", ascending: true)]
let instances = (try? mastodonController.persistentContainer.viewContext.fetch(req).uniques(by: \.url)) ?? []
instancesGroup.children = instances.map {
InstanceTab(instance: $0, viewControllerProvider: viewControllerProvider)
}
}
@objc func handleComposeKeyCommand() {
compose(editing: nil)
}
fileprivate func updateViewControllerSafeAreaInsets(_ vc: MultiColumnNavigationController) {
@objc private func sidebarTapped() {
fastAccountSwitcher?.hide()
}
private func showAddList() {
let service = CreateListService(mastodonController: mastodonController, present: {
self.present($0, animated: true)
}) { list in
let tab = self.listsGroup.tab(forIdentifier: ListTab.identifier(for: list))!
let listVC = tab.viewController as! ListTimelineViewController
listVC.presentEditOnAppear = true
self.selectedTab = tab
}
service.run()
}
private func showAddSavedHashtag() {
let addController = AddSavedHashtagViewController(mastodonController: mastodonController)
let nav = EnhancedNavigationViewController(rootViewController: addController)
present(nav, animated: true)
}
private func showAddSavedInstance() {
let findController = FindInstanceViewController(parentMastodonController: mastodonController)
findController.instanceTimelineDelegate = self
let nav = EnhancedNavigationViewController(rootViewController: findController)
present(nav, animated: true)
}
fileprivate func updateViewControllerSafeAreaInsets(_ vc: UIViewController) {
guard vc is MultiColumnNavigationController || (vc as? AdaptableNavigationController)?.current is MultiColumnNavigationController else {
return
}
// When in sidebar mode, for multi column mode, don't leave an inset for the floating tab bar, because it leaves a massive gap.
// The floating tab bar seems to always be 88pt tall, regardless of, e.g., Dynamic Type size.
vc.additionalSafeAreaInsets = UIEdgeInsets(top: sidebar.isHidden ? 0 : -88, left: 0, bottom: 0, right: 0)
}
private func findSidebarView() -> UIView? {
var next = myProfileCell
while let cur = next {
if cur.superview?.superview === self.view {
return cur
} else {
next = cur.superview
}
}
return nil
}
#if !os(visionOS)
override func fastAccountSwitcherItemOrientation(_ fastAccountSwitcher: FastAccountSwitcherViewController) -> FastAccountSwitcherViewController.ItemOrientation {
guard !sidebar.isHidden,
myProfileCell != nil else {
return super.fastAccountSwitcherItemOrientation(fastAccountSwitcher)
}
return .iconsLeading
}
override func fastAccountSwitcherAddToViewHierarchy(_ fastAccountSwitcher: FastAccountSwitcherViewController) {
guard !sidebar.isHidden,
let myProfileCell else {
super.fastAccountSwitcherAddToViewHierarchy(fastAccountSwitcher)
return
}
fastAccountSwitcher.view.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(fastAccountSwitcher.view)
let currentAccount = fastAccountSwitcher.accountViews.first(where: \.isCurrent)!
NSLayoutConstraint.activate([
currentAccount.centerYAnchor.constraint(equalTo: myProfileCell.centerYAnchor),
fastAccountSwitcher.view.leadingAnchor.constraint(equalTo: selectedTab!.viewController!.view.safeAreaLayoutGuide.leadingAnchor),
fastAccountSwitcher.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
fastAccountSwitcher.view.topAnchor.constraint(equalTo: view.topAnchor),
fastAccountSwitcher.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
}
override func fastAccountSwitcher(_ fastAccountSwitcher: FastAccountSwitcherViewController, triggerZoneContains point: CGPoint) -> Bool {
guard !sidebar.isHidden,
myProfileCell != nil else {
return super.fastAccountSwitcher(fastAccountSwitcher, triggerZoneContains: point)
}
return true
}
#endif
}
@available(iOS 18.0, *)
@ -94,37 +408,13 @@ extension NewMainTabBarViewController {
case notifications
case compose
case explore
case bookmarks
case favorites
case myProfile
var title: String {
switch self {
case .home:
"Home"
case .notifications:
"Notifications"
case .compose:
"Compose"
case .explore:
"Explore"
case .myProfile:
"My Profile"
}
}
var imageName: String {
switch self {
case .home:
"house"
case .notifications:
"bell"
case .compose:
"pencil"
case .explore:
"magnifyingglass"
case .myProfile:
"person"
}
}
case lists
case hashtags
case instances
}
}
@ -153,21 +443,148 @@ extension NewMainTabBarViewController: UITabBarControllerDelegate {
}
func tabBarController(_ tabBarController: UITabBarController, didSelectTab newTab: UITab, previousTab: UITab?) {
if let vc = newTab.viewController as? MultiColumnNavigationController {
self.updateViewControllerSafeAreaInsets(vc)
self.updateViewControllerSafeAreaInsets(newTab.viewController!)
// All tabs in a tab group deliberately share the same view controller, so we have to do this ourselves.
// I think this is pretty unfortunate API design--half the time, the tab bar controller takes care of
// this, but the rest of the time it's up to you.
// The managingNavigationController API would theoretically solve this, but split-screen/multi-column
// nav can't straightforwardly be implemented as UINavigationController subclasses.
// Unfortunately this, in turn, means that when switching between tabs in the same group, we don't
// get the new transition animation.
// This would be much less complicated if the controller just used the individual VCs of items in a group.
if let group = newTab.parent,
group === listsGroup || group === hashtagsGroup || group === instancesGroup,
let nav = group.viewController as? any NavigationControllerProtocol {
updateViewControllerSafeAreaInsets(nav)
if let previousTab {
navigationStacks[previousTab.identifier] = nav.viewControllers
}
if let existing = navigationStacks[newTab.identifier] {
nav.viewControllers = existing
} else if let newVC = newTab.viewController {
nav.viewControllers = [newVC]
} else {
fatalError("unreachable")
}
}
}
}
private var fastAccountSwitcherIndicator: UIView = {
let indicator = FastAccountSwitcherIndicatorView()
// need to explicitly set the frame to get it vertically centered
indicator.frame = CGRect(origin: .zero, size: indicator.intrinsicContentSize)
return indicator
}()
@available(iOS 18.0, *)
extension NewMainTabBarViewController: UITabBarController.Sidebar.Delegate {
func tabBarController(_ tabBarController: UITabBarController, sidebarVisibilityWillChange sidebar: UITabBarController.Sidebar, animator: any UITabBarController.Sidebar.Animating) {
if let vc = selectedViewController as? MultiColumnNavigationController {
animator.addAnimations {
self.updateViewControllerSafeAreaInsets(vc)
vc.view.layoutIfNeeded()
let vc = selectedTab!.parent?.viewController ?? selectedTab!.viewController!
animator.addAnimations {
self.updateViewControllerSafeAreaInsets(vc)
vc.view.layoutIfNeeded()
}
}
func tabBarController(_ tabBarController: UITabBarController, sidebar: UITabBarController.Sidebar, itemFor request: UITabSidebarItem.Request) -> UITabSidebarItem {
let item = UITabSidebarItem(request: request)
if case .tab(let tab) = request.content,
tab.identifier == Tab.myProfile.rawValue,
var config = item.contentConfiguration as? UIListContentConfiguration {
config.directionalLayoutMargins.top = MainSidebarMyProfileCollectionViewCell.verticalImageInset
config.directionalLayoutMargins.bottom = MainSidebarMyProfileCollectionViewCell.verticalImageInset
config.imageProperties.maximumSize = CGSize(width: MainSidebarMyProfileCollectionViewCell.avatarImageSize, height: MainSidebarMyProfileCollectionViewCell.avatarImageSize)
config.imageProperties.cornerRadius = Preferences.shared.avatarStyle.cornerRadiusFraction * MainSidebarMyProfileCollectionViewCell.avatarImageSize
if UIDevice.current.userInterfaceIdiom != .mac {
item.accessories = [
.customView(configuration: .init(customView: fastAccountSwitcherIndicator, placement: .trailing()))
]
item.contentConfiguration = MyProfileContentConfiguration(wrapped: config, view: $myProfileCell) { [unowned self] in
$0.addGestureRecognizer(self.fastAccountSwitcher.createSwitcherGesture())
}
} else {
item.contentConfiguration = config
}
}
return item
}
func tabBarController(_ tabBarController: UITabBarController, sidebar: UITabBarController.Sidebar, contextMenuConfigurationFor tab: UITab) -> UIContextMenuConfiguration? {
guard let id = mastodonController.accountInfo?.id else {
return nil
}
let activity: NSUserActivity
if let listTab = tab as? ListTab {
let timelineActivity = UserActivityManager.showTimelineActivity(timeline: .list(id: listTab.list.id), accountID: id)
if let timelineActivity {
activity = timelineActivity
} else {
return nil
}
} else if let hashtagTab = tab as? HashtagTab {
let timelineActivity = UserActivityManager.showTimelineActivity(timeline: .tag(hashtag: hashtagTab.hashtagName), accountID: id)
if let timelineActivity {
activity = timelineActivity
} else {
return nil
}
} else if tab is InstanceTab {
// don't currently have a scene type for this
return nil
} else if let tabID = Tab(rawValue: tab.identifier) {
switch tabID {
case .home:
return nil
case .notifications:
activity = UserActivityManager.checkNotificationsActivity(mode: Preferences.shared.defaultNotificationsMode, accountID: id)
case .explore:
activity = UserActivityManager.searchActivity(query: nil, accountID: id)
case .bookmarks:
activity = UserActivityManager.bookmarksActivity(accountID: id)
case .favorites:
// TODO
return nil
case .myProfile:
// no 'Open in New Window' activity for my profile, because the context menu clashes with the fast account switcher
return nil
case .compose:
activity = UserActivityManager.newPostActivity(accountID: id)
case .lists, .hashtags, .instances:
return nil
}
} else {
return nil
}
activity.displaysAuxiliaryScene = true
return UIContextMenuConfiguration(actionProvider: { _ in
var actions: [UIAction] = [
UIWindowScene.ActivationAction({ action in
return UIWindowScene.ActivationConfiguration(userActivity: activity)
})
]
if let listTab = tab as? ListTab {
actions.append(UIAction(title: "Delete List", image: UIImage(systemName: "trash"), attributes: .destructive, handler: { [unowned self] _ in
Task {
let service = DeleteListService(list: listTab.list, mastodonController: self.mastodonController) {
self.present($0, animated: true)
}
await service.run()
}
}))
}
return UIMenu(children: actions)
})
}
}
@ -259,3 +676,152 @@ extension NewMainTabBarViewController: AccountSwitchableViewController {
#endif
}
}
@available(iOS 18.0, *)
extension NewMainTabBarViewController: InstanceTimelineViewControllerDelegate {
func didSaveInstance(url: URL) {
dismiss(animated: true) {
let tab = self.instancesGroup.tab(forIdentifier: InstanceTab.identifier(for: url))!
self.selectedTab = tab
}
}
func didUnsaveInstance(url: URL) {
dismiss(animated: true)
}
}
private struct MyProfileContentConfiguration: UIContentConfiguration {
let wrapped: any UIContentConfiguration
@Box var view: UIView?
let configureView: (UIView) -> Void
init(wrapped: any UIContentConfiguration, view: Box<UIView?>, configureView: @escaping (UIView) -> Void) {
self.wrapped = wrapped
self._view = view
self.configureView = configureView
}
func makeContentView() -> any UIView & UIContentView {
let view = wrapped.makeContentView()
self.view = view
configureView(view)
return view
}
func updated(for state: any UIConfigurationState) -> Self {
return .init(wrapped: wrapped.updated(for: state), view: $view, configureView: configureView)
}
}
@available(iOS 18.0, *)
private class MyProfileTab: UITab {
private let mastodonController: MastodonController
private var avatarStyle: AvatarStyle?
init(mastodonController: MastodonController, viewControllerProvider: @escaping (UITab) -> UIViewController) {
self.mastodonController = mastodonController
// try to add the avatar image synchronously if possible
var avatarImage: UIImage?
if !Preferences.shared.grayscaleImages,
let account = mastodonController.account,
let avatarURL = account.avatar,
let avatar = ImageCache.avatars.get(avatarURL) {
avatarImage = Self.renderAvatar(avatar.image)
self.avatarStyle = Preferences.shared.avatarStyle
}
let image = avatarImage ?? UIImage(systemName: "person")!
super.init(title: "My Profile", image: image, identifier: NewMainTabBarViewController.Tab.myProfile.rawValue, viewControllerProvider: viewControllerProvider)
if avatarImage == nil {
Task {
await updateAvatar()
}
}
NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil)
}
private func updateAvatar() async {
guard let account = try? await mastodonController.getOwnAccount(),
let avatarURL = account.avatar,
let image = await ImageCache.avatars.get(avatarURL).1 else {
return
}
let maybeGrayscale = await ImageGrayscalifier.convertIfNecessary(url: avatarURL, image: image) ?? image
let rendered = Self.renderAvatar(maybeGrayscale)
self.avatarStyle = Preferences.shared.avatarStyle
self.image = rendered
}
private static func renderAvatar(_ image: UIImage) -> UIImage {
let size = MainSidebarMyProfileCollectionViewCell.avatarImageSize
let radius = Preferences.shared.avatarStyle.cornerRadiusFraction * size
let rect = CGRect(x: 0, y: 0, width: size, height: size)
let renderer = UIGraphicsImageRenderer(bounds: rect)
let rendered = renderer.image { ctx in
UIBezierPath(roundedRect: rect, cornerRadius: radius).addClip()
image.draw(in: rect)
}
return rendered.withRenderingMode(.alwaysOriginal)
}
@objc private func preferencesChanged() {
if avatarStyle != nil,
avatarStyle != Preferences.shared.avatarStyle {
Task {
await updateAvatar()
}
}
}
}
@available(iOS 18.0, *)
private class ListTab: UITab {
let list: List
init(list: List, viewControllerProvider: @escaping (UITab) -> UIViewController) {
self.list = list
super.init(title: list.title, image: UIImage(systemName: "list.bullet"), identifier: Self.identifier(for: list), viewControllerProvider: viewControllerProvider)
}
static func identifier(for list: List) -> String {
"list:\(list.id)"
}
}
@available(iOS 18.0, *)
private class HashtagTab: UITab {
let hashtagName: String
init(hashtagName: String, viewControllerProvider: @escaping (UITab) -> UIViewController) {
self.hashtagName = hashtagName
super.init(title: hashtagName, image: UIImage(systemName: "number"), identifier: Self.identifier(for: hashtagName), viewControllerProvider: viewControllerProvider)
}
static func identifier(for name: String) -> String {
"hashtag:\(name)"
}
}
@available(iOS 18.0, *)
private class InstanceTab: UITab {
let instance: SavedInstance
init(instance: SavedInstance, viewControllerProvider: @escaping (UITab) -> UIViewController) {
self.instance = instance
super.init(title: instance.url.host!, image: UIImage(systemName: "globe"), identifier: Self.identifier(for: instance), viewControllerProvider: viewControllerProvider)
}
static func identifier(for instance: SavedInstance) -> String {
"instance:\(instance.url.host!)"
}
static func identifier(for instanceURL: URL) -> String {
"instance:\(instanceURL.host!)"
}
}

View File

@ -108,8 +108,8 @@ class NotificationsCollectionViewController: UIViewController, TimelineLikeColle
collectionView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(collectionView)
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])

View File

@ -26,9 +26,7 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
private var older: RequestRange?
private var cancellables = Set<AnyCancellable>()
var collectionView: UICollectionView! {
view as? UICollectionView
}
private(set) var collectionView: UICollectionView!
private(set) var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
var headerCell: ProfileHeaderCollectionViewCell? {
collectionView.cellForItem(at: IndexPath(item: 0, section: 0)) as? ProfileHeaderCollectionViewCell
@ -56,7 +54,9 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
fatalError("init(coder:) has not been implemented")
}
override func loadView() {
override func viewDidLoad() {
super.viewDidLoad()
var config = UICollectionLayoutListConfiguration(appearance: .plain)
config.backgroundColor = .appBackground
config.leadingSwipeActionsConfigurationProvider = { [unowned self] in
@ -103,10 +103,18 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
return section
}
}
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.delegate = self
collectionView.dragDelegate = self
collectionView.allowsFocus = true
collectionView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(collectionView)
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
registerTimelineLikeCells()
dataSource = createDataSource()
@ -115,10 +123,6 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
collectionView.refreshControl = UIRefreshControl()
collectionView.refreshControl!.addTarget(self, action: #selector(refresh), for: .valueChanged)
#endif
}
override func viewDidLoad() {
super.viewDidLoad()
mastodonController.persistentContainer.accountSubject
.receive(on: DispatchQueue.main)

View File

@ -36,7 +36,7 @@ class SearchResultsViewController: UIViewController, CollectionViewController {
weak var delegate: SearchResultsViewControllerDelegate?
var tokenHandler: ((String, SearchOperatorType) -> Void)?
var collectionView: UICollectionView! { view as? UICollectionView }
private(set) var collectionView: UICollectionView!
private var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
/// Types of results to search for.
@ -62,7 +62,9 @@ class SearchResultsViewController: UIViewController, CollectionViewController {
fatalError("init(coder:) has not been implemented")
}
override func loadView() {
override func viewDidLoad() {
super.viewDidLoad()
let layout = UICollectionViewCompositionalLayout { [unowned self] sectionIndex, environment in
let sectionIdentifier = self.dataSource.sectionIdentifier(for: sectionIndex)!
switch sectionIdentifier {
@ -102,7 +104,7 @@ class SearchResultsViewController: UIViewController, CollectionViewController {
return .list(using: config, layoutEnvironment: environment)
}
}
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.delegate = self
collectionView.dragDelegate = self
collectionView.allowsFocus = true
@ -110,12 +112,16 @@ class SearchResultsViewController: UIViewController, CollectionViewController {
#if !os(visionOS)
collectionView.keyboardDismissMode = .interactive
#endif
collectionView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(collectionView)
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
dataSource = createDataSource()
}
override func viewDidLoad() {
super.viewDidLoad()
searchCancellable = searchSubject
.debounce(for: .seconds(1), scheduler: RunLoop.main)

View File

@ -19,9 +19,7 @@ class StatusActionAccountListCollectionViewController: UIViewController, Collect
private var needsInaccurateCountWarning = false
var collectionView: UICollectionView! {
view as? UICollectionView
}
private(set) var collectionView: UICollectionView!
private var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
private var state: State = .unloaded
@ -45,7 +43,11 @@ class StatusActionAccountListCollectionViewController: UIViewController, Collect
fatalError("init(coder:) has not been implemented")
}
override func loadView() {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .appGroupedBackground
var accountsConfig = UICollectionLayoutListConfiguration(appearance: .grouped)
accountsConfig.backgroundColor = .appGroupedBackground
accountsConfig.itemSeparatorHandler = { [unowned self] indexPath, sectionConfig in
@ -85,10 +87,19 @@ class StatusActionAccountListCollectionViewController: UIViewController, Collect
section.readableContentInset(in: environment)
return section
}
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.delegate = self
collectionView.dragDelegate = self
collectionView.allowsFocus = true
collectionView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(collectionView)
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
dataSource = createDataSource()
}

View File

@ -35,6 +35,8 @@ class StatusEditHistoryViewController: UIViewController, CollectionViewControlle
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .appGroupedBackground
var config = UICollectionLayoutListConfiguration(appearance: .grouped)
config.backgroundColor = .appGroupedBackground
config.itemSeparatorHandler = { [unowned self] indexPath, sectionConfig in
@ -62,8 +64,8 @@ class StatusEditHistoryViewController: UIViewController, CollectionViewControlle
collectionView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(collectionView)
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])

View File

@ -123,8 +123,8 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
collectionView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(collectionView)
NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])

View File

@ -0,0 +1,150 @@
//
// AdaptableNavigationController.swift
// Tusker
//
// Created by Shadowfacts on 8/20/24.
// Copyright © 2024 Shadowfacts. All rights reserved.
//
import UIKit
import Combine
@available(iOS 17.0, *)
class AdaptableNavigationController: UIViewController {
private let viewControllersToPrependInCompact: [UIViewController]
private var initialViewControllers: [UIViewController] = []
private lazy var regular = makeRegularNavigationController()
private lazy var compact = makeCompactNavigationController()
private var _current: (any NavigationControllerProtocol)?
var current: any NavigationControllerProtocol {
traitCollection.horizontalSizeClass == .regular ? regular : compact
}
init(viewControllersToPrependInCompact: [UIViewController] = []) {
self.viewControllersToPrependInCompact = viewControllersToPrependInCompact
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
updateNavigationController()
registerForTraitChanges([UITraitHorizontalSizeClass.self]) { (self: AdaptableNavigationController, previousTraitCollection) in
self.updateNavigationController()
}
}
private func updateNavigationController() {
let isTransferring: Bool
var stack: [UIViewController]
if let _current {
_current.removeViewAndController()
stack = _current.viewControllers
isTransferring = true
} else {
stack = initialViewControllers
initialViewControllers = []
isTransferring = false
}
if traitCollection.horizontalSizeClass == .regular {
if isTransferring {
stack.removeFirst(viewControllersToPrependInCompact.count)
}
} else {
stack.insert(contentsOf: viewControllersToPrependInCompact, at: 0)
}
_current = current
current.viewControllers = stack
addChild(current)
current.view.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(current.view)
NSLayoutConstraint.activate([
current.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
current.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
current.view.topAnchor.constraint(equalTo: view.topAnchor),
current.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
current.didMove(toParent: self)
}
private func makeRegularNavigationController() -> any NavigationControllerProtocol {
// TODO: need to figure out how to update the navigation controller if the pref changes
switch Preferences.shared.widescreenNavigationMode {
case .stack:
return EnhancedNavigationViewController()
case .splitScreen:
return SplitNavigationController()
case .multiColumn:
return MultiColumnNavigationController()
}
}
private func makeCompactNavigationController() -> any NavigationControllerProtocol {
EnhancedNavigationViewController()
}
}
@available(iOS 17.0, *)
extension AdaptableNavigationController: NavigationControllerProtocol {
var viewControllers: [UIViewController] {
get {
_current?.viewControllers ?? initialViewControllers
}
set {
if let _current {
_current.viewControllers = newValue
} else {
initialViewControllers = newValue
}
}
}
var topViewController: UIViewController? {
if let _current {
return _current.topViewController
} else {
return initialViewControllers.last
}
}
func popToRootViewController(animated: Bool) -> [UIViewController]? {
if let _current {
return _current.popToRootViewController(animated: animated)
} else {
defer { initialViewControllers = [] }
return initialViewControllers
}
}
func pushViewController(_ vc: UIViewController, animated: Bool) {
if let _current {
_current.pushViewController(vc, animated: animated)
} else {
initialViewControllers.append(vc)
}
}
}
@available(iOS 17.0, *)
extension AdaptableNavigationController: BackgroundableViewController {
func sceneDidEnterBackground() {
(topViewController as? BackgroundableViewController)?.sceneDidEnterBackground()
}
}
@available(iOS 17.0, *)
extension AdaptableNavigationController: StatusBarTappableViewController {
func handleStatusBarTapped(xPosition: CGFloat) -> StatusBarTapActionResult {
(topViewController as? StatusBarTappableViewController)?.handleStatusBarTapped(xPosition: xPosition) ?? .continue
}
}