Compatibility.swift 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import SwiftUI
  2. import UIKit
  3. enum CompatibleSymbol {
  4. static func name(_ name: String, fallback: String) -> String {
  5. UIImage(systemName: name) == nil ? fallback : name
  6. }
  7. }
  8. extension View {
  9. @ViewBuilder func jokerNavigationBarBackground() -> some View {
  10. if #available(iOS 16, *) {
  11. toolbarBackground(.white, for: .navigationBar).toolbarBackground(.visible, for: .navigationBar)
  12. } else { self }
  13. }
  14. @ViewBuilder func jokerThemePresentation() -> some View {
  15. if #available(iOS 16, *) {
  16. presentationDetents([.height(240)]).presentationDragIndicator(.visible)
  17. } else { self }
  18. }
  19. #if DEBUG
  20. @ViewBuilder func jokerPreviewScrollAnchor(atBottom: Bool) -> some View {
  21. if #available(iOS 17, *) { defaultScrollAnchor(atBottom ? .bottom : .top) }
  22. else { self }
  23. }
  24. #endif
  25. }
  26. struct FeedbackShareSheet: UIViewControllerRepresentable {
  27. let text: String
  28. func makeUIViewController(context: Context) -> UIActivityViewController {
  29. UIActivityViewController(activityItems: [text], applicationActivities: nil)
  30. }
  31. func updateUIViewController(_ controller: UIActivityViewController, context: Context) { }
  32. }