PreviewShims.swift 745 B

123456789101112131415161718192021222324252627
  1. //
  2. // PreviewShims.swift
  3. // ark_ui_basic
  4. //
  5. // Bridging helpers for Xcode Preview support.
  6. // Wraps ark_ui_basic views in hosting controllers
  7. // so they can be used with SwiftUI's #Preview macro.
  8. import ark_ui_basic_core
  9. // Helper method before we add fully preview thunk and preview macro support for ark_ui_basic
  10. #if canImport(AppKit) && !targetEnvironment(macCatalyst)
  11. public import AppKit
  12. extension ark_ui_basic.View {
  13. public func _previewVC() -> NSViewController {
  14. ark_ui_basic.NSHostingController(rootView: self)
  15. }
  16. }
  17. #elseif canImport(UIKit)
  18. public import UIKit
  19. extension ark_ui_basic.View {
  20. public func _previewVC() -> UIViewController {
  21. ark_ui_basic.UIHostingController(rootView: self)
  22. }
  23. }
  24. #endif