stream-chat-react-native 5.44.2 → 6.0.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.
Files changed (40) hide show
  1. package/README.md +1 -2
  2. package/android/build.gradle +103 -0
  3. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +4 -0
  6. package/android/src/main/java/com/streamchatreactnative/StreamChatReactNative.java +594 -0
  7. package/android/src/main/java/com/streamchatreactnative/StreamChatReactNativeModule.java +111 -0
  8. package/android/src/main/java/com/streamchatreactnative/StreamChatReactNativePackage.java +45 -0
  9. package/android/src/newarch/com/streamchatreactnative/StreamChatReactNative.java +9 -0
  10. package/android/src/oldarch/com/streamchatreactnative/StreamChatReactNative.java +16 -0
  11. package/ios/ImageHelpers.h +57 -0
  12. package/ios/ImageHelpers.m +179 -0
  13. package/ios/StreamChatReactNative.h +13 -0
  14. package/ios/StreamChatReactNative.mm +417 -0
  15. package/ios/StreamChatReactNative.xcodeproj/project.pbxproj +280 -0
  16. package/package.json +31 -21
  17. package/src/handlers/compressImage.ts +3 -4
  18. package/src/handlers/index.ts +0 -5
  19. package/src/index.js +6 -3
  20. package/src/native/NativeStreamChatReactNative.ts +24 -0
  21. package/src/native/index.tsx +48 -0
  22. package/src/native/types.ts +32 -0
  23. package/src/optionalDependencies/Audio.ts +10 -4
  24. package/src/optionalDependencies/FlatList.ts +21 -0
  25. package/src/{handlers → optionalDependencies}/Sound.tsx +1 -1
  26. package/src/{handlers → optionalDependencies}/Video.tsx +1 -1
  27. package/src/optionalDependencies/deleteFile.ts +19 -0
  28. package/src/optionalDependencies/getLocalAssetUri.ts +8 -3
  29. package/src/optionalDependencies/getPhotos.ts +20 -10
  30. package/src/optionalDependencies/iOS14RefreshGallerySelection.ts +1 -1
  31. package/src/optionalDependencies/index.ts +10 -6
  32. package/src/optionalDependencies/oniOS14GalleryLibrarySelectionChange.ts +1 -1
  33. package/src/optionalDependencies/saveFile.ts +24 -0
  34. package/src/optionalDependencies/shareImage.ts +10 -6
  35. package/src/optionalDependencies/takePhoto.ts +15 -11
  36. package/stream-chat-react-native.podspec +38 -0
  37. package/src/handlers/NetInfo.ts +0 -43
  38. package/src/handlers/deleteFile.ts +0 -11
  39. package/src/handlers/saveFile.ts +0 -11
  40. /package/src/optionalDependencies/{Video.ts → AudioVideo.ts} +0 -0
@@ -0,0 +1,45 @@
1
+ package com.streamchatreactnative;
2
+
3
+ import androidx.annotation.Nullable;
4
+ import com.facebook.react.bridge.NativeModule;
5
+ import com.facebook.react.bridge.ReactApplicationContext;
6
+ import com.facebook.react.module.model.ReactModuleInfo;
7
+ import com.facebook.react.module.model.ReactModuleInfoProvider;
8
+ import com.facebook.react.TurboReactPackage;
9
+
10
+
11
+ import java.util.HashMap;
12
+ import java.util.Map;
13
+
14
+ public class StreamChatReactNativePackage extends TurboReactPackage {
15
+
16
+ @Nullable
17
+ @Override
18
+ public NativeModule getModule(String name, ReactApplicationContext reactContext) {
19
+ if (name.equals(StreamChatReactNativeModule.NAME)) {
20
+ return new StreamChatReactNativeModule(reactContext);
21
+ } else {
22
+ return null;
23
+ }
24
+ }
25
+
26
+ @Override
27
+ public ReactModuleInfoProvider getReactModuleInfoProvider() {
28
+ return () -> {
29
+ final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
30
+ boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
31
+ moduleInfos.put(
32
+ StreamChatReactNativeModule.NAME,
33
+ new ReactModuleInfo(
34
+ StreamChatReactNativeModule.NAME,
35
+ StreamChatReactNativeModule.NAME,
36
+ false, // canOverrideExistingModule
37
+ false, // needsEagerInit
38
+ true, // hasConstants
39
+ false, // isCxxModule
40
+ isTurboModule // isTurboModule
41
+ ));
42
+ return moduleInfos;
43
+ };
44
+ }
45
+ }
@@ -0,0 +1,9 @@
1
+ package com.streamchatreactnative;
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext;
4
+
5
+ abstract class StreamChatReactNativeSpec extends NativeStreamChatReactNativeSpec {
6
+ StreamChatReactNativeSpec(ReactApplicationContext context) {
7
+ super(context);
8
+ }
9
+ }
@@ -0,0 +1,16 @@
1
+ package com.streamchatreactnative;
2
+
3
+ import androidx.annotation.Nullable;
4
+
5
+ import com.facebook.react.bridge.Promise;
6
+ import com.facebook.react.bridge.ReactApplicationContext;
7
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
8
+
9
+ abstract class StreamChatReactNativeSpec extends ReactContextBaseJavaModule {
10
+
11
+ StreamChatReactNativeSpec(ReactApplicationContext context) {
12
+ super(context);
13
+ }
14
+
15
+ public abstract void createResizedImage(String uri, double width, double height, String format, double quality, String mode, boolean onlyScaleDown, Double rotation, @Nullable String outputPath, Boolean keepMeta, Promise promise);
16
+ }
@@ -0,0 +1,57 @@
1
+ /*
2
+ File: ImageHelpers.h
3
+
4
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
5
+ Inc. ("Apple") in consideration of your agreement to the following
6
+ terms, and your use, installation, modification or redistribution of
7
+ this Apple software constitutes acceptance of these terms. If you do
8
+ not agree with these terms, please do not use, install, modify or
9
+ redistribute this Apple software.
10
+
11
+ In consideration of your agreement to abide by the following terms, and
12
+ subject to these terms, Apple grants you a personal, non-exclusive
13
+ license, under Apple's copyrights in this original Apple software (the
14
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
15
+ Software, with or without modifications, in source and/or binary forms;
16
+ provided that if you redistribute the Apple Software in its entirety and
17
+ without modifications, you must retain this notice and the following
18
+ text and disclaimers in all such redistributions of the Apple Software.
19
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
20
+ be used to endorse or promote products derived from the Apple Software
21
+ without specific prior written permission from Apple. Except as
22
+ expressly stated in this notice, no other rights or licenses, express or
23
+ implied, are granted by Apple herein, including but not limited to any
24
+ patent rights that may be infringed by your derivative works or by other
25
+ works in which the Apple Software may be incorporated.
26
+
27
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE
28
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
29
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
30
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
31
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
32
+
33
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
34
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
37
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
38
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
39
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
40
+ POSSIBILITY OF SUCH DAMAGE.
41
+
42
+ Copyright (C) 2009 Apple Inc. All Rights Reserved.
43
+ */
44
+
45
+ #include <UIKit/UIKit.h>
46
+
47
+ extern const CGBitmapInfo kDefaultCGBitmapInfo;
48
+ extern const CGBitmapInfo kDefaultCGBitmapInfoNoAlpha;
49
+
50
+ float GetScaleForProportionalResize( CGSize theSize, CGSize intoSize, bool onlyScaleDown, bool maximize );
51
+ CGContextRef CreateCGBitmapContextForWidthAndHeight( unsigned int width, unsigned int height, CGColorSpaceRef optionalColorSpace, CGBitmapInfo optionalInfo );
52
+
53
+ CGImageRef CreateCGImageFromUIImageScaled( UIImage* inImage, float scaleFactor );
54
+
55
+ @interface UIImage (scale)
56
+ -(UIImage*)scaleToSize:(CGSize)toSize;
57
+ @end
@@ -0,0 +1,179 @@
1
+ /*
2
+ File: ImageHelpers.m
3
+
4
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
5
+ Inc. ("Apple") in consideration of your agreement to the following
6
+ terms, and your use, installation, modification or redistribution of
7
+ this Apple software constitutes acceptance of these terms. If you do
8
+ not agree with these terms, please do not use, install, modify or
9
+ redistribute this Apple software.
10
+
11
+ In consideration of your agreement to abide by the following terms, and
12
+ subject to these terms, Apple grants you a personal, non-exclusive
13
+ license, under Apple's copyrights in this original Apple software (the
14
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
15
+ Software, with or without modifications, in source and/or binary forms;
16
+ provided that if you redistribute the Apple Software in its entirety and
17
+ without modifications, you must retain this notice and the following
18
+ text and disclaimers in all such redistributions of the Apple Software.
19
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
20
+ be used to endorse or promote products derived from the Apple Software
21
+ without specific prior written permission from Apple. Except as
22
+ expressly stated in this notice, no other rights or licenses, express or
23
+ implied, are granted by Apple herein, including but not limited to any
24
+ patent rights that may be infringed by your derivative works or by other
25
+ works in which the Apple Software may be incorporated.
26
+
27
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE
28
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
29
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
30
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
31
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
32
+
33
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
34
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
37
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
38
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
39
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
40
+ POSSIBILITY OF SUCH DAMAGE.
41
+
42
+ Copyright (C) 2009 Apple Inc. All Rights Reserved.
43
+ */
44
+
45
+ #include "ImageHelpers.h"
46
+
47
+ const CGBitmapInfo kDefaultCGBitmapInfo = (kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
48
+ const CGBitmapInfo kDefaultCGBitmapInfoNoAlpha = (kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host);
49
+
50
+ CGColorSpaceRef GetDeviceRGBColorSpace() {
51
+ static CGColorSpaceRef deviceRGBSpace = NULL;
52
+ if( deviceRGBSpace == NULL )
53
+ deviceRGBSpace = CGColorSpaceCreateDeviceRGB();
54
+ return deviceRGBSpace;
55
+ }
56
+
57
+ float GetScaleForProportionalResize( CGSize theSize, CGSize intoSize, bool onlyScaleDown, bool maximize )
58
+ {
59
+ float sx = theSize.width;
60
+ float sy = theSize.height;
61
+ float dx = intoSize.width;
62
+ float dy = intoSize.height;
63
+ float scale = 1;
64
+
65
+ if( sx != 0 && sy != 0 )
66
+ {
67
+ dx = dx / sx;
68
+ dy = dy / sy;
69
+
70
+ // if maximize is true, take LARGER of the scales, else smaller
71
+ if( maximize ) scale = (dx > dy) ? dx : dy;
72
+ else scale = (dx < dy) ? dx : dy;
73
+
74
+ if( scale > 1 && onlyScaleDown ) // reset scale
75
+ scale = 1;
76
+ }
77
+ else
78
+ {
79
+ scale = 0;
80
+ }
81
+ return scale;
82
+ }
83
+
84
+ CGContextRef CreateCGBitmapContextForWidthAndHeight( unsigned int width, unsigned int height,
85
+ CGColorSpaceRef optionalColorSpace, CGBitmapInfo optionalInfo )
86
+ {
87
+ CGColorSpaceRef colorSpace = (optionalColorSpace == NULL) ? GetDeviceRGBColorSpace() : optionalColorSpace;
88
+ CGBitmapInfo alphaInfo = ( (int32_t)optionalInfo < 0 ) ? kDefaultCGBitmapInfo : optionalInfo;
89
+ return CGBitmapContextCreate( NULL, width, height, 8, 0, colorSpace, alphaInfo );
90
+ }
91
+
92
+ CGImageRef CreateCGImageFromUIImageScaled( UIImage* image, float scaleFactor )
93
+ {
94
+ CGImageRef newImage = NULL;
95
+ CGContextRef bmContext = NULL;
96
+ BOOL mustTransform = YES;
97
+ CGAffineTransform transform = CGAffineTransformIdentity;
98
+ UIImageOrientation orientation = image.imageOrientation;
99
+
100
+ CGImageRef srcCGImage = CGImageRetain( image.CGImage );
101
+
102
+ size_t width = CGImageGetWidth(srcCGImage) * scaleFactor;
103
+ size_t height = CGImageGetHeight(srcCGImage) * scaleFactor;
104
+
105
+ // These Orientations are rotated 0 or 180 degrees, so they retain the width/height of the image
106
+ if( (orientation == UIImageOrientationUp) || (orientation == UIImageOrientationDown) || (orientation == UIImageOrientationUpMirrored) || (orientation == UIImageOrientationDownMirrored) )
107
+ {
108
+ bmContext = CreateCGBitmapContextForWidthAndHeight( width, height, NULL, kDefaultCGBitmapInfo );
109
+ }
110
+ else // The other Orientations are rotated ±90 degrees, so they swap width & height.
111
+ {
112
+ bmContext = CreateCGBitmapContextForWidthAndHeight( height, width, NULL, kDefaultCGBitmapInfo );
113
+ }
114
+
115
+ //CGContextSetInterpolationQuality( bmContext, kCGInterpolationLow );
116
+ CGContextSetBlendMode( bmContext, kCGBlendModeCopy ); // we just want to copy the data
117
+
118
+ switch(orientation)
119
+ {
120
+ case UIImageOrientationDown: // 0th row is at the bottom, and 0th column is on the right - Rotate 180 degrees
121
+ transform = CGAffineTransformMake(-1.0, 0.0, 0.0, -1.0, width, height);
122
+ break;
123
+
124
+ case UIImageOrientationLeft: // 0th row is on the left, and 0th column is the bottom - Rotate -90 degrees
125
+ transform = CGAffineTransformMake(0.0, 1.0, -1.0, 0.0, height, 0.0);
126
+ break;
127
+
128
+ case UIImageOrientationRight: // 0th row is on the right, and 0th column is the top - Rotate 90 degrees
129
+ transform = CGAffineTransformMake(0.0, -1.0, 1.0, 0.0, 0.0, width);
130
+ break;
131
+
132
+ case UIImageOrientationUpMirrored: // 0th row is at the top, and 0th column is on the right - Flip Horizontal
133
+ transform = CGAffineTransformMake(-1.0, 0.0, 0.0, 1.0, width, 0.0);
134
+ break;
135
+
136
+ case UIImageOrientationDownMirrored: // 0th row is at the bottom, and 0th column is on the left - Flip Vertical
137
+ transform = CGAffineTransformMake(1.0, 0.0, 0, -1.0, 0.0, height);
138
+ break;
139
+
140
+ case UIImageOrientationLeftMirrored: // 0th row is on the left, and 0th column is the top - Rotate -90 degrees and Flip Vertical
141
+ transform = CGAffineTransformMake(0.0, -1.0, -1.0, 0.0, height, width);
142
+ break;
143
+
144
+ case UIImageOrientationRightMirrored: // 0th row is on the right, and 0th column is the bottom - Rotate 90 degrees and Flip Vertical
145
+ transform = CGAffineTransformMake(0.0, 1.0, 1.0, 0.0, 0.0, 0.0);
146
+ break;
147
+
148
+ default:
149
+ mustTransform = NO;
150
+ break;
151
+ }
152
+
153
+ if( mustTransform ) CGContextConcatCTM( bmContext, transform );
154
+
155
+ CGContextDrawImage( bmContext, CGRectMake(0.0, 0.0, width, height), srcCGImage );
156
+ CGImageRelease( srcCGImage );
157
+ newImage = CGBitmapContextCreateImage( bmContext );
158
+ CFRelease( bmContext );
159
+
160
+ return newImage;
161
+ }
162
+
163
+ @implementation UIImage (scale)
164
+
165
+ -(UIImage*) scaleToSize:(CGSize)toSize
166
+ {
167
+ UIImage *scaledImg = nil;
168
+ float scale = GetScaleForProportionalResize( self.size, toSize, false, false );
169
+ CGImageRef cgImage = CreateCGImageFromUIImageScaled( self, scale );
170
+
171
+ if( cgImage )
172
+ {
173
+ scaledImg = [UIImage imageWithCGImage:cgImage]; // autoreleased
174
+ CGImageRelease( cgImage );
175
+ }
176
+ return scaledImg;
177
+ }
178
+
179
+ @end
@@ -0,0 +1,13 @@
1
+ #ifdef RCT_NEW_ARCH_ENABLED
2
+ #import "StreamChatReactNativeSpec.h"
3
+ #else
4
+ #import <React/RCTBridgeModule.h>
5
+ #endif
6
+
7
+ #ifdef RCT_NEW_ARCH_ENABLED
8
+ @interface StreamChatReactNative : NSObject <NativeStreamChatReactNativeSpec>
9
+ #else
10
+ @interface StreamChatReactNative : NSObject <RCTBridgeModule>
11
+ #endif
12
+
13
+ @end