Fix image preview presentation when order source sheet is open.

Present previews from the top of the presentation chain so tapping lead images inside the sheet no longer conflicts with the already-presented picker.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-07 11:14:57 +08:00
co-authored by Cursor
parent 77fec21563
commit 5a2b7b6097
4 changed files with 31 additions and 20 deletions
+24
View File
@@ -119,6 +119,30 @@ class BaseViewController: UIViewController {
navigationController?.popViewController(animated: true)
}
/// 沿 presentation 链找到当前最顶层控制器,避免 Sheet 已展示时 present 冲突。
func topMostPresentedViewController() -> UIViewController {
var top: UIViewController = self
while let presented = top.presentedViewController {
top = presented
}
return top
}
/// 在当前可见 presentation 链顶端弹出页面。
func presentOnTop(
_ viewController: UIViewController,
animated: Bool = true,
completion: (() -> Void)? = nil
) {
topMostPresentedViewController().present(viewController, animated: animated, completion: completion)
}
/// 全屏预览网络图片。
func presentImagePreview(imageURLs: [String], startIndex: Int) {
guard !imageURLs.isEmpty else { return }
presentOnTop(ImagePreviewViewController(imageURLs: imageURLs, startIndex: startIndex))
}
// MARK: - Notifications
private func registerBaseNotifications() {