forked from mrousavy/react-native-blurhash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlurhashModule.mm
70 lines (53 loc) · 1.6 KB
/
BlurhashModule.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#import "BlurhashModule.h"
#import <React/RCTUtils.h>
#import <UIKit/UIKit.h>
#ifdef RCT_NEW_ARCH_ENABLED
#import <blurhash_codegen/blurhash_codegen.h>
#endif
#if __has_include("react_native_blurhash/react_native_blurhash-Swift.h")
#import "react_native_blurhash/react_native_blurhash-Swift.h"
#else
#import "react_native_blurhash-Swift.h"
#endif
#ifdef RCT_NEW_ARCH_ENABLED
using namespace facebook::react;
@interface BlurhashModule () <NativeBlurhashModuleSpec>
@end
#endif
@interface BlurhashModule ()
@property (nonatomic, strong) BlurhashModuleImpl *impl;
@end
@implementation BlurhashModule
RCT_EXPORT_MODULE()
@synthesize moduleRegistry = _moduleRegistry;
RCT_EXPORT_METHOD(createBlurhashFromImage
: (NSString *)imageUri componentsX
: (double)componentsX componentsY
: (double)componentsY resolve
: (RCTPromiseResolveBlock)resolve reject
: (RCTPromiseRejectBlock)reject)
{
[self.impl createBlurhashFromImage:imageUri
componentsX:componentsX
componentsY:componentsY
resolve:resolve
reject:reject];
}
RCT_EXPORT_METHOD(clearCosineCache)
{
// Not implemented on iOS.
}
- (BlurhashModuleImpl *)impl
{
if (!_impl) {
_impl = [[BlurhashModuleImpl alloc] initWithModuleRegistry:_moduleRegistry];
}
return _impl;
}
#ifdef RCT_NEW_ARCH_ENABLED
- (std::shared_ptr<TurboModule>)getTurboModule:(const ObjCTurboModule::InitParams &)params
{
return std::make_shared<NativeBlurhashModuleSpecJSI>(params);
}
#endif
@end