react-native-firework-sdk 2.10.1 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/android/gradle.properties +1 -1
  2. package/android/src/main/java/com/fireworksdk/bridge/components/storyblock/StoryBlockFragment.kt +18 -1
  3. package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/FWVideoFeed.kt +4 -0
  4. package/android/src/main/java/com/fireworksdk/bridge/models/FWSDKInitOptionsModel.kt +0 -1
  5. package/android/src/main/java/com/fireworksdk/bridge/models/FWSDKInitOptionsModelDeserializer.kt +0 -3
  6. package/android/src/main/java/com/fireworksdk/bridge/models/FWSDKInitOptionsModelSerializer.kt +0 -2
  7. package/android/src/main/java/com/fireworksdk/bridge/models/FWSdkInitResultModel.kt +6 -0
  8. package/android/src/main/java/com/fireworksdk/bridge/models/FWTrackPurchaseModel.kt +9 -0
  9. package/android/src/main/java/com/fireworksdk/bridge/models/FWTrackPurchaseModelDeserializer.kt +45 -0
  10. package/android/src/main/java/com/fireworksdk/bridge/models/FWTrackPurchaseModelSerializer.kt +34 -0
  11. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedItemDetailsModel.kt +1 -0
  12. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlaybackDetails.kt +1 -0
  13. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerConfigModel.kt +2 -1
  14. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerConfigModelDeserializer.kt +4 -1
  15. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerConfigModelSerializer.kt +2 -0
  16. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerLogoConfigurationModel.kt +8 -0
  17. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerLogoConfigurationModelDeserializer.kt +23 -0
  18. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerLogoConfigurationModelSerializer.kt +18 -0
  19. package/android/src/main/java/com/fireworksdk/bridge/models/enums/FWEventName.kt +2 -0
  20. package/android/src/main/java/com/fireworksdk/bridge/models/enums/FWVideoPlayerLogoOption.kt +19 -0
  21. package/android/src/main/java/com/fireworksdk/bridge/reactnative/FWReactNativeSDK.kt +103 -0
  22. package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWStoryBlockManager.kt +12 -0
  23. package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt +8 -0
  24. package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FireworkSDKInterface.kt +2 -0
  25. package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt +22 -9
  26. package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt +74 -122
  27. package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +34 -9
  28. package/android/src/main/java/com/fireworksdk/bridge/utils/FWConfigUtil.kt +13 -0
  29. package/android/src/main/java/com/fireworksdk/bridge/utils/FWFragmentUtil.kt +3 -3
  30. package/android/src/main/java/com/fireworksdk/bridge/utils/FWGlobalDataUtil.kt +5 -2
  31. package/android/src/main/java/com/fireworksdk/bridge/utils/FWModelUtils.kt +64 -0
  32. package/ios/Components/ReplayBadgeConfiguration.swift +12 -0
  33. package/ios/Components/StoryBlock.swift +31 -0
  34. package/ios/Components/StoryBlockConfiguration.swift +1 -0
  35. package/ios/Components/StoryBlockManager.m +24 -0
  36. package/ios/Components/StoryBlockManager.swift +6 -3
  37. package/ios/Components/VideoFeed.swift +18 -3
  38. package/ios/Components/VideoFeedConfiguration.swift +1 -0
  39. package/ios/Components/VideoFeedManager.m +4 -1
  40. package/ios/Components/VideoFeedManager.swift +6 -3
  41. package/ios/Components/VideoPlayerConfiguration.swift +1 -0
  42. package/ios/FWReactNativeSDK.swift +14 -0
  43. package/ios/FireworkSdk.xcodeproj/project.pbxproj +4 -0
  44. package/ios/Modules/FireworkSDKModule/FireworkSDKModule+CTA.swift +17 -15
  45. package/ios/Modules/FireworkSDKModule/FireworkSDKModule+EventTracking.swift +1 -11
  46. package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +1 -0
  47. package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +80 -81
  48. package/ios/Modules/FireworkSDKModule/SDKInitOptions.swift +9 -5
  49. package/ios/Modules/Shopping/ShoppingModule.swift +10 -74
  50. package/lib/commonjs/FireworkSDK.js +30 -25
  51. package/lib/commonjs/FireworkSDK.js.map +1 -1
  52. package/lib/commonjs/VideoShopping.js +6 -12
  53. package/lib/commonjs/VideoShopping.js.map +1 -1
  54. package/lib/commonjs/components/StoryBlock.js +54 -3
  55. package/lib/commonjs/components/StoryBlock.js.map +1 -1
  56. package/lib/commonjs/components/VideoFeed.js +46 -4
  57. package/lib/commonjs/components/VideoFeed.js.map +1 -1
  58. package/lib/commonjs/index.js.map +1 -1
  59. package/lib/commonjs/models/FWNativeErrorAction.js +14 -0
  60. package/lib/commonjs/models/FWNativeErrorAction.js.map +1 -0
  61. package/lib/commonjs/models/ReplayBadgeConfiguration.js +2 -0
  62. package/lib/commonjs/models/ReplayBadgeConfiguration.js.map +1 -0
  63. package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
  64. package/lib/module/FireworkSDK.js +29 -25
  65. package/lib/module/FireworkSDK.js.map +1 -1
  66. package/lib/module/VideoShopping.js +6 -12
  67. package/lib/module/VideoShopping.js.map +1 -1
  68. package/lib/module/components/StoryBlock.js +53 -3
  69. package/lib/module/components/StoryBlock.js.map +1 -1
  70. package/lib/module/components/VideoFeed.js +42 -4
  71. package/lib/module/components/VideoFeed.js.map +1 -1
  72. package/lib/module/index.js.map +1 -1
  73. package/lib/module/models/FWNativeErrorAction.js +7 -0
  74. package/lib/module/models/FWNativeErrorAction.js.map +1 -0
  75. package/lib/module/models/ReplayBadgeConfiguration.js +2 -0
  76. package/lib/module/models/ReplayBadgeConfiguration.js.map +1 -0
  77. package/lib/module/modules/FireworkSDKModule.js.map +1 -1
  78. package/lib/typescript/VideoShopping.d.ts +2 -2
  79. package/lib/typescript/components/StoryBlock.d.ts +18 -1
  80. package/lib/typescript/components/VideoFeed.d.ts +7 -1
  81. package/lib/typescript/index.d.ts +2 -2
  82. package/lib/typescript/models/FWEvents.d.ts +26 -3
  83. package/lib/typescript/models/FWNativeErrorAction.d.ts +4 -0
  84. package/lib/typescript/models/FeedItemDetails.d.ts +6 -1
  85. package/lib/typescript/models/ReplayBadgeConfiguration.d.ts +7 -0
  86. package/lib/typescript/models/StoryBlockConfiguration.d.ts +6 -1
  87. package/lib/typescript/models/VideoFeedConfiguration.d.ts +6 -0
  88. package/lib/typescript/models/VideoPlayerConfiguration.d.ts +6 -1
  89. package/lib/typescript/modules/FireworkSDKModule.d.ts +1 -0
  90. package/package.json +1 -5
  91. package/react-native-firework-sdk.podspec +3 -5
  92. package/src/FireworkSDK.ts +27 -24
  93. package/src/VideoShopping.ts +9 -11
  94. package/src/components/StoryBlock.tsx +69 -7
  95. package/src/components/VideoFeed.tsx +57 -12
  96. package/src/index.ts +2 -0
  97. package/src/models/FWEvents.ts +28 -3
  98. package/src/models/FWNativeErrorAction.ts +4 -0
  99. package/src/models/FeedItemDetails.ts +7 -1
  100. package/src/models/ReplayBadgeConfiguration.ts +7 -0
  101. package/src/models/StoryBlockConfiguration.ts +6 -1
  102. package/src/models/VideoFeedConfiguration.ts +6 -0
  103. package/src/models/VideoPlayerConfiguration.ts +6 -1
  104. package/src/modules/FireworkSDKModule.ts +1 -0
  105. package/FireworkVideoUI.xcframework/Info.plist +0 -40
  106. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/FireworkVideoUI +0 -0
  107. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Headers/FireworkVideoUI-Swift.h +0 -280
  108. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Headers/FireworkVideoUI.h +0 -18
  109. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Info.plist +0 -0
  110. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios.abi.json +0 -1313
  111. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios.private.swiftinterface +0 -42
  112. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  113. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios.swiftinterface +0 -42
  114. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/module.modulemap +0 -11
  115. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/FireworkVideoUI +0 -0
  116. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Headers/FireworkVideoUI-Swift.h +0 -556
  117. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Headers/FireworkVideoUI.h +0 -18
  118. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Info.plist +0 -0
  119. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.abi.json +0 -1313
  120. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +0 -42
  121. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  122. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.swiftinterface +0 -42
  123. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/x86_64-apple-ios-simulator.abi.json +0 -1313
  124. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +0 -42
  125. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  126. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +0 -42
  127. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/module.modulemap +0 -11
  128. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/_CodeSignature/CodeResources +0 -245
  129. package/ios/FireworkVideoUI/FireworkVideoUI/FireworkVideoUI.docc/FireworkVideoUI.md +0 -13
  130. package/ios/FireworkVideoUI/FireworkVideoUI/FireworkVideoUI.h +0 -18
  131. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/AppLanguageManager.swift +0 -154
  132. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/Foundation/Bundle+AppLanguage.swift +0 -73
  133. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/Foundation/NumberFormatter+AppLanguage.swift +0 -25
  134. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/Foundation/URLSession+AppLanguage.swift +0 -52
  135. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UIImageView+AppLanguage.swift +0 -60
  136. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UILabel+AppLanguage.swift +0 -98
  137. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UITextField+AppLanguage.swift +0 -97
  138. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UITextView+AppLanguage.swift +0 -97
  139. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UIView+AppLanguage.swift +0 -71
  140. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UIViewController+AppLanguage.swift +0 -48
  141. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UIWindow+AppLanguage.swift +0 -26
  142. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/LanguageUtil.swift +0 -43
  143. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/Extensions/Foundation/NSObject+LayoutFlip.swift +0 -42
  144. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/Extensions/UIKit/CALayer+LayoutFlip.swift +0 -149
  145. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/Extensions/UIKit/UILabel+LayoutFlip.swift +0 -35
  146. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/Extensions/UIKit/UIView+LayoutFlip.swift +0 -202
  147. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/LayoutFlipManager.swift +0 -59
  148. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/Utils/Extensions/Foundation/DispatchQueue+Once.swift +0 -32
  149. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/Utils/Extensions/Foundation/String+Base64.swift +0 -18
  150. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/Utils/Extensions/UIKit/UIView+UIHierarchy.swift +0 -46
  151. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/Utils/Swizzle.swift +0 -37
  152. package/ios/FireworkVideoUI/FireworkVideoUI.xcodeproj/project.pbxproj +0 -766
  153. package/ios/FireworkVideoUI/FireworkVideoUI.xcworkspace/contents.xcworkspacedata +0 -10
  154. package/ios/FireworkVideoUI/FireworkVideoUI.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  155. package/ios/FireworkVideoUI/FireworkVideoUITests/FireworkVideoUITests.swift +0 -37
  156. package/ios/FireworkVideoUI/Podfile +0 -15
  157. package/ios/FireworkVideoUI/Podfile.lock +0 -16
  158. package/ios/scripts/react_native_firework_sdk_pods.rb +0 -27
@@ -1,149 +0,0 @@
1
- //
2
- // CALayer+LayoutFlip.swift
3
- //
4
- // Created by linjie jiang on 4/25/23.
5
- //
6
-
7
- import UIKit
8
-
9
- extension CALayer {
10
- private struct AssociatedKeys {
11
- static var basicTransform = "basicTransform"
12
- static var isRenderStartLayer = "isRenderStartLayer"
13
- static var affineTransform = "affineTransform"
14
- }
15
-
16
- static func swizzleLayerMethodsForLayoutFlip() {
17
- Swizzle.swizzleSelector(
18
- cls: self,
19
- originalSelector: #selector(CALayer.setAffineTransform(_:)),
20
- customSelector: #selector(CALayer.fw_setAffineTransform(_:)))
21
- Swizzle.swizzleSelector(
22
- cls: self,
23
- originalSelector: #selector(CALayer.affineTransform),
24
- customSelector: #selector(CALayer.fw_affineTransform))
25
- Swizzle.swizzleSelector(
26
- cls: self,
27
- originalSelector: #selector(CALayer.add(_:forKey:)),
28
- customSelector: #selector(CALayer.fw_add(_:forKey:)))
29
- Swizzle.swizzleSelector(
30
- cls: self,
31
- originalSelector: #selector(CALayer.render(in:)),
32
- customSelector: #selector(CALayer.fw_render(in:)))
33
- }
34
-
35
- var basicTransform: CGAffineTransform {
36
- get {
37
- let result = objc_getAssociatedObject(self, &AssociatedKeys.basicTransform) as? NSValue
38
-
39
- return result?.cgAffineTransformValue ?? CGAffineTransformIdentity
40
- }
41
-
42
- set {
43
- let newBasicTransformValue = NSValue(cgAffineTransform: newValue)
44
- if (objc_getAssociatedObject(self, &AssociatedKeys.basicTransform) as? NSValue)
45
- == newBasicTransformValue {
46
- return
47
- }
48
-
49
- let currentAffineTransform = self.affineTransform()
50
- objc_setAssociatedObject(
51
- self,
52
- &AssociatedKeys.basicTransform,
53
- newBasicTransformValue,
54
- .OBJC_ASSOCIATION_RETAIN_NONATOMIC
55
- )
56
- self.setAffineTransform(currentAffineTransform)
57
- }
58
- }
59
-
60
- var isRenderStartLayer: Bool {
61
- get {
62
- let result = objc_getAssociatedObject(self, &AssociatedKeys.isRenderStartLayer) as? Bool
63
- return result ?? false
64
- }
65
-
66
- set {
67
- objc_setAssociatedObject(
68
- self,
69
- &AssociatedKeys.isRenderStartLayer,
70
- newValue,
71
- .OBJC_ASSOCIATION_RETAIN_NONATOMIC
72
- )
73
- }
74
- }
75
-
76
- @objc func fw_setAffineTransform(_ affineTransform: CGAffineTransform) {
77
- if objc_getAssociatedObject(self, &AssociatedKeys.basicTransform) != nil {
78
- objc_setAssociatedObject(
79
- self,
80
- &AssociatedKeys.affineTransform,
81
- NSValue(cgAffineTransform: affineTransform),
82
- .OBJC_ASSOCIATION_RETAIN_NONATOMIC
83
- )
84
- fw_setAffineTransform(CGAffineTransformConcat(basicTransform, affineTransform))
85
- } else {
86
- fw_setAffineTransform(affineTransform)
87
- }
88
- }
89
-
90
- @objc func fw_affineTransform() -> CGAffineTransform {
91
- if objc_getAssociatedObject(self, &AssociatedKeys.basicTransform) != nil {
92
- if let value = objc_getAssociatedObject(self, &AssociatedKeys.affineTransform) as? NSValue {
93
- return value.cgAffineTransformValue
94
- }
95
- return fw_affineTransform()
96
- } else {
97
- return fw_affineTransform()
98
- }
99
- }
100
-
101
- @objc func fw_add(_ anim: CAAnimation, forKey key: String?) {
102
- if objc_getAssociatedObject(self, &AssociatedKeys.basicTransform) != nil,
103
- let basicAnim = anim as? CABasicAnimation,
104
- let keyPath = basicAnim.keyPath,
105
- keyPath.starts(with: "transform.scale"),
106
- self.basicTransform.a == -1,
107
- let fromValue = basicAnim.fromValue as? Double,
108
- let toValue = basicAnim.toValue as? Double {
109
- basicAnim.fromValue = fromValue * -1
110
- basicAnim.toValue = toValue * -1
111
- }
112
-
113
- fw_add(anim, forKey: key)
114
- }
115
-
116
- @objc func fw_render(in ctx: CGContext) {
117
- if objc_getAssociatedObject(self, &AssociatedKeys.basicTransform) != nil {
118
- var isRenderStartLayer = true
119
- var allSuperLayerTransform = basicTransform
120
- var layer = self
121
- while let superlayer = layer.superlayer {
122
- layer = superlayer
123
- if layer.isRenderStartLayer {
124
- isRenderStartLayer = false
125
- break
126
- }
127
- allSuperLayerTransform = CGAffineTransformConcat(layer.basicTransform, allSuperLayerTransform)
128
- }
129
-
130
- if isRenderStartLayer {
131
- self.isRenderStartLayer = true
132
- if allSuperLayerTransform.a == -1 {
133
- ctx.saveGState()
134
- ctx.concatenate(CGAffineTransformMakeScale(-1, 1))
135
- ctx.translateBy(x: -self.bounds.size.width, y: 0)
136
- }
137
- }
138
- fw_render(in: ctx)
139
- if isRenderStartLayer {
140
- self.isRenderStartLayer = false
141
- if allSuperLayerTransform.a == -1 {
142
- ctx.restoreGState()
143
- }
144
- }
145
- } else {
146
- fw_render(in: ctx)
147
- }
148
- }
149
- }
@@ -1,35 +0,0 @@
1
- //
2
- // UILabel+LayoutFlip.swift
3
- //
4
- // Created by linjie jiang on 4/25/23.
5
- //
6
-
7
- import UIKit
8
-
9
- private let gNoUseClasses: [String] = [
10
- "VUlUZXh0RmllbGRMYWJlbA==".decodeBase64String() // UITextFieldLabel
11
- ]
12
- private let gSuperviewNoUseClasses: [String] = [
13
- "VUlEYXRlUGlja2VyQ29udGVudFZpZXc=".decodeBase64String() // UIDatePickerContentView
14
- ]
15
-
16
- extension UILabel {
17
- func shouldUseCalculatedTextAlignment() -> Bool {
18
- for className in gNoUseClasses {
19
- if let cls = NSClassFromString(className),
20
- self.isKind(of: cls) {
21
- return false
22
- }
23
- }
24
-
25
- for className in gSuperviewNoUseClasses {
26
- if let cls = NSClassFromString(className),
27
- let superview = superview,
28
- superview.isKind(of: cls) {
29
- return false
30
- }
31
- }
32
-
33
- return true
34
- }
35
- }
@@ -1,202 +0,0 @@
1
- //
2
- // UIView+LayoutFlip.swift
3
- //
4
- // Created by linjie jiang on 4/25/23.
5
- //
6
-
7
- import UIKit
8
- import WebKit
9
-
10
- private let gNoFlipClasses: [Any] = [
11
- UILabel.self,
12
- UITextView.self,
13
- UITextField.self,
14
- WKWebView.self,
15
- UIImageView.self,
16
- UISearchBar.self,
17
- "PUPhotosSectionHeaderContentView",
18
- "UITableViewIndex",
19
- "UIWebView",
20
- "X1VJUmVtb3RlVmlldw==".decodeBase64String(), // _UIRemoteView
21
- "VUlBdXRvY29ycmVjdFRleHRWaWV3".decodeBase64String() // UIAutocorrectTextView
22
- ]
23
-
24
- enum LayoutFlipViewType: Int {
25
- case auto
26
- case inherit
27
- case normal
28
- case flip
29
- case normalWithAllDescendants
30
- case flipWithAllDescendants
31
- }
32
-
33
- extension UIView {
34
- private struct AssociatedKeys {
35
- static var viewType = "viewType"
36
- static var calculatedViewType = "calculatedViewType"
37
- static var lastType = "lastType"
38
- }
39
-
40
- static func swizzleViewMethodsForLayoutFlip() {
41
- Swizzle.swizzleSelector(
42
- cls: self,
43
- originalSelector: #selector(UIView.didMoveToSuperview),
44
- customSelector: #selector(UIView.fw_didMoveToSuperview))
45
- Swizzle.swizzleSelector(
46
- cls: self,
47
- originalSelector: #selector(UIView.didMoveToWindow),
48
- customSelector: #selector(UIView.fw_didMoveToWindow))
49
- Swizzle.swizzleSelector(
50
- cls: self,
51
- originalSelector: #selector(UIView.snapshotView(afterScreenUpdates:)),
52
- customSelector: #selector(UIView.fw_snapshotView(afterScreenUpdates:)))
53
- }
54
-
55
- var viewType: LayoutFlipViewType {
56
- get {
57
- let rawValue = objc_getAssociatedObject(self, &AssociatedKeys.viewType) as? Int ?? 0
58
- let type = LayoutFlipViewType(rawValue: rawValue) ?? .auto
59
-
60
- return type
61
- }
62
-
63
- set {
64
- if viewType == newValue {
65
- return
66
- }
67
-
68
- objc_setAssociatedObject(
69
- self,
70
- &AssociatedKeys.viewType,
71
- newValue.rawValue,
72
- .OBJC_ASSOCIATION_RETAIN_NONATOMIC
73
- )
74
- renewLayerTransformForceRecursively(false)
75
- }
76
- }
77
-
78
- private(set) var calculatedViewType: LayoutFlipViewType {
79
- get {
80
- let rawValue = objc_getAssociatedObject(self, &AssociatedKeys.calculatedViewType) as? Int ?? 0
81
- var type = LayoutFlipViewType(rawValue: rawValue) ?? .auto
82
- if type == .auto {
83
- if self.window != nil {
84
- updateCalculatedViewType()
85
- let newRawValue = objc_getAssociatedObject(self, &AssociatedKeys.calculatedViewType) as? Int ?? 0
86
- type = LayoutFlipViewType(rawValue: newRawValue) ?? .auto
87
- } else {
88
- type = .normal
89
- }
90
- }
91
-
92
- return type
93
- }
94
-
95
- set {
96
- objc_setAssociatedObject(
97
- self,
98
- &AssociatedKeys.calculatedViewType,
99
- newValue.rawValue,
100
- .OBJC_ASSOCIATION_RETAIN_NONATOMIC
101
- )
102
- }
103
- }
104
-
105
- private var lastType: LayoutFlipViewType {
106
- get {
107
- let rawValue = objc_getAssociatedObject(self, &AssociatedKeys.lastType) as? Int ?? 0
108
- let type = LayoutFlipViewType(rawValue: rawValue) ?? .auto
109
-
110
- return type
111
- }
112
-
113
- set {
114
- objc_setAssociatedObject(
115
- self,
116
- &AssociatedKeys.lastType,
117
- newValue.rawValue,
118
- .OBJC_ASSOCIATION_RETAIN_NONATOMIC
119
- )
120
- }
121
- }
122
-
123
- @objc func fw_didMoveToSuperview() {
124
- fw_didMoveToSuperview()
125
- renewLayerTransformForceRecursively(false)
126
- }
127
-
128
- @objc func fw_didMoveToWindow() {
129
- fw_didMoveToWindow()
130
- renewLayerTransformForceRecursively(false)
131
- LayoutFlipManager.shared.registerUIElement(self)
132
- }
133
-
134
- @objc func fw_snapshotView(afterScreenUpdates afterUpdates: Bool) -> UIView? {
135
- let view = fw_snapshotView(afterScreenUpdates: afterUpdates)
136
- view?.viewType = calculatedViewType
137
- return view
138
- }
139
-
140
- func renewLayerTransformForceRecursively(_ forceRecursively: Bool) {
141
- if !isIOSSDKView {
142
- return
143
- }
144
- updateCalculatedViewType()
145
- let updatedViewType = calculatedViewType
146
- let superViewCalculatedViewType = superview?.calculatedViewType ?? .auto
147
- let shouldFlipCurrentView = updatedViewType == .flip || updatedViewType == .flipWithAllDescendants
148
- let shouldFlipSuperview = superViewCalculatedViewType == .flip
149
- || superViewCalculatedViewType == .flipWithAllDescendants
150
-
151
- let shouldSetFlipTransform = shouldFlipSuperview != shouldFlipCurrentView
152
-
153
- if shouldSetFlipTransform && LayoutFlipManager.shared.enableHorizontalFlip {
154
- layer.basicTransform = CGAffineTransformMakeScale(-1, 1)
155
- } else {
156
- layer.basicTransform = CGAffineTransformIdentity
157
- }
158
-
159
- if updatedViewType != lastType || forceRecursively {
160
- for subView in subviews {
161
- subView.renewLayerTransformForceRecursively(forceRecursively)
162
- }
163
- }
164
-
165
- lastType = updatedViewType
166
- }
167
-
168
- private func automaticViewType() -> LayoutFlipViewType {
169
- if self is UIWindow {
170
- return .normal
171
- }
172
-
173
- for element in gNoFlipClasses {
174
- if let cls = element as? AnyClass,
175
- self.isKind(of: cls) {
176
- return .normal
177
-
178
- } else if let className = element as? String,
179
- let cls = NSClassFromString(className),
180
- self.isKind(of: cls) {
181
- return .normal
182
- }
183
- }
184
-
185
- return superview != nil ? .inherit : .normal
186
- }
187
-
188
- private func updateCalculatedViewType() {
189
- var resultCalculatedViewType = viewType
190
- if resultCalculatedViewType == .auto {
191
- resultCalculatedViewType = automaticViewType()
192
- }
193
- let superViewCalculatedViewType = superview?.calculatedViewType ?? .auto
194
- if superViewCalculatedViewType == .flipWithAllDescendants
195
- || superViewCalculatedViewType == .normalWithAllDescendants
196
- || resultCalculatedViewType == .inherit {
197
- calculatedViewType = superViewCalculatedViewType
198
- } else {
199
- calculatedViewType = resultCalculatedViewType
200
- }
201
- }
202
- }
@@ -1,59 +0,0 @@
1
- //
2
- // LayoutFlipManager.swift
3
- //
4
- // Created by linjie jiang on 4/25/23.
5
- //
6
-
7
- import UIKit
8
-
9
- class LayoutFlipManager {
10
- static let shared = LayoutFlipManager()
11
-
12
- static func swizzelMethods() {
13
- DispatchQueue.once {
14
- UIView.swizzleViewMethodsForLayoutFlip()
15
- CALayer.swizzleLayerMethodsForLayoutFlip()
16
- }
17
- }
18
-
19
- var enableHorizontalFlip: Bool = false {
20
- didSet {
21
- if enableHorizontalFlip == oldValue {
22
- return
23
- }
24
-
25
- var rootViews: Set<UIView> = Set()
26
- for element in registeredUIElements.allObjects {
27
- element.performReload()
28
-
29
- if element.window != nil && element.window != element {
30
- continue
31
- }
32
- rootViews.insert(rootViewForView(element))
33
- }
34
-
35
- for rootView in rootViews {
36
- rootView.renewLayerTransformForceRecursively(true)
37
- }
38
- }
39
- }
40
-
41
- private var registeredUIElements: NSHashTable<UIView> = NSHashTable.weakObjects()
42
-
43
- func registerUIElement(_ element: UIView) {
44
- self.registeredUIElements.add(element)
45
- }
46
-
47
- private func rootViewForView(_ view: UIView) -> UIView {
48
- if let window = view.window {
49
- return window
50
- }
51
-
52
- var rootView: UIView = view
53
- while let superview = rootView.superview {
54
- rootView = superview
55
- }
56
-
57
- return rootView
58
- }
59
- }
@@ -1,32 +0,0 @@
1
- //
2
- // DispatchQueue+Once.swift
3
- //
4
- // Created by Jeff Zheng on 2022/3/1.
5
- //
6
-
7
- import Foundation
8
-
9
- public extension DispatchQueue {
10
- private static var _onceContainer = [String]()
11
-
12
- /// Execute a block only once.
13
- class func once(
14
- file: String = #file, function: String = #function, line: Int = #line, block: () -> Void
15
- ) {
16
- let token = file + ":" + function + ":" + String(line)
17
- once(token: token, block: block)
18
- }
19
-
20
- /// Execute a block only once.
21
- class func once(token: String, block: () -> Void) {
22
- objc_sync_enter(self)
23
- defer { objc_sync_exit(self) }
24
-
25
- guard !_onceContainer.contains(token) else {
26
- return
27
- }
28
-
29
- _onceContainer.append(token)
30
- block()
31
- }
32
- }
@@ -1,18 +0,0 @@
1
- //
2
- // String+Base64.swift
3
- //
4
- // Created by linjie jiang on 4/25/23.
5
- //
6
-
7
- import Foundation
8
-
9
- extension String {
10
- func decodeBase64String() -> String {
11
- if let decodedData = Data(base64Encoded: self),
12
- let decodedString = String(data: decodedData, encoding: .utf8) {
13
- return decodedString
14
- }
15
-
16
- return ""
17
- }
18
- }
@@ -1,46 +0,0 @@
1
- //
2
- // UIView+UIHierarchy.swift
3
- //
4
- // Created by Jeff Zheng on 2021/12/22.
5
- //
6
-
7
- import UIKit
8
- import FireworkVideo
9
-
10
- public extension UIView {
11
- var parentViewController: UIViewController? {
12
- var parentResponder: UIResponder? = self
13
- while parentResponder != nil {
14
- parentResponder = parentResponder!.next
15
- if let viewController = parentResponder as? UIViewController {
16
- return viewController
17
- }
18
- }
19
-
20
- return nil
21
- }
22
-
23
- var isIOSSDKView: Bool {
24
- guard self.window != nil else {
25
- return false
26
- }
27
- guard let parentVC = self.parentViewController else {
28
- return false
29
- }
30
- let iOSSDKBundle = Bundle(for: FireworkVideoSDK.self)
31
-
32
- if iOSSDKBundle == Bundle(for: type(of: parentVC)) {
33
- return true
34
- }
35
-
36
- var ancestorVC = parentVC.parent
37
- while ancestorVC != nil {
38
- if iOSSDKBundle == Bundle(for: type(of: ancestorVC!)) {
39
- return true
40
- }
41
- ancestorVC = ancestorVC!.parent
42
- }
43
-
44
- return false
45
- }
46
- }
@@ -1,37 +0,0 @@
1
- //
2
- // Swizzle.swift
3
- //
4
- // Created by linjie jiang on 2023/2/7.
5
- //
6
-
7
- import Foundation
8
-
9
- public class Swizzle {
10
- public static func swizzleSelector(cls: AnyClass, originalSelector: Selector, customSelector: Selector) {
11
- guard let originalMethod = class_getInstanceMethod(cls, originalSelector) else { return }
12
- guard let customMethod = class_getInstanceMethod(cls, customSelector) else { return }
13
-
14
- if class_addMethod(
15
- cls,
16
- originalSelector,
17
- method_getImplementation(customMethod),
18
- method_getTypeEncoding(customMethod)
19
- ) {
20
- class_replaceMethod(
21
- cls,
22
- customSelector,
23
- method_getImplementation(originalMethod),
24
- method_getTypeEncoding(originalMethod)
25
- )
26
- } else {
27
- method_exchangeImplementations(originalMethod, customMethod)
28
- }
29
- }
30
-
31
- public static func swizzleClassSelector(cls: AnyClass, originalSelector: Selector, customSelector: Selector) {
32
- guard let originalMethod = class_getClassMethod(cls, originalSelector) else { return }
33
- guard let customMethod = class_getClassMethod(cls, customSelector) else { return }
34
-
35
- method_exchangeImplementations(originalMethod, customMethod)
36
- }
37
- }