mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2025-02-02 18:36:44 +01:00
Merge pull request #783 from mastodon/ios_15
Bump Deplyment Target to iOS 15
This commit is contained in:
commit
3e2282cb03
@ -307,8 +307,6 @@
|
||||
DB72602725E36A6F00235243 /* MastodonServerRulesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB72602625E36A6F00235243 /* MastodonServerRulesViewModel.swift */; };
|
||||
DB7274F4273BB9B200577D95 /* ListBatchFetchViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB7274F3273BB9B200577D95 /* ListBatchFetchViewModel.swift */; };
|
||||
DB73B490261F030A002E9E9F /* SafariActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB73B48F261F030A002E9E9F /* SafariActivity.swift */; };
|
||||
DB73BF4927140BA300781945 /* UICollectionViewDiffableDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB73BF4827140BA300781945 /* UICollectionViewDiffableDataSource.swift */; };
|
||||
DB73BF4B27140C0800781945 /* UITableViewDiffableDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB73BF4A27140C0800781945 /* UITableViewDiffableDataSource.swift */; };
|
||||
DB75BF1E263C1C1B00EDBF1F /* CustomScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB75BF1D263C1C1B00EDBF1F /* CustomScheduler.swift */; };
|
||||
DB789A0B25F9F2950071ACA0 /* ComposeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB789A0A25F9F2950071ACA0 /* ComposeViewController.swift */; };
|
||||
DB789A1225F9F2CC0071ACA0 /* ComposeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB789A1125F9F2CC0071ACA0 /* ComposeViewModel.swift */; };
|
||||
@ -881,8 +879,6 @@
|
||||
DB72602625E36A6F00235243 /* MastodonServerRulesViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MastodonServerRulesViewModel.swift; sourceTree = "<group>"; };
|
||||
DB7274F3273BB9B200577D95 /* ListBatchFetchViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListBatchFetchViewModel.swift; sourceTree = "<group>"; };
|
||||
DB73B48F261F030A002E9E9F /* SafariActivity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariActivity.swift; sourceTree = "<group>"; };
|
||||
DB73BF4827140BA300781945 /* UICollectionViewDiffableDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UICollectionViewDiffableDataSource.swift; sourceTree = "<group>"; };
|
||||
DB73BF4A27140C0800781945 /* UITableViewDiffableDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITableViewDiffableDataSource.swift; sourceTree = "<group>"; };
|
||||
DB75BF1D263C1C1B00EDBF1F /* CustomScheduler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomScheduler.swift; sourceTree = "<group>"; };
|
||||
DB789A0A25F9F2950071ACA0 /* ComposeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeViewController.swift; sourceTree = "<group>"; };
|
||||
DB789A1125F9F2CC0071ACA0 /* ComposeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeViewModel.swift; sourceTree = "<group>"; };
|
||||
@ -2285,8 +2281,6 @@
|
||||
DB9E0D6E25EE008500CFDD76 /* UIInterpolatingMotionEffect.swift */,
|
||||
2AE244472927831100BDBF7C /* UIImage+SFSymbols.swift */,
|
||||
DBCC3B2F261440A50045B23D /* UITabBarController.swift */,
|
||||
DB73BF4827140BA300781945 /* UICollectionViewDiffableDataSource.swift */,
|
||||
DB73BF4A27140C0800781945 /* UITableViewDiffableDataSource.swift */,
|
||||
2A1FE47D2938C11200784BF1 /* Collection+IsNotEmpty.swift */,
|
||||
);
|
||||
path = Extension;
|
||||
@ -3319,7 +3313,6 @@
|
||||
DB5B729E273113F300081888 /* FollowingListViewModel+State.swift in Sources */,
|
||||
DBF9814C265E339500E4BA07 /* ProfileFieldAddEntryCollectionViewCell.swift in Sources */,
|
||||
DB63F76227996B6600455B82 /* SearchHistoryViewController+DataSourceProvider.swift in Sources */,
|
||||
DB73BF4927140BA300781945 /* UICollectionViewDiffableDataSource.swift in Sources */,
|
||||
DBA5E7AB263BD3F5004598BB /* TimelineTableViewCellContextMenuConfiguration.swift in Sources */,
|
||||
DB73B490261F030A002E9E9F /* SafariActivity.swift in Sources */,
|
||||
2AE244482927831100BDBF7C /* UIImage+SFSymbols.swift in Sources */,
|
||||
@ -3409,7 +3402,6 @@
|
||||
DB1E346825F518E20079D7DF /* CategoryPickerSection.swift in Sources */,
|
||||
DB7274F4273BB9B200577D95 /* ListBatchFetchViewModel.swift in Sources */,
|
||||
DB0618052785A73D0030EE79 /* RegisterItem.swift in Sources */,
|
||||
DB73BF4B27140C0800781945 /* UITableViewDiffableDataSource.swift in Sources */,
|
||||
DBB525642612C988002F1F29 /* MeProfileViewModel.swift in Sources */,
|
||||
DB3EA8EF281B837000598866 /* DiscoveryCommunityViewController+DataSourceProvider.swift in Sources */,
|
||||
DB6B74EF272FB55000C70B6E /* FollowerListViewController.swift in Sources */,
|
||||
@ -3831,7 +3823,7 @@
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INTENTS_CODEGEN_LANGUAGE = Swift;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
@ -3889,7 +3881,7 @@
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INTENTS_CODEGEN_LANGUAGE = Swift;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
@ -4091,7 +4083,7 @@
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INTENTS_CODEGEN_LANGUAGE = Swift;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
@ -4373,7 +4365,7 @@
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INTENTS_CODEGEN_LANGUAGE = Swift;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
|
@ -228,11 +228,7 @@ extension StatusSection {
|
||||
}
|
||||
var _snapshot = NSDiffableDataSourceSnapshot<PollSection, PollItem>()
|
||||
_snapshot.appendSections([.main])
|
||||
if #available(iOS 15.0, *) {
|
||||
statusView.pollTableViewDiffableDataSource?.applySnapshotUsingReloadData(_snapshot)
|
||||
} else {
|
||||
statusView.pollTableViewDiffableDataSource?.apply(_snapshot, animatingDifferences: false)
|
||||
}
|
||||
statusView.pollTableViewDiffableDataSource?.applySnapshotUsingReloadData(_snapshot)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,40 +0,0 @@
|
||||
//
|
||||
// UICollectionViewDiffableDataSource.swift
|
||||
// Mastodon
|
||||
//
|
||||
// Created by Cirno MainasuK on 2021-10-11.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
// ref: https://www.jessesquires.com/blog/2021/07/08/diffable-data-source-behavior-changes-and-reconfiguring-cells-in-ios-15/
|
||||
extension UICollectionViewDiffableDataSource {
|
||||
func reloadData(
|
||||
snapshot: NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
|
||||
completion: (() -> Void)? = nil
|
||||
) {
|
||||
if #available(iOS 15.0, *) {
|
||||
self.applySnapshotUsingReloadData(snapshot, completion: completion)
|
||||
} else {
|
||||
self.apply(snapshot, animatingDifferences: false, completion: completion)
|
||||
}
|
||||
}
|
||||
|
||||
func applySnapshot(
|
||||
_ snapshot: NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
|
||||
animated: Bool,
|
||||
completion: (() -> Void)? = nil) {
|
||||
|
||||
if #available(iOS 15.0, *) {
|
||||
self.apply(snapshot, animatingDifferences: animated, completion: completion)
|
||||
} else {
|
||||
if animated {
|
||||
self.apply(snapshot, animatingDifferences: true, completion: completion)
|
||||
} else {
|
||||
UIView.performWithoutAnimation {
|
||||
self.apply(snapshot, animatingDifferences: true, completion: completion)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
//
|
||||
// UITableViewDiffableDataSource.swift
|
||||
// Mastodon
|
||||
//
|
||||
// Created by Cirno MainasuK on 2021-10-11.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
// ref: https://www.jessesquires.com/blog/2021/07/08/diffable-data-source-behavior-changes-and-reconfiguring-cells-in-ios-15/
|
||||
extension UITableViewDiffableDataSource {
|
||||
func reloadData(
|
||||
snapshot: NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
|
||||
completion: (() -> Void)? = nil
|
||||
) {
|
||||
if #available(iOS 15.0, *) {
|
||||
self.applySnapshotUsingReloadData(snapshot, completion: completion)
|
||||
} else {
|
||||
self.apply(snapshot, animatingDifferences: false, completion: completion)
|
||||
}
|
||||
}
|
||||
|
||||
func applySnapshot(
|
||||
_ snapshot: NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
|
||||
animated: Bool,
|
||||
completion: (() -> Void)? = nil) {
|
||||
|
||||
if #available(iOS 15.0, *) {
|
||||
self.apply(snapshot, animatingDifferences: animated, completion: completion)
|
||||
} else {
|
||||
if animated {
|
||||
self.apply(snapshot, animatingDifferences: true, completion: completion)
|
||||
} else {
|
||||
UIView.performWithoutAnimation {
|
||||
self.apply(snapshot, animatingDifferences: true, completion: completion)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -59,7 +59,7 @@ extension DiscoveryCommunityViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
diffableDataSource.applySnapshot(snapshot, animated: false)
|
||||
diffableDataSource.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ extension DiscoveryForYouViewModel {
|
||||
let items = records.map { DiscoveryItem.user($0) }
|
||||
snapshot.appendItems(items, toSection: .forYou)
|
||||
|
||||
diffableDataSource.applySnapshot(snapshot, animated: false)
|
||||
diffableDataSource.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ extension DiscoveryNewsViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
diffableDataSource.applySnapshot(snapshot, animated: false)
|
||||
diffableDataSource.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ extension DiscoveryPostsViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
diffableDataSource.applySnapshot(snapshot, animated: false)
|
||||
diffableDataSource.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
|
@ -131,17 +131,13 @@ extension HomeTimelineViewModel {
|
||||
snapshot: NSDiffableDataSourceSnapshot<StatusSection, StatusItem>,
|
||||
animatingDifferences: Bool
|
||||
) async {
|
||||
diffableDataSource?.apply(snapshot, animatingDifferences: animatingDifferences)
|
||||
await diffableDataSource?.apply(snapshot, animatingDifferences: animatingDifferences)
|
||||
}
|
||||
|
||||
@MainActor func updateSnapshotUsingReloadData(
|
||||
snapshot: NSDiffableDataSourceSnapshot<StatusSection, StatusItem>
|
||||
) {
|
||||
if #available(iOS 15.0, *) {
|
||||
self.diffableDataSource?.applySnapshotUsingReloadData(snapshot)
|
||||
} else {
|
||||
diffableDataSource?.applySnapshot(snapshot, animated: false, completion: nil)
|
||||
}
|
||||
self.diffableDataSource?.applySnapshotUsingReloadData(snapshot)
|
||||
}
|
||||
|
||||
struct Difference<T> {
|
||||
|
@ -148,12 +148,7 @@ extension HomeTimelineViewModel {
|
||||
}
|
||||
|
||||
// reconfigure item
|
||||
if #available(iOS 15.0, *) {
|
||||
snapshot.reconfigureItems([item])
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
snapshot.reloadItems([item])
|
||||
}
|
||||
snapshot.reconfigureItems([item])
|
||||
await updateSnapshotUsingReloadData(snapshot: snapshot)
|
||||
|
||||
// fetch data
|
||||
@ -176,15 +171,10 @@ extension HomeTimelineViewModel {
|
||||
}
|
||||
|
||||
// reconfigure item again
|
||||
if #available(iOS 15.0, *) {
|
||||
snapshot.reconfigureItems([item])
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
snapshot.reloadItems([item])
|
||||
}
|
||||
snapshot.reconfigureItems([item])
|
||||
await updateSnapshotUsingReloadData(snapshot: snapshot)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// MARK: - SuggestionAccountViewModelDelegate
|
||||
|
@ -111,17 +111,13 @@ extension NotificationTimelineViewModel {
|
||||
snapshot: NSDiffableDataSourceSnapshot<NotificationSection, NotificationItem>,
|
||||
animatingDifferences: Bool
|
||||
) async {
|
||||
diffableDataSource?.apply(snapshot, animatingDifferences: animatingDifferences)
|
||||
await diffableDataSource?.apply(snapshot, animatingDifferences: animatingDifferences)
|
||||
}
|
||||
|
||||
@MainActor func updateSnapshotUsingReloadData(
|
||||
snapshot: NSDiffableDataSourceSnapshot<NotificationSection, NotificationItem>
|
||||
) async {
|
||||
if #available(iOS 15.0, *) {
|
||||
await self.diffableDataSource?.applySnapshotUsingReloadData(snapshot)
|
||||
} else {
|
||||
diffableDataSource?.applySnapshot(snapshot, animated: false, completion: nil)
|
||||
}
|
||||
await self.diffableDataSource?.applySnapshotUsingReloadData(snapshot)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ extension MastodonLoginViewController: MastodonLoginViewModelDelegate {
|
||||
snapshot.appendSections([MastodonLoginViewSection.servers])
|
||||
snapshot.appendItems(viewModel.filteredServers)
|
||||
|
||||
dataSource?.applySnapshot(snapshot, animated: false)
|
||||
dataSource?.apply(snapshot, animatingDifferences: false)
|
||||
|
||||
OperationQueue.main.addOperation {
|
||||
let numberOfResults = viewModel.filteredServers.count
|
||||
|
@ -43,11 +43,7 @@ final class MastodonPickServerViewController: UIViewController, NeedsDependency
|
||||
tableView.separatorStyle = .none
|
||||
tableView.backgroundColor = .clear
|
||||
tableView.keyboardDismissMode = .onDrag
|
||||
if #available(iOS 15.0, *) {
|
||||
tableView.sectionHeaderTopPadding = .leastNonzeroMagnitude
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
}
|
||||
tableView.sectionHeaderTopPadding = .leastNonzeroMagnitude
|
||||
return tableView
|
||||
}()
|
||||
|
||||
|
@ -24,7 +24,7 @@ extension MastodonPickServerViewModel {
|
||||
sectionHeaderSnapshot.appendSections([.main])
|
||||
sectionHeaderSnapshot.appendItems(categoryPickerItems, toSection: .main)
|
||||
serverSectionHeaderView.delegate = pickServerServerSectionTableHeaderViewDelegate
|
||||
serverSectionHeaderView.diffableDataSource?.applySnapshot(sectionHeaderSnapshot, animated: false) { [weak self] in
|
||||
serverSectionHeaderView.diffableDataSource?.apply(sectionHeaderSnapshot, animatingDifferences: false) { [weak self] in
|
||||
guard let self = self else { return }
|
||||
guard let indexPath = self.serverSectionHeaderView.diffableDataSource?.indexPath(for: .all) else { return }
|
||||
self.serverSectionHeaderView.collectionView.selectItem(at: indexPath, animated: false, scrollPosition: .centeredHorizontally)
|
||||
|
@ -55,19 +55,10 @@ struct MastodonRegisterView: View {
|
||||
// Delete
|
||||
if viewModel.avatarImage != nil {
|
||||
Divider()
|
||||
if #available(iOS 15.0, *) {
|
||||
Button(role: .destructive) {
|
||||
viewModel.avatarMediaMenuActionPublisher.send(.delete)
|
||||
} label: {
|
||||
Label(L10n.Scene.Register.Input.Avatar.delete, systemImage: "delete.left")
|
||||
}
|
||||
} else {
|
||||
// Fallback on earlier ve rsions
|
||||
Button {
|
||||
viewModel.avatarMediaMenuActionPublisher.send(.delete)
|
||||
} label: {
|
||||
Label(L10n.Scene.Register.Input.Avatar.delete, systemImage: "delete.left")
|
||||
}
|
||||
Button(role: .destructive) {
|
||||
viewModel.avatarMediaMenuActionPublisher.send(.delete)
|
||||
} label: {
|
||||
Label(L10n.Scene.Register.Input.Avatar.delete, systemImage: "delete.left")
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
|
@ -37,11 +37,7 @@ final class MastodonServerRulesViewController: UIViewController, NeedsDependency
|
||||
tableView.separatorStyle = .none
|
||||
tableView.backgroundColor = .clear
|
||||
tableView.keyboardDismissMode = .onDrag
|
||||
if #available(iOS 15.0, *) {
|
||||
tableView.sectionHeaderTopPadding = 0
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
}
|
||||
tableView.sectionHeaderTopPadding = 0
|
||||
return tableView
|
||||
}()
|
||||
|
||||
|
@ -21,6 +21,6 @@ extension MastodonServerRulesViewModel {
|
||||
return ServerRuleItem.rule(ruleContext)
|
||||
}
|
||||
snapshot.appendItems(ruleItems, toSection: .rules)
|
||||
diffableDataSource?.applySnapshot(snapshot, animated: false, completion: nil)
|
||||
diffableDataSource?.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
}
|
||||
|
@ -66,11 +66,7 @@ extension OnboardingViewControllerAppearance {
|
||||
navigationItem.standardAppearance = barAppearance
|
||||
navigationItem.compactAppearance = barAppearance
|
||||
navigationItem.scrollEdgeAppearance = barAppearance
|
||||
if #available(iOS 15.0, *) {
|
||||
navigationItem.compactScrollEdgeAppearance = barAppearance
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
}
|
||||
navigationItem.compactScrollEdgeAppearance = barAppearance
|
||||
}
|
||||
|
||||
func setupNavigationBarBackgroundView() {
|
||||
|
@ -336,11 +336,7 @@ extension WelcomeViewController: OnboardingViewControllerAppearance {
|
||||
navigationItem.standardAppearance = barAppearance
|
||||
navigationItem.compactAppearance = barAppearance
|
||||
navigationItem.scrollEdgeAppearance = barAppearance
|
||||
if #available(iOS 15.0, *) {
|
||||
navigationItem.compactScrollEdgeAppearance = barAppearance
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
}
|
||||
navigationItem.compactScrollEdgeAppearance = barAppearance
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ extension BookmarkViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
diffableDataSource.applySnapshot(snapshot, animated: false)
|
||||
diffableDataSource.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ extension FavoriteViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
diffableDataSource.applySnapshot(snapshot, animated: false)
|
||||
diffableDataSource.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ final class FollowedTagsViewModel: NSObject {
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections([.main])
|
||||
snapshot.appendItems(records.map {.hashtag($0) })
|
||||
self.diffableDataSource?.applySnapshot(snapshot, animated: true)
|
||||
self.diffableDataSource?.apply(snapshot, animatingDifferences: true)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
|
@ -27,12 +27,7 @@ extension FollowerListViewModel {
|
||||
var snapshot = NSDiffableDataSourceSnapshot<UserSection, UserItem>()
|
||||
snapshot.appendSections([.main])
|
||||
snapshot.appendItems([.bottomLoader], toSection: .main)
|
||||
if #available(iOS 15.0, *) {
|
||||
diffableDataSource?.applySnapshotUsingReloadData(snapshot, completion: nil)
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
diffableDataSource?.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
diffableDataSource?.applySnapshotUsingReloadData(snapshot, completion: nil)
|
||||
|
||||
userFetchedResultsController.$records
|
||||
.receive(on: DispatchQueue.main)
|
||||
|
@ -28,13 +28,8 @@ extension FollowingListViewModel {
|
||||
var snapshot = NSDiffableDataSourceSnapshot<UserSection, UserItem>()
|
||||
snapshot.appendSections([.main])
|
||||
snapshot.appendItems([.bottomLoader], toSection: .main)
|
||||
if #available(iOS 15.0, *) {
|
||||
diffableDataSource?.applySnapshotUsingReloadData(snapshot, completion: nil)
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
diffableDataSource?.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
|
||||
diffableDataSource?.applySnapshotUsingReloadData(snapshot)
|
||||
|
||||
userFetchedResultsController.$records
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] records in
|
||||
|
@ -83,7 +83,7 @@ extension UserTimelineViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
diffableDataSource.applySnapshot(snapshot, animated: false)
|
||||
diffableDataSource.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
|
@ -28,13 +28,8 @@ extension UserListViewModel {
|
||||
var snapshot = NSDiffableDataSourceSnapshot<UserSection, UserItem>()
|
||||
snapshot.appendSections([.main])
|
||||
snapshot.appendItems([.bottomLoader], toSection: .main)
|
||||
if #available(iOS 15.0, *) {
|
||||
diffableDataSource?.applySnapshotUsingReloadData(snapshot, completion: nil)
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
diffableDataSource?.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
|
||||
diffableDataSource?.applySnapshotUsingReloadData(snapshot)
|
||||
|
||||
// trigger initial loading
|
||||
stateMachine.enter(UserListViewModel.State.Reloading.self)
|
||||
|
||||
|
@ -47,11 +47,7 @@ class ReportStatusViewController: UIViewController, NeedsDependency, ReportViewC
|
||||
tableView.backgroundColor = .clear
|
||||
tableView.keyboardDismissMode = .onDrag
|
||||
tableView.allowsMultipleSelection = true
|
||||
if #available(iOS 15.0, *) {
|
||||
tableView.sectionHeaderTopPadding = .leastNonzeroMagnitude
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
}
|
||||
tableView.sectionHeaderTopPadding = .leastNonzeroMagnitude
|
||||
return tableView
|
||||
}()
|
||||
|
||||
|
@ -65,7 +65,7 @@ extension ReportStatusViewModel {
|
||||
break
|
||||
}
|
||||
|
||||
diffableDataSource.applySnapshot(snapshot, animated: false) { [weak self] in
|
||||
diffableDataSource.apply(snapshot, animatingDifferences: false) { [weak self] in
|
||||
guard let self = self else { return }
|
||||
guard let diffableDataSource = self.diffableDataSource else { return }
|
||||
|
||||
|
@ -52,11 +52,7 @@ final class ReportSupplementaryViewController: UIViewController, NeedsDependency
|
||||
tableView.separatorStyle = .none
|
||||
tableView.backgroundColor = .clear
|
||||
tableView.keyboardDismissMode = .onDrag
|
||||
if #available(iOS 15.0, *) {
|
||||
tableView.sectionHeaderTopPadding = .leastNonzeroMagnitude
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
}
|
||||
tableView.sectionHeaderTopPadding = .leastNonzeroMagnitude
|
||||
return tableView
|
||||
}()
|
||||
|
||||
|
@ -42,11 +42,7 @@ extension ReportViewControllerAppearance {
|
||||
navigationItem.standardAppearance = barAppearance
|
||||
navigationItem.compactAppearance = barAppearance
|
||||
navigationItem.scrollEdgeAppearance = barAppearance
|
||||
if #available(iOS 15.0, *) {
|
||||
navigationItem.compactScrollEdgeAppearance = barAppearance
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
}
|
||||
navigationItem.compactScrollEdgeAppearance = barAppearance
|
||||
}
|
||||
|
||||
func setupNavigationBarBackgroundView() {
|
||||
|
@ -135,10 +135,7 @@ extension SearchViewController {
|
||||
navigationItem.standardAppearance = navigationBarAppearance
|
||||
navigationItem.scrollEdgeAppearance = navigationBarAppearance
|
||||
navigationItem.compactAppearance = navigationBarAppearance
|
||||
|
||||
if #available(iOS 15, *) {
|
||||
navigationItem.compactScrollEdgeAppearance = navigationBarAppearance
|
||||
}
|
||||
navigationItem.compactScrollEdgeAppearance = navigationBarAppearance
|
||||
}
|
||||
|
||||
private func setupSearchBar() {
|
||||
|
@ -54,7 +54,7 @@ extension SearchHistoryViewModel {
|
||||
var snapshot = NSDiffableDataSourceSnapshot<SearchHistorySection, SearchHistoryItem>()
|
||||
snapshot.appendSections([.main])
|
||||
snapshot.appendItems(items, toSection: .main)
|
||||
diffableDataSource.apply(snapshot, animatingDifferences: false)
|
||||
await diffableDataSource.apply(snapshot, animatingDifferences: false)
|
||||
} catch {
|
||||
// do nothing
|
||||
}
|
||||
|
@ -34,12 +34,7 @@ extension SuggestionAccountViewModel {
|
||||
let items: [RecommendAccountItem] = records.map { RecommendAccountItem.account($0) }
|
||||
snapshot.appendItems(items, toSection: .main)
|
||||
|
||||
if #available(iOS 15.0, *) {
|
||||
tableViewDiffableDataSource.applySnapshotUsingReloadData(snapshot, completion: nil)
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
tableViewDiffableDataSource.applySnapshot(snapshot, animated: false, completion: nil)
|
||||
}
|
||||
tableViewDiffableDataSource.applySnapshotUsingReloadData(snapshot, completion: nil)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
@ -71,13 +66,7 @@ extension SuggestionAccountViewModel {
|
||||
}
|
||||
|
||||
snapshot.appendItems(items, toSection: .main)
|
||||
|
||||
if #available(iOS 15.0, *) {
|
||||
collectionViewDiffableDataSource.applySnapshotUsingReloadData(snapshot, completion: nil)
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
collectionViewDiffableDataSource.applySnapshot(snapshot, animated: false, completion: nil)
|
||||
}
|
||||
collectionViewDiffableDataSource.applySnapshotUsingReloadData(snapshot, completion: nil)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
|
@ -154,17 +154,13 @@ extension ThreadViewModel {
|
||||
snapshot: NSDiffableDataSourceSnapshot<StatusSection, StatusItem>,
|
||||
animatingDifferences: Bool
|
||||
) async {
|
||||
diffableDataSource?.apply(snapshot, animatingDifferences: animatingDifferences)
|
||||
await diffableDataSource?.apply(snapshot, animatingDifferences: animatingDifferences)
|
||||
}
|
||||
|
||||
@MainActor func updateSnapshotUsingReloadData(
|
||||
snapshot: NSDiffableDataSourceSnapshot<StatusSection, StatusItem>
|
||||
) async {
|
||||
if #available(iOS 15.0, *) {
|
||||
await self.diffableDataSource?.applySnapshotUsingReloadData(snapshot)
|
||||
} else {
|
||||
diffableDataSource?.applySnapshot(snapshot, animated: false, completion: nil)
|
||||
}
|
||||
await self.diffableDataSource?.applySnapshotUsingReloadData(snapshot)
|
||||
}
|
||||
|
||||
// Some UI tweaks to present replies and conversation smoothly
|
||||
|
@ -7,7 +7,7 @@ let package = Package(
|
||||
name: "MastodonSDK",
|
||||
defaultLocalization: "en",
|
||||
platforms: [
|
||||
.iOS(.v14),
|
||||
.iOS(.v15),
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
|
@ -50,43 +50,16 @@ extension NSManagedObjectContext {
|
||||
|
||||
extension NSManagedObjectContext {
|
||||
public func perform<T>(block: @escaping () throws -> T) async throws -> T {
|
||||
if #available(iOS 15.0, *) {
|
||||
return try await perform(schedule: .enqueued) {
|
||||
try block()
|
||||
}
|
||||
} else {
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
self.perform {
|
||||
do {
|
||||
let value = try block()
|
||||
continuation.resume(returning: value)
|
||||
} catch {
|
||||
continuation.resume(throwing: error)
|
||||
}
|
||||
}
|
||||
} // end return
|
||||
return try await perform(schedule: .enqueued) {
|
||||
try block()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public func performChanges<T>(block: @escaping () throws -> T) async throws -> T {
|
||||
if #available(iOS 15.0, *) {
|
||||
return try await perform(schedule: .enqueued) {
|
||||
let value = try block()
|
||||
try self.saveOrRollback()
|
||||
return value
|
||||
}
|
||||
} else {
|
||||
return try await withCheckedThrowingContinuation { continuation in
|
||||
self.perform {
|
||||
do {
|
||||
let value = try block()
|
||||
try self.saveOrRollback()
|
||||
continuation.resume(returning: value)
|
||||
} catch {
|
||||
continuation.resume(throwing: error)
|
||||
}
|
||||
}
|
||||
} // end return
|
||||
return try await perform(schedule: .enqueued) {
|
||||
let value = try block()
|
||||
try self.saveOrRollback()
|
||||
return value
|
||||
}
|
||||
} // end func
|
||||
}
|
||||
|
@ -52,9 +52,7 @@ extension ThemeService {
|
||||
UINavigationBar.appearance().standardAppearance = appearance
|
||||
UINavigationBar.appearance().compactAppearance = appearance
|
||||
UINavigationBar.appearance().scrollEdgeAppearance = appearance
|
||||
if #available(iOS 15.0, *) {
|
||||
UINavigationBar.appearance().compactScrollEdgeAppearance = appearance
|
||||
}
|
||||
UINavigationBar.appearance().compactScrollEdgeAppearance = appearance
|
||||
|
||||
// set tab bar appearance
|
||||
let tabBarAppearance = UITabBarAppearance()
|
||||
@ -76,11 +74,7 @@ extension ThemeService {
|
||||
tabBarAppearance.backgroundColor = theme.tabBarBackgroundColor
|
||||
tabBarAppearance.selectionIndicatorTintColor = ThemeService.tintColor
|
||||
UITabBar.appearance().standardAppearance = tabBarAppearance
|
||||
if #available(iOS 15.0, *) {
|
||||
UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
}
|
||||
UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
|
||||
UITabBar.appearance().barTintColor = theme.tabBarBackgroundColor
|
||||
|
||||
// set table view cell appearance
|
||||
|
@ -48,13 +48,13 @@ extension ItemProviderLoader {
|
||||
let maxPixelSize: Int = 1536 // fit 120MB RAM limit
|
||||
#endif
|
||||
|
||||
let downsampleOptions = [
|
||||
let downsampleOptions: [CFString: Any] = [
|
||||
kCGImageSourceCreateThumbnailFromImageAlways: true,
|
||||
kCGImageSourceCreateThumbnailWithTransform: true,
|
||||
kCGImageSourceThumbnailMaxPixelSize: maxPixelSize,
|
||||
] as CFDictionary
|
||||
]
|
||||
|
||||
guard let cgImage = CGImageSourceCreateThumbnailAtIndex(source, 0, downsampleOptions) else {
|
||||
guard let cgImage = CGImageSourceCreateThumbnailAtIndex(source, 0, downsampleOptions as CFDictionary) else {
|
||||
// fallback to loadItem when create thumbnail failure
|
||||
itemProvider.loadItem(forTypeIdentifier: UTType.image.identifier, options: nil) { image, error in
|
||||
if let error = error {
|
||||
@ -77,7 +77,7 @@ extension ItemProviderLoader {
|
||||
}
|
||||
|
||||
let data = NSMutableData()
|
||||
guard let imageDestination = CGImageDestinationCreateWithData(data, kUTTypeJPEG, 1, nil) else {
|
||||
guard let imageDestination = CGImageDestinationCreateWithData(data, UTType.jpeg.identifier as CFString, 1, nil) else {
|
||||
promise(.success(nil))
|
||||
return
|
||||
}
|
||||
|
@ -48,14 +48,10 @@ extension Date {
|
||||
if earlierDate.timeIntervalSince(latestDate) < -(7 * 24 * 60 * 60) {
|
||||
let currentYear = Date.calendar.dateComponents([.year], from: Date())
|
||||
let earlierDateYear = Date.calendar.dateComponents([.year], from: earlierDate)
|
||||
if #available(iOS 15.0, *) {
|
||||
if currentYear.year! > earlierDateYear.year! {
|
||||
return earlierDate.formatted(.dateTime.year().month(.abbreviated).day())
|
||||
} else {
|
||||
return earlierDate.formatted(.dateTime.month(.abbreviated).day())
|
||||
}
|
||||
if currentYear.year! > earlierDateYear.year! {
|
||||
return earlierDate.formatted(.dateTime.year().month(.abbreviated).day())
|
||||
} else {
|
||||
return Date.abbreviatedDateFormatter.string(from: earlierDate)
|
||||
return earlierDate.formatted(.dateTime.month(.abbreviated).day())
|
||||
}
|
||||
} else {
|
||||
return Date.relativeTimestampFormatter.localizedString(for: earlierDate, relativeTo: latestDate)
|
||||
|
@ -15,19 +15,17 @@ extension MetaTextView {
|
||||
|
||||
// fix #660
|
||||
// https://github.com/mastodon/mastodon-ios/issues/660
|
||||
if #available(iOS 15.0, *) {
|
||||
var nextResponder = self.next;
|
||||
|
||||
// Force the event to bubble through ALL responders
|
||||
// This is a workaround as somewhere down the chain the paste event gets eaten
|
||||
while (nextResponder != nil) {
|
||||
if let nextResponder = nextResponder {
|
||||
if (nextResponder.responds(to: #selector(UIResponderStandardEditActions.paste(_:)))) {
|
||||
nextResponder.perform(#selector(UIResponderStandardEditActions.paste(_:)), with: sender)
|
||||
}
|
||||
var nextResponder = self.next;
|
||||
|
||||
// Force the event to bubble through ALL responders
|
||||
// This is a workaround as somewhere down the chain the paste event gets eaten
|
||||
while (nextResponder != nil) {
|
||||
if let nextResponder = nextResponder {
|
||||
if (nextResponder.responds(to: #selector(UIResponderStandardEditActions.paste(_:)))) {
|
||||
nextResponder.perform(#selector(UIResponderStandardEditActions.paste(_:)), with: sender)
|
||||
}
|
||||
nextResponder = nextResponder?.next;
|
||||
}
|
||||
} // end if
|
||||
nextResponder = nextResponder?.next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,21 +33,15 @@ public final class StatusCardControl: UIControl {
|
||||
private let titleLabel = UILabel()
|
||||
private let linkLabel = UILabel()
|
||||
private lazy var showEmbedButton: UIButton = {
|
||||
if #available(iOS 15.0, *) {
|
||||
var configuration = UIButton.Configuration.gray()
|
||||
configuration.background.visualEffect = UIBlurEffect(style: .systemUltraThinMaterial)
|
||||
configuration.baseBackgroundColor = .clear
|
||||
configuration.cornerStyle = .capsule
|
||||
configuration.buttonSize = .large
|
||||
configuration.title = L10n.Common.Controls.Status.loadEmbed
|
||||
configuration.image = UIImage(systemName: "play.fill")
|
||||
configuration.imagePadding = 12
|
||||
return UIButton(configuration: configuration, primaryAction: UIAction { [weak self] _ in
|
||||
self?.showWebView()
|
||||
})
|
||||
}
|
||||
|
||||
return UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
|
||||
var configuration = UIButton.Configuration.gray()
|
||||
configuration.background.visualEffect = UIBlurEffect(style: .systemUltraThinMaterial)
|
||||
configuration.baseBackgroundColor = .clear
|
||||
configuration.cornerStyle = .capsule
|
||||
configuration.buttonSize = .large
|
||||
configuration.title = L10n.Common.Controls.Status.loadEmbed
|
||||
configuration.image = UIImage(systemName: "play.fill")
|
||||
configuration.imagePadding = 12
|
||||
return UIButton(configuration: configuration, primaryAction: UIAction { [weak self] _ in
|
||||
self?.showWebView()
|
||||
})
|
||||
}()
|
||||
@ -85,10 +79,7 @@ public final class StatusCardControl: UIControl {
|
||||
layer.cornerCurve = .continuous
|
||||
layer.cornerRadius = 10
|
||||
|
||||
if #available(iOS 15, *) {
|
||||
maximumContentSizeCategory = .accessibilityLarge
|
||||
}
|
||||
|
||||
maximumContentSizeCategory = .accessibilityLarge
|
||||
highlightView.backgroundColor = UIColor.label.withAlphaComponent(0.1)
|
||||
highlightView.isHidden = true
|
||||
|
||||
|
@ -421,12 +421,7 @@ extension StatusView.ViewModel {
|
||||
var snapshot = NSDiffableDataSourceSnapshot<PollSection, PollItem>()
|
||||
snapshot.appendSections([.main])
|
||||
snapshot.appendItems(items, toSection: .main)
|
||||
if #available(iOS 15.0, *) {
|
||||
statusView.pollTableViewDiffableDataSource?.applySnapshotUsingReloadData(snapshot)
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
statusView.pollTableViewDiffableDataSource?.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
statusView.pollTableViewDiffableDataSource?.applySnapshotUsingReloadData(snapshot)
|
||||
|
||||
statusView.pollTableViewHeightLayoutConstraint.constant = CGFloat(items.count) * PollOptionTableViewCell.height
|
||||
statusView.setPollDisplay()
|
||||
|
@ -260,12 +260,7 @@ public final class StatusView: UIView {
|
||||
authorView.avatarButton.avatarImageView.cancelTask()
|
||||
if var snapshot = pollTableViewDiffableDataSource?.snapshot() {
|
||||
snapshot.deleteAllItems()
|
||||
if #available(iOS 15.0, *) {
|
||||
pollTableViewDiffableDataSource?.applySnapshotUsingReloadData(snapshot)
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
pollTableViewDiffableDataSource?.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
pollTableViewDiffableDataSource?.applySnapshotUsingReloadData(snapshot)
|
||||
}
|
||||
|
||||
setHeaderDisplay(isDisplay: false)
|
||||
|
@ -46,7 +46,6 @@ extension MastodonTests {
|
||||
wait(for: [expectation], timeout: 10)
|
||||
}
|
||||
|
||||
@available(iOS 15.0, *)
|
||||
func testConnectOnion() async throws {
|
||||
let request = URLRequest(
|
||||
url: URL(string: "http://a232ncr7jexk2chvubaq2v6qdizbocllqap7mnn7w7vrdutyvu32jeyd.onion/@k0gen")!,
|
||||
|
Loading…
x
Reference in New Issue
Block a user