2021-04-28 09:02:34 +02:00
|
|
|
//
|
|
|
|
// MediaPreviewViewController.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK Cirno on 2021-4-28.
|
|
|
|
//
|
|
|
|
|
|
|
|
import os.log
|
|
|
|
import UIKit
|
|
|
|
import Combine
|
|
|
|
import Pageboy
|
2022-01-27 14:23:39 +01:00
|
|
|
import MastodonAsset
|
2022-10-08 07:43:06 +02:00
|
|
|
import MastodonCore
|
|
|
|
import MastodonUI
|
2022-01-27 14:23:39 +01:00
|
|
|
import MastodonLocalization
|
2021-04-28 09:02:34 +02:00
|
|
|
|
|
|
|
final class MediaPreviewViewController: UIViewController, NeedsDependency {
|
|
|
|
|
2021-04-28 13:06:45 +02:00
|
|
|
static let closeButtonSize = CGSize(width: 30, height: 30)
|
|
|
|
|
2021-04-28 09:02:34 +02:00
|
|
|
weak var context: AppContext! { willSet { precondition(!isViewLoaded) } }
|
|
|
|
weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } }
|
|
|
|
|
|
|
|
var disposeBag = Set<AnyCancellable>()
|
|
|
|
var viewModel: MediaPreviewViewModel!
|
2021-04-29 13:49:46 +02:00
|
|
|
|
2021-04-28 09:02:34 +02:00
|
|
|
let visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .systemMaterial))
|
2021-07-01 13:18:41 +02:00
|
|
|
let pagingViewController = MediaPreviewPagingViewController()
|
2021-04-28 13:06:45 +02:00
|
|
|
|
|
|
|
let closeButtonBackground: UIVisualEffectView = {
|
|
|
|
let backgroundView = UIVisualEffectView(effect: UIBlurEffect(style: .systemUltraThinMaterial))
|
|
|
|
backgroundView.alpha = 0.9
|
|
|
|
backgroundView.layer.masksToBounds = true
|
|
|
|
backgroundView.layer.cornerRadius = MediaPreviewViewController.closeButtonSize.width * 0.5
|
|
|
|
return backgroundView
|
|
|
|
}()
|
|
|
|
|
|
|
|
let closeButtonBackgroundVisualEffectView = UIVisualEffectView(effect: UIVibrancyEffect(blurEffect: UIBlurEffect(style: .systemUltraThinMaterial)))
|
|
|
|
|
|
|
|
let closeButton: UIButton = {
|
2021-04-30 13:34:45 +02:00
|
|
|
let button = HighlightDimmableButton()
|
|
|
|
button.expandEdgeInsets = UIEdgeInsets(top: -10, left: -10, bottom: -10, right: -10)
|
2021-04-28 13:06:45 +02:00
|
|
|
button.imageView?.tintColor = .label
|
|
|
|
button.setImage(UIImage(systemName: "xmark", withConfiguration: UIImage.SymbolConfiguration(pointSize: 16, weight: .bold))!, for: .normal)
|
|
|
|
return button
|
|
|
|
}()
|
2021-04-28 09:02:34 +02:00
|
|
|
|
|
|
|
deinit {
|
|
|
|
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
extension MediaPreviewViewController {
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
|
|
|
|
overrideUserInterfaceStyle = .dark
|
|
|
|
|
|
|
|
visualEffectView.frame = view.bounds
|
2021-09-29 13:34:54 +02:00
|
|
|
visualEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
2021-04-28 09:02:34 +02:00
|
|
|
view.addSubview(visualEffectView)
|
|
|
|
|
2021-07-01 13:18:41 +02:00
|
|
|
pagingViewController.view.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
addChild(pagingViewController)
|
|
|
|
visualEffectView.contentView.addSubview(pagingViewController.view)
|
2022-11-17 17:45:27 +01:00
|
|
|
visualEffectView.pinTo(to: pagingViewController.view)
|
2021-07-01 13:18:41 +02:00
|
|
|
pagingViewController.didMove(toParent: self)
|
2021-04-28 09:02:34 +02:00
|
|
|
|
2021-04-28 13:06:45 +02:00
|
|
|
closeButtonBackground.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
view.addSubview(closeButtonBackground)
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
closeButtonBackground.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor, constant: 12),
|
|
|
|
closeButtonBackground.leadingAnchor.constraint(equalTo: view.layoutMarginsGuide.leadingAnchor)
|
|
|
|
])
|
|
|
|
closeButtonBackgroundVisualEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
|
|
closeButtonBackground.contentView.addSubview(closeButtonBackgroundVisualEffectView)
|
|
|
|
|
|
|
|
closeButton.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
closeButtonBackgroundVisualEffectView.contentView.addSubview(closeButton)
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
closeButton.topAnchor.constraint(equalTo: closeButtonBackgroundVisualEffectView.topAnchor),
|
|
|
|
closeButton.leadingAnchor.constraint(equalTo: closeButtonBackgroundVisualEffectView.leadingAnchor),
|
|
|
|
closeButtonBackgroundVisualEffectView.trailingAnchor.constraint(equalTo: closeButton.trailingAnchor),
|
|
|
|
closeButtonBackgroundVisualEffectView.bottomAnchor.constraint(equalTo: closeButton.bottomAnchor),
|
|
|
|
closeButton.heightAnchor.constraint(equalToConstant: MediaPreviewViewController.closeButtonSize.height).priority(.defaultHigh),
|
|
|
|
closeButton.widthAnchor.constraint(equalToConstant: MediaPreviewViewController.closeButtonSize.width).priority(.defaultHigh),
|
|
|
|
])
|
|
|
|
|
2021-04-28 09:02:34 +02:00
|
|
|
viewModel.mediaPreviewImageViewControllerDelegate = self
|
|
|
|
|
2021-07-01 13:18:41 +02:00
|
|
|
pagingViewController.interPageSpacing = 10
|
|
|
|
pagingViewController.delegate = self
|
|
|
|
pagingViewController.dataSource = viewModel
|
2021-04-28 13:06:45 +02:00
|
|
|
|
|
|
|
closeButton.addTarget(self, action: #selector(MediaPreviewViewController.closeButtonPressed(_:)), for: .touchUpInside)
|
|
|
|
|
|
|
|
// bind view model
|
2022-01-27 14:23:39 +01:00
|
|
|
viewModel.$currentPage
|
2021-04-28 13:06:45 +02:00
|
|
|
.receive(on: DispatchQueue.main)
|
|
|
|
.sink { [weak self] index in
|
|
|
|
guard let self = self else { return }
|
2022-01-27 14:23:39 +01:00
|
|
|
switch self.viewModel.transitionItem.source {
|
2022-02-09 13:35:19 +01:00
|
|
|
case .attachment:
|
2022-01-27 14:23:39 +01:00
|
|
|
break
|
|
|
|
case .attachments(let mediaGridContainerView):
|
2021-04-28 13:06:45 +02:00
|
|
|
UIView.animate(withDuration: 0.3) {
|
2022-01-27 14:23:39 +01:00
|
|
|
mediaGridContainerView.setAlpha(1)
|
|
|
|
mediaGridContainerView.setAlpha(0, index: index)
|
2021-04-28 13:06:45 +02:00
|
|
|
}
|
2021-04-28 14:36:10 +02:00
|
|
|
case .profileAvatar, .profileBanner:
|
2021-04-28 14:10:17 +02:00
|
|
|
break
|
2021-04-28 13:06:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
.store(in: &disposeBag)
|
2022-02-09 13:35:19 +01:00
|
|
|
|
|
|
|
viewModel.$currentPage
|
|
|
|
.receive(on: DispatchQueue.main)
|
|
|
|
.sink { [weak self] index in
|
|
|
|
guard let self = self else { return }
|
|
|
|
switch self.viewModel.item {
|
|
|
|
case .attachment(let previewContext):
|
|
|
|
let needsHideCloseButton: Bool = {
|
|
|
|
guard index < previewContext.attachments.count else { return false }
|
|
|
|
let attachment = previewContext.attachments[index]
|
|
|
|
return attachment.kind == .video // not hide buttno for audio
|
|
|
|
}()
|
|
|
|
self.closeButtonBackground.isHidden = needsHideCloseButton
|
|
|
|
default:
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.store(in: &disposeBag)
|
2022-11-15 03:52:16 +01:00
|
|
|
|
|
|
|
viewModel.$showingChrome
|
|
|
|
.receive(on: DispatchQueue.main)
|
|
|
|
.removeDuplicates()
|
|
|
|
.sink { [weak self] showingChrome in
|
|
|
|
UIView.animate(withDuration: 0.3) {
|
|
|
|
self?.setNeedsStatusBarAppearanceUpdate()
|
|
|
|
self?.closeButtonBackground.alpha = showingChrome ? 1 : 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.store(in: &disposeBag)
|
2022-05-26 17:19:47 +02:00
|
|
|
|
|
|
|
// viewModel.$isPoping
|
|
|
|
// .receive(on: DispatchQueue.main)
|
|
|
|
// .removeDuplicates()
|
|
|
|
// .sink { [weak self] _ in
|
|
|
|
// guard let self = self else { return }
|
|
|
|
// // statusBar style update with animation
|
|
|
|
// self.setNeedsStatusBarAppearanceUpdate()
|
|
|
|
// UIView.animate(withDuration: 0.3) {
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// .store(in: &disposeBag)
|
2021-04-28 13:06:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-11-15 03:52:16 +01:00
|
|
|
extension MediaPreviewViewController {
|
|
|
|
|
|
|
|
override var prefersStatusBarHidden: Bool {
|
|
|
|
!viewModel.showingChrome
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-04-28 13:06:45 +02:00
|
|
|
extension MediaPreviewViewController {
|
|
|
|
|
|
|
|
@objc private func closeButtonPressed(_ sender: UIButton) {
|
|
|
|
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
|
|
|
|
dismiss(animated: true, completion: nil)
|
2021-04-28 09:02:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - MediaPreviewingViewController
|
|
|
|
extension MediaPreviewViewController: MediaPreviewingViewController {
|
|
|
|
|
2021-07-01 13:18:41 +02:00
|
|
|
func isInteractiveDismissible() -> Bool {
|
|
|
|
if let mediaPreviewImageViewController = pagingViewController.currentViewController as? MediaPreviewImageViewController {
|
2021-04-28 13:06:45 +02:00
|
|
|
let previewImageView = mediaPreviewImageViewController.previewImageView
|
|
|
|
// TODO: allow zooming pan dismiss
|
|
|
|
guard previewImageView.zoomScale == previewImageView.minimumZoomScale else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
let safeAreaInsets = previewImageView.safeAreaInsets
|
|
|
|
let statusBarFrameHeight = view.window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0
|
2021-07-01 13:18:41 +02:00
|
|
|
let dismissible = previewImageView.contentOffset.y <= -(safeAreaInsets.top - statusBarFrameHeight) + 3 // add 3pt tolerance
|
|
|
|
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: dismissible %s", ((#file as NSString).lastPathComponent), #line, #function, dismissible ? "true" : "false")
|
|
|
|
return dismissible
|
2021-04-28 13:06:45 +02:00
|
|
|
}
|
2022-02-09 13:35:19 +01:00
|
|
|
|
|
|
|
if let _ = pagingViewController.currentViewController as? MediaPreviewVideoViewController {
|
|
|
|
return true
|
|
|
|
}
|
2021-04-28 13:06:45 +02:00
|
|
|
|
2021-07-01 13:18:41 +02:00
|
|
|
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: dismissible false", ((#file as NSString).lastPathComponent), #line, #function)
|
2021-04-28 13:06:45 +02:00
|
|
|
return false
|
2021-04-28 09:02:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - PageboyViewControllerDelegate
|
|
|
|
extension MediaPreviewViewController: PageboyViewControllerDelegate {
|
|
|
|
func pageboyViewController(
|
|
|
|
_ pageboyViewController: PageboyViewController,
|
|
|
|
willScrollToPageAt index: PageboyViewController.PageIndex,
|
|
|
|
direction: PageboyViewController.NavigationDirection,
|
|
|
|
animated: Bool
|
|
|
|
) {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
func pageboyViewController(
|
|
|
|
_ pageboyViewController: PageboyViewController,
|
|
|
|
didScrollTo position: CGPoint,
|
|
|
|
direction: PageboyViewController.NavigationDirection,
|
|
|
|
animated: Bool
|
|
|
|
) {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
func pageboyViewController(
|
|
|
|
_ pageboyViewController: PageboyViewController,
|
|
|
|
didScrollToPageAt index: PageboyViewController.PageIndex,
|
|
|
|
direction: PageboyViewController.NavigationDirection,
|
|
|
|
animated: Bool
|
|
|
|
) {
|
|
|
|
// update page control
|
|
|
|
// pageControl.currentPage = index
|
2022-01-27 14:23:39 +01:00
|
|
|
viewModel.currentPage = index
|
2021-04-28 09:02:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func pageboyViewController(
|
|
|
|
_ pageboyViewController: PageboyViewController,
|
|
|
|
didReloadWith currentViewController: UIViewController,
|
|
|
|
currentPageIndex: PageboyViewController.PageIndex
|
|
|
|
) {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: - MediaPreviewImageViewControllerDelegate
|
|
|
|
extension MediaPreviewViewController: MediaPreviewImageViewControllerDelegate {
|
|
|
|
|
|
|
|
func mediaPreviewImageViewController(_ viewController: MediaPreviewImageViewController, tapGestureRecognizerDidTrigger tapGestureRecognizer: UITapGestureRecognizer) {
|
2022-02-18 12:33:12 +01:00
|
|
|
let location = tapGestureRecognizer.location(in: viewController.previewImageView.imageView)
|
|
|
|
let isContainsTap = viewController.previewImageView.imageView.frame.contains(location)
|
|
|
|
|
2022-11-15 03:52:16 +01:00
|
|
|
if isContainsTap {
|
|
|
|
self.viewModel.showingChrome.toggle()
|
|
|
|
} else {
|
|
|
|
dismiss(animated: true, completion: nil)
|
|
|
|
}
|
2021-04-28 09:02:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func mediaPreviewImageViewController(_ viewController: MediaPreviewImageViewController, longPressGestureRecognizerDidTrigger longPressGestureRecognizer: UILongPressGestureRecognizer) {
|
2021-04-29 13:49:46 +02:00
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
2022-01-27 14:23:39 +01:00
|
|
|
func mediaPreviewImageViewController(
|
|
|
|
_ viewController: MediaPreviewImageViewController,
|
|
|
|
contextMenuActionPerform action: MediaPreviewImageViewController.ContextMenuAction
|
|
|
|
) {
|
2021-04-29 13:49:46 +02:00
|
|
|
switch action {
|
|
|
|
case .savePhoto:
|
2022-01-27 14:23:39 +01:00
|
|
|
let _savePublisher: AnyPublisher<Void, Error>? = {
|
2021-07-21 13:45:24 +02:00
|
|
|
switch viewController.viewModel.item {
|
2022-01-27 14:23:39 +01:00
|
|
|
case .remote(let previewContext):
|
|
|
|
guard let assetURL = previewContext.assetURL else { return nil }
|
|
|
|
return context.photoLibraryService.save(imageSource: .url(assetURL))
|
|
|
|
case .local(let previewContext):
|
|
|
|
return context.photoLibraryService.save(imageSource: .image(previewContext.image))
|
2021-07-21 13:45:24 +02:00
|
|
|
}
|
|
|
|
}()
|
2022-01-27 14:23:39 +01:00
|
|
|
guard let savePublisher = _savePublisher else {
|
|
|
|
return
|
|
|
|
}
|
2021-07-21 13:45:24 +02:00
|
|
|
savePublisher
|
|
|
|
.sink { [weak self] completion in
|
|
|
|
guard let self = self else { return }
|
|
|
|
switch completion {
|
|
|
|
case .failure(let error):
|
|
|
|
guard let error = error as? PhotoLibraryService.PhotoLibraryError,
|
|
|
|
case .noPermission = error else { return }
|
2022-01-27 14:23:39 +01:00
|
|
|
let alertController = SettingService.openSettingsAlertController(
|
|
|
|
title: L10n.Common.Alerts.SavePhotoFailure.title,
|
|
|
|
message: L10n.Common.Alerts.SavePhotoFailure.message
|
|
|
|
)
|
2022-11-17 23:02:43 +01:00
|
|
|
_ = self.coordinator.present(
|
2022-01-27 14:23:39 +01:00
|
|
|
scene: .alertController(alertController: alertController),
|
|
|
|
from: self,
|
|
|
|
transition: .alertController(animated: true, completion: nil)
|
|
|
|
)
|
2021-07-21 13:45:24 +02:00
|
|
|
case .finished:
|
|
|
|
break
|
2021-04-30 13:28:06 +02:00
|
|
|
}
|
2021-07-21 13:45:24 +02:00
|
|
|
} receiveValue: { _ in
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
.store(in: &context.disposeBag)
|
2021-07-06 14:02:30 +02:00
|
|
|
case .copyPhoto:
|
2022-01-27 14:23:39 +01:00
|
|
|
let _copyPublisher: AnyPublisher<Void, Error>? = {
|
2021-07-21 13:45:24 +02:00
|
|
|
switch viewController.viewModel.item {
|
2022-01-27 14:23:39 +01:00
|
|
|
case .remote(let previewContext):
|
|
|
|
guard let assetURL = previewContext.assetURL else { return nil }
|
|
|
|
return context.photoLibraryService.copy(imageSource: .url(assetURL))
|
|
|
|
case .local(let previewContext):
|
|
|
|
return context.photoLibraryService.copy(imageSource: .image(previewContext.image))
|
2021-07-21 13:45:24 +02:00
|
|
|
}
|
|
|
|
}()
|
2022-01-27 14:23:39 +01:00
|
|
|
guard let copyPublisher = _copyPublisher else {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-07-21 13:45:24 +02:00
|
|
|
copyPublisher
|
|
|
|
.sink { completion in
|
|
|
|
switch completion {
|
|
|
|
case .failure(let error):
|
|
|
|
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: copy photo fail: %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription)
|
|
|
|
case .finished:
|
|
|
|
break
|
2021-07-06 14:02:30 +02:00
|
|
|
}
|
2021-07-21 13:45:24 +02:00
|
|
|
} receiveValue: { _ in
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
.store(in: &context.disposeBag)
|
2021-04-29 13:49:46 +02:00
|
|
|
case .share:
|
|
|
|
let applicationActivities: [UIActivity] = [
|
|
|
|
SafariActivity(sceneCoordinator: self.coordinator)
|
|
|
|
]
|
|
|
|
let activityViewController = UIActivityViewController(
|
2022-01-27 14:23:39 +01:00
|
|
|
activityItems: {
|
|
|
|
var activityItems: [Any] = []
|
|
|
|
switch viewController.viewModel.item {
|
|
|
|
case .remote(let previewContext):
|
|
|
|
if let assetURL = previewContext.assetURL {
|
|
|
|
activityItems.append(assetURL)
|
|
|
|
}
|
|
|
|
case .local(let previewContext):
|
|
|
|
activityItems.append(previewContext.image)
|
|
|
|
}
|
|
|
|
return activityItems
|
|
|
|
}(),
|
2021-04-29 13:49:46 +02:00
|
|
|
applicationActivities: applicationActivities
|
|
|
|
)
|
|
|
|
activityViewController.popoverPresentationController?.sourceView = viewController.previewImageView.imageView
|
|
|
|
self.present(activityViewController, animated: true, completion: nil)
|
|
|
|
}
|
2021-04-28 09:02:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-05-21 09:23:02 +02:00
|
|
|
|
|
|
|
extension MediaPreviewViewController {
|
|
|
|
|
|
|
|
var closeKeyCommand: UIKeyCommand {
|
|
|
|
UIKeyCommand(
|
|
|
|
title: L10n.Scene.Preview.Keyboard.closePreview,
|
|
|
|
image: nil,
|
|
|
|
action: #selector(MediaPreviewViewController.closePreviewKeyCommandHandler(_:)),
|
|
|
|
input: "i",
|
|
|
|
modifierFlags: [],
|
|
|
|
propertyList: nil,
|
|
|
|
alternates: [],
|
|
|
|
discoverabilityTitle: nil,
|
|
|
|
attributes: [],
|
|
|
|
state: .off
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
var showNextKeyCommand: UIKeyCommand {
|
|
|
|
UIKeyCommand(
|
|
|
|
title: L10n.Scene.Preview.Keyboard.closePreview,
|
|
|
|
image: nil,
|
|
|
|
action: #selector(MediaPreviewViewController.showNextKeyCommandHandler(_:)),
|
|
|
|
input: "j",
|
|
|
|
modifierFlags: [],
|
|
|
|
propertyList: nil,
|
|
|
|
alternates: [],
|
|
|
|
discoverabilityTitle: nil,
|
|
|
|
attributes: [],
|
|
|
|
state: .off
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var showPreviousKeyCommand: UIKeyCommand {
|
|
|
|
UIKeyCommand(
|
|
|
|
title: L10n.Scene.Preview.Keyboard.closePreview,
|
|
|
|
image: nil,
|
|
|
|
action: #selector(MediaPreviewViewController.showPreviousKeyCommandHandler(_:)),
|
|
|
|
input: "k",
|
|
|
|
modifierFlags: [],
|
|
|
|
propertyList: nil,
|
|
|
|
alternates: [],
|
|
|
|
discoverabilityTitle: nil,
|
|
|
|
attributes: [],
|
|
|
|
state: .off
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override var keyCommands: [UIKeyCommand] {
|
|
|
|
return [
|
|
|
|
closeKeyCommand,
|
|
|
|
showNextKeyCommand,
|
|
|
|
showPreviousKeyCommand,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc private func closePreviewKeyCommandHandler(_ sender: UIKeyCommand) {
|
|
|
|
dismiss(animated: true, completion: nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc private func showNextKeyCommandHandler(_ sender: UIKeyCommand) {
|
2021-07-01 13:18:41 +02:00
|
|
|
pagingViewController.scrollToPage(.next, animated: true, completion: nil)
|
2021-05-21 09:23:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@objc private func showPreviousKeyCommandHandler(_ sender: UIKeyCommand) {
|
2021-07-01 13:18:41 +02:00
|
|
|
pagingViewController.scrollToPage(.previous, animated: true, completion: nil)
|
2021-05-21 09:23:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|