ReadKeep/readeck/Utils/SafariUtil.swift
Ilyas Hallak 28cecf585c feat: Implement native List view with swipe actions and Safari integration
- Replace ScrollView + LazyVStack with native List for better performance
- Add swipe actions for bookmark management (archive left, favorite/delete right)
- Implement programmatic navigation with NavigationStack and navigationDestination
- Create reusable SafariUtil for opening URLs in SFSafariViewController
- Add clipboard URL detection and paste functionality in AddBookmarkView
- Improve BookmarkCardView layout with better image handling and meta info
- Add comprehensive date formatting with relative time display
- Implement proper progress bar visualization for reading progress

Navigation improvements:
- Use Button + navigationDestination instead of NavigationLink
- Add selectedBookmarkId state management for programmatic navigation
- Support for share extension URL handling with notification system

UI/UX enhancements:
- Native iOS swipe gestures with haptic feedback
- Consistent Safari integration across all views
- Better accessibility with proper button targets
- Improved visual hierarchy with refined spacing and typography
- Added image fallback chain (image → thumbnail → icon → placeholder)

Technical changes:
- Remove ScrollView scroll tracking complexity
- Simplify FAB button logic (always visible on unread tab)
- Add String+Identifiable extension for navigation
- Refactor duplicate Safari opening code into utility class
2025-06-14 22:25:19 +02:00

26 lines
1016 B
Swift

import UIKit
import SafariServices
class SafariUtil {
static func openInSafari(url: String) {
guard let url = URL(string: url) else { return }
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let window = windowScene.windows.first,
let rootViewController = window.rootViewController {
let safariViewController = SFSafariViewController(url: url)
safariViewController.preferredBarTintColor = UIColor.systemBackground
safariViewController.preferredControlTintColor = UIColor.tintColor
// Finde den präsentierenden View Controller
var presentingViewController = rootViewController
while let presented = presentingViewController.presentedViewController {
presentingViewController = presented
}
presentingViewController.present(safariViewController, animated: true)
}
}
}