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
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# ``FireworkVideoUI``
|
|
2
|
+
|
|
3
|
+
<!--@START_MENU_TOKEN@-->Summary<!--@END_MENU_TOKEN@-->
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
<!--@START_MENU_TOKEN@-->Text<!--@END_MENU_TOKEN@-->
|
|
8
|
+
|
|
9
|
+
## Topics
|
|
10
|
+
|
|
11
|
+
### <!--@START_MENU_TOKEN@-->Group<!--@END_MENU_TOKEN@-->
|
|
12
|
+
|
|
13
|
+
- <!--@START_MENU_TOKEN@-->``Symbol``<!--@END_MENU_TOKEN@-->
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// FireworkVideoUI.h
|
|
3
|
+
// FireworkVideoUI
|
|
4
|
+
//
|
|
5
|
+
// Created by linjie jiang on 4/25/23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
|
|
10
|
+
//! Project version number for FireworkVideoUI.
|
|
11
|
+
FOUNDATION_EXPORT double FireworkVideoUIVersionNumber;
|
|
12
|
+
|
|
13
|
+
//! Project version string for FireworkVideoUI.
|
|
14
|
+
FOUNDATION_EXPORT const unsigned char FireworkVideoUIVersionString[];
|
|
15
|
+
|
|
16
|
+
// In this header, you should import all the public headers of your framework using statements like #import <FireworkVideoUI/PublicHeader.h>
|
|
17
|
+
|
|
18
|
+
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AppLanguageManager.swift
|
|
3
|
+
//
|
|
4
|
+
// Created by linjie jiang on 2023/2/7.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import UIKit
|
|
8
|
+
|
|
9
|
+
private let appLanguageStorageKey = "firework_sdk_app_language_storage_key"
|
|
10
|
+
|
|
11
|
+
enum AppLanguageLayoutDirection: Int {
|
|
12
|
+
case ltr, rtl, unsupported
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/// The manager of supporting app language
|
|
16
|
+
public class AppLanguageManager {
|
|
17
|
+
public struct NotificationName {
|
|
18
|
+
/// The notification name for language change
|
|
19
|
+
public static let AppLanguageChanged = Notification.Name(
|
|
20
|
+
rawValue: "firework.notification.name.appLanguageChanged"
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public static let shared = AppLanguageManager()
|
|
25
|
+
|
|
26
|
+
var systemLanguage: String?
|
|
27
|
+
private var systemLanguageCode: String? {
|
|
28
|
+
guard let language = systemLanguage else {
|
|
29
|
+
return nil
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return LanguageUtil.getLanguageCode(language)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/// Get current app language.
|
|
36
|
+
public private(set) var appLanguage: String? {
|
|
37
|
+
didSet {
|
|
38
|
+
if appLanguage != nil {
|
|
39
|
+
AppLanguageManager.swizzelMethods()
|
|
40
|
+
LayoutFlipManager.shared.enableHorizontalFlip = shouldHorizontalFlip
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if appLanguage != oldValue {
|
|
44
|
+
NotificationCenter.default.post(name: NotificationName.AppLanguageChanged, object: nil)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var appLanguageCode: String? {
|
|
50
|
+
guard let language = appLanguage else {
|
|
51
|
+
return nil
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return LanguageUtil.getLanguageCode(language)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var appLanguageLayoutDirection: AppLanguageLayoutDirection? {
|
|
58
|
+
guard let languageCode = appLanguageCode else {
|
|
59
|
+
return nil
|
|
60
|
+
}
|
|
61
|
+
let direction = Locale.characterDirection(forLanguage: languageCode)
|
|
62
|
+
switch direction {
|
|
63
|
+
case .leftToRight:
|
|
64
|
+
return .ltr
|
|
65
|
+
case .rightToLeft:
|
|
66
|
+
return .rtl
|
|
67
|
+
default:
|
|
68
|
+
return .unsupported
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
var shouldHorizontalFlip: Bool {
|
|
73
|
+
guard let appLanguageCode = appLanguageCode else {
|
|
74
|
+
return false
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
guard let systemLanguageCode = systemLanguageCode else {
|
|
78
|
+
return false
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let appLanguageDirection = Locale.characterDirection(forLanguage: appLanguageCode)
|
|
82
|
+
let systemLanguageDirection = Locale.characterDirection(forLanguage: systemLanguageCode)
|
|
83
|
+
|
|
84
|
+
if appLanguageDirection == .leftToRight, systemLanguageDirection == .rightToLeft {
|
|
85
|
+
return true
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if appLanguageDirection == .rightToLeft, systemLanguageDirection == .leftToRight {
|
|
89
|
+
return true
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return false
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private static func swizzelMethods() {
|
|
96
|
+
DispatchQueue.once {
|
|
97
|
+
UIViewController.swizzleViewControllerMethodsForAppLanguage()
|
|
98
|
+
Bundle.swizzleBundleMethodsForAppLanguage()
|
|
99
|
+
URLSession.swizzleURLSessionMethodsForAppLanguage()
|
|
100
|
+
NumberFormatter.swizzleNumberFormatterMethodsForAppLanguage()
|
|
101
|
+
UIImageView.swizzleImageViewMethodsForAppLanguage()
|
|
102
|
+
UILabel.swizzleLabelMethodsForAppLanguage()
|
|
103
|
+
UITextField.swizzleTextFieldMethodsForAppLanguage()
|
|
104
|
+
UITextView.swizzleTextViewMethodsForAppLanguage()
|
|
105
|
+
UIWindow.swizzleWindowMethodsForAppLanguage()
|
|
106
|
+
UIView.swizzleViewMethodsForAppLanguage()
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
LayoutFlipManager.swizzelMethods()
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private init() {
|
|
113
|
+
initializeManager()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private func initializeManager() {
|
|
117
|
+
self.systemLanguage = Locale.preferredLanguages.first
|
|
118
|
+
let cachedAppLanguage = UserDefaults.standard.object(forKey: appLanguageStorageKey) as? String
|
|
119
|
+
if LanguageUtil.isValidLanguage(cachedAppLanguage) {
|
|
120
|
+
self.appLanguage = cachedAppLanguage
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/// Change app language
|
|
125
|
+
///
|
|
126
|
+
/// - Parameters:
|
|
127
|
+
/// - language: app language. We will use system langauge when language is nil.
|
|
128
|
+
/// - Returns: The result of changing app language.
|
|
129
|
+
@discardableResult
|
|
130
|
+
public func changeAppLanguage(_ language: String?) -> Bool {
|
|
131
|
+
guard let language = language, language.count > 0 else {
|
|
132
|
+
appLanguage = nil
|
|
133
|
+
UserDefaults.standard.removeObject(forKey: appLanguageStorageKey)
|
|
134
|
+
UserDefaults.standard.synchronize()
|
|
135
|
+
return true
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if LanguageUtil.isValidLanguage(language) {
|
|
139
|
+
appLanguage = language
|
|
140
|
+
UserDefaults.standard.set(language, forKey: appLanguageStorageKey)
|
|
141
|
+
UserDefaults.standard.synchronize()
|
|
142
|
+
return true
|
|
143
|
+
} else {
|
|
144
|
+
return false
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Bundle+
|
|
2
|
+
// Bundle+AppLanguage.swift
|
|
3
3
|
//
|
|
4
4
|
// Created by linjie jiang on 2023/2/7.
|
|
5
5
|
//
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
import Foundation
|
|
8
8
|
import FireworkVideo
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
static func
|
|
12
|
-
|
|
10
|
+
extension Bundle {
|
|
11
|
+
static func swizzleBundleMethodsForAppLanguage() {
|
|
12
|
+
Swizzle.swizzleSelector(
|
|
13
13
|
cls: self,
|
|
14
14
|
originalSelector: #selector(Bundle.localizedString(forKey:value:table:)),
|
|
15
15
|
customSelector: #selector(Bundle.fw_localizedString(forKey:value:table:)))
|
|
@@ -20,8 +20,8 @@ public extension Bundle {
|
|
|
20
20
|
value: String?,
|
|
21
21
|
table tableName: String?
|
|
22
22
|
) -> String {
|
|
23
|
-
if let language =
|
|
24
|
-
let languageCode =
|
|
23
|
+
if let language = AppLanguageManager.shared.appLanguage,
|
|
24
|
+
let languageCode = AppLanguageManager.shared.appLanguageCode,
|
|
25
25
|
Bundle(for: FireworkVideoSDK.self) == self {
|
|
26
26
|
let iOSSDKBundle = Bundle(for: FireworkVideoSDK.self)
|
|
27
27
|
|
|
@@ -38,7 +38,7 @@ public extension Bundle {
|
|
|
38
38
|
return item != "Base" && item != "en"
|
|
39
39
|
}
|
|
40
40
|
if let targeLanguage = targeLanguageList.first(where: { item in
|
|
41
|
-
let targeLanguageCode =
|
|
41
|
+
let targeLanguageCode = LanguageUtil.getLanguageCode(item)
|
|
42
42
|
return languageCode == targeLanguageCode
|
|
43
43
|
}) {
|
|
44
44
|
languageBundlePath = iOSSDKBundle.path(forResource: targeLanguage, ofType: "lproj")
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
//
|
|
2
|
-
// NumberFormatter+
|
|
2
|
+
// NumberFormatter+AppLanguage.swift
|
|
3
3
|
//
|
|
4
4
|
// Created by linjie jiang on 2023/2/20.
|
|
5
5
|
//
|
|
6
6
|
|
|
7
7
|
import Foundation
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
static func
|
|
11
|
-
|
|
9
|
+
extension NumberFormatter {
|
|
10
|
+
static func swizzleNumberFormatterMethodsForAppLanguage() {
|
|
11
|
+
Swizzle.swizzleSelector(
|
|
12
12
|
cls: self,
|
|
13
13
|
originalSelector: #selector(NumberFormatter.string(from:)),
|
|
14
14
|
customSelector: #selector(NumberFormatter.fw_string(from:)))
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
@objc func fw_string(from number: NSNumber) -> String? {
|
|
18
|
-
if let language =
|
|
18
|
+
if let language = AppLanguageManager.shared.appLanguage,
|
|
19
19
|
self.numberStyle == .currency {
|
|
20
20
|
self.locale = Locale(identifier: language)
|
|
21
21
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// URLSession+
|
|
2
|
+
// URLSession+AppLanguage.swift
|
|
3
3
|
//
|
|
4
4
|
// Created by linjie jiang on 2023/2/20.
|
|
5
5
|
//
|
|
@@ -11,19 +11,19 @@ private var FWHostList: [String] = [
|
|
|
11
11
|
"p2.fwpixel.com"
|
|
12
12
|
]
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
static func
|
|
14
|
+
extension URLSession {
|
|
15
|
+
static func swizzleURLSessionMethodsForAppLanguage() {
|
|
16
16
|
// swiftlint:disable:next line_length
|
|
17
17
|
let orginalSelector1 = #selector(URLSession.dataTask(with:completionHandler:) as (URLSession) -> (URLRequest, @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask)
|
|
18
18
|
let customSelector1 = #selector(URLSession.fw_dataTask(with:completionHandler:))
|
|
19
|
-
|
|
19
|
+
Swizzle.swizzleSelector(
|
|
20
20
|
cls: self,
|
|
21
21
|
originalSelector: orginalSelector1,
|
|
22
22
|
customSelector: customSelector1)
|
|
23
23
|
// swiftlint:disable:next line_length
|
|
24
24
|
let orginalSelector2 = #selector(URLSession.dataTask(with:) as (URLSession) -> (URLRequest) -> URLSessionDataTask)
|
|
25
25
|
let customSelector2 = #selector(URLSession.fw_dataTask(with:))
|
|
26
|
-
|
|
26
|
+
Swizzle.swizzleSelector(
|
|
27
27
|
cls: self,
|
|
28
28
|
originalSelector: orginalSelector2,
|
|
29
29
|
customSelector: customSelector2)
|
|
@@ -52,8 +52,8 @@ public extension URLSession {
|
|
|
52
52
|
host = request.url?.host ?? ""
|
|
53
53
|
#endif
|
|
54
54
|
|
|
55
|
-
if let language =
|
|
56
|
-
let languageCode =
|
|
55
|
+
if let language = AppLanguageManager.shared.appLanguage,
|
|
56
|
+
let languageCode = AppLanguageManager.shared.appLanguageCode,
|
|
57
57
|
FWHostList.contains(host) {
|
|
58
58
|
var mutableRequest = request
|
|
59
59
|
if language != languageCode {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// UIImageView+
|
|
2
|
+
// UIImageView+AppLanguage.swift
|
|
3
3
|
//
|
|
4
4
|
// Created by linjie jiang on 2023/2/22.
|
|
5
5
|
//
|
|
@@ -16,17 +16,17 @@ private let FWImageNamesWithDirections: [String] = [
|
|
|
16
16
|
]
|
|
17
17
|
|
|
18
18
|
extension UIImageView {
|
|
19
|
-
static func
|
|
20
|
-
|
|
19
|
+
static func swizzleImageViewMethodsForAppLanguage() {
|
|
20
|
+
Swizzle.swizzleSelector(
|
|
21
21
|
cls: self,
|
|
22
22
|
originalSelector: #selector(UIImageView.didMoveToWindow),
|
|
23
23
|
customSelector: #selector(UIImageView.fw_imageViewDidMoveToWindow))
|
|
24
|
-
|
|
24
|
+
Swizzle.swizzleSelector(
|
|
25
25
|
cls: self,
|
|
26
26
|
originalSelector: #selector(setter: UIImageView.image),
|
|
27
27
|
customSelector: #selector(UIImageView.fw_setImage(_:))
|
|
28
28
|
)
|
|
29
|
-
|
|
29
|
+
Swizzle.swizzleSelector(
|
|
30
30
|
cls: self,
|
|
31
31
|
originalSelector: #selector(UIImageView.awakeFromNib),
|
|
32
32
|
customSelector: #selector(UIImageView.fw_imageViewAwakeFromNib)
|
|
@@ -49,7 +49,7 @@ extension UIImageView {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
private func updateViewType(_ image: UIImage?) {
|
|
52
|
-
self.
|
|
52
|
+
self.viewType = shouldFlipImage(image) ? .flip : .auto
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
private func shouldFlipImage(_ image: UIImage?) -> Bool {
|
|
@@ -57,7 +57,7 @@ extension UIImageView {
|
|
|
57
57
|
return false
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
if
|
|
60
|
+
if AppLanguageManager.shared.shouldHorizontalFlip, self.isIOSSDKView {
|
|
61
61
|
let iOSSDKBundle = Bundle(for: FireworkVideoSDK.self)
|
|
62
62
|
|
|
63
63
|
for imageName in FWImageNamesWithDirections {
|
|
@@ -80,7 +80,7 @@ extension UIImageView {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
if
|
|
83
|
+
if AppLanguageManager.shared.shouldHorizontalFlip,
|
|
84
84
|
image.flipsForRightToLeftLayoutDirection == true,
|
|
85
85
|
self.isIOSSDKView {
|
|
86
86
|
return true
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// UILabel+
|
|
2
|
+
// UILabel+AppLanguage.swift
|
|
3
3
|
//
|
|
4
4
|
// Created by linjie jiang on 2023/2/22.
|
|
5
5
|
//
|
|
@@ -8,39 +8,39 @@ import UIKit
|
|
|
8
8
|
|
|
9
9
|
extension UILabel {
|
|
10
10
|
private struct AssociatedKeys {
|
|
11
|
-
static var
|
|
11
|
+
static var hasCalculatedTextAlignment = "hasCalculatedTextAlignmentKey"
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
private var
|
|
14
|
+
private var hasCalculatedTextAlignment: Bool {
|
|
15
15
|
get {
|
|
16
|
-
let result = objc_getAssociatedObject(self, &AssociatedKeys.
|
|
16
|
+
let result = objc_getAssociatedObject(self, &AssociatedKeys.hasCalculatedTextAlignment) as? Bool
|
|
17
17
|
return result ?? false
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
set {
|
|
21
21
|
objc_setAssociatedObject(
|
|
22
22
|
self,
|
|
23
|
-
&AssociatedKeys.
|
|
23
|
+
&AssociatedKeys.hasCalculatedTextAlignment,
|
|
24
24
|
newValue,
|
|
25
25
|
.OBJC_ASSOCIATION_RETAIN_NONATOMIC
|
|
26
26
|
)
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
static func
|
|
31
|
-
|
|
30
|
+
static func swizzleLabelMethodsForAppLanguage() {
|
|
31
|
+
Swizzle.swizzleSelector(cls: self,
|
|
32
32
|
originalSelector: #selector(setter: UILabel.textAlignment),
|
|
33
33
|
customSelector: #selector(UILabel.fw_setLabelTextAlignment(_:)))
|
|
34
|
-
|
|
34
|
+
Swizzle.swizzleSelector(cls: self,
|
|
35
35
|
originalSelector: #selector(UILabel.didMoveToWindow),
|
|
36
36
|
customSelector: #selector(UILabel.fw_labelDidMoveToWindow))
|
|
37
|
-
|
|
37
|
+
Swizzle.swizzleSelector(cls: self,
|
|
38
38
|
originalSelector: #selector(UILabel.removeFromSuperview),
|
|
39
39
|
customSelector: #selector(UILabel.fw_labelRemoveFromSuperview))
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
@objc func fw_setLabelTextAlignment(_ textAlignment: NSTextAlignment) {
|
|
43
|
-
|
|
43
|
+
addReloadClosure(key: "alignment") { [weak self] in
|
|
44
44
|
guard let self = self else {
|
|
45
45
|
return
|
|
46
46
|
}
|
|
@@ -52,7 +52,7 @@ extension UILabel {
|
|
|
52
52
|
@objc func fw_labelDidMoveToWindow() {
|
|
53
53
|
fw_labelDidMoveToWindow()
|
|
54
54
|
if shouldCalculateTextAlignment(),
|
|
55
|
-
!self.
|
|
55
|
+
!self.hasCalculatedTextAlignment,
|
|
56
56
|
self.isIOSSDKView {
|
|
57
57
|
self.textAlignment = self.textAlignment
|
|
58
58
|
}
|
|
@@ -60,13 +60,13 @@ extension UILabel {
|
|
|
60
60
|
|
|
61
61
|
@objc func fw_labelRemoveFromSuperview() {
|
|
62
62
|
fw_labelRemoveFromSuperview()
|
|
63
|
-
self.
|
|
63
|
+
self.hasCalculatedTextAlignment = false
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
private func calculatedTextAlignment(_ textAlignment: NSTextAlignment) -> NSTextAlignment {
|
|
67
67
|
if shouldCalculateTextAlignment(),
|
|
68
|
-
let layoutDirection =
|
|
69
|
-
self.
|
|
68
|
+
let layoutDirection = AppLanguageManager.shared.appLanguageLayoutDirection {
|
|
69
|
+
self.hasCalculatedTextAlignment = true
|
|
70
70
|
if layoutDirection == .rtl {
|
|
71
71
|
if textAlignment == .center {
|
|
72
72
|
return textAlignment
|
|
@@ -85,11 +85,11 @@ extension UILabel {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
private func shouldCalculateTextAlignment() -> Bool {
|
|
88
|
-
if
|
|
88
|
+
if AppLanguageManager.shared.shouldHorizontalFlip,
|
|
89
89
|
self.isIOSSDKView,
|
|
90
|
-
let layoutDirection =
|
|
90
|
+
let layoutDirection = AppLanguageManager.shared.appLanguageLayoutDirection,
|
|
91
91
|
layoutDirection != .unsupported,
|
|
92
|
-
|
|
92
|
+
shouldUseCalculatedTextAlignment() {
|
|
93
93
|
return true
|
|
94
94
|
}
|
|
95
95
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// UITextField+
|
|
2
|
+
// UITextField+AppLanguage.swift
|
|
3
3
|
//
|
|
4
4
|
// Created by linjie jiang on 2023/2/23.
|
|
5
5
|
//
|
|
@@ -8,39 +8,39 @@ import UIKit
|
|
|
8
8
|
|
|
9
9
|
extension UITextField {
|
|
10
10
|
private struct AssociatedKeys {
|
|
11
|
-
static var
|
|
11
|
+
static var hasCalculatedTextAlignment = "hasCalculatedTextAlignmentKey"
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
private var
|
|
14
|
+
private var hasCalculatedTextAlignment: Bool {
|
|
15
15
|
get {
|
|
16
|
-
let result = objc_getAssociatedObject(self, &AssociatedKeys.
|
|
16
|
+
let result = objc_getAssociatedObject(self, &AssociatedKeys.hasCalculatedTextAlignment) as? Bool
|
|
17
17
|
return result ?? false
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
set {
|
|
21
21
|
objc_setAssociatedObject(
|
|
22
22
|
self,
|
|
23
|
-
&AssociatedKeys.
|
|
23
|
+
&AssociatedKeys.hasCalculatedTextAlignment,
|
|
24
24
|
newValue,
|
|
25
25
|
.OBJC_ASSOCIATION_RETAIN_NONATOMIC
|
|
26
26
|
)
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
static func
|
|
31
|
-
|
|
30
|
+
static func swizzleTextFieldMethodsForAppLanguage() {
|
|
31
|
+
Swizzle.swizzleSelector(cls: self,
|
|
32
32
|
originalSelector: #selector(setter: UITextField.textAlignment),
|
|
33
33
|
customSelector: #selector(UITextField.fw_setTextFieldTextAlignment(_:)))
|
|
34
|
-
|
|
34
|
+
Swizzle.swizzleSelector(cls: self,
|
|
35
35
|
originalSelector: #selector(UITextField.didMoveToWindow),
|
|
36
36
|
customSelector: #selector(UITextField.fw_textFieldDidMoveToWindow))
|
|
37
|
-
|
|
37
|
+
Swizzle.swizzleSelector(cls: self,
|
|
38
38
|
originalSelector: #selector(UITextField.removeFromSuperview),
|
|
39
39
|
customSelector: #selector(UITextField.fw_textFieldRemoveFromSuperview))
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
@objc func fw_setTextFieldTextAlignment(_ textAlignment: NSTextAlignment) {
|
|
43
|
-
|
|
43
|
+
addReloadClosure(key: "alignment") { [weak self] in
|
|
44
44
|
guard let self = self else {
|
|
45
45
|
return
|
|
46
46
|
}
|
|
@@ -52,7 +52,7 @@ extension UITextField {
|
|
|
52
52
|
@objc func fw_textFieldDidMoveToWindow() {
|
|
53
53
|
fw_textFieldDidMoveToWindow()
|
|
54
54
|
if shouldCalculateTextAlignment(),
|
|
55
|
-
!self.
|
|
55
|
+
!self.hasCalculatedTextAlignment,
|
|
56
56
|
self.isIOSSDKView {
|
|
57
57
|
self.textAlignment = self.textAlignment
|
|
58
58
|
}
|
|
@@ -60,13 +60,13 @@ extension UITextField {
|
|
|
60
60
|
|
|
61
61
|
@objc func fw_textFieldRemoveFromSuperview() {
|
|
62
62
|
fw_textFieldRemoveFromSuperview()
|
|
63
|
-
self.
|
|
63
|
+
self.hasCalculatedTextAlignment = false
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
private func calculatedTextAlignment(_ textAlignment: NSTextAlignment) -> NSTextAlignment {
|
|
67
67
|
if shouldCalculateTextAlignment(),
|
|
68
|
-
let layoutDirection =
|
|
69
|
-
self.
|
|
68
|
+
let layoutDirection = AppLanguageManager.shared.appLanguageLayoutDirection {
|
|
69
|
+
self.hasCalculatedTextAlignment = true
|
|
70
70
|
if layoutDirection == .rtl {
|
|
71
71
|
if textAlignment == .center {
|
|
72
72
|
return textAlignment
|
|
@@ -85,9 +85,9 @@ extension UITextField {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
private func shouldCalculateTextAlignment() -> Bool {
|
|
88
|
-
if
|
|
88
|
+
if AppLanguageManager.shared.shouldHorizontalFlip,
|
|
89
89
|
self.isIOSSDKView,
|
|
90
|
-
let layoutDirection =
|
|
90
|
+
let layoutDirection = AppLanguageManager.shared.appLanguageLayoutDirection,
|
|
91
91
|
layoutDirection != .unsupported {
|
|
92
92
|
return true
|
|
93
93
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// UITextView+
|
|
2
|
+
// UITextView+AppLanguage.swift
|
|
3
3
|
//
|
|
4
4
|
// Created by linjie jiang on 2023/2/23.
|
|
5
5
|
//
|
|
@@ -8,39 +8,39 @@ import UIKit
|
|
|
8
8
|
|
|
9
9
|
extension UITextView {
|
|
10
10
|
private struct AssociatedKeys {
|
|
11
|
-
static var
|
|
11
|
+
static var hasCalculatedTextAlignment = "hasCalculatedTextAlignmentKey"
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
private var
|
|
14
|
+
private var hasCalculatedTextAlignment: Bool {
|
|
15
15
|
get {
|
|
16
|
-
let result = objc_getAssociatedObject(self, &AssociatedKeys.
|
|
16
|
+
let result = objc_getAssociatedObject(self, &AssociatedKeys.hasCalculatedTextAlignment) as? Bool
|
|
17
17
|
return result ?? false
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
set {
|
|
21
21
|
objc_setAssociatedObject(
|
|
22
22
|
self,
|
|
23
|
-
&AssociatedKeys.
|
|
23
|
+
&AssociatedKeys.hasCalculatedTextAlignment,
|
|
24
24
|
newValue,
|
|
25
25
|
.OBJC_ASSOCIATION_RETAIN_NONATOMIC
|
|
26
26
|
)
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
static func
|
|
31
|
-
|
|
30
|
+
static func swizzleTextViewMethodsForAppLanguage() {
|
|
31
|
+
Swizzle.swizzleSelector(cls: self,
|
|
32
32
|
originalSelector: #selector(setter: UITextView.textAlignment),
|
|
33
33
|
customSelector: #selector(UITextView.fw_setTextViewTextAlignment(_:)))
|
|
34
|
-
|
|
34
|
+
Swizzle.swizzleSelector(cls: self,
|
|
35
35
|
originalSelector: #selector(UITextView.didMoveToWindow),
|
|
36
36
|
customSelector: #selector(UITextView.fw_textViewDidMoveToWindow))
|
|
37
|
-
|
|
37
|
+
Swizzle.swizzleSelector(cls: self,
|
|
38
38
|
originalSelector: #selector(UITextView.removeFromSuperview),
|
|
39
39
|
customSelector: #selector(UITextView.fw_textViewRemoveFromSuperview))
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
@objc func fw_setTextViewTextAlignment(_ textAlignment: NSTextAlignment) {
|
|
43
|
-
|
|
43
|
+
addReloadClosure(key: "alignment") { [weak self] in
|
|
44
44
|
guard let self = self else {
|
|
45
45
|
return
|
|
46
46
|
}
|
|
@@ -52,7 +52,7 @@ extension UITextView {
|
|
|
52
52
|
@objc func fw_textViewDidMoveToWindow() {
|
|
53
53
|
fw_textViewDidMoveToWindow()
|
|
54
54
|
if shouldCalculateTextAlignment(),
|
|
55
|
-
!self.
|
|
55
|
+
!self.hasCalculatedTextAlignment,
|
|
56
56
|
self.isIOSSDKView {
|
|
57
57
|
self.textAlignment = self.textAlignment
|
|
58
58
|
}
|
|
@@ -60,13 +60,13 @@ extension UITextView {
|
|
|
60
60
|
|
|
61
61
|
@objc func fw_textViewRemoveFromSuperview() {
|
|
62
62
|
fw_textViewRemoveFromSuperview()
|
|
63
|
-
self.
|
|
63
|
+
self.hasCalculatedTextAlignment = false
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
private func calculatedTextAlignment(_ textAlignment: NSTextAlignment) -> NSTextAlignment {
|
|
67
67
|
if shouldCalculateTextAlignment(),
|
|
68
|
-
let layoutDirection =
|
|
69
|
-
self.
|
|
68
|
+
let layoutDirection = AppLanguageManager.shared.appLanguageLayoutDirection {
|
|
69
|
+
self.hasCalculatedTextAlignment = true
|
|
70
70
|
if layoutDirection == .rtl {
|
|
71
71
|
if textAlignment == .center {
|
|
72
72
|
return textAlignment
|
|
@@ -85,9 +85,9 @@ extension UITextView {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
private func shouldCalculateTextAlignment() -> Bool {
|
|
88
|
-
if
|
|
88
|
+
if AppLanguageManager.shared.shouldHorizontalFlip,
|
|
89
89
|
self.isIOSSDKView,
|
|
90
|
-
let layoutDirection =
|
|
90
|
+
let layoutDirection = AppLanguageManager.shared.appLanguageLayoutDirection,
|
|
91
91
|
layoutDirection != .unsupported {
|
|
92
92
|
return true
|
|
93
93
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// UIView+
|
|
2
|
+
// UIView+AppLanguage.swift
|
|
3
3
|
//
|
|
4
4
|
// Created by linjie jiang on 2023/3/11.
|
|
5
5
|
//
|
|
@@ -8,13 +8,13 @@ import UIKit
|
|
|
8
8
|
import FireworkVideo
|
|
9
9
|
|
|
10
10
|
extension UIView {
|
|
11
|
-
static func
|
|
12
|
-
|
|
11
|
+
static func swizzleViewMethodsForAppLanguage() {
|
|
12
|
+
Swizzle.swizzleSelector(
|
|
13
13
|
cls: self,
|
|
14
14
|
originalSelector: #selector(UIView.init(frame:)),
|
|
15
15
|
customSelector: #selector(UIView.fw_init(frame:))
|
|
16
16
|
)
|
|
17
|
-
|
|
17
|
+
Swizzle.swizzleSelector(
|
|
18
18
|
cls: self,
|
|
19
19
|
originalSelector: #selector(UIView.awakeFromNib),
|
|
20
20
|
customSelector: #selector(UIView.fw_viewAwakeFromNib)
|
|
@@ -24,15 +24,15 @@ extension UIView {
|
|
|
24
24
|
@objc func fw_init(frame: CGRect) -> UIView {
|
|
25
25
|
let view = self.fw_init(frame: frame)
|
|
26
26
|
if view is FireworkPlayerView {
|
|
27
|
-
view.
|
|
27
|
+
view.viewType = .normal
|
|
28
28
|
}
|
|
29
29
|
return view
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
@objc func fw_viewAwakeFromNib() {
|
|
33
33
|
self.fw_viewAwakeFromNib()
|
|
34
|
-
if self is FireworkPlayerView,
|
|
35
|
-
self.
|
|
34
|
+
if self is FireworkPlayerView, AppLanguageManager.shared.shouldHorizontalFlip {
|
|
35
|
+
self.viewType = .normal
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|