react-native-firework-sdk 2.0.0 → 2.1.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/android/build.gradle +5 -3
- package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/StoryBlockFragment.kt +129 -0
- package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/StoryBlockFrameLayout.kt +84 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWEventName.kt +2 -1
- package/android/src/main/java/com/fireworksdk/bridge/models/FWProductInfoViewConfiguration.kt +18 -5
- package/android/src/main/java/com/fireworksdk/bridge/models/FWProductInfoViewConfigurationDeserializer.kt +33 -9
- package/android/src/main/java/com/fireworksdk/bridge/models/FWShoppingCtaResult.kt +17 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWShoppingCtaResultDeserializer.kt +33 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWStoryBlockManager.kt +126 -45
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt +6 -3
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWVideoShoppingInterface.kt +2 -2
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWNavigatorModule.kt +9 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt +81 -50
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +9 -2
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWConfigUtil.kt +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWGlobalDataUtil.kt +4 -0
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWLanguageUtil.kt +48 -16
- package/android/src/main/res/layout/fw_bridge_story_block.xml +24 -0
- package/ios/Components/StoryBlock.swift +33 -2
- package/ios/Components/StoryBlockManager.m +32 -0
- package/ios/Components/VideoFeed.swift +9 -29
- package/ios/Components/VideoFeedManager.m +11 -6
- package/ios/FireworkSdk.xcodeproj/project.pbxproj +378 -104
- package/ios/Models/NativeToRN/FireworkEventName.swift +3 -1
- package/ios/Models/RNToNative/RCTConvert+Shopping.swift +21 -0
- package/ios/Models/RNToNative/RCTConvert+VideoFeed.swift +27 -0
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +5 -1
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +1 -0
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +30 -0
- package/ios/Modules/Shopping/ProductInfoViewConfiguration.swift +13 -0
- package/ios/Modules/Shopping/ShoppingCTAResult.swift +16 -0
- package/ios/Modules/Shopping/ShoppingModule.m +2 -1
- package/ios/Modules/Shopping/ShoppingModule.swift +106 -30
- package/ios/Support/MultiHostStreaming/FWMultiHostStreaming.podspec +24 -0
- package/ios/Support/MultiHostStreaming/src/MultiHostStreamingSDK.swift +17 -0
- package/ios/Utils/AppLanguage/Bundle+FWSwizzle.swift +58 -0
- package/ios/Utils/AppLanguage/FWAppLanguageManager.swift +139 -0
- package/ios/Utils/AppLanguage/FWLanguageUtil.swift +43 -0
- package/ios/Utils/AppLanguage/NumberFormatter+FWSwizzle.swift +25 -0
- package/ios/Utils/AppLanguage/UIImageView+FWSwizzle.swift +91 -0
- package/ios/Utils/AppLanguage/UILabel+FWSwizzle.swift +98 -0
- package/ios/Utils/AppLanguage/UITextField+FWSwizzle.swift +97 -0
- package/ios/Utils/AppLanguage/UITextView+FWSwizzle.swift +97 -0
- package/ios/Utils/AppLanguage/UIView+FWSwizzle.swift +38 -0
- package/ios/Utils/AppLanguage/UIViewController+FWSwizzle.swift +32 -0
- package/ios/Utils/AppLanguage/UIWindow+FWSwizzle.swift +26 -0
- package/ios/Utils/AppLanguage/URLSession+FWSwizzle.swift +69 -0
- package/ios/Utils/{DispatchQueue+FWOnce.swift → Extensions/DispatchQueue+FWOnce.swift} +3 -3
- package/ios/Utils/{UINavigationController+FWSwizzle.swift → Extensions/Swizzle/UINavigationController+FWSwizzle.swift} +6 -8
- package/ios/Utils/Extensions/UIView+FWUIHierarchy.swift +47 -0
- package/ios/Utils/FWRTL/Classes/Manager/FWRTLManager.h +25 -0
- package/ios/Utils/FWRTL/Classes/Manager/FWRTLManager.m +75 -0
- package/ios/Utils/FWRTL/Classes/UICategories/CALayer+FWRTL.h +21 -0
- package/ios/Utils/FWRTL/Classes/UICategories/CALayer+FWRTL.m +124 -0
- package/ios/Utils/FWRTL/Classes/UICategories/FWRTLRemoteViewControllerAdaptor.h +11 -0
- package/ios/Utils/FWRTL/Classes/UICategories/FWRTLRemoteViewControllerAdaptor.m +86 -0
- package/ios/Utils/FWRTL/Classes/UICategories/FWRTLWhiteListManager.h +16 -0
- package/ios/Utils/FWRTL/Classes/UICategories/FWRTLWhiteListManager.m +55 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UILabel+FWRTL.h +18 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UILabel+FWRTL.m +39 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UIView+FWRTL.h +54 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UIView+FWRTL.m +141 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UIWindow+FWRTL.h +16 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UIWindow+FWRTL.m +20 -0
- package/ios/Utils/FWRTL/Classes/Utils/FWRTLDefinitions.h +52 -0
- package/ios/Utils/FWRTL/Classes/Utils/NSObject+FWRTLReloadBlock.h +19 -0
- package/ios/Utils/FWRTL/Classes/Utils/NSObject+FWRTLReloadBlock.m +49 -0
- package/ios/Utils/FWRTL/Classes/Utils/NSString+FWRTL.h +21 -0
- package/ios/Utils/FWRTL/Classes/Utils/NSString+FWRTL.m +38 -0
- package/ios/Utils/FWRTL/Classes/Utils/UIImage+FWRTL.h +18 -0
- package/ios/Utils/FWRTL/Classes/Utils/UIImage+FWRTL.m +43 -0
- package/ios/Utils/FWSwizzleLoader.m +6 -1
- package/ios/Utils/FWSwizzleLoader.swift +13 -0
- package/ios/Utils/FWSwizzleUtil.swift +17 -9
- package/ios/react_native_firework_sdk.h +1 -0
- package/ios/scripts/react_native_firework_sdk_pods.rb +31 -0
- package/lib/commonjs/FireworkSDK.js +21 -4
- package/lib/commonjs/FireworkSDK.js.map +1 -1
- package/lib/commonjs/VideoShopping.js +20 -37
- package/lib/commonjs/VideoShopping.js.map +1 -1
- package/lib/commonjs/components/StoryBlock.js +190 -125
- package/lib/commonjs/components/StoryBlock.js.map +1 -1
- package/lib/commonjs/components/VideoFeed.js +11 -1
- package/lib/commonjs/components/VideoFeed.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/FWEventName.js +2 -0
- package/lib/commonjs/models/FWEventName.js.map +1 -1
- package/lib/commonjs/models/ShoppingCTAResult.js +2 -0
- package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
- package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
- package/lib/module/FireworkSDK.js +21 -4
- package/lib/module/FireworkSDK.js.map +1 -1
- package/lib/module/VideoShopping.js +20 -39
- package/lib/module/VideoShopping.js.map +1 -1
- package/lib/module/components/StoryBlock.js +179 -131
- package/lib/module/components/StoryBlock.js.map +1 -1
- package/lib/module/components/VideoFeed.js +10 -1
- package/lib/module/components/VideoFeed.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/FWEventName.js +2 -0
- package/lib/module/models/FWEventName.js.map +1 -1
- package/lib/module/models/ShoppingCTAResult.js +2 -0
- package/lib/module/modules/FireworkSDKModule.js.map +1 -1
- package/lib/module/modules/ShoppingModule.js.map +1 -1
- package/lib/typescript/FireworkSDK.d.ts +7 -4
- package/lib/typescript/VideoShopping.d.ts +9 -11
- package/lib/typescript/components/StoryBlock.d.ts +19 -25
- package/lib/typescript/index.d.ts +6 -6
- package/lib/typescript/models/FWEventName.d.ts +2 -0
- package/lib/typescript/models/FWEvents.d.ts +14 -1
- package/lib/typescript/models/ProductInfoViewConfiguration.d.ts +36 -1
- package/lib/typescript/models/ShoppingCTAResult.d.ts +11 -0
- package/lib/typescript/modules/FireworkSDKModule.d.ts +1 -2
- package/lib/typescript/modules/ShoppingModule.d.ts +2 -1
- package/package.json +2 -2
- package/react-native-firework-sdk.podspec +26 -24
- package/src/FireworkSDK.ts +18 -5
- package/src/VideoShopping.ts +40 -53
- package/src/components/StoryBlock.tsx +199 -96
- package/src/components/VideoFeed.tsx +11 -0
- package/src/index.ts +15 -7
- package/src/models/FWEventName.ts +2 -0
- package/src/models/FWEvents.ts +14 -1
- package/src/models/ProductInfoViewConfiguration.ts +38 -1
- package/src/models/ShoppingCTAResult.ts +11 -0
- package/src/modules/FireworkSDKModule.ts +1 -2
- package/src/modules/ShoppingModule.ts +5 -5
- package/android/src/main/java/com/fireworksdk/bridge/constants/FWCommandConstant.kt +0 -6
- package/ios/Utils/UIView+ParentViewController.swift +0 -21
- package/lib/commonjs/models/AddToCartResult.js +0 -2
- package/lib/module/models/AddToCartResult.js +0 -2
- package/lib/typescript/models/AddToCartResult.d.ts +0 -10
- package/src/models/AddToCartResult.ts +0 -10
- /package/ios/Utils/{String+Color.swift → Extensions/String+Color.swift} +0 -0
- /package/ios/Utils/{UIView+Constraints.swift → Extensions/UIView+Constraints.swift} +0 -0
- /package/ios/Utils/{UIViewController+AttachChild.swift → Extensions/UIViewController+AttachChild.swift} +0 -0
- /package/lib/commonjs/models/{AddToCartResult.js.map → ShoppingCTAResult.js.map} +0 -0
- /package/lib/module/models/{AddToCartResult.js.map → ShoppingCTAResult.js.map} +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// View+ParentViewController.swift
|
|
3
|
+
// react-native-firework-sdk
|
|
4
|
+
//
|
|
5
|
+
// Created by Jeff Zheng on 2021/12/22.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import UIKit
|
|
9
|
+
import FireworkVideo
|
|
10
|
+
|
|
11
|
+
extension UIView {
|
|
12
|
+
var fwParentViewController: UIViewController? {
|
|
13
|
+
var parentResponder: UIResponder? = self
|
|
14
|
+
while parentResponder != nil {
|
|
15
|
+
parentResponder = parentResponder!.next
|
|
16
|
+
if let viewController = parentResponder as? UIViewController {
|
|
17
|
+
return viewController
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return nil
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var isIOSSDKView: Bool {
|
|
25
|
+
guard self.window != nil else {
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
guard let parentVC = self.fwParentViewController else {
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
let iOSSDKBundle = Bundle(for: FireworkVideoSDK.self)
|
|
32
|
+
|
|
33
|
+
if iOSSDKBundle == Bundle(for: type(of: parentVC)) {
|
|
34
|
+
return true
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var ancestorVC = parentVC.parent
|
|
38
|
+
while ancestorVC != nil {
|
|
39
|
+
if iOSSDKBundle == Bundle(for: type(of: ancestorVC!)) {
|
|
40
|
+
return true
|
|
41
|
+
}
|
|
42
|
+
ancestorVC = ancestorVC!.parent
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//
|
|
2
|
+
// UILabel+FWRTL.m
|
|
3
|
+
// FWRTL
|
|
4
|
+
//
|
|
5
|
+
// Created by ByteDance on 2018/12/6.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import "UILabel+FWRTL.h"
|
|
9
|
+
#import "NSObject+FWRTLReloadBlock.h"
|
|
10
|
+
#import "FWRTLDefinitions.h"
|
|
11
|
+
#import "FWRTLManager.h"
|
|
12
|
+
|
|
13
|
+
@implementation UILabel (FWRTL)
|
|
14
|
+
|
|
15
|
+
- (BOOL)fwrtl_shouldUseCalculatedTextAlignment
|
|
16
|
+
{
|
|
17
|
+
static dispatch_once_t onceToken;
|
|
18
|
+
static NSArray<NSString *> *whiteListClasses;
|
|
19
|
+
static NSArray<NSString *> *superviewWhiteListClasses;
|
|
20
|
+
dispatch_once(&onceToken, ^{
|
|
21
|
+
// UITextFieldLabel
|
|
22
|
+
whiteListClasses = @[FWBase64Decode(@"VUlUZXh0RmllbGRMYWJlbA==")];
|
|
23
|
+
// UIDatePickerContentView
|
|
24
|
+
superviewWhiteListClasses = @[FWBase64Decode(@"VUlEYXRlUGlja2VyQ29udGVudFZpZXc=")];
|
|
25
|
+
});
|
|
26
|
+
for (NSString *className in whiteListClasses) {
|
|
27
|
+
if ([self isKindOfClass:NSClassFromString(className)]) {
|
|
28
|
+
return NO;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (NSString *className in superviewWhiteListClasses) {
|
|
32
|
+
if ([self.superview isKindOfClass:NSClassFromString(className)]) {
|
|
33
|
+
return NO;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return YES;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//
|
|
2
|
+
// UIView+FWRTL.h
|
|
3
|
+
// FWRTL
|
|
4
|
+
//
|
|
5
|
+
// Created by ByteDance on 2018/9/10.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <UIKit/UIKit.h>
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The view's behavior in RTL environment
|
|
12
|
+
* - FWRTLViewTypeAuto: The view's behavior will be automatically judged according to its class.
|
|
13
|
+
* - FWRTLViewTypeInherit: The view's behavior will depend on its superview.
|
|
14
|
+
* - FWRTLViewTypeNormal: The view itself will always be normal in any conditions.
|
|
15
|
+
* - FWRTLViewTypeFlip: The view itself will always be flipped in any conditions.
|
|
16
|
+
* - FWRTLViewTypeNormalWithAllDescendants: The view and all its descendants will always be normal in any conditions.
|
|
17
|
+
* - FWRTLViewTypeFlipWithAllDescendants: The view and all its descendants will always be flipped in any conditions.
|
|
18
|
+
*/
|
|
19
|
+
typedef enum : NSUInteger {
|
|
20
|
+
FWRTLViewTypeAuto,
|
|
21
|
+
FWRTLViewTypeInherit,
|
|
22
|
+
FWRTLViewTypeNormal,
|
|
23
|
+
FWRTLViewTypeFlip,
|
|
24
|
+
FWRTLViewTypeNormalWithAllDescendants,
|
|
25
|
+
FWRTLViewTypeFlipWithAllDescendants,
|
|
26
|
+
} FWRTLViewType;
|
|
27
|
+
|
|
28
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
29
|
+
|
|
30
|
+
@interface UIView (FWRTL)
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Set the view's behavior via this property
|
|
34
|
+
*/
|
|
35
|
+
@property (nonatomic, assign) FWRTLViewType fwrtl_viewType;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The view's calculated behavior considering its view type and its view hierarchy
|
|
39
|
+
*/
|
|
40
|
+
@property (nonatomic, assign, readonly) FWRTLViewType fwrtl_calculatedViewType;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Force renewing the view's RTL behavior w/wo its descendants
|
|
44
|
+
*/
|
|
45
|
+
- (void)fwrtl_renewLayerTransformForceRecursively:(BOOL)forceRecursively;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* [For Overriding] The view's actual behavior when it's set to FWRTLViewTypeAuto
|
|
49
|
+
*/
|
|
50
|
+
- (FWRTLViewType)fwrtl_automaticViewType;
|
|
51
|
+
|
|
52
|
+
@end
|
|
53
|
+
|
|
54
|
+
NS_ASSUME_NONNULL_END
|