react-native-firework-sdk 2.1.0 → 2.2.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.
- package/FireworkVideoUI.xcframework/Info.plist +40 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/FireworkVideoUI +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Headers/FireworkVideoUI-Swift.h +280 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Headers/FireworkVideoUI.h +18 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Info.plist +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios.abi.json +1327 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios.private.swiftinterface +41 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios.swiftinterface +41 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/module.modulemap +11 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/FireworkVideoUI +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Headers/FireworkVideoUI-Swift.h +556 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Headers/FireworkVideoUI.h +18 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Info.plist +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.abi.json +1327 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +41 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.swiftinterface +41 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/x86_64-apple-ios-simulator.abi.json +1327 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +41 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +41 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/module.modulemap +11 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/_CodeSignature/CodeResources +245 -0
- package/README.md +1 -1
- package/android/build.gradle +1 -2
- package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/FWVideoFeed.kt +6 -0
- package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/StoryBlockFrameLayout.kt +6 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWAdBadgeConfigModelDeserializer.kt +3 -3
- package/android/src/main/java/com/fireworksdk/bridge/models/FWEventName.kt +3 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWFontInfoModelDeserializer.kt +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/models/FWProductInfoViewConfigurationDeserializer.kt +10 -6
- package/android/src/main/java/com/fireworksdk/bridge/models/FWSDKInitOptionsModelDeserializer.kt +3 -3
- package/android/src/main/java/com/fireworksdk/bridge/models/FWShoppingCtaResultDeserializer.kt +2 -2
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedConfigModelDeserializer.kt +14 -12
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedPropsModel.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedPropsModelDeserializer.kt +11 -7
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedSource.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlaybackDetails.kt +8 -8
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerConfigModel.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerConfigModelDeserializer.kt +19 -12
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoShoppingProductDeserializer.kt +11 -11
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWStoryBlockManager.kt +5 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt +5 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWLiveStreamModule.kt +45 -4
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt +2 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt +112 -36
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +7 -4
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWConfigUtil.kt +26 -32
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWGlobalDataUtil.kt +6 -0
- package/ios/Components/StoryBlock.swift +5 -6
- package/ios/Components/StoryBlockManager.m +1 -0
- package/ios/Components/StoryBlockManager.swift +4 -0
- package/ios/Components/VideoFeed.swift +12 -8
- package/ios/Components/VideoFeedManager.m +1 -0
- package/ios/Components/VideoFeedManager.swift +4 -0
- package/ios/Components/VideoPlayerConfiguration.swift +1 -0
- package/ios/FireworkSdk.xcodeproj/project.pbxproj +261 -471
- package/ios/FireworkVideoUI/FireworkVideoUI/FireworkVideoUI.docc/FireworkVideoUI.md +13 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/FireworkVideoUI.h +18 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/AppLanguageManager.swift +147 -0
- package/ios/{Utils/AppLanguage/Bundle+FWSwizzle.swift → FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/Foundation/Bundle+AppLanguage.swift} +7 -7
- package/ios/{Utils/AppLanguage/NumberFormatter+FWSwizzle.swift → FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/Foundation/NumberFormatter+AppLanguage.swift} +5 -5
- package/ios/{Utils/AppLanguage/URLSession+FWSwizzle.swift → FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/Foundation/URLSession+AppLanguage.swift} +7 -7
- package/ios/{Utils/AppLanguage/UIImageView+FWSwizzle.swift → FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UIImageView+AppLanguage.swift} +8 -8
- package/ios/{Utils/AppLanguage/UILabel+FWSwizzle.swift → FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UILabel+AppLanguage.swift} +17 -17
- package/ios/{Utils/AppLanguage/UITextField+FWSwizzle.swift → FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UITextField+AppLanguage.swift} +16 -16
- package/ios/{Utils/AppLanguage/UITextView+FWSwizzle.swift → FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UITextView+AppLanguage.swift} +16 -16
- package/ios/{Utils/AppLanguage/UIView+FWSwizzle.swift → FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UIView+AppLanguage.swift} +7 -7
- package/ios/{Utils/AppLanguage/UIViewController+FWSwizzle.swift → FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UIViewController+AppLanguage.swift} +19 -5
- package/ios/{Utils/AppLanguage/UIWindow+FWSwizzle.swift → FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UIWindow+AppLanguage.swift} +5 -5
- package/ios/{Utils/AppLanguage/FWLanguageUtil.swift → FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/LanguageUtil.swift} +4 -4
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/Extensions/Foundation/NSObject+LayoutFlip.swift +42 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/Extensions/UIKit/CALayer+LayoutFlip.swift +160 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/Extensions/UIKit/UILabel+LayoutFlip.swift +35 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/Extensions/UIKit/UIView+LayoutFlip.swift +199 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/LayoutFlipManager.swift +59 -0
- package/ios/{Utils/Extensions/DispatchQueue+FWOnce.swift → FireworkVideoUI/FireworkVideoUI/Sources/Utils/Extensions/Foundation/DispatchQueue+Once.swift} +4 -4
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/Utils/Extensions/Foundation/String+Base64.swift +18 -0
- package/ios/{Utils/Extensions/UIView+FWUIHierarchy.swift → FireworkVideoUI/FireworkVideoUI/Sources/Utils/Extensions/UIKit/UIView+UIHierarchy.swift} +4 -5
- package/ios/{Utils/FWSwizzleUtil.swift → FireworkVideoUI/FireworkVideoUI/Sources/Utils/Swizzle.swift} +2 -2
- package/ios/FireworkVideoUI/FireworkVideoUI.xcodeproj/project.pbxproj +766 -0
- package/ios/FireworkVideoUI/FireworkVideoUI.xcworkspace/contents.xcworkspacedata +10 -0
- package/ios/FireworkVideoUI/FireworkVideoUI.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/FireworkVideoUI/FireworkVideoUITests/FireworkVideoUITests.swift +37 -0
- package/ios/FireworkVideoUI/Podfile +15 -0
- package/ios/FireworkVideoUI/Podfile.lock +16 -0
- package/ios/Models/NativeToRN/FireworkEventName.swift +4 -0
- package/ios/Models/NativeToRN/FireworkSDK+Json.swift +5 -1
- package/ios/Models/RNToNative/RCTConvert+StoryBlock.swift +2 -1
- package/ios/Models/RNToNative/RCTConvert+VideoFeed.swift +2 -1
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +8 -100
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule+EventTracking.swift +34 -16
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +23 -7
- package/ios/Modules/FireworkSDKModule/SDKInitOptions.swift +0 -1
- package/ios/Modules/LiveStream/LiveStreamModule.swift +1 -0
- package/ios/Modules/Shopping/ProductInfoViewConfiguration.swift +0 -8
- package/ios/Modules/Shopping/ShoppingModule.swift +0 -18
- package/ios/Support/MultiHostStreaming/FWMultiHostStreaming.podspec +4 -6
- package/ios/Utils/Extensions/Swizzle/UINavigationController+FWSwizzle.swift +4 -1
- package/ios/scripts/react_native_firework_sdk_pods.rb +22 -26
- package/lib/commonjs/FireworkSDK.js +40 -17
- package/lib/commonjs/FireworkSDK.js.map +1 -1
- package/lib/commonjs/LiveStream.js +2 -2
- package/lib/commonjs/LiveStream.js.map +1 -1
- package/lib/commonjs/VideoShopping.js +1 -1
- package/lib/commonjs/VideoShopping.js.map +1 -1
- package/lib/commonjs/components/StoryBlock.js +9 -9
- package/lib/commonjs/components/StoryBlock.js.map +1 -1
- package/lib/commonjs/components/VideoFeed.js +6 -4
- package/lib/commonjs/components/VideoFeed.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/FWEventName.js +1 -0
- package/lib/commonjs/models/FWEventName.js.map +1 -1
- package/lib/commonjs/models/VideoPlaybackEventName.js +3 -0
- package/lib/commonjs/models/VideoPlaybackEventName.js.map +1 -1
- package/lib/module/FireworkSDK.js +39 -17
- package/lib/module/FireworkSDK.js.map +1 -1
- package/lib/module/LiveStream.js +2 -2
- package/lib/module/LiveStream.js.map +1 -1
- package/lib/module/VideoShopping.js +1 -1
- package/lib/module/VideoShopping.js.map +1 -1
- package/lib/module/components/StoryBlock.js +9 -7
- package/lib/module/components/StoryBlock.js.map +1 -1
- package/lib/module/components/VideoFeed.js +6 -4
- package/lib/module/components/VideoFeed.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/FWEventName.js +1 -0
- package/lib/module/models/FWEventName.js.map +1 -1
- package/lib/module/models/VideoPlaybackEventName.js +3 -0
- package/lib/module/models/VideoPlaybackEventName.js.map +1 -1
- package/lib/typescript/FireworkSDK.d.ts +8 -4
- package/lib/typescript/LiveStream.d.ts +2 -2
- package/lib/typescript/VideoShopping.d.ts +1 -1
- package/lib/typescript/components/StoryBlock.d.ts +7 -0
- package/lib/typescript/components/VideoFeed.d.ts +7 -0
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/models/FWEventName.d.ts +1 -0
- package/lib/typescript/models/ProductInfoViewConfiguration.d.ts +0 -31
- package/lib/typescript/models/SDKInitOptions.d.ts +6 -1
- package/lib/typescript/models/StoryBlockSource.d.ts +1 -1
- package/lib/typescript/models/VideoFeedSource.d.ts +1 -1
- package/lib/typescript/models/VideoPlaybackDetails.d.ts +16 -0
- package/lib/typescript/models/VideoPlaybackEventName.d.ts +13 -1
- package/lib/typescript/models/VideoPlayerConfiguration.d.ts +4 -0
- package/package.json +7 -2
- package/react-native-firework-sdk.podspec +10 -5
- package/src/FireworkSDK.ts +41 -15
- package/src/LiveStream.ts +2 -2
- package/src/VideoShopping.ts +1 -1
- package/src/components/StoryBlock.tsx +12 -3
- package/src/components/VideoFeed.tsx +12 -4
- package/src/index.ts +0 -2
- package/src/models/FWEventName.ts +1 -0
- package/src/models/ProductInfoViewConfiguration.ts +0 -32
- package/src/models/SDKInitOptions.ts +6 -1
- package/src/models/StoryBlockSource.ts +2 -1
- package/src/models/VideoFeedSource.ts +2 -1
- package/src/models/VideoPlaybackDetails.ts +16 -0
- package/src/models/VideoPlaybackEventName.ts +13 -1
- package/src/models/VideoPlayerConfiguration.ts +4 -0
- package/ios/Utils/AppLanguage/FWAppLanguageManager.swift +0 -139
- package/ios/Utils/FWRTL/Classes/Manager/FWRTLManager.h +0 -25
- package/ios/Utils/FWRTL/Classes/Manager/FWRTLManager.m +0 -75
- package/ios/Utils/FWRTL/Classes/UICategories/CALayer+FWRTL.h +0 -21
- package/ios/Utils/FWRTL/Classes/UICategories/CALayer+FWRTL.m +0 -124
- package/ios/Utils/FWRTL/Classes/UICategories/FWRTLRemoteViewControllerAdaptor.h +0 -11
- package/ios/Utils/FWRTL/Classes/UICategories/FWRTLRemoteViewControllerAdaptor.m +0 -86
- package/ios/Utils/FWRTL/Classes/UICategories/FWRTLWhiteListManager.h +0 -16
- package/ios/Utils/FWRTL/Classes/UICategories/FWRTLWhiteListManager.m +0 -55
- package/ios/Utils/FWRTL/Classes/UICategories/UILabel+FWRTL.h +0 -18
- package/ios/Utils/FWRTL/Classes/UICategories/UILabel+FWRTL.m +0 -39
- package/ios/Utils/FWRTL/Classes/UICategories/UIView+FWRTL.h +0 -54
- package/ios/Utils/FWRTL/Classes/UICategories/UIView+FWRTL.m +0 -141
- package/ios/Utils/FWRTL/Classes/UICategories/UIWindow+FWRTL.h +0 -16
- package/ios/Utils/FWRTL/Classes/UICategories/UIWindow+FWRTL.m +0 -20
- package/ios/Utils/FWRTL/Classes/Utils/FWRTLDefinitions.h +0 -52
- package/ios/Utils/FWRTL/Classes/Utils/NSObject+FWRTLReloadBlock.h +0 -19
- package/ios/Utils/FWRTL/Classes/Utils/NSObject+FWRTLReloadBlock.m +0 -49
- package/ios/Utils/FWRTL/Classes/Utils/NSString+FWRTL.h +0 -21
- package/ios/Utils/FWRTL/Classes/Utils/NSString+FWRTL.m +0 -38
- package/ios/Utils/FWRTL/Classes/Utils/UIImage+FWRTL.h +0 -18
- package/ios/Utils/FWRTL/Classes/Utils/UIImage+FWRTL.m +0 -43
- /package/ios/Support/MultiHostStreaming/{src → Sources}/MultiHostStreamingSDK.swift +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// UIViewController+
|
|
2
|
+
// UIViewController+AppLanguage.swift
|
|
3
3
|
//
|
|
4
4
|
// Created by linjie jiang on 2023/2/21.
|
|
5
5
|
//
|
|
@@ -8,12 +8,18 @@ import UIKit
|
|
|
8
8
|
import FireworkVideo
|
|
9
9
|
|
|
10
10
|
extension UIViewController {
|
|
11
|
-
static func
|
|
12
|
-
|
|
11
|
+
static func swizzleViewControllerMethodsForAppLanguage() {
|
|
12
|
+
Swizzle.swizzleSelector(
|
|
13
13
|
cls: self,
|
|
14
14
|
originalSelector: #selector(UIViewController.present(_:animated:completion:)),
|
|
15
15
|
customSelector: #selector(UIViewController.fw_present(_:animated:completion:))
|
|
16
16
|
)
|
|
17
|
+
|
|
18
|
+
Swizzle.swizzleSelector(
|
|
19
|
+
cls: self,
|
|
20
|
+
originalSelector: #selector(UIViewController.viewDidLoad),
|
|
21
|
+
customSelector: #selector(UIViewController.fw_viewDidLoad)
|
|
22
|
+
)
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
@objc func fw_present(
|
|
@@ -23,10 +29,18 @@ extension UIViewController {
|
|
|
23
29
|
) {
|
|
24
30
|
let iOSSDKBundle = Bundle(for: FireworkVideoSDK.self)
|
|
25
31
|
let viewControllerToPresentBundle = Bundle(for: type(of: viewControllerToPresent))
|
|
26
|
-
if
|
|
32
|
+
if AppLanguageManager.shared.shouldHorizontalFlip,
|
|
27
33
|
viewControllerToPresentBundle == iOSSDKBundle {
|
|
28
|
-
viewControllerToPresent.view.
|
|
34
|
+
viewControllerToPresent.view.viewType = .flip
|
|
29
35
|
}
|
|
30
36
|
fw_present(viewControllerToPresent, animated: flag, completion: completion)
|
|
31
37
|
}
|
|
38
|
+
|
|
39
|
+
@objc func fw_viewDidLoad() {
|
|
40
|
+
fw_viewDidLoad()
|
|
41
|
+
if self is StoryBlockViewController
|
|
42
|
+
|| self is VideoFeedViewController {
|
|
43
|
+
self.view.viewType = .flip
|
|
44
|
+
}
|
|
45
|
+
}
|
|
32
46
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// UIWindow+
|
|
2
|
+
// UIWindow+AppLanguage.swift
|
|
3
3
|
//
|
|
4
4
|
// Created by linjie jiang on 2023/2/24.
|
|
5
5
|
//
|
|
@@ -8,8 +8,8 @@ import UIKit
|
|
|
8
8
|
import FireworkVideo
|
|
9
9
|
|
|
10
10
|
extension UIWindow {
|
|
11
|
-
static func
|
|
12
|
-
|
|
11
|
+
static func swizzleWindowMethodsForAppLanguage() {
|
|
12
|
+
Swizzle.swizzleSelector(cls: self,
|
|
13
13
|
originalSelector: #selector(setter: UIWindow.rootViewController),
|
|
14
14
|
customSelector: #selector(UIWindow.fw_setRootViewController(_:)))
|
|
15
15
|
}
|
|
@@ -17,10 +17,10 @@ extension UIWindow {
|
|
|
17
17
|
@objc func fw_setRootViewController(_ rootViewController: UIViewController?) {
|
|
18
18
|
fw_setRootViewController(rootViewController)
|
|
19
19
|
let iOSSDKBundle = Bundle(for: FireworkVideoSDK.self)
|
|
20
|
-
if
|
|
20
|
+
if AppLanguageManager.shared.shouldHorizontalFlip,
|
|
21
21
|
let viewController = rootViewController,
|
|
22
22
|
Bundle(for: type(of: viewController)) == iOSSDKBundle {
|
|
23
|
-
viewController.view.
|
|
23
|
+
viewController.view.viewType = .flip
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// LanguageUtil.swift
|
|
3
3
|
//
|
|
4
4
|
// Created by linjie jiang on 2023/2/9.
|
|
5
5
|
//
|
|
6
6
|
|
|
7
7
|
import Foundation
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
class LanguageUtil {
|
|
10
|
+
static func getLanguageCode(_ language: String) -> String? {
|
|
11
11
|
guard language.count > 0 else {
|
|
12
12
|
return nil
|
|
13
13
|
}
|
|
@@ -25,7 +25,7 @@ public class FWLanguageUtil {
|
|
|
25
25
|
return languageCode.lowercased()
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
static func isValidLanguage(_ language: String?) -> Bool {
|
|
29
29
|
guard let language = language else {
|
|
30
30
|
return false
|
|
31
31
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//
|
|
2
|
+
// NSObject+LayoutFlip.swift
|
|
3
|
+
//
|
|
4
|
+
// Created by linjie jiang on 4/25/23.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
|
|
9
|
+
typealias ReloadClosure = () -> Void
|
|
10
|
+
|
|
11
|
+
extension NSObject {
|
|
12
|
+
private struct AssociatedKeys {
|
|
13
|
+
static var reloadClosures = "reloadBlocks"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
private var reloadClosures: [String: ReloadClosure] {
|
|
17
|
+
get {
|
|
18
|
+
let result = objc_getAssociatedObject(self, &AssociatedKeys.reloadClosures) as? [String: ReloadClosure]
|
|
19
|
+
return result ?? [:]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
set {
|
|
23
|
+
objc_setAssociatedObject(
|
|
24
|
+
self,
|
|
25
|
+
&AssociatedKeys.reloadClosures,
|
|
26
|
+
newValue,
|
|
27
|
+
.OBJC_ASSOCIATION_RETAIN_NONATOMIC
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
func performReload() {
|
|
33
|
+
for (_, closure) in reloadClosures {
|
|
34
|
+
closure()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
func addReloadClosure(key: String, reloadClosure: @escaping ReloadClosure) {
|
|
39
|
+
reloadClosures[key] = reloadClosure
|
|
40
|
+
reloadClosure()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
//
|
|
2
|
+
// CALayer+LayoutFlip.swift
|
|
3
|
+
//
|
|
4
|
+
// Created by linjie jiang on 4/25/23.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import UIKit
|
|
8
|
+
|
|
9
|
+
private var gHasEnabledHorizontalFlip = false
|
|
10
|
+
|
|
11
|
+
extension CALayer {
|
|
12
|
+
private struct AssociatedKeys {
|
|
13
|
+
static var basicTransform = "basicTransform"
|
|
14
|
+
static var isRenderStartLayer = "isRenderStartLayer"
|
|
15
|
+
static var affineTransform = "affineTransform"
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static func swizzleLayerMethodsForLayoutFlip() {
|
|
19
|
+
Swizzle.swizzleSelector(
|
|
20
|
+
cls: self,
|
|
21
|
+
originalSelector: #selector(CALayer.setAffineTransform(_:)),
|
|
22
|
+
customSelector: #selector(CALayer.fw_setAffineTransform(_:)))
|
|
23
|
+
Swizzle.swizzleSelector(
|
|
24
|
+
cls: self,
|
|
25
|
+
originalSelector: #selector(CALayer.affineTransform),
|
|
26
|
+
customSelector: #selector(CALayer.fw_affineTransform))
|
|
27
|
+
Swizzle.swizzleSelector(
|
|
28
|
+
cls: self,
|
|
29
|
+
originalSelector: #selector(CALayer.add(_:forKey:)),
|
|
30
|
+
customSelector: #selector(CALayer.fw_add(_:forKey:)))
|
|
31
|
+
Swizzle.swizzleSelector(
|
|
32
|
+
cls: self,
|
|
33
|
+
originalSelector: #selector(CALayer.render(in:)),
|
|
34
|
+
customSelector: #selector(CALayer.fw_render(in:)))
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var basicTransform: CGAffineTransform {
|
|
38
|
+
get {
|
|
39
|
+
let result = objc_getAssociatedObject(self, &AssociatedKeys.basicTransform) as? NSValue
|
|
40
|
+
|
|
41
|
+
return result?.cgAffineTransformValue ?? CGAffineTransformIdentity
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
set {
|
|
45
|
+
if objc_getAssociatedObject(self, &AssociatedKeys.basicTransform) == nil,
|
|
46
|
+
CGAffineTransformIsIdentity(newValue) {
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
objc_setAssociatedObject(
|
|
51
|
+
self,
|
|
52
|
+
&AssociatedKeys.basicTransform,
|
|
53
|
+
NSValue(cgAffineTransform: newValue),
|
|
54
|
+
.OBJC_ASSOCIATION_RETAIN_NONATOMIC
|
|
55
|
+
)
|
|
56
|
+
self.setAffineTransform(self.affineTransform())
|
|
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.basicTransform,
|
|
70
|
+
newValue,
|
|
71
|
+
.OBJC_ASSOCIATION_RETAIN_NONATOMIC
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@objc func fw_setAffineTransform(_ affineTransform: CGAffineTransform) {
|
|
77
|
+
if !gHasEnabledHorizontalFlip && LayoutFlipManager.shared.enableHorizontalFlip {
|
|
78
|
+
gHasEnabledHorizontalFlip = true
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if gHasEnabledHorizontalFlip {
|
|
82
|
+
objc_setAssociatedObject(
|
|
83
|
+
self,
|
|
84
|
+
&AssociatedKeys.affineTransform,
|
|
85
|
+
NSValue(cgAffineTransform: affineTransform),
|
|
86
|
+
.OBJC_ASSOCIATION_RETAIN_NONATOMIC
|
|
87
|
+
)
|
|
88
|
+
fw_setAffineTransform(CGAffineTransformConcat(basicTransform, affineTransform))
|
|
89
|
+
} else {
|
|
90
|
+
fw_setAffineTransform(affineTransform)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@objc func fw_affineTransform() -> CGAffineTransform {
|
|
95
|
+
if !gHasEnabledHorizontalFlip && LayoutFlipManager.shared.enableHorizontalFlip {
|
|
96
|
+
gHasEnabledHorizontalFlip = true
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if gHasEnabledHorizontalFlip {
|
|
100
|
+
if let value = objc_getAssociatedObject(self, &AssociatedKeys.affineTransform) as? NSValue {
|
|
101
|
+
return value.cgAffineTransformValue
|
|
102
|
+
}
|
|
103
|
+
return fw_affineTransform()
|
|
104
|
+
} else {
|
|
105
|
+
return fw_affineTransform()
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@objc func fw_add(_ anim: CAAnimation, forKey key: String?) {
|
|
110
|
+
if let basicAnim = anim as? CABasicAnimation,
|
|
111
|
+
let keyPath = basicAnim.keyPath,
|
|
112
|
+
keyPath.starts(with: "transform.scale"),
|
|
113
|
+
self.basicTransform.a == -1,
|
|
114
|
+
let fromValue = basicAnim.fromValue as? Double,
|
|
115
|
+
let toValue = basicAnim.toValue as? Double {
|
|
116
|
+
basicAnim.fromValue = fromValue * -1
|
|
117
|
+
basicAnim.toValue = toValue * -1
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
fw_add(anim, forKey: key)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@objc func fw_render(in ctx: CGContext) {
|
|
124
|
+
if !gHasEnabledHorizontalFlip && LayoutFlipManager.shared.enableHorizontalFlip {
|
|
125
|
+
gHasEnabledHorizontalFlip = true
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if gHasEnabledHorizontalFlip {
|
|
129
|
+
var isRenderStartLayer = true
|
|
130
|
+
var allSuperLayerTransform = basicTransform
|
|
131
|
+
var layer = self
|
|
132
|
+
while let superlayer = layer.superlayer {
|
|
133
|
+
layer = superlayer
|
|
134
|
+
if layer.isRenderStartLayer {
|
|
135
|
+
isRenderStartLayer = false
|
|
136
|
+
break
|
|
137
|
+
}
|
|
138
|
+
allSuperLayerTransform = CGAffineTransformConcat(layer.basicTransform, allSuperLayerTransform)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if isRenderStartLayer {
|
|
142
|
+
self.isRenderStartLayer = true
|
|
143
|
+
if allSuperLayerTransform.a == -1 {
|
|
144
|
+
ctx.saveGState()
|
|
145
|
+
ctx.concatenate(CGAffineTransformMakeScale(-1, 1))
|
|
146
|
+
ctx.translateBy(x: -self.bounds.size.width, y: 0)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
fw_render(in: ctx)
|
|
150
|
+
if isRenderStartLayer {
|
|
151
|
+
self.isRenderStartLayer = false
|
|
152
|
+
if allSuperLayerTransform.a == -1 {
|
|
153
|
+
ctx.restoreGState()
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
fw_render(in: ctx)
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
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
|
+
updateCalculatedViewType()
|
|
142
|
+
let updatedViewType = calculatedViewType
|
|
143
|
+
let superViewCalculatedViewType = superview?.calculatedViewType ?? .auto
|
|
144
|
+
let shouldFlipCurrentView = updatedViewType == .flip || updatedViewType == .flipWithAllDescendants
|
|
145
|
+
let shouldFlipSuperview = superViewCalculatedViewType == .flip
|
|
146
|
+
|| superViewCalculatedViewType == .flipWithAllDescendants
|
|
147
|
+
|
|
148
|
+
let shouldSetFlipTransform = shouldFlipSuperview != shouldFlipCurrentView
|
|
149
|
+
|
|
150
|
+
if shouldSetFlipTransform && LayoutFlipManager.shared.enableHorizontalFlip {
|
|
151
|
+
layer.basicTransform = CGAffineTransformMakeScale(-1, 1)
|
|
152
|
+
} else {
|
|
153
|
+
layer.basicTransform = CGAffineTransformIdentity
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if updatedViewType != lastType || forceRecursively {
|
|
157
|
+
for subView in subviews {
|
|
158
|
+
subView.renewLayerTransformForceRecursively(forceRecursively)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
lastType = updatedViewType
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
private func automaticViewType() -> LayoutFlipViewType {
|
|
166
|
+
if self is UIWindow {
|
|
167
|
+
return .normal
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
for element in gNoFlipClasses {
|
|
171
|
+
if let cls = element as? AnyClass,
|
|
172
|
+
self.isKind(of: cls) {
|
|
173
|
+
return .normal
|
|
174
|
+
|
|
175
|
+
} else if let className = element as? String,
|
|
176
|
+
let cls = NSClassFromString(className),
|
|
177
|
+
self.isKind(of: cls) {
|
|
178
|
+
return .normal
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return superview != nil ? .inherit : .normal
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
private func updateCalculatedViewType() {
|
|
186
|
+
var resultCalculatedViewType = viewType
|
|
187
|
+
if resultCalculatedViewType == .auto {
|
|
188
|
+
resultCalculatedViewType = automaticViewType()
|
|
189
|
+
}
|
|
190
|
+
let superViewCalculatedViewType = superview?.calculatedViewType ?? .auto
|
|
191
|
+
if superViewCalculatedViewType == .flipWithAllDescendants
|
|
192
|
+
|| superViewCalculatedViewType == .normalWithAllDescendants
|
|
193
|
+
|| resultCalculatedViewType == .inherit {
|
|
194
|
+
calculatedViewType = superViewCalculatedViewType
|
|
195
|
+
} else {
|
|
196
|
+
calculatedViewType = resultCalculatedViewType
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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,16 +1,16 @@
|
|
|
1
1
|
//
|
|
2
|
-
// DispatchQueue+
|
|
2
|
+
// DispatchQueue+Once.swift
|
|
3
3
|
//
|
|
4
4
|
// Created by Jeff Zheng on 2022/3/1.
|
|
5
5
|
//
|
|
6
6
|
|
|
7
7
|
import Foundation
|
|
8
8
|
|
|
9
|
-
extension DispatchQueue {
|
|
9
|
+
public extension DispatchQueue {
|
|
10
10
|
private static var _onceContainer = [String]()
|
|
11
11
|
|
|
12
12
|
/// Execute a block only once.
|
|
13
|
-
|
|
13
|
+
class func once(
|
|
14
14
|
file: String = #file, function: String = #function, line: Int = #line, block: () -> Void
|
|
15
15
|
) {
|
|
16
16
|
let token = file + ":" + function + ":" + String(line)
|
|
@@ -18,7 +18,7 @@ extension DispatchQueue {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/// Execute a block only once.
|
|
21
|
-
|
|
21
|
+
class func once(token: String, block: () -> Void) {
|
|
22
22
|
objc_sync_enter(self)
|
|
23
23
|
defer { objc_sync_exit(self) }
|
|
24
24
|
|
package/ios/FireworkVideoUI/FireworkVideoUI/Sources/Utils/Extensions/Foundation/String+Base64.swift
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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,6 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
3
|
-
// react-native-firework-sdk
|
|
2
|
+
// UIView+UIHierarchy.swift
|
|
4
3
|
//
|
|
5
4
|
// Created by Jeff Zheng on 2021/12/22.
|
|
6
5
|
//
|
|
@@ -8,8 +7,8 @@
|
|
|
8
7
|
import UIKit
|
|
9
8
|
import FireworkVideo
|
|
10
9
|
|
|
11
|
-
extension UIView {
|
|
12
|
-
var
|
|
10
|
+
public extension UIView {
|
|
11
|
+
var parentViewController: UIViewController? {
|
|
13
12
|
var parentResponder: UIResponder? = self
|
|
14
13
|
while parentResponder != nil {
|
|
15
14
|
parentResponder = parentResponder!.next
|
|
@@ -25,7 +24,7 @@ extension UIView {
|
|
|
25
24
|
guard self.window != nil else {
|
|
26
25
|
return false
|
|
27
26
|
}
|
|
28
|
-
guard let parentVC = self.
|
|
27
|
+
guard let parentVC = self.parentViewController else {
|
|
29
28
|
return false
|
|
30
29
|
}
|
|
31
30
|
let iOSSDKBundle = Bundle(for: FireworkVideoSDK.self)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// Swizzle.swift
|
|
3
3
|
//
|
|
4
4
|
// Created by linjie jiang on 2023/2/7.
|
|
5
5
|
//
|
|
6
6
|
|
|
7
7
|
import Foundation
|
|
8
8
|
|
|
9
|
-
public class
|
|
9
|
+
public class Swizzle {
|
|
10
10
|
public static func swizzleSelector(cls: AnyClass, originalSelector: Selector, customSelector: Selector) {
|
|
11
11
|
guard let originalMethod = class_getInstanceMethod(cls, originalSelector) else { return }
|
|
12
12
|
guard let customMethod = class_getInstanceMethod(cls, customSelector) else { return }
|