🚑️ Fix #4794 - Resolve context preview glitches

`CroppingPreviewParameters` used the wrong frame — the entire cell, inclusive of what was under the sidebar. The revised code uses the cell’s contentView as the preview and includes the respective preview for dismissing the preview.

`CroppingPreviewParameters` is still used on the sidebar.
This commit is contained in:
Stuart Breckenridge committed 2025-09-25 21:35:44 +08:00
1 parent cd31f676ce
commit 92bddedb96
1 file changed
+25 -1
@@ -545,7 +545,31 @@ class MainTimelineViewController: UITableViewController, UndoableCommandRunner {
return nil
}
return UITargetedPreview(view: cell, parameters: CroppingPreviewParameters(view: cell))
let previewView = cell.contentView
let inset: CGFloat = 12
let visibleBounds = previewView.bounds.insetBy(dx: inset, dy: 2)
let parameters = UIPreviewParameters()
parameters.backgroundColor = .clear
parameters.visiblePath = UIBezierPath(roundedRect: visibleBounds,
cornerRadius: 20)
return UITargetedPreview(view: previewView, parameters: parameters)
}
override func tableView(_ tableView: UITableView, previewForDismissingContextMenuWithConfiguration configuration: UIContextMenuConfiguration) -> UITargetedPreview? {
guard let row = configuration.identifier as? Int,
let cell = tableView.cellForRow(at: IndexPath(row: row, section: 0)) else {
return nil
}
let previewView = cell.contentView
let inset: CGFloat = 0
let visibleBounds = previewView.bounds.insetBy(dx: inset, dy: 2)
let parameters = UIPreviewParameters()
parameters.backgroundColor = .clear
parameters.visiblePath = UIBezierPath(roundedRect: visibleBounds,
cornerRadius: 20)
return UITargetedPreview(view: previewView, parameters: parameters)
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {