Merge branch 'release-1.4.3' into feature-purple-tint

# Conflicts:
#	Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist
This commit is contained in:
CMK 2022-06-02 19:47:30 +08:00
commit 368ab71e7a
4 changed files with 140 additions and 51 deletions

View File

@ -378,6 +378,7 @@
DB697DDD278F521D004EF2F7 /* DataSourceFacade.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB697DDC278F521D004EF2F7 /* DataSourceFacade.swift */; };
DB697DDF278F524F004EF2F7 /* DataSourceFacade+Profile.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB697DDE278F524F004EF2F7 /* DataSourceFacade+Profile.swift */; };
DB697DE1278F5296004EF2F7 /* DataSourceFacade+Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB697DE0278F5296004EF2F7 /* DataSourceFacade+Model.swift */; };
DB6988DE2848D11C002398EF /* PagerTabStripNavigateable.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB6988DD2848D11C002398EF /* PagerTabStripNavigateable.swift */; };
DB6B35182601FA3400DC1E11 /* MastodonAttachmentService.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB6B35172601FA3400DC1E11 /* MastodonAttachmentService.swift */; };
DB6B351E2601FAEE00DC1E11 /* ComposeStatusAttachmentCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB6B351D2601FAEE00DC1E11 /* ComposeStatusAttachmentCollectionViewCell.swift */; };
DB6B74EF272FB55000C70B6E /* FollowerListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB6B74EE272FB55000C70B6E /* FollowerListViewController.swift */; };
@ -1139,6 +1140,7 @@
DB697DDC278F521D004EF2F7 /* DataSourceFacade.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataSourceFacade.swift; sourceTree = "<group>"; };
DB697DDE278F524F004EF2F7 /* DataSourceFacade+Profile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataSourceFacade+Profile.swift"; sourceTree = "<group>"; };
DB697DE0278F5296004EF2F7 /* DataSourceFacade+Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataSourceFacade+Model.swift"; sourceTree = "<group>"; };
DB6988DD2848D11C002398EF /* PagerTabStripNavigateable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PagerTabStripNavigateable.swift; sourceTree = "<group>"; };
DB6B35172601FA3400DC1E11 /* MastodonAttachmentService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MastodonAttachmentService.swift; sourceTree = "<group>"; };
DB6B351D2601FAEE00DC1E11 /* ComposeStatusAttachmentCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeStatusAttachmentCollectionViewCell.swift; sourceTree = "<group>"; };
DB6B74EE272FB55000C70B6E /* FollowerListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowerListViewController.swift; sourceTree = "<group>"; };
@ -1750,6 +1752,7 @@
DBCA0EBB282BB38A0029E2B0 /* PageboyNavigateable.swift */,
DB1D843326579931000346B3 /* TableViewControllerNavigateable.swift */,
DB1D842D26552C4D000346B3 /* StatusTableViewControllerNavigateable.swift */,
DB6988DD2848D11C002398EF /* PagerTabStripNavigateable.swift */,
);
path = Protocol;
sourceTree = "<group>";
@ -4250,6 +4253,7 @@
DB63F752279944AA00455B82 /* SearchHistorySectionHeaderCollectionReusableView.swift in Sources */,
DB3E6FDD2806A40F00B035AE /* DiscoveryHashtagsViewController.swift in Sources */,
DB938EED2623F79B00E5B6C1 /* ThreadViewModel.swift in Sources */,
DB6988DE2848D11C002398EF /* PagerTabStripNavigateable.swift in Sources */,
DBBC24AC26A53D9300398BB9 /* ComposeStatusContentTableViewCell.swift in Sources */,
DBC7A67C260DFADE00E57475 /* StatusPublishService.swift in Sources */,
2DCB73FD2615C13900EC03D4 /* SearchRecommendCollectionHeader.swift in Sources */,

View File

@ -0,0 +1,106 @@
//
// PagerTabStripNavigateable.swift
// Mastodon
//
// Created by MainasuK on 2022-6-2.
//
import UIKit
import XLPagerTabStrip
import MastodonLocalization
typealias PagerTabStripNavigateable = PagerTabStripNavigateableCore & PagerTabStripNavigateableRelay
protocol PagerTabStripNavigateableCore: AnyObject {
var navigateablePageViewController: PagerTabStripViewController { get }
var pagerTabStripNavigateKeyCommands: [UIKeyCommand] { get }
func pagerTabStripNavigateKeyCommandHandler(_ sender: UIKeyCommand)
func navigate(direction: PagerTabStripNavigationDirection)
}
@objc protocol PagerTabStripNavigateableRelay: AnyObject {
func pagerTabStripNavigateKeyCommandHandlerRelay(_ sender: UIKeyCommand)
}
enum PagerTabStripNavigationDirection: String, CaseIterable {
case previous
case next
var title: String {
switch self {
case .previous: return L10n.Common.Controls.Keyboard.SegmentedControl.previousSection
case .next: return L10n.Common.Controls.Keyboard.SegmentedControl.nextSection
}
}
// UIKeyCommand input
var input: String {
switch self {
case .previous: return "["
case .next: return "]"
}
}
var modifierFlags: UIKeyModifierFlags {
switch self {
case .previous: return [.shift, .command]
case .next: return [.shift, .command]
}
}
var propertyList: Any {
return rawValue
}
}
extension PagerTabStripNavigateableCore where Self: PagerTabStripNavigateableRelay {
var pagerTabStripNavigateKeyCommands: [UIKeyCommand] {
PagerTabStripNavigationDirection.allCases.map { direction in
UIKeyCommand(
title: direction.title,
image: nil,
action: #selector(Self.pagerTabStripNavigateKeyCommandHandlerRelay(_:)),
input: direction.input,
modifierFlags: direction.modifierFlags,
propertyList: direction.propertyList,
alternates: [],
discoverabilityTitle: nil,
attributes: [],
state: .off
)
}
}
func pagerTabStripNavigateKeyCommandHandler(_ sender: UIKeyCommand) {
guard let rawValue = sender.propertyList as? String,
let direction = PagerTabStripNavigationDirection(rawValue: rawValue) else { return }
navigate(direction: direction)
}
}
extension PagerTabStripNavigateableCore {
func navigate(direction: PagerTabStripNavigationDirection) {
let index = navigateablePageViewController.currentIndex
let targetIndex: Int
switch direction {
case .previous:
targetIndex = index - 1
case .next:
targetIndex = index + 1
}
guard targetIndex >= 0,
!navigateablePageViewController.viewControllers.isEmpty,
targetIndex < navigateablePageViewController.viewControllers.count,
navigateablePageViewController.canMoveTo(index: targetIndex)
else {
return
}
navigateablePageViewController.moveToViewController(at: targetIndex)
}
}

View File

@ -112,6 +112,12 @@ extension StatusTableViewControllerNavigateableCore where Self: DataSourceProvid
@MainActor
private func previewImage() async {
guard let status = await statusRecord() else { return }
// workaround media preview not first responder issue
if let presentedViewController = presentedViewController as? MediaPreviewViewController {
presentedViewController.dismiss(animated: true, completion: nil)
return
}
guard let provider = self as? (DataSourceProvider & MediaPreviewableViewController) else { return }
guard let indexPathForSelectedRow = tableView.indexPathForSelectedRow,

View File

@ -261,7 +261,6 @@ extension ProfileViewController {
bindTitleView()
bindMoreBarButtonItem()
bindPager()
// updateBarButtonInsets()
}
override func viewDidAppear(_ animated: Bool) {
@ -270,32 +269,6 @@ extension ProfileViewController {
setNeedsStatusBarAppearanceUpdate()
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
// updateBarButtonInsets()
}
}
extension ProfileViewController {
// private func updateBarButtonInsets() {
// let margin: CGFloat = {
// switch traitCollection.userInterfaceIdiom {
// case .phone:
// return ProfileViewController.containerViewMarginForCompactHorizontalSizeClass
// default:
// return traitCollection.horizontalSizeClass == .regular ?
// ProfileViewController.containerViewMarginForRegularHorizontalSizeClass :
// ProfileViewController.containerViewMarginForCompactHorizontalSizeClass
// }
// }()
//
// profileHeaderViewController.buttonBar.layout.contentInset.left = margin
// profileHeaderViewController.buttonBar.layout.contentInset.right = margin
// }
}
extension ProfileViewController {
@ -869,28 +842,28 @@ extension ProfileViewController: ScrollViewContainer {
}
}
//extension ProfileViewController {
//
// override var keyCommands: [UIKeyCommand]? {
// if !viewModel.isEditing.value {
// return pageboyNavigateKeyCommands
// }
//
// return nil
// }
//
//}
//
//// MARK: - PageboyNavigateable
//extension ProfileViewController: PageboyNavigateable {
//
// var navigateablePageViewController: PageboyViewController {
// return profileSegmentedViewController.pagingViewController
// }
//
// @objc func pageboyNavigateKeyCommandHandlerRelay(_ sender: UIKeyCommand) {
// pageboyNavigateKeyCommandHandler(sender)
// }
//
//}
extension ProfileViewController {
override var keyCommands: [UIKeyCommand]? {
if !viewModel.isEditing {
return pagerTabStripNavigateKeyCommands
}
return nil
}
}
// MARK: - PagerTabStripNavigateable
extension ProfileViewController: PagerTabStripNavigateable {
var navigateablePageViewController: PagerTabStripViewController {
return profilePagingViewController
}
@objc func pagerTabStripNavigateKeyCommandHandlerRelay(_ sender: UIKeyCommand) {
pagerTabStripNavigateKeyCommandHandler(sender)
}
}