[iPad] Fixes game context menu actions
This commit is contained in:
parent
da8415f4aa
commit
836297718b
@ -66,6 +66,8 @@ class GameCollectionViewController: UICollectionViewController
|
|||||||
private weak var _previewTransitionViewController: PreviewGameViewController?
|
private weak var _previewTransitionViewController: PreviewGameViewController?
|
||||||
private weak var _previewTransitionDestinationViewController: UIViewController?
|
private weak var _previewTransitionDestinationViewController: UIViewController?
|
||||||
|
|
||||||
|
private weak var _popoverSourceView: UIView?
|
||||||
|
|
||||||
private var _renameAction: UIAlertAction?
|
private var _renameAction: UIAlertAction?
|
||||||
private var _changingArtworkGame: Game?
|
private var _changingArtworkGame: Game?
|
||||||
private var _importingSaveFileGame: Game?
|
private var _importingSaveFileGame: Game?
|
||||||
@ -521,7 +523,9 @@ private extension GameCollectionViewController
|
|||||||
|
|
||||||
func delete(_ game: Game)
|
func delete(_ game: Game)
|
||||||
{
|
{
|
||||||
let confirmationAlertController = UIAlertController(title: NSLocalizedString("Are you sure you want to delete this game? All associated data, such as saves, save states, and cheat codes, will also be deleted.", comment: ""), message: nil, preferredStyle: .actionSheet)
|
let confirmationAlertController = UIAlertController(title: NSLocalizedString("Are you sure you want to delete this game?", comment: ""),
|
||||||
|
message: NSLocalizedString("All associated data, such as saves, save states, and cheat codes, will also be deleted.", comment: ""),
|
||||||
|
preferredStyle: .alert)
|
||||||
confirmationAlertController.addAction(UIAlertAction(title: NSLocalizedString("Delete Game", comment: ""), style: .destructive, handler: { action in
|
confirmationAlertController.addAction(UIAlertAction(title: NSLocalizedString("Delete Game", comment: ""), style: .destructive, handler: { action in
|
||||||
|
|
||||||
DatabaseManager.shared.performBackgroundTask { (context) in
|
DatabaseManager.shared.performBackgroundTask { (context) in
|
||||||
@ -591,6 +595,7 @@ private extension GameCollectionViewController
|
|||||||
let importController = ImportController(documentTypes: [kUTTypeImage as String])
|
let importController = ImportController(documentTypes: [kUTTypeImage as String])
|
||||||
importController.delegate = self
|
importController.delegate = self
|
||||||
importController.importOptions = [clipboardImportOption, photoLibraryImportOption, gamesDatabaseImportOption]
|
importController.importOptions = [clipboardImportOption, photoLibraryImportOption, gamesDatabaseImportOption]
|
||||||
|
importController.sourceView = self._popoverSourceView
|
||||||
self.present(importController, animated: true, completion: nil)
|
self.present(importController, animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -719,6 +724,8 @@ private extension GameCollectionViewController
|
|||||||
let copyDeepLinkActivity = CopyDeepLinkActivity()
|
let copyDeepLinkActivity = CopyDeepLinkActivity()
|
||||||
|
|
||||||
let activityViewController = UIActivityViewController(activityItems: [symbolicURL, game], applicationActivities: [copyDeepLinkActivity])
|
let activityViewController = UIActivityViewController(activityItems: [symbolicURL, game], applicationActivities: [copyDeepLinkActivity])
|
||||||
|
activityViewController.popoverPresentationController?.sourceView = self._popoverSourceView?.superview
|
||||||
|
activityViewController.popoverPresentationController?.sourceRect = self._popoverSourceView?.frame ?? .zero
|
||||||
activityViewController.completionWithItemsHandler = { (activityType, finished, returnedItems, error) in
|
activityViewController.completionWithItemsHandler = { (activityType, finished, returnedItems, error) in
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -844,6 +851,9 @@ extension GameCollectionViewController: UIViewControllerPreviewingDelegate
|
|||||||
|
|
||||||
previewingContext.sourceRect = layoutAttributes.frame
|
previewingContext.sourceRect = layoutAttributes.frame
|
||||||
|
|
||||||
|
let cell = collectionView.cellForItem(at: indexPath)
|
||||||
|
self._popoverSourceView = cell
|
||||||
|
|
||||||
let game = self.dataSource.item(at: indexPath)
|
let game = self.dataSource.item(at: indexPath)
|
||||||
|
|
||||||
let gameViewController = self.makePreviewGameViewController(for: game)
|
let gameViewController = self.makePreviewGameViewController(for: game)
|
||||||
@ -1011,6 +1021,9 @@ extension GameCollectionViewController
|
|||||||
let game = self.dataSource.item(at: indexPath)
|
let game = self.dataSource.item(at: indexPath)
|
||||||
let actions = self.actions(for: game)
|
let actions = self.actions(for: game)
|
||||||
|
|
||||||
|
let cell = self.collectionView.cellForItem(at: indexPath)
|
||||||
|
self._popoverSourceView = cell
|
||||||
|
|
||||||
return UIContextMenuConfiguration(identifier: indexPath as NSIndexPath, previewProvider: { [weak self] in
|
return UIContextMenuConfiguration(identifier: indexPath as NSIndexPath, previewProvider: { [weak self] in
|
||||||
guard let self = self else { return nil }
|
guard let self = self else { return nil }
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,8 @@ class ImportController: NSObject
|
|||||||
var delegate: ImportControllerDelegate?
|
var delegate: ImportControllerDelegate?
|
||||||
var importOptions: [ImportOption]?
|
var importOptions: [ImportOption]?
|
||||||
|
|
||||||
var barButtonItem: UIBarButtonItem?
|
weak var barButtonItem: UIBarButtonItem?
|
||||||
|
weak var sourceView: UIView?
|
||||||
|
|
||||||
private weak var presentingViewController: UIViewController?
|
private weak var presentingViewController: UIViewController?
|
||||||
|
|
||||||
@ -84,7 +85,15 @@ class ImportController: NSObject
|
|||||||
}
|
}
|
||||||
alertController.addAction(filesAction)
|
alertController.addAction(filesAction)
|
||||||
|
|
||||||
alertController.popoverPresentationController?.barButtonItem = self.barButtonItem
|
if let sourceView = self.sourceView
|
||||||
|
{
|
||||||
|
alertController.popoverPresentationController?.sourceView = sourceView.superview
|
||||||
|
alertController.popoverPresentationController?.sourceRect = sourceView.frame
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alertController.popoverPresentationController?.barButtonItem = self.barButtonItem
|
||||||
|
}
|
||||||
|
|
||||||
self.presentedViewController = alertController
|
self.presentedViewController = alertController
|
||||||
self.presentingViewController?.present(alertController, animated: true, completion: nil)
|
self.presentingViewController?.present(alertController, animated: true, completion: nil)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user