From 4e4a7f0cedc029b8548b0d8ccebfd35430f39a21 Mon Sep 17 00:00:00 2001 From: Rakuyo Date: Mon, 27 May 2024 14:11:26 +0800 Subject: [PATCH] feat: Improve support for multiple platforms --- Sources/Base/View/BaseView.swift | 2 ++ Sources/Core/Utilities/OptionalSize+CG.swift | 2 ++ Sources/Epoxy/CollectionView/CollectionView.swift | 2 ++ .../CollectionView/ContextMenu/AnyItemModel+ContextMenu.swift | 2 ++ .../ContextMenu/CollectionViewContextMenuDelegate.swift | 2 ++ .../CollectionView/ContextMenu/ContextMenuProviding.swift | 2 ++ .../CollectionView/ContextMenu/ItemModel+ContextMenu.swift | 2 ++ .../CollectionView/ContextMenu/RAKInternalItemModeling.swift | 2 ++ Sources/Epoxy/CollectionView/Tools/EpoxyModeled+Padding.swift | 2 ++ Sources/Epoxy/Row/BaseStyledEpoxyView.swift | 2 ++ Sources/Epoxy/Row/ButtonRow/AnyButtonImageContent.swift | 2 ++ Sources/Epoxy/Row/ButtonRow/ButtonImageContentProviding.swift | 2 ++ Sources/Epoxy/Row/ButtonRow/ButtonRow.swift | 4 +++- Sources/Epoxy/Row/ButtonRow/ButtonRowStateContent.swift | 2 ++ Sources/Epoxy/Row/ImageRow/AnyImageContent.swift | 2 ++ Sources/Epoxy/Row/ImageRow/ImageContentProviding.swift | 2 ++ Sources/Epoxy/Row/ImageRow/ImageRow.swift | 2 ++ Sources/Epoxy/Row/SwitchRow.swift | 2 ++ Sources/Epoxy/Row/TextFieldRow.swift | 2 ++ Sources/Epoxy/Row/TextRow.swift | 2 ++ 20 files changed, 41 insertions(+), 1 deletion(-) diff --git a/Sources/Base/View/BaseView.swift b/Sources/Base/View/BaseView.swift index ed446ef..ad54cad 100644 --- a/Sources/Base/View/BaseView.swift +++ b/Sources/Base/View/BaseView.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) import UIKit /// A wrapper for the frame nature of `UIView` @@ -39,3 +40,4 @@ open class BaseView: UIView { @objc open dynamic func addInitialLayout() { } } +#endif diff --git a/Sources/Core/Utilities/OptionalSize+CG.swift b/Sources/Core/Utilities/OptionalSize+CG.swift index 49c45af..c355cd1 100644 --- a/Sources/Core/Utilities/OptionalSize+CG.swift +++ b/Sources/Core/Utilities/OptionalSize+CG.swift @@ -12,11 +12,13 @@ public typealias OptionalCGSize = OptionalSize // MARK: - Logic +#if !os(watchOS) extension OptionalSize where T == CGFloat { public static var noIntrinsicMetric: Self { .init(UIView.noIntrinsicMetric) } } +#endif extension OptionalSize where T == Float { public var cgFloatWidth: CGFloat? { diff --git a/Sources/Epoxy/CollectionView/CollectionView.swift b/Sources/Epoxy/CollectionView/CollectionView.swift index c8567ae..ea09f47 100644 --- a/Sources/Epoxy/CollectionView/CollectionView.swift +++ b/Sources/Epoxy/CollectionView/CollectionView.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) && !os(tvOS) && !os(visionOS) import UIKit import EpoxyCollectionView @@ -50,3 +51,4 @@ extension CollectionView { contextMenuDelegate?.collectionView(self, willPerformPreviewActionForMenuWith: configuration, animator: animator) } } +#endif diff --git a/Sources/Epoxy/CollectionView/ContextMenu/AnyItemModel+ContextMenu.swift b/Sources/Epoxy/CollectionView/ContextMenu/AnyItemModel+ContextMenu.swift index 77c01f6..4521b62 100644 --- a/Sources/Epoxy/CollectionView/ContextMenu/AnyItemModel+ContextMenu.swift +++ b/Sources/Epoxy/CollectionView/ContextMenu/AnyItemModel+ContextMenu.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) && !os(tvOS) && !os(visionOS) import UIKit import EpoxyCollectionView @@ -28,3 +29,4 @@ extension AnyItemModel: RAKInternalItemModeling { return config } } +#endif diff --git a/Sources/Epoxy/CollectionView/ContextMenu/CollectionViewContextMenuDelegate.swift b/Sources/Epoxy/CollectionView/ContextMenu/CollectionViewContextMenuDelegate.swift index 9ee3e7c..aa4bc51 100644 --- a/Sources/Epoxy/CollectionView/ContextMenu/CollectionViewContextMenuDelegate.swift +++ b/Sources/Epoxy/CollectionView/ContextMenu/CollectionViewContextMenuDelegate.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) && !os(tvOS) && !os(visionOS) import UIKit import EpoxyCollectionView @@ -33,3 +34,4 @@ extension CollectionViewContextMenuDelegate { animator _: UIContextMenuInteractionCommitAnimating ) { } } +#endif diff --git a/Sources/Epoxy/CollectionView/ContextMenu/ContextMenuProviding.swift b/Sources/Epoxy/CollectionView/ContextMenu/ContextMenuProviding.swift index 643d3ba..617dd3d 100644 --- a/Sources/Epoxy/CollectionView/ContextMenu/ContextMenuProviding.swift +++ b/Sources/Epoxy/CollectionView/ContextMenu/ContextMenuProviding.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) && !os(tvOS) && !os(visionOS) import UIKit import EpoxyCore @@ -36,3 +37,4 @@ extension CallbackContextEpoxyModeled where Self: ContextMenuProviding { copy(updating: willShowContextMenuProperty, to: value) } } +#endif diff --git a/Sources/Epoxy/CollectionView/ContextMenu/ItemModel+ContextMenu.swift b/Sources/Epoxy/CollectionView/ContextMenu/ItemModel+ContextMenu.swift index 9b6bc46..96170d4 100644 --- a/Sources/Epoxy/CollectionView/ContextMenu/ItemModel+ContextMenu.swift +++ b/Sources/Epoxy/CollectionView/ContextMenu/ItemModel+ContextMenu.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) && !os(tvOS) && !os(visionOS) import UIKit import EpoxyCollectionView @@ -49,3 +50,4 @@ extension ItemModel { return view } } +#endif diff --git a/Sources/Epoxy/CollectionView/ContextMenu/RAKInternalItemModeling.swift b/Sources/Epoxy/CollectionView/ContextMenu/RAKInternalItemModeling.swift index 4a4842a..aedb298 100644 --- a/Sources/Epoxy/CollectionView/ContextMenu/RAKInternalItemModeling.swift +++ b/Sources/Epoxy/CollectionView/ContextMenu/RAKInternalItemModeling.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) && !os(tvOS) && !os(visionOS) import UIKit import EpoxyCollectionView @@ -14,3 +15,4 @@ import EpoxyCollectionView protocol RAKInternalItemModeling: InternalItemModeling { func handleWillShowContextMenu(_ cell: ItemWrapperView, with metadata: ItemCellMetadata) -> UIContextMenuConfiguration? } +#endif diff --git a/Sources/Epoxy/CollectionView/Tools/EpoxyModeled+Padding.swift b/Sources/Epoxy/CollectionView/Tools/EpoxyModeled+Padding.swift index 74e6299..0d916f5 100644 --- a/Sources/Epoxy/CollectionView/Tools/EpoxyModeled+Padding.swift +++ b/Sources/Epoxy/CollectionView/Tools/EpoxyModeled+Padding.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) && !os(visionOS) import UIKit import EpoxyCore @@ -16,3 +17,4 @@ extension EpoxyModeled where Self: PaddingProviding { padding(value.edgeInsets) } } +#endif diff --git a/Sources/Epoxy/Row/BaseStyledEpoxyView.swift b/Sources/Epoxy/Row/BaseStyledEpoxyView.swift index 111e03f..31fea1a 100644 --- a/Sources/Epoxy/Row/BaseStyledEpoxyView.swift +++ b/Sources/Epoxy/Row/BaseStyledEpoxyView.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) && !os(visionOS) import UIKit import EpoxyCore @@ -26,3 +27,4 @@ open class BaseStyledEpoxyView: RAKBase.BaseView, StyledView { fatalError("init(coder:) has not been implemented") } } +#endif diff --git a/Sources/Epoxy/Row/ButtonRow/AnyButtonImageContent.swift b/Sources/Epoxy/Row/ButtonRow/AnyButtonImageContent.swift index de497d4..536822c 100644 --- a/Sources/Epoxy/Row/ButtonRow/AnyButtonImageContent.swift +++ b/Sources/Epoxy/Row/ButtonRow/AnyButtonImageContent.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) import UIKit import RAKCore @@ -57,3 +58,4 @@ extension AnyButtonImageContent: FastImageContentProviding { .init(UIImage(systemName: name, withConfiguration: configuration)) } } +#endif diff --git a/Sources/Epoxy/Row/ButtonRow/ButtonImageContentProviding.swift b/Sources/Epoxy/Row/ButtonRow/ButtonImageContentProviding.swift index cdf0d14..40cb325 100644 --- a/Sources/Epoxy/Row/ButtonRow/ButtonImageContentProviding.swift +++ b/Sources/Epoxy/Row/ButtonRow/ButtonImageContentProviding.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) import UIKit // MARK: - ButtonImageContentProviding @@ -42,3 +43,4 @@ extension String: ButtonImageContentProviding { } } } +#endif diff --git a/Sources/Epoxy/Row/ButtonRow/ButtonRow.swift b/Sources/Epoxy/Row/ButtonRow/ButtonRow.swift index a8fbac6..028dd77 100644 --- a/Sources/Epoxy/Row/ButtonRow/ButtonRow.swift +++ b/Sources/Epoxy/Row/ButtonRow/ButtonRow.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(tvOS) && !os(watchOS) && !os(visionOS) import UIKit import EpoxyCore @@ -126,7 +127,7 @@ extension ButtonRow: StyledView { addTarget(self, action: #selector(buttonDidTouchDown(_:)), for: .touchDown) addTarget(self, action: #selector(buttonDidClick(_:)), for: .touchUpInside) - if #available(iOS 14.0, *) { + if #available(iOS 14.0, tvOS 14.0, *) { addTarget(self, action: #selector(buttonDidTriggerMenuAction(_:)), for: .menuActionTriggered) } } @@ -291,3 +292,4 @@ extension ButtonRow: BehaviorsConfigurableView { } } } +#endif diff --git a/Sources/Epoxy/Row/ButtonRow/ButtonRowStateContent.swift b/Sources/Epoxy/Row/ButtonRow/ButtonRowStateContent.swift index 9be521d..e7ede56 100644 --- a/Sources/Epoxy/Row/ButtonRow/ButtonRowStateContent.swift +++ b/Sources/Epoxy/Row/ButtonRow/ButtonRowStateContent.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) && !os(tvOS) && !os(visionOS) import UIKit import RAKCore @@ -22,3 +23,4 @@ protocol ButtonRowStateContent { titleColor: ConvertibleToColor ) } +#endif diff --git a/Sources/Epoxy/Row/ImageRow/AnyImageContent.swift b/Sources/Epoxy/Row/ImageRow/AnyImageContent.swift index ffc8a68..abd109b 100644 --- a/Sources/Epoxy/Row/ImageRow/AnyImageContent.swift +++ b/Sources/Epoxy/Row/ImageRow/AnyImageContent.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) import UIKit import RAKCore @@ -57,3 +58,4 @@ extension AnyImageContent: FastImageContentProviding { .init(UIImage(systemName: name, withConfiguration: configuration)) } } +#endif diff --git a/Sources/Epoxy/Row/ImageRow/ImageContentProviding.swift b/Sources/Epoxy/Row/ImageRow/ImageContentProviding.swift index 500d5db..515715f 100644 --- a/Sources/Epoxy/Row/ImageRow/ImageContentProviding.swift +++ b/Sources/Epoxy/Row/ImageRow/ImageContentProviding.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) import UIKit // MARK: - ImageContentProviding @@ -42,3 +43,4 @@ extension String: ImageContentProviding { } } } +#endif diff --git a/Sources/Epoxy/Row/ImageRow/ImageRow.swift b/Sources/Epoxy/Row/ImageRow/ImageRow.swift index 4bc0dc9..5af0098 100644 --- a/Sources/Epoxy/Row/ImageRow/ImageRow.swift +++ b/Sources/Epoxy/Row/ImageRow/ImageRow.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) && !os(visionOS) import UIKit import EpoxyCore @@ -117,3 +118,4 @@ extension ImageRow: ContentConfigurableView { // MARK: BehaviorsConfigurableView extension ImageRow: BehaviorsConfigurableView { } +#endif diff --git a/Sources/Epoxy/Row/SwitchRow.swift b/Sources/Epoxy/Row/SwitchRow.swift index eefe62a..8ff9578 100644 --- a/Sources/Epoxy/Row/SwitchRow.swift +++ b/Sources/Epoxy/Row/SwitchRow.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) && !os(tvOS) && !os(visionOS) import UIKit import Combine @@ -128,3 +129,4 @@ extension SwitchRow: BehaviorsConfigurableView { .store(in: &cancellable) } } +#endif diff --git a/Sources/Epoxy/Row/TextFieldRow.swift b/Sources/Epoxy/Row/TextFieldRow.swift index b280473..41254c8 100644 --- a/Sources/Epoxy/Row/TextFieldRow.swift +++ b/Sources/Epoxy/Row/TextFieldRow.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) && !os(tvOS) && !os(visionOS) import UIKit import Combine @@ -198,3 +199,4 @@ extension TextFieldRow: UITextFieldDelegate { textField.resignFirstResponder() } } +#endif diff --git a/Sources/Epoxy/Row/TextRow.swift b/Sources/Epoxy/Row/TextRow.swift index 825fd0a..d6a7ed1 100644 --- a/Sources/Epoxy/Row/TextRow.swift +++ b/Sources/Epoxy/Row/TextRow.swift @@ -6,6 +6,7 @@ // Copyright © 2024 RakuyoKit. All rights reserved. // +#if !os(watchOS) && !os(tvOS) && !os(visionOS) import UIKit import EpoxyCore @@ -103,3 +104,4 @@ extension TextRow: ContentConfigurableView { // MARK: BehaviorsConfigurableView extension TextRow: BehaviorsConfigurableView { } +#endif