From 401f1155f7ed73760a32a79c589e995289bdd653 Mon Sep 17 00:00:00 2001 From: Andrew Finnell Date: Sat, 22 Aug 2020 15:45:10 -0400 Subject: [PATCH] Remove SwiftUI shims, since it won't work on iOS https://losingfight.com/blog/2020/08/22/uiviewrepresentable-doesnt-respect-intrinsiccontentsize-invalidation/ --- .../render/NativeMarkText+AppKit.swift | 34 ------------------ .../render/NativeMarkText+UIKit.swift | 35 ------------------- 2 files changed, 69 deletions(-) delete mode 100644 Sources/NativeMarkKit/render/NativeMarkText+AppKit.swift delete mode 100644 Sources/NativeMarkKit/render/NativeMarkText+UIKit.swift diff --git a/Sources/NativeMarkKit/render/NativeMarkText+AppKit.swift b/Sources/NativeMarkKit/render/NativeMarkText+AppKit.swift deleted file mode 100644 index e0e1afa..0000000 --- a/Sources/NativeMarkKit/render/NativeMarkText+AppKit.swift +++ /dev/null @@ -1,34 +0,0 @@ -import Foundation -#if canImport(AppKit) && canImport(SwiftUI) -import AppKit -import SwiftUI - -public struct NativeMarkText: NSViewRepresentable { - public typealias NSViewType = NativeMarkLabel - - // TODO: make sure style sheet is customizable - let nativeMark: String - let onOpenLink: ((URL) -> Void)? - let styleSheet: StyleSheet - - public init(_ nativeMark: String, styleSheet: StyleSheet = .default, onOpenLink: ((URL) -> Void)? = URLOpener.open) { - self.nativeMark = nativeMark - self.onOpenLink = onOpenLink - self.styleSheet = styleSheet - } - - public func makeNSView(context: Context) -> NativeMarkLabel { - let label = NativeMarkLabel(nativeMark: nativeMark, styleSheet: styleSheet) - label.setContentHuggingPriority(.defaultLow, for: .horizontal) - label.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) - label.onOpenLink = onOpenLink - return label - } - - public func updateNSView(_ nsView: NativeMarkLabel, context: Context) { - nsView.nativeMark = nativeMark - nsView.onOpenLink = onOpenLink - } -} - -#endif diff --git a/Sources/NativeMarkKit/render/NativeMarkText+UIKit.swift b/Sources/NativeMarkKit/render/NativeMarkText+UIKit.swift deleted file mode 100644 index 0c64935..0000000 --- a/Sources/NativeMarkKit/render/NativeMarkText+UIKit.swift +++ /dev/null @@ -1,35 +0,0 @@ -import Foundation -#if canImport(UIKit) && canImport(SwiftUI) -import UIKit -import SwiftUI - -public struct NativeMarkText: UIViewRepresentable { - public typealias UIViewType = NativeMarkLabel - - // TODO: make sure style sheet is customizable - // TODO: figure out how to make this thing size correctly in SwiftUI - let nativeMark: String - let onOpenLink: ((URL) -> Void)? - let styleSheet: StyleSheet - - public init(_ nativeMark: String, styleSheet: StyleSheet = .default, onOpenLink: ((URL) -> Void)? = URLOpener.open) { - self.nativeMark = nativeMark - self.onOpenLink = onOpenLink - self.styleSheet = styleSheet - } - - public func makeUIView(context: Context) -> NativeMarkLabel { - let label = NativeMarkLabel(nativeMark: nativeMark, styleSheet: styleSheet) - label.setContentHuggingPriority(.defaultLow, for: .horizontal) - label.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) - label.onOpenLink = onOpenLink - return label - } - - public func updateUIView(_ nsView: NativeMarkLabel, context: Context) { - nsView.nativeMark = nativeMark - nsView.onOpenLink = onOpenLink - } -} - -#endif