Compare commits
8 Commits
0f6492a051
...
229b51686c
Author | SHA1 | Date |
---|---|---|
Shadowfacts | 229b51686c | |
Shadowfacts | e156a97861 | |
Shadowfacts | bdec14c463 | |
Shadowfacts | ec0509c645 | |
Shadowfacts | 4500e9be27 | |
Shadowfacts | a2cc3a0436 | |
Shadowfacts | dc654812b1 | |
Shadowfacts | f122383d0b |
|
@ -194,7 +194,6 @@
|
|||
D691771929A7B8820054D7EF /* ProfileHeaderMovedOverlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D691771829A7B8820054D7EF /* ProfileHeaderMovedOverlayView.swift */; };
|
||||
D691772E29AA5D420054D7EF /* UserActivityHandlingContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = D691772D29AA5D420054D7EF /* UserActivityHandlingContext.swift */; };
|
||||
D693A72825CF282E003A14E2 /* TrendingHashtagsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D693A72725CF282E003A14E2 /* TrendingHashtagsViewController.swift */; };
|
||||
D693A72A25CF8C1E003A14E2 /* ProfileDirectoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D693A72925CF8C1E003A14E2 /* ProfileDirectoryViewController.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 */; };
|
||||
|
@ -596,7 +595,6 @@
|
|||
D691771829A7B8820054D7EF /* ProfileHeaderMovedOverlayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileHeaderMovedOverlayView.swift; sourceTree = "<group>"; };
|
||||
D691772D29AA5D420054D7EF /* UserActivityHandlingContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserActivityHandlingContext.swift; sourceTree = "<group>"; };
|
||||
D693A72725CF282E003A14E2 /* TrendingHashtagsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrendingHashtagsViewController.swift; sourceTree = "<group>"; };
|
||||
D693A72925CF8C1E003A14E2 /* ProfileDirectoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileDirectoryViewController.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>"; };
|
||||
|
@ -910,7 +908,6 @@
|
|||
D601FA81297EEC3F00A8E8B5 /* SuggestedProfileCardCollectionViewCell.swift */,
|
||||
D601FA82297EEC3F00A8E8B5 /* SuggestedProfileCardCollectionViewCell.xib */,
|
||||
D6BC74852AFC4772000DD603 /* SuggestedProfileCardView.swift */,
|
||||
D693A72925CF8C1E003A14E2 /* ProfileDirectoryViewController.swift */,
|
||||
D693A72D25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.swift */,
|
||||
D693A72E25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.xib */,
|
||||
D6C3F4FA299035650009FCFF /* TrendsViewController.swift */,
|
||||
|
@ -2071,7 +2068,6 @@
|
|||
D65C6BF525478A9C00A6E89C /* BackgroundableViewController.swift in Sources */,
|
||||
D61DC84D28F500D200B82C6E /* ProfileViewController.swift in Sources */,
|
||||
D600891F29848DE2005B4D00 /* AddInstancePinnedTimelineView.swift in Sources */,
|
||||
D693A72A25CF8C1E003A14E2 /* ProfileDirectoryViewController.swift in Sources */,
|
||||
D693A72F25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.swift in Sources */,
|
||||
D627943223A5466600D38C68 /* SelectableTableViewCell.swift in Sources */,
|
||||
D6EAE0DB2550CC8A002DB0AC /* FocusableTextField.swift in Sources */,
|
||||
|
@ -2971,8 +2967,8 @@
|
|||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://git.shadowfacts.net/shadowfacts/HTMLStreamer.git";
|
||||
requirement = {
|
||||
kind = upToNextMinorVersion;
|
||||
minimumVersion = 0.1.0;
|
||||
kind = exactVersion;
|
||||
version = 0.1.2;
|
||||
};
|
||||
};
|
||||
D63CC700290EC0B8000E19DE /* XCRemoteSwiftPackageReference "sentry-cocoa" */ = {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
// Copyright © 2018 Shadowfacts. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(visionOS)
|
||||
import UIKit
|
||||
|
||||
extension UIViewController: UIViewControllerTransitioningDelegate {
|
||||
|
@ -34,3 +35,4 @@ extension UIViewController: UIViewControllerTransitioningDelegate {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,233 +0,0 @@
|
|||
//
|
||||
// ProfileDirectoryViewController.swift
|
||||
// Tusker
|
||||
//
|
||||
// Created by Shadowfacts on 2/6/21.
|
||||
// Copyright © 2021 Shadowfacts. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Pachyderm
|
||||
|
||||
class ProfileDirectoryViewController: UIViewController {
|
||||
|
||||
private let mastodonController: MastodonController
|
||||
|
||||
private var collectionView: UICollectionView!
|
||||
private var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
|
||||
|
||||
private var scope: Scope = .everywhere
|
||||
private var order: DirectoryOrder = .active
|
||||
|
||||
init(mastodonController: MastodonController) {
|
||||
self.mastodonController = mastodonController
|
||||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
title = NSLocalizedString("Profile Directory", comment: "profile directory title")
|
||||
|
||||
let filterItem = UIBarButtonItem(image: UIImage(systemName: "line.3.horizontal.decrease.circle"), menu: nil)
|
||||
filterItem.accessibilityLabel = "Filter"
|
||||
navigationItem.rightBarButtonItem = filterItem
|
||||
updateFilterMenu()
|
||||
|
||||
let layout = UICollectionViewCompositionalLayout(sectionProvider: { (sectionIndex, layoutEnvironment) in
|
||||
let itemHeight = NSCollectionLayoutDimension.absolute(200)
|
||||
let itemWidth: NSCollectionLayoutDimension
|
||||
if case .compact = layoutEnvironment.traitCollection.horizontalSizeClass {
|
||||
itemWidth = .fractionalWidth(1)
|
||||
} else {
|
||||
itemWidth = .absolute((layoutEnvironment.container.contentSize.width - 16 - 8 * 2) / 2)
|
||||
}
|
||||
|
||||
let itemSize = NSCollectionLayoutSize(widthDimension: itemWidth, heightDimension: itemHeight)
|
||||
let item = NSCollectionLayoutItem(layoutSize: itemSize)
|
||||
let itemB = NSCollectionLayoutItem(layoutSize: itemSize)
|
||||
|
||||
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: itemHeight)
|
||||
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item, itemB])
|
||||
group.interItemSpacing = .flexible(16)
|
||||
|
||||
let section = NSCollectionLayoutSection(group: group)
|
||||
section.interGroupSpacing = 16
|
||||
section.contentInsets = NSDirectionalEdgeInsets(top: 8, leading: 8, bottom: 8, trailing: 8)
|
||||
return section
|
||||
})
|
||||
|
||||
collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: layout)
|
||||
collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||
collectionView.backgroundColor = .appSecondaryBackground
|
||||
collectionView.register(UINib(nibName: "FeaturedProfileCollectionViewCell", bundle: .main), forCellWithReuseIdentifier: "featuredProfileCell")
|
||||
collectionView.delegate = self
|
||||
collectionView.dragDelegate = self
|
||||
collectionView.allowsFocus = true
|
||||
view.addSubview(collectionView)
|
||||
|
||||
dataSource = createDataSource()
|
||||
updateProfiles()
|
||||
}
|
||||
|
||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||
let dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { (collectionView, indexPath, item) in
|
||||
guard case let .account(account) = item else { fatalError() }
|
||||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "featuredProfileCell", for: indexPath) as! FeaturedProfileCollectionViewCell
|
||||
cell.updateUI(account: account)
|
||||
return cell
|
||||
}
|
||||
return dataSource
|
||||
}
|
||||
|
||||
private func updateFilterMenu() {
|
||||
let scopeMenu = UIMenu(options: .displayInline, children: [
|
||||
UIAction(title: "Everywhere", subtitle: "Users from the whole network", image: UIImage(systemName: "globe"), state: scope == .everywhere ? .on : .off, handler: { [unowned self] _ in
|
||||
self.scope = .everywhere
|
||||
self.updateFilterMenu()
|
||||
self.updateProfiles()
|
||||
}),
|
||||
UIAction(title: mastodonController.accountInfo!.instanceURL.host!, subtitle: "Only users from your instance", image: UIImage(systemName: "house"), state: scope == .instance ? .on : .off, handler: { [unowned self] _ in
|
||||
self.scope = .instance
|
||||
self.updateFilterMenu()
|
||||
self.updateProfiles()
|
||||
}),
|
||||
])
|
||||
let orderMenu = UIMenu(options: .displayInline, children: DirectoryOrder.allCases.map { order in
|
||||
UIAction(title: order.title, subtitle: order.subtitle, image: nil, state: self.order == order ? .on : .off) { [unowned self] _ in
|
||||
self.order = order
|
||||
self.updateFilterMenu()
|
||||
self.updateProfiles()
|
||||
}
|
||||
})
|
||||
navigationItem.rightBarButtonItem!.menu = UIMenu(children: [
|
||||
scopeMenu,
|
||||
orderMenu,
|
||||
])
|
||||
}
|
||||
|
||||
private func updateProfiles() {
|
||||
let scope = self.scope
|
||||
let order = self.order
|
||||
let local = scope == .instance
|
||||
let request = Client.getFeaturedProfiles(local: local, order: order)
|
||||
mastodonController.run(request) { (response) in
|
||||
guard case let .success(accounts, _) = response,
|
||||
self.scope == scope,
|
||||
self.order == order else {
|
||||
return
|
||||
}
|
||||
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections([.featuredProfiles])
|
||||
snapshot.appendItems(accounts.map { .account($0) })
|
||||
DispatchQueue.main.async {
|
||||
self.dataSource.apply(snapshot)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension ProfileDirectoryViewController {
|
||||
enum Section {
|
||||
case featuredProfiles
|
||||
}
|
||||
enum Item: Hashable {
|
||||
case account(Account)
|
||||
|
||||
func hash(into hasher: inout Hasher) {
|
||||
guard case let .account(account) = self else { return }
|
||||
hasher.combine(account.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension ProfileDirectoryViewController: TuskerNavigationDelegate {
|
||||
var apiController: MastodonController! { mastodonController }
|
||||
}
|
||||
|
||||
extension ProfileDirectoryViewController: ToastableViewController {
|
||||
}
|
||||
|
||||
extension ProfileDirectoryViewController: MenuActionProvider {
|
||||
}
|
||||
|
||||
extension ProfileDirectoryViewController: UICollectionViewDelegate {
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
guard let item = dataSource.itemIdentifier(for: indexPath),
|
||||
case let .account(account) = item else {
|
||||
return
|
||||
}
|
||||
show(ProfileViewController(accountID: account.id, mastodonController: mastodonController), sender: nil)
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
|
||||
guard let item = dataSource.itemIdentifier(for: indexPath),
|
||||
case let .account(account) = item else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return UIContextMenuConfiguration(identifier: nil) {
|
||||
return ProfileViewController(accountID: account.id, mastodonController: self.mastodonController)
|
||||
} actionProvider: { (_) in
|
||||
let actions = self.actionsForProfile(accountID: account.id, source: .view(self.collectionView.cellForItem(at: indexPath)))
|
||||
return UIMenu(children: actions)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) {
|
||||
if let viewController = animator.previewViewController {
|
||||
animator.preferredCommitStyle = .pop
|
||||
animator.addCompletion {
|
||||
self.show(viewController, sender: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension ProfileDirectoryViewController: UICollectionViewDragDelegate {
|
||||
func collectionView(_ collectionView: UICollectionView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
|
||||
guard let item = dataSource.itemIdentifier(for: indexPath),
|
||||
case let .account(account) = item,
|
||||
let currentAccountID = mastodonController.accountInfo?.id else {
|
||||
return []
|
||||
}
|
||||
let provider = NSItemProvider(object: account.url as NSURL)
|
||||
let activity = UserActivityManager.showProfileActivity(id: account.id, accountID: currentAccountID)
|
||||
activity.displaysAuxiliaryScene = true
|
||||
provider.registerObject(activity, visibility: .all)
|
||||
return [UIDragItem(itemProvider: provider)]
|
||||
}
|
||||
}
|
||||
|
||||
extension ProfileDirectoryViewController {
|
||||
enum Scope: CaseIterable {
|
||||
case instance, everywhere
|
||||
}
|
||||
}
|
||||
|
||||
private extension DirectoryOrder {
|
||||
var title: String {
|
||||
switch self {
|
||||
case .active:
|
||||
return "Active"
|
||||
case .new:
|
||||
return "New"
|
||||
}
|
||||
}
|
||||
var subtitle: String {
|
||||
switch self {
|
||||
case .active:
|
||||
return "Users who have posted lately"
|
||||
case .new:
|
||||
return "Recently joined users"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
// Copyright © 2023 Shadowfacts. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(visionOS)
|
||||
import UIKit
|
||||
import Pachyderm
|
||||
import SwiftUI
|
||||
|
@ -221,3 +222,4 @@ private struct SuggestionSourceView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
|
||||
import UIKit
|
||||
import Pachyderm
|
||||
#if os(visionOS)
|
||||
import SwiftUI
|
||||
#endif
|
||||
|
||||
class SuggestedProfilesViewController: UIViewController, CollectionViewController {
|
||||
|
||||
|
@ -53,10 +56,22 @@ class SuggestedProfilesViewController: UIViewController, CollectionViewControlle
|
|||
}
|
||||
|
||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||
#if os(visionOS)
|
||||
let accountCell = UICollectionView.CellRegistration<UICollectionViewCell, (String, Suggestion.Source)> { [unowned self] cell, indexPath, item in
|
||||
if let account = self.mastodonController.persistentContainer.account(for: item.0) {
|
||||
cell.contentConfiguration = UIHostingConfiguration(content: {
|
||||
SuggestedProfileCardView(account: account)
|
||||
})
|
||||
} else {
|
||||
cell.contentConfiguration = nil
|
||||
}
|
||||
}
|
||||
#else
|
||||
let accountCell = UICollectionView.CellRegistration<SuggestedProfileCardCollectionViewCell, (String, Suggestion.Source)>(cellNib: UINib(nibName: "SuggestedProfileCardCollectionViewCell", bundle: .main)) { cell, indexPath, item in
|
||||
cell.delegate = self
|
||||
cell.updateUI(accountID: item.0, source: item.1)
|
||||
}
|
||||
#endif
|
||||
let dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in
|
||||
switch itemIdentifier {
|
||||
case .account(let id, let source):
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
// Copyright © 2022 Shadowfacts. All rights reserved.
|
||||
//
|
||||
|
||||
#if !os(visionOS)
|
||||
import UIKit
|
||||
import Pachyderm
|
||||
import WebURLFoundationExtras
|
||||
|
@ -172,3 +173,4 @@ extension TrendingLinkCardCollectionViewCell {
|
|||
case regular, compact
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -11,6 +11,9 @@ import Pachyderm
|
|||
import WebURLFoundationExtras
|
||||
import SafariServices
|
||||
import Combine
|
||||
#if os(visionOS)
|
||||
import SwiftUI
|
||||
#endif
|
||||
|
||||
class TrendingLinksViewController: UIViewController, CollectionViewController {
|
||||
|
||||
|
@ -90,10 +93,18 @@ class TrendingLinksViewController: UIViewController, CollectionViewController {
|
|||
let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, itemIdentifier in
|
||||
cell.indicator.startAnimating()
|
||||
}
|
||||
#if os(visionOS)
|
||||
let linkCell = UICollectionView.CellRegistration<UICollectionViewCell, Card> { cell, indexPath, item in
|
||||
cell.contentConfiguration = UIHostingConfiguration(content: {
|
||||
TrendingLinkCardView(card: item)
|
||||
})
|
||||
}
|
||||
#else
|
||||
let linkCell = UICollectionView.CellRegistration<TrendingLinkCardCollectionViewCell, Card>(cellNib: UINib(nibName: "TrendingLinkCardCollectionViewCell", bundle: .main)) { cell, indexPath, item in
|
||||
cell.verticalSize = .compact
|
||||
cell.updateUI(card: item)
|
||||
}
|
||||
#endif
|
||||
let confirmLoadMoreCell = UICollectionView.CellRegistration<ConfirmLoadMoreCollectionViewCell, Bool> { cell, indexPath, isLoading in
|
||||
cell.confirmLoadMore = self.confirmLoadMore
|
||||
cell.isLoading = isLoading
|
||||
|
|
|
@ -57,12 +57,14 @@ struct BehaviorPrefsView: View {
|
|||
Toggle(isOn: $preferences.openLinksInApps) {
|
||||
Text("Open Links in Apps")
|
||||
}
|
||||
#if !os(visionOS)
|
||||
Toggle(isOn: $preferences.useInAppSafari) {
|
||||
Text("Use In-App Safari")
|
||||
}
|
||||
Toggle(isOn: $preferences.inAppSafariAutomaticReaderMode) {
|
||||
Text("Always Use Reader Mode in In-App Safari")
|
||||
}.disabled(!preferences.useInAppSafari)
|
||||
#endif
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
|
|
@ -470,6 +470,17 @@ class CustomAlertActionButton: UIControl {
|
|||
}
|
||||
}
|
||||
|
||||
#if os(visionOS)
|
||||
extension CustomAlertController: UIViewControllerTransitioningDelegate {
|
||||
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
|
||||
return CustomAlertPresentationAnimation()
|
||||
}
|
||||
|
||||
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
|
||||
return CustomAlertDismissAnimation()
|
||||
}
|
||||
}
|
||||
#else
|
||||
extension CustomAlertController {
|
||||
override func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
|
||||
return CustomAlertPresentationAnimation()
|
||||
|
@ -479,6 +490,7 @@ extension CustomAlertController {
|
|||
return CustomAlertDismissAnimation()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
class CustomAlertPresentationAnimation: NSObject, UIViewControllerAnimatedTransitioning {
|
||||
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
|
||||
|
|
|
@ -437,7 +437,11 @@ extension MenuActionProvider {
|
|||
|
||||
private func addOpenInNewWindow(actions: inout [UIAction], activity: @escaping @autoclosure () -> NSUserActivity) {
|
||||
let options = UIWindowScene.ActivationRequestOptions()
|
||||
#if os(visionOS)
|
||||
options.placement = .standard()
|
||||
#else
|
||||
options.preferredPresentationStyle = .automatic
|
||||
#endif
|
||||
actions.append(UIWindowScene.ActivationAction { (_) in
|
||||
let activity = activity()
|
||||
activity.displaysAuxiliaryScene = true
|
||||
|
|
|
@ -46,14 +46,15 @@ extension TuskerNavigationDelegate {
|
|||
|
||||
func selected(url: URL, allowResolveStatuses: Bool = true, allowUniversalLinks: Bool = true) {
|
||||
func openSafari() {
|
||||
#if os(visionOS)
|
||||
UIApplication.shared.open(url)
|
||||
#else
|
||||
if Preferences.shared.useInAppSafari,
|
||||
url.scheme == "https" || url.scheme == "http" {
|
||||
let config = SFSafariViewController.Configuration()
|
||||
config.entersReaderIfAvailable = Preferences.shared.inAppSafariAutomaticReaderMode
|
||||
let vc = SFSafariViewController(url: url, configuration: config)
|
||||
#if !os(visionOS)
|
||||
vc.preferredControlTintColor = Preferences.shared.accentColor.color
|
||||
#endif
|
||||
present(vc, animated: true)
|
||||
} else if UIApplication.shared.canOpenURL(url) {
|
||||
UIApplication.shared.open(url, options: [:])
|
||||
|
@ -66,6 +67,7 @@ extension TuskerNavigationDelegate {
|
|||
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
|
||||
present(alert, animated: true)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if allowResolveStatuses,
|
||||
|
@ -127,13 +129,17 @@ extension TuskerNavigationDelegate {
|
|||
func showLoadingLargeImage(url: URL, cache: ImageCache, description: String?, animatingFrom sourceView: UIImageView) {
|
||||
let vc = LoadingLargeImageViewController(url: url, cache: cache, imageDescription: description)
|
||||
vc.animationSourceView = sourceView
|
||||
#if !os(visionOS)
|
||||
vc.transitioningDelegate = self
|
||||
#endif
|
||||
present(vc, animated: true)
|
||||
}
|
||||
|
||||
func gallery(attachments: [Attachment], sourceViews: [UIImageView?], startIndex: Int) -> GalleryViewController {
|
||||
let vc = GalleryViewController(attachments: attachments, sourceViews: sourceViews, startIndex: startIndex)
|
||||
#if !os(visionOS)
|
||||
vc.transitioningDelegate = self
|
||||
#endif
|
||||
return vc
|
||||
}
|
||||
|
||||
|
|
|
@ -236,6 +236,20 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
|
|||
}
|
||||
|
||||
extension ContentTextView: UITextViewDelegate {
|
||||
#if os(visionOS)
|
||||
func textView(_ textView: UITextView, primaryActionFor textItem: UITextItem, defaultAction: UIAction) -> UIAction? {
|
||||
guard case .link(let url) = textItem.content else {
|
||||
return defaultAction
|
||||
}
|
||||
if url.scheme == dataDetectorsScheme {
|
||||
return defaultAction
|
||||
} else {
|
||||
return UIAction { _ in
|
||||
self.handleLinkTapped(url: url, text: (self.text as NSString).substring(with: textItem.range))
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
|
||||
// the builtin data detectors use the x-apple-data-detectors scheme, and we allow the text view to handle those itself
|
||||
if URL.scheme == dataDetectorsScheme {
|
||||
|
@ -249,6 +263,7 @@ extension ContentTextView: UITextViewDelegate {
|
|||
return false
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
extension ContentTextView: MenuActionProvider {
|
||||
|
|
Loading…
Reference in New Issue