stream-chat-react-native 9.5.1-beta.3 → 9.5.1-beta.5
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/StreamChatReactNative.mm +18 -7
- package/package.json +2 -2
- package/ios/ImageHelpers.h +0 -57
- package/ios/ImageHelpers.m +0 -179
|
@@ -9,7 +9,18 @@
|
|
|
9
9
|
#import "RCTImageLoader.h"
|
|
10
10
|
#endif
|
|
11
11
|
|
|
12
|
-
NSString *moduleName = @"StreamChatReactNative";
|
|
12
|
+
static NSString *const moduleName = @"StreamChatReactNative";
|
|
13
|
+
|
|
14
|
+
// These helpers are declared `static` so their symbols keep internal linkage and
|
|
15
|
+
// are not exported from the framework. Otherwise they collide (duplicate symbol
|
|
16
|
+
// link error) with libraries that vendor the same image-resizer sources, e.g.
|
|
17
|
+
// @bam.tech/react-native-image-resizer. See issue #3227.
|
|
18
|
+
static bool saveImage(NSString *fullPath, UIImage *image, NSString *format, float quality);
|
|
19
|
+
static NSString *generateFilePath(NSString *ext, NSString *outputPath);
|
|
20
|
+
static UIImage *rotateImage(UIImage *inputImage, float rotationDegrees);
|
|
21
|
+
static float getScaleForProportionalResize(CGSize theSize, CGSize intoSize, bool onlyScaleDown, bool maximize);
|
|
22
|
+
static UIImage *scaleImage(UIImage *image, CGSize toSize, NSString *mode, bool onlyScaleDown);
|
|
23
|
+
static NSDictionary *transformImage(UIImage *image, int rotation, CGSize newSize, NSString *fullPath, NSString *format, int quality, NSDictionary *options);
|
|
13
24
|
|
|
14
25
|
@implementation StreamChatReactNative
|
|
15
26
|
|
|
@@ -67,7 +78,7 @@ RCT_REMAP_METHOD(createResizedImage, uri:(NSString *)uri width:(double)width hei
|
|
|
67
78
|
|
|
68
79
|
|
|
69
80
|
|
|
70
|
-
bool saveImage(NSString * fullPath, UIImage * image, NSString * format, float quality)
|
|
81
|
+
static bool saveImage(NSString * fullPath, UIImage * image, NSString * format, float quality)
|
|
71
82
|
{
|
|
72
83
|
NSData* data = nil;
|
|
73
84
|
if ([format isEqualToString:@"JPEG"]) {
|
|
@@ -84,7 +95,7 @@ bool saveImage(NSString * fullPath, UIImage * image, NSString * format, float qu
|
|
|
84
95
|
return [fileManager createFileAtPath:fullPath contents:data attributes:nil];
|
|
85
96
|
}
|
|
86
97
|
|
|
87
|
-
NSString * generateFilePath(NSString * ext, NSString * outputPath)
|
|
98
|
+
static NSString * generateFilePath(NSString * ext, NSString * outputPath)
|
|
88
99
|
{
|
|
89
100
|
NSString* directory;
|
|
90
101
|
|
|
@@ -115,7 +126,7 @@ NSString * generateFilePath(NSString * ext, NSString * outputPath)
|
|
|
115
126
|
return fullPath;
|
|
116
127
|
}
|
|
117
128
|
|
|
118
|
-
UIImage * rotateImage(UIImage *inputImage, float rotationDegrees)
|
|
129
|
+
static UIImage * rotateImage(UIImage *inputImage, float rotationDegrees)
|
|
119
130
|
{
|
|
120
131
|
|
|
121
132
|
// We want only fixed 0, 90, 180, 270 degree rotations.
|
|
@@ -148,7 +159,7 @@ UIImage * rotateImage(UIImage *inputImage, float rotationDegrees)
|
|
|
148
159
|
}
|
|
149
160
|
}
|
|
150
161
|
|
|
151
|
-
float getScaleForProportionalResize(CGSize theSize, CGSize intoSize, bool onlyScaleDown, bool maximize)
|
|
162
|
+
static float getScaleForProportionalResize(CGSize theSize, CGSize intoSize, bool onlyScaleDown, bool maximize)
|
|
152
163
|
{
|
|
153
164
|
float sx = theSize.width;
|
|
154
165
|
float sy = theSize.height;
|
|
@@ -184,7 +195,7 @@ float getScaleForProportionalResize(CGSize theSize, CGSize intoSize, bool onlySc
|
|
|
184
195
|
// any :image scale factor.
|
|
185
196
|
// The returned image is an unscaled image (scale = 1.0)
|
|
186
197
|
// so no additional scaling math needs to be done to get its pixel dimensions
|
|
187
|
-
UIImage* scaleImage (UIImage* image, CGSize toSize, NSString* mode, bool onlyScaleDown)
|
|
198
|
+
static UIImage* scaleImage (UIImage* image, CGSize toSize, NSString* mode, bool onlyScaleDown)
|
|
188
199
|
{
|
|
189
200
|
|
|
190
201
|
// Need to do scaling corrections
|
|
@@ -222,7 +233,7 @@ UIImage* scaleImage (UIImage* image, CGSize toSize, NSString* mode, bool onlySca
|
|
|
222
233
|
return newImage;
|
|
223
234
|
}
|
|
224
235
|
|
|
225
|
-
NSDictionary * transformImage(UIImage *image,
|
|
236
|
+
static NSDictionary * transformImage(UIImage *image,
|
|
226
237
|
int rotation,
|
|
227
238
|
CGSize newSize,
|
|
228
239
|
NSString* fullPath,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stream-chat-react-native",
|
|
3
3
|
"description": "The official React Native SDK for Stream Chat, a service for building chat applications",
|
|
4
|
-
"version": "9.5.1-beta.
|
|
4
|
+
"version": "9.5.1-beta.5",
|
|
5
5
|
"homepage": "https://www.npmjs.com/package/stream-chat-react-native",
|
|
6
6
|
"author": {
|
|
7
7
|
"company": "Stream.io Inc",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"es6-symbol": "^3.1.3",
|
|
32
32
|
"mime": "^4.0.7",
|
|
33
|
-
"stream-chat-react-native-core": "9.5.1-beta.
|
|
33
|
+
"stream-chat-react-native-core": "9.5.1-beta.5"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@react-native-camera-roll/camera-roll": ">=7.9.0",
|
package/ios/ImageHelpers.h
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
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
|
package/ios/ImageHelpers.m
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
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
|