@leonsilicon/react-native-wishlist 0.0.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/LICENSE +20 -0
- package/MGWishList.podspec +40 -0
- package/README.md +281 -0
- package/android/CMakeLists.txt +86 -0
- package/android/build.gradle +72 -0
- package/android/gradle.properties +5 -0
- package/android/spotless.gradle +24 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/wishlist/ContentContainer.kt +22 -0
- package/android/src/main/java/com/wishlist/Orchestrator.kt +38 -0
- package/android/src/main/java/com/wishlist/TemplateContainer.kt +30 -0
- package/android/src/main/java/com/wishlist/TemplateContainerViewManager.kt +65 -0
- package/android/src/main/java/com/wishlist/TemplateInterceptor.kt +29 -0
- package/android/src/main/java/com/wishlist/TemplateInterceptorViewManager.kt +23 -0
- package/android/src/main/java/com/wishlist/UIScheduler.kt +15 -0
- package/android/src/main/java/com/wishlist/Wishlist.kt +135 -0
- package/android/src/main/java/com/wishlist/WishlistManagerModule.kt +51 -0
- package/android/src/main/java/com/wishlist/WishlistPackage.kt +47 -0
- package/android/src/main/java/com/wishlist/WishlistSoLoader.kt +17 -0
- package/android/src/main/java/com/wishlist/WishlistViewManager.kt +69 -0
- package/android/src/main/jni/ErrorHandlerAndroid.cpp +16 -0
- package/android/src/main/jni/ErrorHandlerAndroid.h +13 -0
- package/android/src/main/jni/JNIStateRegistry.cpp +22 -0
- package/android/src/main/jni/JNIStateRegistry.h +23 -0
- package/android/src/main/jni/OnLoad.cpp +12 -0
- package/android/src/main/jni/Orchestrator.cpp +167 -0
- package/android/src/main/jni/Orchestrator.hpp +78 -0
- package/android/src/main/jni/UISchedulerAndroid.cpp +20 -0
- package/android/src/main/jni/UISchedulerAndroid.h +18 -0
- package/android/src/main/jni/WishlistManagerModule.cpp +91 -0
- package/android/src/main/jni/WishlistManagerModule.hpp +43 -0
- package/android/src/main/jni/wishlist.h +19 -0
- package/cpp/ContentContainer/MGContentContainerComponentDescriptor.h +40 -0
- package/cpp/ContentContainer/MGContentContainerShadowNode.cpp +21 -0
- package/cpp/ContentContainer/MGContentContainerShadowNode.h +30 -0
- package/cpp/ContentContainer/MGContentContainerState.cpp +31 -0
- package/cpp/ContentContainer/MGContentContainerState.h +39 -0
- package/cpp/DataBinding/MGBindingProvider.hpp +21 -0
- package/cpp/DataBinding/MGDataBinding.hpp +23 -0
- package/cpp/DataBinding/MGDataBindingImpl.cpp +112 -0
- package/cpp/DataBinding/MGDataBindingImpl.hpp +35 -0
- package/cpp/DependencyInjection/MGDI.hpp +33 -0
- package/cpp/DependencyInjection/MGDIImpl.cpp +65 -0
- package/cpp/DependencyInjection/MGDIImpl.hpp +45 -0
- package/cpp/DependencyInjection/MGUIManagerHolder.cpp +21 -0
- package/cpp/DependencyInjection/MGUIManagerHolder.h +24 -0
- package/cpp/ItemProvider/ComponentsPool.cpp +91 -0
- package/cpp/ItemProvider/ComponentsPool.h +49 -0
- package/cpp/ItemProvider/ItemProvider.cpp +60 -0
- package/cpp/ItemProvider/ItemProvider.h +67 -0
- package/cpp/ItemProvider/ShadowNodeBinding.cpp +356 -0
- package/cpp/ItemProvider/ShadowNodeBinding.h +59 -0
- package/cpp/ItemProvider/ShadowNodeCopyMachine.cpp +95 -0
- package/cpp/ItemProvider/ShadowNodeCopyMachine.h +25 -0
- package/cpp/MGErrorHandler.h +12 -0
- package/cpp/MGViewportCarer/MGVSyncRequester.hpp +18 -0
- package/cpp/MGViewportCarer/MGViewportCarer.hpp +42 -0
- package/cpp/MGViewportCarer/MGViewportCarerImpl.cpp +453 -0
- package/cpp/MGViewportCarer/MGViewportCarerImpl.h +80 -0
- package/cpp/MGViewportCarer/MGViewportCarerListener.hpp +27 -0
- package/cpp/TemplateContainer/MGTemplateContainerComponentDescriptor.h +15 -0
- package/cpp/TemplateContainer/MGTemplateContainerShadowNode.cpp +43 -0
- package/cpp/TemplateContainer/MGTemplateContainerShadowNode.h +42 -0
- package/cpp/TemplateContainer/MGTemplateContainerState.cpp +37 -0
- package/cpp/TemplateContainer/MGTemplateContainerState.h +39 -0
- package/cpp/UIScheduler/MGUIScheduler.cpp +8 -0
- package/cpp/UIScheduler/MGUIScheduler.hpp +18 -0
- package/cpp/Wishlist/MGWishlistComponentDescriptor.h +14 -0
- package/cpp/Wishlist/MGWishlistShadowNode.cpp +49 -0
- package/cpp/Wishlist/MGWishlistShadowNode.h +37 -0
- package/cpp/Wishlist/MGWishlistState.cpp +57 -0
- package/cpp/Wishlist/MGWishlistState.h +42 -0
- package/cpp/WishlistDefine.h +3 -0
- package/cpp/WishlistJsRuntime.cpp +139 -0
- package/cpp/WishlistJsRuntime.h +59 -0
- package/ios/MGContentContainerComponent.h +9 -0
- package/ios/MGContentContainerComponent.mm +34 -0
- package/ios/MGErrorHandlerIOS.h +13 -0
- package/ios/MGErrorHandlerIOS.mm +12 -0
- package/ios/MGObjCJSIUtils.h +63 -0
- package/ios/MGTemplateContainerComponent.h +12 -0
- package/ios/MGTemplateContainerComponent.mm +105 -0
- package/ios/MGTemplateInterceptorComponent.h +9 -0
- package/ios/MGTemplateInterceptorComponent.mm +72 -0
- package/ios/MGWishListComponent.h +17 -0
- package/ios/MGWishListComponent.mm +187 -0
- package/ios/MGWishlistManager.h +21 -0
- package/ios/MGWishlistManager.mm +319 -0
- package/ios/MGWishlistQueue.h +11 -0
- package/ios/MGWishlistQueue.m +34 -0
- package/ios/Orchestrator/MGOrchestrator.h +35 -0
- package/ios/Orchestrator/MGOrchestrator.mm +139 -0
- package/ios/Orchestrator/MGOrchestratorCppAdapter.cpp +25 -0
- package/ios/Orchestrator/MGOrchestratorCppAdapter.hpp +32 -0
- package/ios/UIScheduleriOS/MGUIScheduleriOS.hpp +19 -0
- package/ios/UIScheduleriOS/MGUIScheduleriOS.mm +21 -0
- package/lib/commonjs/Colors.js +399 -0
- package/lib/commonjs/Colors.js.map +1 -0
- package/lib/commonjs/ComponentPool.js +28 -0
- package/lib/commonjs/ComponentPool.js.map +1 -0
- package/lib/commonjs/Components/ForEach.js +21 -0
- package/lib/commonjs/Components/ForEach.js.map +1 -0
- package/lib/commonjs/Components/ForEachBase.js +19 -0
- package/lib/commonjs/Components/ForEachBase.js.map +1 -0
- package/lib/commonjs/Components/IF.js +34 -0
- package/lib/commonjs/Components/IF.js.map +1 -0
- package/lib/commonjs/Components/Pressable.js +73 -0
- package/lib/commonjs/Components/Pressable.js.map +1 -0
- package/lib/commonjs/Components/Switch.js +52 -0
- package/lib/commonjs/Components/Switch.js.map +1 -0
- package/lib/commonjs/Components/WishlistImage.js +29 -0
- package/lib/commonjs/Components/WishlistImage.js.map +1 -0
- package/lib/commonjs/Components/WishlistText.js +24 -0
- package/lib/commonjs/Components/WishlistText.js.map +1 -0
- package/lib/commonjs/Components/WishlistView.js +10 -0
- package/lib/commonjs/Components/WishlistView.js.map +1 -0
- package/lib/commonjs/EventHandler.js +72 -0
- package/lib/commonjs/EventHandler.js.map +1 -0
- package/lib/commonjs/InflatorRepository.js +155 -0
- package/lib/commonjs/InflatorRepository.js.map +1 -0
- package/lib/commonjs/OrchestratorBinding.js +12 -0
- package/lib/commonjs/OrchestratorBinding.js.map +1 -0
- package/lib/commonjs/Specs/NativeContentContainer.js +12 -0
- package/lib/commonjs/Specs/NativeContentContainer.js.map +1 -0
- package/lib/commonjs/Specs/NativeTemplateContainer.js +12 -0
- package/lib/commonjs/Specs/NativeTemplateContainer.js.map +1 -0
- package/lib/commonjs/Specs/NativeTemplateInterceptor.js +10 -0
- package/lib/commonjs/Specs/NativeTemplateInterceptor.js.map +1 -0
- package/lib/commonjs/Specs/NativeWishlist.js +16 -0
- package/lib/commonjs/Specs/NativeWishlist.js.map +1 -0
- package/lib/commonjs/Specs/NativeWishlistManager.js +9 -0
- package/lib/commonjs/Specs/NativeWishlistManager.js.map +1 -0
- package/lib/commonjs/TemplateContext.js +17 -0
- package/lib/commonjs/TemplateContext.js.map +1 -0
- package/lib/commonjs/TemplateItem.js +2 -0
- package/lib/commonjs/TemplateItem.js.map +1 -0
- package/lib/commonjs/TemplateValue.js +68 -0
- package/lib/commonjs/TemplateValue.js.map +1 -0
- package/lib/commonjs/Utils.js +20 -0
- package/lib/commonjs/Utils.js.map +1 -0
- package/lib/commonjs/Wishlist.js +290 -0
- package/lib/commonjs/Wishlist.js.map +1 -0
- package/lib/commonjs/WishlistContext.js +17 -0
- package/lib/commonjs/WishlistContext.js.map +1 -0
- package/lib/commonjs/WishlistData.js +149 -0
- package/lib/commonjs/WishlistData.js.map +1 -0
- package/lib/commonjs/WishlistDataCopy.js +115 -0
- package/lib/commonjs/WishlistDataCopy.js.map +1 -0
- package/lib/commonjs/WishlistJsRuntime.android.js +22 -0
- package/lib/commonjs/WishlistJsRuntime.android.js.map +1 -0
- package/lib/commonjs/WishlistJsRuntime.js +42 -0
- package/lib/commonjs/WishlistJsRuntime.js.map +1 -0
- package/lib/commonjs/createTemplateComponent.js +196 -0
- package/lib/commonjs/createTemplateComponent.js.map +1 -0
- package/lib/commonjs/global.d.js +2 -0
- package/lib/commonjs/global.d.js.map +1 -0
- package/lib/commonjs/index.js +83 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/renderTemplate.js +14 -0
- package/lib/commonjs/renderTemplate.js.map +1 -0
- package/lib/module/Colors.js +395 -0
- package/lib/module/Colors.js.map +1 -0
- package/lib/module/ComponentPool.js +24 -0
- package/lib/module/ComponentPool.js.map +1 -0
- package/lib/module/Components/ForEach.js +17 -0
- package/lib/module/Components/ForEach.js.map +1 -0
- package/lib/module/Components/ForEachBase.js +14 -0
- package/lib/module/Components/ForEachBase.js.map +1 -0
- package/lib/module/Components/IF.js +29 -0
- package/lib/module/Components/IF.js.map +1 -0
- package/lib/module/Components/Pressable.js +68 -0
- package/lib/module/Components/Pressable.js.map +1 -0
- package/lib/module/Components/Switch.js +45 -0
- package/lib/module/Components/Switch.js.map +1 -0
- package/lib/module/Components/WishlistImage.js +25 -0
- package/lib/module/Components/WishlistImage.js.map +1 -0
- package/lib/module/Components/WishlistText.js +20 -0
- package/lib/module/Components/WishlistText.js.map +1 -0
- package/lib/module/Components/WishlistView.js +6 -0
- package/lib/module/Components/WishlistView.js.map +1 -0
- package/lib/module/EventHandler.js +66 -0
- package/lib/module/EventHandler.js.map +1 -0
- package/lib/module/InflatorRepository.js +149 -0
- package/lib/module/InflatorRepository.js.map +1 -0
- package/lib/module/OrchestratorBinding.js +8 -0
- package/lib/module/OrchestratorBinding.js.map +1 -0
- package/lib/module/Specs/NativeContentContainer.js +7 -0
- package/lib/module/Specs/NativeContentContainer.js.map +1 -0
- package/lib/module/Specs/NativeTemplateContainer.js +7 -0
- package/lib/module/Specs/NativeTemplateContainer.js.map +1 -0
- package/lib/module/Specs/NativeTemplateInterceptor.js +5 -0
- package/lib/module/Specs/NativeTemplateInterceptor.js.map +1 -0
- package/lib/module/Specs/NativeWishlist.js +11 -0
- package/lib/module/Specs/NativeWishlist.js.map +1 -0
- package/lib/module/Specs/NativeWishlistManager.js +5 -0
- package/lib/module/Specs/NativeWishlistManager.js.map +1 -0
- package/lib/module/TemplateContext.js +12 -0
- package/lib/module/TemplateContext.js.map +1 -0
- package/lib/module/TemplateItem.js +2 -0
- package/lib/module/TemplateItem.js.map +1 -0
- package/lib/module/TemplateValue.js +63 -0
- package/lib/module/TemplateValue.js.map +1 -0
- package/lib/module/Utils.js +15 -0
- package/lib/module/Utils.js.map +1 -0
- package/lib/module/Wishlist.js +284 -0
- package/lib/module/Wishlist.js.map +1 -0
- package/lib/module/WishlistContext.js +12 -0
- package/lib/module/WishlistContext.js.map +1 -0
- package/lib/module/WishlistData.js +144 -0
- package/lib/module/WishlistData.js.map +1 -0
- package/lib/module/WishlistDataCopy.js +111 -0
- package/lib/module/WishlistDataCopy.js.map +1 -0
- package/lib/module/WishlistJsRuntime.android.js +16 -0
- package/lib/module/WishlistJsRuntime.android.js.map +1 -0
- package/lib/module/WishlistJsRuntime.js +35 -0
- package/lib/module/WishlistJsRuntime.js.map +1 -0
- package/lib/module/createTemplateComponent.js +191 -0
- package/lib/module/createTemplateComponent.js.map +1 -0
- package/lib/module/global.d.js +2 -0
- package/lib/module/global.d.js.map +1 -0
- package/lib/module/index.js +14 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/renderTemplate.js +10 -0
- package/lib/module/renderTemplate.js.map +1 -0
- package/lib/typescript/Colors.d.ts +7 -0
- package/lib/typescript/Colors.d.ts.map +1 -0
- package/lib/typescript/ComponentPool.d.ts +10 -0
- package/lib/typescript/ComponentPool.d.ts.map +1 -0
- package/lib/typescript/Components/ForEach.d.ts +2 -0
- package/lib/typescript/Components/ForEach.d.ts.map +1 -0
- package/lib/typescript/Components/ForEachBase.d.ts +3 -0
- package/lib/typescript/Components/ForEachBase.d.ts.map +1 -0
- package/lib/typescript/Components/IF.d.ts +3 -0
- package/lib/typescript/Components/IF.d.ts.map +1 -0
- package/lib/typescript/Components/Pressable.d.ts +15 -0
- package/lib/typescript/Components/Pressable.d.ts.map +1 -0
- package/lib/typescript/Components/Switch.d.ts +17 -0
- package/lib/typescript/Components/Switch.d.ts.map +1 -0
- package/lib/typescript/Components/WishlistImage.d.ts +3 -0
- package/lib/typescript/Components/WishlistImage.d.ts.map +1 -0
- package/lib/typescript/Components/WishlistText.d.ts +3 -0
- package/lib/typescript/Components/WishlistText.d.ts.map +1 -0
- package/lib/typescript/Components/WishlistView.d.ts +3 -0
- package/lib/typescript/Components/WishlistView.d.ts.map +1 -0
- package/lib/typescript/EventHandler.d.ts +9 -0
- package/lib/typescript/EventHandler.d.ts.map +1 -0
- package/lib/typescript/InflatorRepository.d.ts +28 -0
- package/lib/typescript/InflatorRepository.d.ts.map +1 -0
- package/lib/typescript/OrchestratorBinding.d.ts +13 -0
- package/lib/typescript/OrchestratorBinding.d.ts.map +1 -0
- package/lib/typescript/Specs/NativeContentContainer.d.ts +6 -0
- package/lib/typescript/Specs/NativeContentContainer.d.ts.map +1 -0
- package/lib/typescript/Specs/NativeTemplateContainer.d.ts +9 -0
- package/lib/typescript/Specs/NativeTemplateContainer.d.ts.map +1 -0
- package/lib/typescript/Specs/NativeTemplateInterceptor.d.ts +6 -0
- package/lib/typescript/Specs/NativeTemplateInterceptor.d.ts.map +1 -0
- package/lib/typescript/Specs/NativeWishlist.d.ts +22 -0
- package/lib/typescript/Specs/NativeWishlist.d.ts.map +1 -0
- package/lib/typescript/Specs/NativeWishlistManager.d.ts +7 -0
- package/lib/typescript/Specs/NativeWishlistManager.d.ts.map +1 -0
- package/lib/typescript/TemplateContext.d.ts +9 -0
- package/lib/typescript/TemplateContext.d.ts.map +1 -0
- package/lib/typescript/TemplateItem.d.ts +13 -0
- package/lib/typescript/TemplateItem.d.ts.map +1 -0
- package/lib/typescript/TemplateValue.d.ts +16 -0
- package/lib/typescript/TemplateValue.d.ts.map +1 -0
- package/lib/typescript/Utils.d.ts +3 -0
- package/lib/typescript/Utils.d.ts.map +1 -0
- package/lib/typescript/Wishlist.d.ts +59 -0
- package/lib/typescript/Wishlist.d.ts.map +1 -0
- package/lib/typescript/WishlistContext.d.ts +11 -0
- package/lib/typescript/WishlistContext.d.ts.map +1 -0
- package/lib/typescript/WishlistData.d.ts +20 -0
- package/lib/typescript/WishlistData.d.ts.map +1 -0
- package/lib/typescript/WishlistDataCopy.d.ts +25 -0
- package/lib/typescript/WishlistDataCopy.d.ts.map +1 -0
- package/lib/typescript/WishlistJsRuntime.android.d.ts +4 -0
- package/lib/typescript/WishlistJsRuntime.android.d.ts.map +1 -0
- package/lib/typescript/WishlistJsRuntime.d.ts +6 -0
- package/lib/typescript/WishlistJsRuntime.d.ts.map +1 -0
- package/lib/typescript/createTemplateComponent.d.ts +35 -0
- package/lib/typescript/createTemplateComponent.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +8 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/renderTemplate.d.ts +3 -0
- package/lib/typescript/renderTemplate.d.ts.map +1 -0
- package/package.json +195 -0
- package/src/Colors.ts +474 -0
- package/src/ComponentPool.ts +33 -0
- package/src/Components/ForEach.tsx +22 -0
- package/src/Components/ForEachBase.tsx +8 -0
- package/src/Components/IF.tsx +20 -0
- package/src/Components/Pressable.tsx +111 -0
- package/src/Components/Switch.tsx +49 -0
- package/src/Components/WishlistImage.tsx +25 -0
- package/src/Components/WishlistText.tsx +14 -0
- package/src/Components/WishlistView.tsx +4 -0
- package/src/EventHandler.ts +78 -0
- package/src/InflatorRepository.ts +231 -0
- package/src/OrchestratorBinding.ts +15 -0
- package/src/Specs/NativeContentContainer.ts +9 -0
- package/src/Specs/NativeTemplateContainer.ts +13 -0
- package/src/Specs/NativeTemplateInterceptor.ts +8 -0
- package/src/Specs/NativeWishlist.ts +42 -0
- package/src/Specs/NativeWishlistManager.ts +7 -0
- package/src/TemplateContext.tsx +14 -0
- package/src/TemplateItem.ts +15 -0
- package/src/TemplateValue.tsx +101 -0
- package/src/Utils.ts +15 -0
- package/src/Wishlist.tsx +417 -0
- package/src/WishlistContext.tsx +15 -0
- package/src/WishlistData.ts +179 -0
- package/src/WishlistDataCopy.ts +138 -0
- package/src/WishlistJsRuntime.android.ts +20 -0
- package/src/WishlistJsRuntime.ts +59 -0
- package/src/createTemplateComponent.tsx +263 -0
- package/src/global.d.ts +1 -0
- package/src/index.ts +17 -0
- package/src/renderTemplate.ts +22 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#import "MGTemplateContainerComponent.h"
|
|
2
|
+
#import <react/renderer/components/wishlist/ComponentDescriptors.h>
|
|
3
|
+
#import "MGTemplateContainerComponentDescriptor.h"
|
|
4
|
+
#import "MGTemplateContainerShadowNode.h"
|
|
5
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
6
|
+
|
|
7
|
+
using namespace facebook::react;
|
|
8
|
+
|
|
9
|
+
static std::vector<std::string> parseTemplateNames(std::string const &namesJson)
|
|
10
|
+
{
|
|
11
|
+
if (namesJson.empty()) {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
NSString *jsonString = [NSString stringWithUTF8String:namesJson.c_str()];
|
|
16
|
+
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
|
|
17
|
+
if (!jsonData) {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
NSError *error = nil;
|
|
22
|
+
id parsed = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
|
|
23
|
+
if (error || ![parsed isKindOfClass:NSArray.class]) {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
NSArray *names = (NSArray *)parsed;
|
|
28
|
+
std::vector<std::string> result;
|
|
29
|
+
result.reserve(names.count);
|
|
30
|
+
for (id name in names) {
|
|
31
|
+
if ([name isKindOfClass:NSString.class]) {
|
|
32
|
+
result.emplace_back([(NSString *)name UTF8String]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@implementation MGTemplateContainerComponent {
|
|
39
|
+
MGTemplateContainerShadowNode::ConcreteState::Shared _state;
|
|
40
|
+
MGWishListComponent *_wishList;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
44
|
+
{
|
|
45
|
+
if (self = [super initWithFrame:frame]) {
|
|
46
|
+
static const auto defaultProps = std::make_shared<const MGTemplateContainerProps>();
|
|
47
|
+
_props = defaultProps;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return self;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- (void)setWishlist:(MGWishListComponent *)wishList
|
|
54
|
+
{
|
|
55
|
+
_wishList = wishList;
|
|
56
|
+
[self updateWishlist];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#pragma mark - RCTComponentViewProtocol
|
|
60
|
+
|
|
61
|
+
+ (facebook::react::ComponentDescriptorProvider)componentDescriptorProvider
|
|
62
|
+
{
|
|
63
|
+
return facebook::react::concreteComponentDescriptorProvider<
|
|
64
|
+
facebook::react::MGTemplateContainerComponentDescriptor>();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
68
|
+
{
|
|
69
|
+
[super updateProps:props oldProps:oldProps];
|
|
70
|
+
[self updateWishlist];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
- (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState
|
|
74
|
+
{
|
|
75
|
+
auto templateState = std::static_pointer_cast<MGTemplateContainerShadowNode::ConcreteState const>(state);
|
|
76
|
+
_state = templateState;
|
|
77
|
+
[self updateWishlist];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
- (void)prepareForRecycle
|
|
81
|
+
{
|
|
82
|
+
[super prepareForRecycle];
|
|
83
|
+
|
|
84
|
+
_wishList = nil;
|
|
85
|
+
_state.reset();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
- (void)updateWishlist
|
|
89
|
+
{
|
|
90
|
+
if (!_wishList || !_state) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
auto props = std::static_pointer_cast<const MGTemplateContainerProps>(_props);
|
|
94
|
+
auto state = std::static_pointer_cast<MGTemplateContainerShadowNode::ConcreteState const>(_state);
|
|
95
|
+
[_wishList setWishlistId:props->wishlistId];
|
|
96
|
+
[_wishList setInflatorId:props->inflatorId];
|
|
97
|
+
[_wishList setTemplates:state->getData().getTemplates() withNames:parseTemplateNames(props->names)];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@end
|
|
101
|
+
|
|
102
|
+
Class<RCTComponentViewProtocol> MGTemplateContainerCls(void)
|
|
103
|
+
{
|
|
104
|
+
return MGTemplateContainerComponent.class;
|
|
105
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#import "MGTemplateInterceptorComponent.h"
|
|
2
|
+
#import <react/renderer/components/wishlist/ComponentDescriptors.h>
|
|
3
|
+
#import <react/renderer/components/wishlist/Props.h>
|
|
4
|
+
#import "MGTemplateContainerComponent.h"
|
|
5
|
+
#import "MGWishListComponent.h"
|
|
6
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
7
|
+
|
|
8
|
+
using namespace facebook::react;
|
|
9
|
+
|
|
10
|
+
@implementation MGTemplateInterceptorComponent {
|
|
11
|
+
MGWishListComponent *_wishlist;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#pragma mark - RCTComponentViewProtocol
|
|
15
|
+
|
|
16
|
+
+ (facebook::react::ComponentDescriptorProvider)componentDescriptorProvider
|
|
17
|
+
{
|
|
18
|
+
return facebook::react::concreteComponentDescriptorProvider<
|
|
19
|
+
facebook::react::MGTemplateInterceptorComponentDescriptor>();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* Called for mounting (attaching) a child component view inside `self`
|
|
24
|
+
* component view.
|
|
25
|
+
* Receiver must add `childComponentView` as a subview.
|
|
26
|
+
*/
|
|
27
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
28
|
+
{
|
|
29
|
+
if ([childComponentView isKindOfClass:[MGTemplateContainerComponent class]]) {
|
|
30
|
+
MGTemplateContainerComponent *container = (MGTemplateContainerComponent *)childComponentView;
|
|
31
|
+
if (_wishlist != nil) {
|
|
32
|
+
[container setWishlist:_wishlist];
|
|
33
|
+
}
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if ([childComponentView isKindOfClass:[MGWishListComponent class]]) {
|
|
37
|
+
_wishlist = (MGWishListComponent *)childComponentView;
|
|
38
|
+
}
|
|
39
|
+
[super mountChildComponentView:childComponentView index:index];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
* Called for unmounting (detaching) a child component view from `self`
|
|
44
|
+
* component view.
|
|
45
|
+
* Receiver must remove `childComponentView` as a subview.
|
|
46
|
+
*/
|
|
47
|
+
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
48
|
+
{
|
|
49
|
+
if ([childComponentView isKindOfClass:[MGWishListComponent class]]) {
|
|
50
|
+
_wishlist = nil;
|
|
51
|
+
}
|
|
52
|
+
if ([childComponentView isKindOfClass:[MGTemplateContainerComponent class]]) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
[super unmountChildComponentView:childComponentView index:index];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#pragma clang diagnostic push
|
|
59
|
+
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
|
|
60
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
61
|
+
{
|
|
62
|
+
auto wProps = std::static_pointer_cast<const MGTemplateInterceptorProps>(props);
|
|
63
|
+
_props = wProps;
|
|
64
|
+
}
|
|
65
|
+
#pragma clang diagnostic pop
|
|
66
|
+
|
|
67
|
+
@end
|
|
68
|
+
|
|
69
|
+
Class<RCTComponentViewProtocol> MGTemplateInterceptorCls(void)
|
|
70
|
+
{
|
|
71
|
+
return MGTemplateInterceptorComponent.class;
|
|
72
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <React-RCTFabric/React/RCTScrollViewComponentView.h>
|
|
3
|
+
#import <React-RCTFabric/React/RCTViewComponentView.h>
|
|
4
|
+
#include <react/renderer/components/wishlist/RCTComponentViewHelpers.h>
|
|
5
|
+
|
|
6
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
7
|
+
|
|
8
|
+
@interface MGWishListComponent : RCTScrollViewComponentView <RCTMGWishlistViewProtocol>
|
|
9
|
+
|
|
10
|
+
- (void)setTemplates:(std::vector<std::shared_ptr<facebook::react::ShadowNode const>>)templates
|
|
11
|
+
withNames:(std::vector<std::string>)names;
|
|
12
|
+
- (void)setInflatorId:(std::string)inflatorId;
|
|
13
|
+
- (void)setWishlistId:(std::string)wishlistId;
|
|
14
|
+
|
|
15
|
+
@end
|
|
16
|
+
|
|
17
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
#import "MGWishListComponent.h"
|
|
2
|
+
#import <React/RCTConversions.h>
|
|
3
|
+
#import <React/RCTImageResponseDelegate.h>
|
|
4
|
+
#import <React/RCTImageResponseObserverProxy.h>
|
|
5
|
+
|
|
6
|
+
#import <React/RCTBridgeModule.h>
|
|
7
|
+
#import <React/RCTComponentViewFactory.h>
|
|
8
|
+
#import <react/renderer/components/rncore/EventEmitters.h>
|
|
9
|
+
#import <react/renderer/components/rncore/Props.h>
|
|
10
|
+
#include <react/renderer/components/wishlist/Props.h>
|
|
11
|
+
#include <react/renderer/components/wishlist/ShadowNodes.h>
|
|
12
|
+
#import "MGOrchestrator.h"
|
|
13
|
+
#import "MGWishlistComponentDescriptor.h"
|
|
14
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
15
|
+
#include "WishlistDefine.h"
|
|
16
|
+
|
|
17
|
+
#define MG_INITIAL_CONTENT_SIZE 100000
|
|
18
|
+
|
|
19
|
+
using namespace facebook::react;
|
|
20
|
+
|
|
21
|
+
@interface RCTScrollViewComponentView (MGWishList)
|
|
22
|
+
|
|
23
|
+
- (void)scrollViewDidScroll:(UIScrollView *)sv;
|
|
24
|
+
|
|
25
|
+
@end
|
|
26
|
+
|
|
27
|
+
@implementation MGWishListComponent {
|
|
28
|
+
MGWishlistShadowNode::ConcreteState::Shared _state;
|
|
29
|
+
std::string _inflatorId;
|
|
30
|
+
std::string _wishlistId;
|
|
31
|
+
MGOrchestrator *_orchestrator;
|
|
32
|
+
std::shared_ptr<const MGWishlistEventEmitter> _emitter;
|
|
33
|
+
int _initialIndex;
|
|
34
|
+
BOOL _ignoreScrollEvents;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
38
|
+
{
|
|
39
|
+
if (self = [super initWithFrame:frame]) {
|
|
40
|
+
self.clipsToBounds = YES;
|
|
41
|
+
self.scrollView.showsVerticalScrollIndicator = NO;
|
|
42
|
+
self.scrollView.clipsToBounds = YES;
|
|
43
|
+
_ignoreScrollEvents = NO;
|
|
44
|
+
}
|
|
45
|
+
return self;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
49
|
+
{
|
|
50
|
+
[super mountChildComponentView:childComponentView index:index];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- (void)setInflatorId:(std::string)nextInflatorId
|
|
54
|
+
{
|
|
55
|
+
_inflatorId = nextInflatorId;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
- (void)setWishlistId:(std::string)wishlistId
|
|
59
|
+
{
|
|
60
|
+
_wishlistId = wishlistId;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView
|
|
64
|
+
{
|
|
65
|
+
[self scrollToItem:0 animated:YES]; // Maybe it would be better to scroll to initial (which is not always 0)
|
|
66
|
+
return NO;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
- (void)setTemplates:(std::vector<std::shared_ptr<facebook::react::ShadowNode const>>)templates
|
|
70
|
+
withNames:(std::vector<std::string>)names
|
|
71
|
+
{
|
|
72
|
+
if (!_orchestrator) {
|
|
73
|
+
self.scrollView.contentSize = CGSizeMake(self.frame.size.width, MG_INITIAL_CONTENT_SIZE);
|
|
74
|
+
self.scrollView.contentOffset = CGPointMake(0, MG_INITIAL_CONTENT_SIZE / 2);
|
|
75
|
+
|
|
76
|
+
std::shared_ptr<MGViewportCarerImpl> viewportCarer = _state->getData().viewportCarer;
|
|
77
|
+
_orchestrator = [[MGOrchestrator alloc] initWith:self wishlistId:_wishlistId viewportCarer:viewportCarer];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
[_orchestrator
|
|
81
|
+
renderAsyncWithDimensions:{(float)self.scrollView.frame.size.width, (float)self.scrollView.frame.size.height}
|
|
82
|
+
initialContentSize:MG_INITIAL_CONTENT_SIZE
|
|
83
|
+
initialIndex:_initialIndex
|
|
84
|
+
templates:templates
|
|
85
|
+
names:names
|
|
86
|
+
inflatorId:_inflatorId];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
#pragma mark - RCTComponentViewProtocol
|
|
90
|
+
|
|
91
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
92
|
+
{
|
|
93
|
+
return concreteComponentDescriptorProvider<MGWishlistComponentDescriptor>();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
#pragma clang diagnostic push
|
|
97
|
+
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
|
|
98
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
99
|
+
{
|
|
100
|
+
std::shared_ptr<const MGWishlistProps> wProps = std::static_pointer_cast<const MGWishlistProps>(props);
|
|
101
|
+
_initialIndex = wProps->initialIndex;
|
|
102
|
+
|
|
103
|
+
_props = wProps;
|
|
104
|
+
}
|
|
105
|
+
#pragma clang diagnostic pop
|
|
106
|
+
|
|
107
|
+
- (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState
|
|
108
|
+
{
|
|
109
|
+
// Updating content size or offset can trigger scroll events but we do not want to
|
|
110
|
+
// process those as they can have invalid offset or were already processed.
|
|
111
|
+
_ignoreScrollEvents = YES;
|
|
112
|
+
|
|
113
|
+
assert(std::dynamic_pointer_cast<MGWishlistShadowNode::ConcreteState const>(state));
|
|
114
|
+
_state = std::static_pointer_cast<MGWishlistShadowNode::ConcreteState const>(state);
|
|
115
|
+
auto &data = _state->getData();
|
|
116
|
+
|
|
117
|
+
CGSize contentSize = RCTCGSizeFromSize(data.contentBoundingRect.size);
|
|
118
|
+
self.contentView.frame = CGRect{RCTCGPointFromPoint(data.contentBoundingRect.origin), contentSize};
|
|
119
|
+
self.scrollView.contentSize = contentSize;
|
|
120
|
+
|
|
121
|
+
#if MG_WISHLIST_DEBUG
|
|
122
|
+
std::cout << "updateState {offset: " << data.contentOffset << ", contentHeight: " << contentSize.height << "}"
|
|
123
|
+
<< std::endl;
|
|
124
|
+
#endif
|
|
125
|
+
|
|
126
|
+
if (data.contentOffset != MG_NO_OFFSET) {
|
|
127
|
+
[self.scrollView setContentOffset:{0, data.contentOffset} animated:NO];
|
|
128
|
+
data.viewportCarer->didUpdateContentOffset();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
_ignoreScrollEvents = NO;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
#pragma clang diagnostic push
|
|
135
|
+
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
|
|
136
|
+
- (void)updateEventEmitter:(EventEmitter::Shared const &)eventEmitter
|
|
137
|
+
{
|
|
138
|
+
_emitter = std::static_pointer_cast<MGWishlistEventEmitter const>(eventEmitter);
|
|
139
|
+
}
|
|
140
|
+
#pragma clang diagnostic pop
|
|
141
|
+
|
|
142
|
+
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
|
143
|
+
{
|
|
144
|
+
if (_ignoreScrollEvents) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
[_orchestrator didScrollAsyncWithDimensions:{(float)scrollView.frame.size.width, (float)scrollView.frame.size.height}
|
|
149
|
+
contentOffset:scrollView.contentOffset.y
|
|
150
|
+
inflatorId:_inflatorId];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
- (void)prepareForRecycle
|
|
154
|
+
{
|
|
155
|
+
_state.reset();
|
|
156
|
+
_orchestrator = nil;
|
|
157
|
+
[super prepareForRecycle];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
- (void)setBridge:(RCTBridge *)bridge
|
|
161
|
+
{
|
|
162
|
+
// TODO here you can intercept uiManager by registering fake surface
|
|
163
|
+
// bridge.surfacePresentsr
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
|
|
167
|
+
{
|
|
168
|
+
RCTMGWishlistHandleCommand(self, commandName, args);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
- (void)scrollToItem:(NSInteger)index animated:(BOOL)animated
|
|
172
|
+
{
|
|
173
|
+
if (animated && _orchestrator != nil) {
|
|
174
|
+
[_orchestrator scrollToItem:index];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (!animated) {
|
|
178
|
+
// TODO (restart Wishlist with different initial index)
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@end
|
|
183
|
+
|
|
184
|
+
Class<RCTComponentViewProtocol> MGWishlistCls(void)
|
|
185
|
+
{
|
|
186
|
+
return MGWishListComponent.class;
|
|
187
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#import <React/RCTViewManager.h>
|
|
2
|
+
#import <wishlist/wishlist.h>
|
|
3
|
+
|
|
4
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
5
|
+
|
|
6
|
+
@interface MGWishlistManager : NSObject <NativeWishlistManagerSpec>
|
|
7
|
+
@end
|
|
8
|
+
|
|
9
|
+
@interface MGWishlistComponentManager : RCTViewManager
|
|
10
|
+
@end
|
|
11
|
+
|
|
12
|
+
@interface MGTemplateContainerManager : RCTViewManager
|
|
13
|
+
@end
|
|
14
|
+
|
|
15
|
+
@interface MGTemplateInterceptorManager : RCTViewManager
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@interface MGContentContainerManager : RCTViewManager
|
|
19
|
+
@end
|
|
20
|
+
|
|
21
|
+
NS_ASSUME_NONNULL_END
|