forked from shadowfacts/Tusker
Re-add status cell dragging
This commit is contained in:
parent
817ef0c2cc
commit
ba1300b1b7
|
@ -68,9 +68,8 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
}
|
||||
let layout = UICollectionViewCompositionalLayout.list(using: config)
|
||||
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
// TODO: delegates
|
||||
collectionView.delegate = self
|
||||
// collectionView.dragDelegate = self
|
||||
collectionView.dragDelegate = self
|
||||
|
||||
registerTimelineLikeCells()
|
||||
collectionView.register(PublicTimelineDescriptionCollectionViewCell.self, forCellWithReuseIdentifier: "publicTimelineDescription")
|
||||
|
@ -344,6 +343,12 @@ extension TimelineViewController: UICollectionViewDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
extension TimelineViewController: UICollectionViewDragDelegate {
|
||||
func collectionView(_ collectionView: UICollectionView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
|
||||
(collectionView.cellForItem(at: indexPath) as? TimelineStatusCollectionViewCell)?.dragItemsForBeginning(session: session) ?? []
|
||||
}
|
||||
}
|
||||
|
||||
extension TimelineViewController: TuskerNavigationDelegate {
|
||||
var apiController: MastodonController { mastodonController }
|
||||
}
|
||||
|
|
|
@ -168,7 +168,6 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
|
|||
reblogButton.widthAnchor.constraint(equalTo: replyButton.widthAnchor),
|
||||
moreButton.widthAnchor.constraint(equalTo: replyButton.widthAnchor),
|
||||
|
||||
// TODO: gah
|
||||
placeholderReplyButtonLeadingConstraint,
|
||||
replyButton.topAnchor.constraint(equalTo: $0.topAnchor),
|
||||
replyButton.bottomAnchor.constraint(equalTo: $0.bottomAnchor),
|
||||
|
@ -564,6 +563,21 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
|
|||
return UISwipeActionsConfiguration(actions: actions)
|
||||
}
|
||||
|
||||
func dragItemsForBeginning(session: UIDragSession) -> [UIDragItem] {
|
||||
// the poll options view is tracking while the user is dragging between options
|
||||
// while that's happening, don't initiate a drag
|
||||
guard !pollView.isTracking,
|
||||
let status = mastodonController.persistentContainer.status(for: statusID),
|
||||
let accountID = mastodonController.accountInfo?.id else {
|
||||
return []
|
||||
}
|
||||
let provider = NSItemProvider(object: status.url! as NSURL)
|
||||
let activity = UserActivityManager.showConversationActivity(mainStatusID: status.id, accountID: accountID)
|
||||
activity.displaysAuxiliaryScene = true
|
||||
provider.registerObject(activity, visibility: .all)
|
||||
return [UIDragItem(itemProvider: provider)]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension TimelineStatusCollectionViewCell: UIContextMenuInteractionDelegate {
|
||||
|
|
Loading…
Reference in New Issue