react-native-firework-sdk 1.9.0 → 1.10.0-beta.1
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/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 +8 -7
- package/ios/Components/VideoFeedManager.m +1 -0
- package/ios/Components/VideoFeedManager.swift +4 -0
- package/ios/FireworkSdk.xcodeproj/project.pbxproj +1 -171
- 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 +764 -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/RNToNative/RCTConvert+StoryBlock.swift +2 -1
- package/ios/Models/RNToNative/RCTConvert+VideoFeed.swift +2 -1
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +8 -98
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule+EventTracking.swift +34 -16
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +23 -6
- package/ios/Modules/LiveStream/LiveStreamModule.swift +1 -0
- 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 +19 -6
- package/lib/commonjs/FireworkSDK.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 +3 -1
- package/lib/commonjs/components/StoryBlock.js.map +1 -1
- package/lib/commonjs/components/VideoFeed.js +3 -1
- package/lib/commonjs/components/VideoFeed.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 +18 -6
- package/lib/module/FireworkSDK.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 +3 -1
- package/lib/module/components/StoryBlock.js.map +1 -1
- package/lib/module/components/VideoFeed.js +3 -1
- package/lib/module/components/VideoFeed.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 +1 -0
- package/lib/typescript/VideoShopping.d.ts +1 -1
- package/lib/typescript/components/StoryBlock.d.ts +8 -0
- package/lib/typescript/components/VideoFeed.d.ts +8 -0
- package/lib/typescript/models/FWEventName.d.ts +1 -0
- package/lib/typescript/models/StoryBlockSource.d.ts +1 -1
- package/lib/typescript/models/VideoFeedSource.d.ts +1 -1
- package/lib/typescript/models/VideoPlaybackEventName.d.ts +13 -1
- package/package.json +5 -1
- package/react-native-firework-sdk.podspec +10 -5
- package/src/FireworkSDK.ts +22 -5
- package/src/VideoShopping.ts +1 -1
- package/src/components/StoryBlock.tsx +10 -0
- package/src/components/VideoFeed.tsx +10 -0
- package/src/models/FWEventName.ts +1 -0
- package/src/models/StoryBlockSource.ts +2 -1
- package/src/models/VideoFeedSource.ts +2 -1
- package/src/models/VideoPlaybackEventName.ts +13 -1
- 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
|
@@ -48,6 +48,14 @@ export interface IVideoFeedProps {
|
|
|
48
48
|
* The dynamic content parameters of the feed. Required when the source is set as dynamicContent.
|
|
49
49
|
*/
|
|
50
50
|
dynamicContentParameters?: { [key: string]: string[] };
|
|
51
|
+
/**
|
|
52
|
+
* Hashtag filter expression is an s-expression used to provide feeds filtered by hashtags with specified criteria.
|
|
53
|
+
* Queries are specified with boolean predicates on what hashtags are there on the video.
|
|
54
|
+
* For instance, (and sport food) (or sport food) (and sport (or food comedy)) sport are all valid expressions.
|
|
55
|
+
* Non-UTF-8 characters are not allowed. If using boolean predicates, the expression needs to be wrapped with parenthesis.
|
|
56
|
+
* Only supported on iOS.
|
|
57
|
+
*/
|
|
58
|
+
hashtagFilterExpression?: string;
|
|
51
59
|
/**
|
|
52
60
|
* One of three available display modes. Defaults to row.
|
|
53
61
|
*/
|
|
@@ -201,6 +209,7 @@ class VideoFeed extends React.Component<IVideoFeedProps> {
|
|
|
201
209
|
mode = 'row',
|
|
202
210
|
adConfiguration,
|
|
203
211
|
enablePictureInPicture = false,
|
|
212
|
+
hashtagFilterExpression = '',
|
|
204
213
|
} = this.props;
|
|
205
214
|
const videoFeedConfiguration = this._getVideoFeedConfiguration();
|
|
206
215
|
const titleHidden = videoFeedConfiguration?.title?.hidden ?? false;
|
|
@@ -250,6 +259,7 @@ class VideoFeed extends React.Component<IVideoFeedProps> {
|
|
|
250
259
|
key += `_vastAttributes:${vastAttributesString}`;
|
|
251
260
|
key += `_showAdBadge:${showAdBadge}`;
|
|
252
261
|
key += `_appLanguage:${appLanguage}`;
|
|
262
|
+
key += `_hashtagFilterExpression:${hashtagFilterExpression}`;
|
|
253
263
|
|
|
254
264
|
return (
|
|
255
265
|
<FWVideoFeed
|
|
@@ -13,6 +13,7 @@ export enum FWEventName {
|
|
|
13
13
|
ShareBaseURLUpdated = 'fw:share-base-url-updated',
|
|
14
14
|
AdBadgeConfigurationUpdated = 'fw:ad-badge-configuration-updated',
|
|
15
15
|
AppLanguageUpdated = 'fw:app-language-updated',
|
|
16
|
+
NativeAppLanguageUpdated = 'fw:native-app-language-updated',
|
|
16
17
|
LogMessage = 'fw:log-message',
|
|
17
18
|
CustomLinkButtonClick = 'fw:shopping:custom-link-button-click',
|
|
18
19
|
}
|
|
@@ -7,6 +7,14 @@ enum VideoPlaybackEventName {
|
|
|
7
7
|
* Video started.
|
|
8
8
|
*/
|
|
9
9
|
Start = 'fw:video:start',
|
|
10
|
+
/**
|
|
11
|
+
* Video paused. Only supported on iOS.
|
|
12
|
+
*/
|
|
13
|
+
Pause = 'fw:video:pause',
|
|
14
|
+
/**
|
|
15
|
+
* Video resume. Only supported on iOS.
|
|
16
|
+
*/
|
|
17
|
+
Resume = 'fw:video:resume',
|
|
10
18
|
/**
|
|
11
19
|
* Video reached 25%.
|
|
12
20
|
*/
|
|
@@ -24,7 +32,11 @@ enum VideoPlaybackEventName {
|
|
|
24
32
|
*/
|
|
25
33
|
Complete = 'fw:video:complete',
|
|
26
34
|
/**
|
|
27
|
-
*
|
|
35
|
+
* Ad video started playing. Only supported on iOS.
|
|
36
|
+
*/
|
|
37
|
+
AdStart = 'fw:video:ad-start',
|
|
38
|
+
/**
|
|
39
|
+
* Ad video completed playing.
|
|
28
40
|
*/
|
|
29
41
|
AdEnd = 'fw:video:ad-end',
|
|
30
42
|
/**
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// FWAppLanguageManager.swift
|
|
3
|
-
//
|
|
4
|
-
// Created by linjie jiang on 2023/2/7.
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
import Foundation
|
|
8
|
-
|
|
9
|
-
private let appLanguageStorageKey = "firework_sdk_app_language_storage_key"
|
|
10
|
-
|
|
11
|
-
public enum AppLanguageLayoutDirection: Int {
|
|
12
|
-
case ltr, rtl, unsupported
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public class FWAppLanguageManager {
|
|
16
|
-
public static let shared = FWAppLanguageManager()
|
|
17
|
-
|
|
18
|
-
private var _systemLanguage: String?
|
|
19
|
-
private var _systemLanguageCode: String? {
|
|
20
|
-
guard let language = _systemLanguage else {
|
|
21
|
-
return nil
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return FWLanguageUtil.getLanguageCode(language)
|
|
25
|
-
}
|
|
26
|
-
private var _hasInitialized: Bool = false
|
|
27
|
-
|
|
28
|
-
public var appLanguage: String? {
|
|
29
|
-
didSet {
|
|
30
|
-
if appLanguage != nil {
|
|
31
|
-
FWAppLanguageManager.swizzelMethods()
|
|
32
|
-
FWRTLManager.sharedInstance().enableHorizontalFlip = shouldHorizontalFlip
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public var appLanguageCode: String? {
|
|
38
|
-
guard let language = appLanguage else {
|
|
39
|
-
return nil
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return FWLanguageUtil.getLanguageCode(language)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public var appLanguageLayoutDirection: AppLanguageLayoutDirection? {
|
|
46
|
-
guard let languageCode = appLanguageCode else {
|
|
47
|
-
return nil
|
|
48
|
-
}
|
|
49
|
-
let direction = Locale.characterDirection(forLanguage: languageCode)
|
|
50
|
-
switch direction {
|
|
51
|
-
case .leftToRight:
|
|
52
|
-
return .ltr
|
|
53
|
-
case .rightToLeft:
|
|
54
|
-
return .rtl
|
|
55
|
-
default:
|
|
56
|
-
return .unsupported
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public var shouldHorizontalFlip: Bool {
|
|
61
|
-
guard let appLanguageCode = appLanguageCode else {
|
|
62
|
-
return false
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
guard let systemLanguageCode = _systemLanguageCode else {
|
|
66
|
-
return false
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
let appLanguageDirection = Locale.characterDirection(forLanguage: appLanguageCode)
|
|
70
|
-
let systemLanguageDirection = Locale.characterDirection(forLanguage: systemLanguageCode)
|
|
71
|
-
|
|
72
|
-
if appLanguageDirection == .leftToRight, systemLanguageDirection == .rightToLeft {
|
|
73
|
-
return true
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if appLanguageDirection == .rightToLeft, systemLanguageDirection == .leftToRight {
|
|
77
|
-
return true
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return false
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private static func swizzelMethods() {
|
|
84
|
-
DispatchQueue.once {
|
|
85
|
-
UIViewController.swizzleMethodsForViewController()
|
|
86
|
-
Bundle.swizzleMethodsForBundle()
|
|
87
|
-
URLSession.swizzleMethodsForURLSession()
|
|
88
|
-
NumberFormatter.swizzleMethodsForNumberFormatter()
|
|
89
|
-
UIImageView.swizzleMethodsForImageView()
|
|
90
|
-
UILabel.swizzleMethodsForLabel()
|
|
91
|
-
UITextField.swizzleMethodsForTextField()
|
|
92
|
-
UITextView.swizzleMethodsForTextView()
|
|
93
|
-
UIWindow.swizzleMethodsForWindow()
|
|
94
|
-
UIView.swizzleMethodsForView()
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
private init() {
|
|
99
|
-
initializeManager()
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
public func initializeManager() {
|
|
103
|
-
guard !_hasInitialized else {
|
|
104
|
-
return
|
|
105
|
-
}
|
|
106
|
-
_hasInitialized = true
|
|
107
|
-
|
|
108
|
-
self._systemLanguage = Locale.preferredLanguages.first
|
|
109
|
-
let cachedAppLanguage = UserDefaults.standard.object(forKey: appLanguageStorageKey) as? String
|
|
110
|
-
if FWLanguageUtil.isValidLanguage(cachedAppLanguage) {
|
|
111
|
-
self.appLanguage = cachedAppLanguage
|
|
112
|
-
}
|
|
113
|
-
#if DEBUG
|
|
114
|
-
print("""
|
|
115
|
-
FWAppLanguageManager init method
|
|
116
|
-
current app language: \(self.appLanguage ?? "")
|
|
117
|
-
system language: \(self._systemLanguage ?? "")
|
|
118
|
-
""")
|
|
119
|
-
#endif
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
public func changeAppLanguage(_ language: String?) -> Bool {
|
|
123
|
-
guard let language = language, language.count > 0 else {
|
|
124
|
-
appLanguage = nil
|
|
125
|
-
UserDefaults.standard.removeObject(forKey: appLanguageStorageKey)
|
|
126
|
-
UserDefaults.standard.synchronize()
|
|
127
|
-
return true
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if FWLanguageUtil.isValidLanguage(language) {
|
|
131
|
-
appLanguage = language
|
|
132
|
-
UserDefaults.standard.set(language, forKey: appLanguageStorageKey)
|
|
133
|
-
UserDefaults.standard.synchronize()
|
|
134
|
-
return true
|
|
135
|
-
} else {
|
|
136
|
-
return false
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// FWRTLManager.h
|
|
3
|
-
// FWRTL
|
|
4
|
-
//
|
|
5
|
-
// Created by ByteDance on 2018/9/10.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import <Foundation/Foundation.h>
|
|
9
|
-
|
|
10
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
11
|
-
|
|
12
|
-
@interface FWRTLManager : NSObject
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Turn on / off FWRTL via this property.
|
|
16
|
-
*/
|
|
17
|
-
@property (nonatomic, assign) BOOL enableHorizontalFlip;
|
|
18
|
-
|
|
19
|
-
+ (instancetype)sharedInstance;
|
|
20
|
-
|
|
21
|
-
- (void)registerUIElement:(UIView *)element;
|
|
22
|
-
|
|
23
|
-
@end
|
|
24
|
-
|
|
25
|
-
NS_ASSUME_NONNULL_END
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// FWRTLManager.m
|
|
3
|
-
// FWRTL
|
|
4
|
-
//
|
|
5
|
-
// Created by ByteDance on 2018/9/10.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import "FWRTLManager.h"
|
|
9
|
-
#import "UIView+FWRTL.h"
|
|
10
|
-
#import "NSObject+FWRTLReloadBlock.h"
|
|
11
|
-
#import "FWRTLDefinitions.h"
|
|
12
|
-
|
|
13
|
-
@interface FWRTLManager ()
|
|
14
|
-
|
|
15
|
-
@property (nonatomic, strong) NSPointerArray *registeredUIElements;
|
|
16
|
-
|
|
17
|
-
@end
|
|
18
|
-
|
|
19
|
-
@implementation FWRTLManager
|
|
20
|
-
|
|
21
|
-
+ (instancetype)sharedInstance
|
|
22
|
-
{
|
|
23
|
-
static FWRTLManager *manager;
|
|
24
|
-
static dispatch_once_t onceToken;
|
|
25
|
-
dispatch_once(&onceToken, ^{
|
|
26
|
-
manager = [[FWRTLManager alloc] init];
|
|
27
|
-
manager.registeredUIElements = [NSPointerArray pointerArrayWithOptions:NSPointerFunctionsWeakMemory];
|
|
28
|
-
});
|
|
29
|
-
return manager;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
- (void)registerUIElement:(UIView *)element
|
|
33
|
-
{
|
|
34
|
-
[self.registeredUIElements addPointer:(__bridge void * _Nullable)(element)];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
- (void)setEnableHorizontalFlip:(BOOL)enableHorizontalFlip
|
|
38
|
-
{
|
|
39
|
-
if (enableHorizontalFlip == _enableHorizontalFlip) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
_enableHorizontalFlip = enableHorizontalFlip;
|
|
43
|
-
NSInteger count = self.registeredUIElements.count;
|
|
44
|
-
NSMutableSet<UIView *> *rootViews = [NSMutableSet set];
|
|
45
|
-
for (NSInteger i = 0; i < count; i++) {
|
|
46
|
-
UIView *element = (UIView *)[self.registeredUIElements pointerAtIndex:i];
|
|
47
|
-
[element fwrtl_performReload];
|
|
48
|
-
if (!element) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
if (element.window && element.window != element) {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
[rootViews addObject:[self rootViewForView:element]];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
[rootViews enumerateObjectsUsingBlock:^(UIView * _Nonnull obj, BOOL * _Nonnull stop) {
|
|
59
|
-
[obj fwrtl_renewLayerTransformForceRecursively:YES];
|
|
60
|
-
}];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
- (UIView *)rootViewForView:(UIView *)view
|
|
64
|
-
{
|
|
65
|
-
if (view.window) {
|
|
66
|
-
return view.window;
|
|
67
|
-
}
|
|
68
|
-
UIView *rootView = view;
|
|
69
|
-
while (rootView.superview) {
|
|
70
|
-
rootView = rootView.superview;
|
|
71
|
-
}
|
|
72
|
-
return rootView;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// CALayer+FWRTL.h
|
|
3
|
-
// FWRTL
|
|
4
|
-
//
|
|
5
|
-
// Created by ByteDance on 2018/9/10.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import <QuartzCore/QuartzCore.h>
|
|
9
|
-
|
|
10
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
11
|
-
|
|
12
|
-
@interface CALayer (FWRTL)
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Additional property for CALayer, which will be multiplied to the original transform before set.
|
|
16
|
-
*/
|
|
17
|
-
@property (nonatomic, assign) CGAffineTransform fwrtl_basicTransform;
|
|
18
|
-
|
|
19
|
-
@end
|
|
20
|
-
|
|
21
|
-
NS_ASSUME_NONNULL_END
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// CALayer+FWRTL.m
|
|
3
|
-
// FWRTL
|
|
4
|
-
//
|
|
5
|
-
// Created by ByteDance on 2018/9/10.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import "CALayer+FWRTL.h"
|
|
9
|
-
#import "FWRTLDefinitions.h"
|
|
10
|
-
#import "FWRTLManager.h"
|
|
11
|
-
|
|
12
|
-
static BOOL shouldEnableHorizontalFlip = NO;
|
|
13
|
-
|
|
14
|
-
@implementation CALayer (FWRTL)
|
|
15
|
-
|
|
16
|
-
+ (void)load
|
|
17
|
-
{
|
|
18
|
-
FWSwizzle(self, setAffineTransform:, fwrtl_setAffineTransform:);
|
|
19
|
-
FWSwizzle(self, affineTransform, fwrtl_affineTransform);
|
|
20
|
-
FWSwizzle(self, addAnimation:forKey:, fwrtl_addAnimation:forKey:);
|
|
21
|
-
FWSwizzle(self, renderInContext:, fwrtl_renderInContext:);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
- (void)setFwrtl_basicTransform:(CGAffineTransform)fwrtl_basicTransform
|
|
25
|
-
{
|
|
26
|
-
if (!objc_getAssociatedObject(self, @selector(fwrtl_basicTransform)) && CGAffineTransformIsIdentity(fwrtl_basicTransform)) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
objc_setAssociatedObject(self, @selector(fwrtl_basicTransform), [NSValue valueWithCGAffineTransform:fwrtl_basicTransform], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
30
|
-
self.affineTransform = self.affineTransform;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
- (CGAffineTransform)fwrtl_basicTransform
|
|
34
|
-
{
|
|
35
|
-
NSValue *value = objc_getAssociatedObject(self, _cmd);
|
|
36
|
-
return value ? [value CGAffineTransformValue] : CGAffineTransformIdentity;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
- (void)setFwrtl_isRenderStartLayer:(BOOL)fwrtl_isRenderStartLayer
|
|
40
|
-
{
|
|
41
|
-
objc_setAssociatedObject(self, @selector(fwrtl_isRenderStartLayer), @(fwrtl_isRenderStartLayer), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
- (BOOL)fwrtl_isRenderStartLayer
|
|
45
|
-
{
|
|
46
|
-
return [objc_getAssociatedObject(self, _cmd) boolValue];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
- (void)fwrtl_setAffineTransform:(CGAffineTransform)m
|
|
50
|
-
{
|
|
51
|
-
if (!shouldEnableHorizontalFlip && [FWRTLManager sharedInstance].enableHorizontalFlip) {
|
|
52
|
-
shouldEnableHorizontalFlip = YES;
|
|
53
|
-
}
|
|
54
|
-
if (shouldEnableHorizontalFlip) {
|
|
55
|
-
objc_setAssociatedObject(self, @selector(fwrtl_affineTransform), [NSValue valueWithCGAffineTransform:m], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
56
|
-
[self fwrtl_setAffineTransform:CGAffineTransformConcat(self.fwrtl_basicTransform, m)];
|
|
57
|
-
} else {
|
|
58
|
-
[self fwrtl_setAffineTransform:m];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
- (CGAffineTransform)fwrtl_affineTransform
|
|
63
|
-
{
|
|
64
|
-
if (!shouldEnableHorizontalFlip && [FWRTLManager sharedInstance].enableHorizontalFlip) {
|
|
65
|
-
shouldEnableHorizontalFlip = YES;
|
|
66
|
-
}
|
|
67
|
-
if (shouldEnableHorizontalFlip) {
|
|
68
|
-
NSValue *value = objc_getAssociatedObject(self, @selector(fwrtl_affineTransform));
|
|
69
|
-
return value ? [value CGAffineTransformValue] : [self fwrtl_affineTransform];
|
|
70
|
-
} else {
|
|
71
|
-
return [self fwrtl_affineTransform];
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
- (void)fwrtl_addAnimation:(CAAnimation *)anim forKey:(NSString *)key
|
|
76
|
-
{
|
|
77
|
-
if ([anim isKindOfClass:[CABasicAnimation class]]) {
|
|
78
|
-
CABasicAnimation *basicAnim = (CABasicAnimation *)anim;
|
|
79
|
-
if ([basicAnim.keyPath hasPrefix:@"transform.scale"] && self.fwrtl_basicTransform.a == -1) {
|
|
80
|
-
basicAnim.fromValue = @([basicAnim.fromValue floatValue] * -1);
|
|
81
|
-
basicAnim.toValue = @([basicAnim.toValue floatValue] * -1);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
[self fwrtl_addAnimation:anim forKey:key];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
- (void)fwrtl_renderInContext:(CGContextRef)ctx
|
|
88
|
-
{
|
|
89
|
-
if (!shouldEnableHorizontalFlip && [FWRTLManager sharedInstance].enableHorizontalFlip) {
|
|
90
|
-
shouldEnableHorizontalFlip = YES;
|
|
91
|
-
}
|
|
92
|
-
if (shouldEnableHorizontalFlip) {
|
|
93
|
-
BOOL isRenderStartLayer = YES;
|
|
94
|
-
CGAffineTransform allSuperLayerTransform = self.fwrtl_basicTransform;
|
|
95
|
-
CALayer *layer = self;
|
|
96
|
-
while (layer.superlayer) {
|
|
97
|
-
layer = layer.superlayer;
|
|
98
|
-
if ([layer fwrtl_isRenderStartLayer]) {
|
|
99
|
-
isRenderStartLayer = NO;
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
allSuperLayerTransform = CGAffineTransformConcat(layer.fwrtl_basicTransform, allSuperLayerTransform);
|
|
103
|
-
}
|
|
104
|
-
if (isRenderStartLayer) {
|
|
105
|
-
[self setFwrtl_isRenderStartLayer:YES];
|
|
106
|
-
if (allSuperLayerTransform.a == -1) {
|
|
107
|
-
CGContextSaveGState(ctx);
|
|
108
|
-
CGContextConcatCTM(ctx, CGAffineTransformMakeScale(-1, 1));
|
|
109
|
-
CGContextTranslateCTM(ctx, -self.bounds.size.width, 0);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
[self fwrtl_renderInContext:ctx];
|
|
113
|
-
if (isRenderStartLayer) {
|
|
114
|
-
[self setFwrtl_isRenderStartLayer:NO];
|
|
115
|
-
if (allSuperLayerTransform.a == -1) {
|
|
116
|
-
CGContextRestoreGState(ctx);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
[self fwrtl_renderInContext:ctx];
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
@end
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// UIWebView+FWRTL.m
|
|
3
|
-
// FWRTL
|
|
4
|
-
//
|
|
5
|
-
// Created by ByteDance on 2018/10/9.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import "FWRTLRemoteViewControllerAdaptor.h"
|
|
9
|
-
#import "UIView+FWRTL.h"
|
|
10
|
-
#import "FWRTLDefinitions.h"
|
|
11
|
-
#import "FWRTLManager.h"
|
|
12
|
-
|
|
13
|
-
@implementation SFSafariViewController (FWRTL)
|
|
14
|
-
|
|
15
|
-
+ (void)load
|
|
16
|
-
{
|
|
17
|
-
FWSwizzle(self, viewDidLoad, alpweb_viewDidLoad);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
- (void)alpweb_viewDidLoad
|
|
21
|
-
{
|
|
22
|
-
[self alpweb_viewDidLoad];
|
|
23
|
-
self.view.fwrtl_viewType = FWRTLViewTypeNormalWithAllDescendants;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@end
|
|
27
|
-
|
|
28
|
-
@implementation SKCloudServiceSetupViewController (FWRTL)
|
|
29
|
-
|
|
30
|
-
+ (void)load
|
|
31
|
-
{
|
|
32
|
-
FWSwizzle(self, viewDidLoad, alpsk_viewDidLoad);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
- (void)alpsk_viewDidLoad
|
|
36
|
-
{
|
|
37
|
-
[self alpsk_viewDidLoad];
|
|
38
|
-
self.view.fwrtl_viewType = FWRTLViewTypeNormalWithAllDescendants;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@end
|
|
42
|
-
|
|
43
|
-
@implementation UIActivityViewController (FWRTL)
|
|
44
|
-
|
|
45
|
-
+ (void)load
|
|
46
|
-
{
|
|
47
|
-
FWSwizzle(self, viewDidLoad, fwrtl_act_viewDidLoad);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
- (void)fwrtl_act_viewDidLoad
|
|
51
|
-
{
|
|
52
|
-
[self fwrtl_act_viewDidLoad];
|
|
53
|
-
self.view.fwrtl_viewType = FWRTLViewTypeNormalWithAllDescendants;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
@end
|
|
57
|
-
|
|
58
|
-
@implementation UIImagePickerController (FWRTL)
|
|
59
|
-
|
|
60
|
-
+ (void)load
|
|
61
|
-
{
|
|
62
|
-
FWSwizzle(self, loadView, fwrtl_act_loadView);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
- (void)fwrtl_act_loadView
|
|
66
|
-
{
|
|
67
|
-
[self fwrtl_act_loadView];
|
|
68
|
-
self.view.fwrtl_viewType = FWRTLViewTypeNormalWithAllDescendants;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
@end
|
|
72
|
-
|
|
73
|
-
@implementation SKStoreProductViewController (FWRTL)
|
|
74
|
-
|
|
75
|
-
+ (void)load
|
|
76
|
-
{
|
|
77
|
-
FWSwizzle(self, loadView, fwrtl_act_loadView);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
- (void)fwrtl_act_loadView
|
|
81
|
-
{
|
|
82
|
-
[self fwrtl_act_loadView];
|
|
83
|
-
self.view.fwrtl_viewType = FWRTLViewTypeNormalWithAllDescendants;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
@end
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// FWRTLWhiteListManager.m
|
|
3
|
-
// FWRTL
|
|
4
|
-
//
|
|
5
|
-
// Created by ByteDanceon 2018/12/6.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import "FWRTLWhiteListManager.h"
|
|
9
|
-
#import "UIView+FWRTL.h"
|
|
10
|
-
#import <objc/runtime.h>
|
|
11
|
-
#import "FWRTLManager.h"
|
|
12
|
-
#import "UIView+FWRTL.h"
|
|
13
|
-
#import "NSObject+FWRTLReloadBlock.h"
|
|
14
|
-
#import "FWRTLDefinitions.h"
|
|
15
|
-
|
|
16
|
-
@implementation FWRTLWhiteListManager
|
|
17
|
-
|
|
18
|
-
+ (void)load
|
|
19
|
-
{
|
|
20
|
-
NSArray<NSString *> *noFlipWhiteListClasses = @[@"UILabel", @"UITextView", @"UITextField", @"UIWebView", @"WKWebView", @"UIImageView", @"UISearchBar", @"PUPhotosSectionHeaderContentView", @"UITableViewIndex", FWBase64Decode(@"X1VJUmVtb3RlVmlldw==") /* _UIRemoteView */ , FWBase64Decode(@"VUlBdXRvY29ycmVjdFRleHRWaWV3") /* UIAutocorrectTextView */ ];
|
|
21
|
-
[noFlipWhiteListClasses enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
22
|
-
BOOL shouldFlip = NO;
|
|
23
|
-
BOOL shouldInherit = NO;
|
|
24
|
-
if ([obj hasPrefix:@"!"]) {
|
|
25
|
-
shouldFlip = YES;
|
|
26
|
-
obj = [obj substringFromIndex:1];
|
|
27
|
-
}
|
|
28
|
-
if ([obj hasSuffix:@"!"]) {
|
|
29
|
-
shouldInherit = YES;
|
|
30
|
-
obj = [obj substringToIndex:obj.length - 1];
|
|
31
|
-
}
|
|
32
|
-
Class class = NSClassFromString(obj);
|
|
33
|
-
SEL sel = NSSelectorFromString(@"fwrtl_automaticViewType");
|
|
34
|
-
if (!class) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
IMP implementation = imp_implementationWithBlock(^(NSObject *self) {
|
|
38
|
-
if (shouldInherit) {
|
|
39
|
-
return shouldFlip ? FWRTLViewTypeFlipWithAllDescendants : FWRTLViewTypeNormalWithAllDescendants;
|
|
40
|
-
} else {
|
|
41
|
-
return shouldFlip ? FWRTLViewTypeFlip : FWRTLViewTypeNormal;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
if (!class_addMethod(class, sel, implementation, method_getTypeEncoding(class_getInstanceMethod([UIView class], @selector(fwrtl_automaticViewType))))) {
|
|
45
|
-
Method method = class_getInstanceMethod(class, sel);
|
|
46
|
-
if (!method) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
method_setImplementation(method, implementation);
|
|
51
|
-
}
|
|
52
|
-
}];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// UILabel+FWRTL.h
|
|
3
|
-
// FWRTL
|
|
4
|
-
//
|
|
5
|
-
// Created by ByteDance on 2018/12/6.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import <UIKit/UIKit.h>
|
|
9
|
-
|
|
10
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
11
|
-
|
|
12
|
-
@interface UILabel (FWRTL)
|
|
13
|
-
|
|
14
|
-
- (BOOL)fwrtl_shouldUseCalculatedTextAlignment;
|
|
15
|
-
|
|
16
|
-
@end
|
|
17
|
-
|
|
18
|
-
NS_ASSUME_NONNULL_END
|