From 4ad9072e802dabba001bfd16dc4e0aa9dec7aa98 Mon Sep 17 00:00:00 2001 From: Jayden Date: Thu, 23 May 2024 18:58:00 +0800 Subject: [PATCH 1/2] Bug fix: CPS-830 --- .../Extensions/UIKit/UIView+AppLanguage.swift | 47 ++++++++++--------- .../Extensions/UIKit/UIView+LayoutFlip.swift | 9 ++++ 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/Sources/FireworkVideoUI/AppLanguage/Extensions/UIKit/UIView+AppLanguage.swift b/Sources/FireworkVideoUI/AppLanguage/Extensions/UIKit/UIView+AppLanguage.swift index 914642e..7f733ba 100644 --- a/Sources/FireworkVideoUI/AppLanguage/Extensions/UIKit/UIView+AppLanguage.swift +++ b/Sources/FireworkVideoUI/AppLanguage/Extensions/UIKit/UIView+AppLanguage.swift @@ -64,31 +64,32 @@ extension UIView { view.viewType = .normal } + let swiftUIImageLayerClassName = "SW1hZ2VMYXllcg==".decodeBase64String() + let swiftUITextLayerClassName = "Q0dEcmF3aW5nTGF5ZXI=".decodeBase64String() + let layerClassName = String(describing: type(of: self.layer)) + + if AppLanguageManager.shared.shouldHorizontalFlip, + layerClassName == swiftUITextLayerClassName || + layerClassName == swiftUIImageLayerClassName { + view.viewType = .normal + } + DispatchQueue.main.async { - if AppLanguageManager.shared.shouldHorizontalFlip { - let swiftUIImageLayerClassName = "SW1hZ2VMYXllcg==".decodeBase64String() - let swiftUITextLayerClassName = "Q0dEcmF3aW5nTGF5ZXI=".decodeBase64String() - let layerClassName = String(describing: type(of: self.layer)) - if layerClassName == swiftUITextLayerClassName { - view.viewType = .normal - } else if layerClassName == swiftUIImageLayerClassName { - var resultViewType = LayoutFlipViewType.normal - if let contents = self.layer.contents as? CFTypeRef, - CFGetTypeID(contents) == CGImage.typeID { - let image = self.layer.contents as! CGImage - for imageName in gNamesOfImagesWithDirection { - let imageWithDirection = UIImage( - named: imageName, - in: Bundle(for: FireworkVideoSDK.self), - compatibleWith: nil - )?.cgImage - if image == imageWithDirection { - resultViewType = .flip - break - } - } + if AppLanguageManager.shared.shouldHorizontalFlip, + layerClassName == swiftUIImageLayerClassName, + let contents = self.layer.contents as? CFTypeRef, + CFGetTypeID(contents) == CGImage.typeID { + let image = self.layer.contents as! CGImage + for imageName in gNamesOfImagesWithDirection { + let imageWithDirection = UIImage( + named: imageName, + in: Bundle(for: FireworkVideoSDK.self), + compatibleWith: nil + )?.cgImage + if image == imageWithDirection { + view.viewType = .flip + break } - view.viewType = resultViewType } } diff --git a/Sources/FireworkVideoUI/LayoutFlip/Extensions/UIKit/UIView+LayoutFlip.swift b/Sources/FireworkVideoUI/LayoutFlip/Extensions/UIKit/UIView+LayoutFlip.swift index e459aea..a7fb95f 100644 --- a/Sources/FireworkVideoUI/LayoutFlip/Extensions/UIKit/UIView+LayoutFlip.swift +++ b/Sources/FireworkVideoUI/LayoutFlip/Extensions/UIKit/UIView+LayoutFlip.swift @@ -50,6 +50,10 @@ extension UIView { cls: self, originalSelector: #selector(UIView.snapshotView(afterScreenUpdates:)), customSelector: #selector(UIView.fw_snapshotView(afterScreenUpdates:))) + Swizzle.swizzleSelector( + cls: self, + originalSelector: #selector(UIView.layoutSubviews), + customSelector: #selector(UIView.fw_layoutSubviews)) } var viewType: LayoutFlipViewType { @@ -137,6 +141,11 @@ extension UIView { return view } + @objc func fw_layoutSubviews() { + fw_layoutSubviews() + renewLayerTransformForceRecursively(false) + } + func renewLayerTransformForceRecursively(_ forceRecursively: Bool) { if !isIOSSDKView { return From ae785996a44f637950d33794408c4b9a563a2497 Mon Sep 17 00:00:00 2001 From: Jayden Date: Thu, 23 May 2024 19:03:03 +0800 Subject: [PATCH 2/2] Update FireworkVideoUI.podspec --- FireworkVideoUI.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FireworkVideoUI.podspec b/FireworkVideoUI.podspec index 8fbf8dd..e4ea145 100644 --- a/FireworkVideoUI.podspec +++ b/FireworkVideoUI.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'FireworkVideoUI' - s.version = '0.1.1' + s.version = '0.1.2' s.summary = 'An extension library meant to provide easier interfaces for the FireworkVideoSDK.' s.homepage = 'https://github.com/loopsocial/firework_ios_sdk_ui_extensions' s.license = 'Apache License, Version 2.0'