Skip to content

Commit

Permalink
Merge pull request #2274 from dnicolson/fix-tvos-long-press
Browse files Browse the repository at this point in the history
Fix long press on tvOS
  • Loading branch information
JoeMatt authored Jan 9, 2024
2 parents a093b96 + 8df4b10 commit 3cbb88d
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ let PVGameLibraryCollectionViewGamesCellIdentifier = "RecentlyPlayedCollectionCe

let PVRequiresMigrationKey = "PVRequiresMigration"

// should we use the "new" context menus added in iOS 13, or use an action sheet
let useModernContextMenus = true

// For Obj-C
public extension NSNotification {
@objc
Expand Down Expand Up @@ -445,12 +442,11 @@ final class PVGameLibraryViewController: GCEventViewController, UITextFieldDeleg
sections.map { !$0.isEmpty }.bind(to: libraryInfoContainerView.rx.isHidden).disposed(by: disposeBag)
#endif

// attach long press gesture only on pre-iOS 13, and tvOS
if useModernContextMenus == false || NSClassFromString("UIContextMenuConfiguration") == nil {
collectionView.rx.longPressed(Section.Item.self)
.bind(onNext: self.longPressed)
.disposed(by: disposeBag)
}
#if os(tvOS)
collectionView.rx.longPressed(Section.Item.self)
.bind(onNext: self.longPressed)
.disposed(by: disposeBag)
#endif

collectionView.rx.setDelegate(self).disposed(by: disposeBag)
collectionView.bounces = true
Expand Down Expand Up @@ -1069,8 +1065,7 @@ final class PVGameLibraryViewController: GCEventViewController, UITextFieldDeleg

#if !os(tvOS)
func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
guard useModernContextMenus,
let cell = collectionView.cellForItem(at: indexPath),
guard let cell = collectionView.cellForItem(at: indexPath),
let item: Section.Item = try? collectionView.rx.model(at: indexPath)
else { return nil }

Expand Down

0 comments on commit 3cbb88d

Please sign in to comment.