More updates
This commit is contained in:
commit
9649e7cc8d
|
@ -109,17 +109,28 @@ var getPhotosReturnChecker = createStrictShapeTypeChecker({
|
|||
}).isRequired,
|
||||
});
|
||||
|
||||
/**
|
||||
* `CameraRoll` provides access to the local camera roll / gallery.
|
||||
*/
|
||||
class CameraRoll {
|
||||
|
||||
static GroupTypesOptions: Array<string>;
|
||||
static AssetTypeOptions: Array<string>;
|
||||
/**
|
||||
* Saves the image with tag `tag` to the camera roll.
|
||||
* Saves the image to the camera roll / gallery.
|
||||
*
|
||||
* @param {string} tag - Can be any of the three kinds of tags we accept:
|
||||
* 1. URL
|
||||
* 2. assets-library tag
|
||||
* 3. tag returned from storing an image in memory
|
||||
* @param {string} tag On Android, this is a local URI, such
|
||||
* as `"file:///sdcard/img.png"`.
|
||||
*
|
||||
* On iOS, the tag can be one of the following:
|
||||
*
|
||||
* - local URI
|
||||
* - assets-library tag
|
||||
* - a tag not maching any of the above, which means the image data will
|
||||
* be stored in memory (and consume memory as long as the process is alive)
|
||||
*
|
||||
* @param successCallback Invoked with the value of `tag` on success.
|
||||
* @param errorCallback Invoked with error message on error.
|
||||
*/
|
||||
static saveImageWithTag(tag, successCallback, errorCallback) {
|
||||
invariant(
|
||||
|
@ -140,10 +151,10 @@ class CameraRoll {
|
|||
* Invokes `callback` with photo identifier objects from the local camera
|
||||
* roll of the device matching shape defined by `getPhotosReturnChecker`.
|
||||
*
|
||||
* @param {object} params - See `getPhotosParamChecker`.
|
||||
* @param {function} callback - Invoked with arg of shape defined by
|
||||
* `getPhotosReturnChecker` on success.
|
||||
* @param {function} errorCallback - Invoked with error message on error.
|
||||
* @param {object} params See `getPhotosParamChecker`.
|
||||
* @param {function} callback Invoked with arg of shape defined by
|
||||
* `getPhotosReturnChecker` on success.
|
||||
* @param {function} errorCallback Invoked with error message on error.
|
||||
*/
|
||||
static getPhotos(params, callback, errorCallback) {
|
||||
var metaCallback = callback;
|
||||
|
|
|
@ -24,6 +24,7 @@ var ImageStylePropTypes = {
|
|||
borderColor: ReactPropTypes.string,
|
||||
borderWidth: ReactPropTypes.number,
|
||||
borderRadius: ReactPropTypes.number,
|
||||
overflow: ReactPropTypes.oneOf(['visible', 'hidden']),
|
||||
|
||||
// iOS-Specific style to "tint" an image.
|
||||
// It changes the color of all the non-transparent pixels to the tintColor
|
||||
|
|
|
@ -12,36 +12,33 @@
|
|||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
static void *const RCTDownloadTaskWrapperCompletionBlockKey = (void *)&RCTDownloadTaskWrapperCompletionBlockKey;
|
||||
static void *const RCTDownloadTaskWrapperProgressBlockKey = (void *)&RCTDownloadTaskWrapperProgressBlockKey;
|
||||
@interface NSObject (RCTDownloadTaskWrapper)
|
||||
|
||||
@interface NSURLSessionTask (RCTDownloadTaskWrapper)
|
||||
|
||||
@property (nonatomic, copy, setter=rct_setCompletionBlock:) RCTDataCompletionBlock rct_completionBlock;
|
||||
@property (nonatomic, copy, setter=rct_setProgressBlock:) RCTDataProgressBlock rct_progressBlock;
|
||||
@property (nonatomic, copy) RCTDataCompletionBlock reactCompletionBlock;
|
||||
@property (nonatomic, copy) RCTDataProgressBlock reactProgressBlock;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSURLSessionTask (RCTDownloadTaskWrapper)
|
||||
@implementation NSObject (RCTDownloadTaskWrapper)
|
||||
|
||||
- (RCTDataCompletionBlock)rct_completionBlock
|
||||
- (RCTDataCompletionBlock)reactCompletionBlock
|
||||
{
|
||||
return objc_getAssociatedObject(self, RCTDownloadTaskWrapperCompletionBlockKey);
|
||||
return objc_getAssociatedObject(self, _cmd);
|
||||
}
|
||||
|
||||
- (void)rct_setCompletionBlock:(RCTDataCompletionBlock)completionBlock
|
||||
- (void)setReactCompletionBlock:(RCTDataCompletionBlock)completionBlock
|
||||
{
|
||||
objc_setAssociatedObject(self, RCTDownloadTaskWrapperCompletionBlockKey, completionBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
||||
objc_setAssociatedObject(self, @selector(reactCompletionBlock), completionBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
||||
}
|
||||
|
||||
- (RCTDataProgressBlock)rct_progressBlock
|
||||
- (RCTDataProgressBlock)reactProgressBlock
|
||||
{
|
||||
return objc_getAssociatedObject(self, RCTDownloadTaskWrapperProgressBlockKey);
|
||||
return objc_getAssociatedObject(self, _cmd);
|
||||
}
|
||||
|
||||
- (void)rct_setProgressBlock:(RCTDataProgressBlock)progressBlock
|
||||
- (void)setReactProgressBlock:(RCTDataProgressBlock)progressBlock
|
||||
{
|
||||
objc_setAssociatedObject(self, RCTDownloadTaskWrapperProgressBlockKey, progressBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
||||
objc_setAssociatedObject(self, @selector(reactProgressBlock), progressBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -63,9 +60,8 @@ static void *const RCTDownloadTaskWrapperProgressBlockKey = (void *)&RCTDownload
|
|||
- (NSURLSessionDownloadTask *)downloadData:(NSURL *)url progressBlock:(RCTDataProgressBlock)progressBlock completionBlock:(RCTDataCompletionBlock)completionBlock
|
||||
{
|
||||
NSURLSessionDownloadTask *task = [_URLSession downloadTaskWithURL:url];
|
||||
task.rct_completionBlock = completionBlock;
|
||||
task.rct_progressBlock = progressBlock;
|
||||
|
||||
task.reactCompletionBlock = completionBlock;
|
||||
task.reactProgressBlock = progressBlock;
|
||||
return task;
|
||||
}
|
||||
|
||||
|
@ -73,28 +69,28 @@ static void *const RCTDownloadTaskWrapperProgressBlockKey = (void *)&RCTDownload
|
|||
|
||||
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(NSURL *)location
|
||||
{
|
||||
if (downloadTask.rct_completionBlock) {
|
||||
if (downloadTask.reactCompletionBlock) {
|
||||
NSData *data = [NSData dataWithContentsOfURL:location];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
downloadTask.rct_completionBlock(downloadTask.response, data, nil);
|
||||
downloadTask.reactCompletionBlock(downloadTask.response, data, nil);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)didWriteData totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite;
|
||||
{
|
||||
if (downloadTask.rct_progressBlock) {
|
||||
if (downloadTask.reactProgressBlock) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
downloadTask.rct_progressBlock(totalBytesWritten, totalBytesExpectedToWrite);
|
||||
downloadTask.reactProgressBlock(totalBytesWritten, totalBytesExpectedToWrite);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error
|
||||
{
|
||||
if (error && task.rct_completionBlock) {
|
||||
if (error && task.reactCompletionBlock) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
task.rct_completionBlock(nil, nil, error);
|
||||
task.reactCompletionBlock(nil, nil, error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,11 +51,6 @@ class StyleSheetValidation {
|
|||
|
||||
static addValidStylePropTypes(stylePropTypes) {
|
||||
for (var key in stylePropTypes) {
|
||||
invariant(
|
||||
allStylePropTypes[key] === undefined ||
|
||||
allStylePropTypes[key] === stylePropTypes[key],
|
||||
'Attemped to redefine existing style prop type "' + key + '".'
|
||||
);
|
||||
allStylePropTypes[key] = stylePropTypes[key];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,9 +20,11 @@ var Dimensions = require('Dimensions');
|
|||
*
|
||||
* ### Displaying a line that's as thin as the device permits
|
||||
*
|
||||
* A width of 1 is actually pretty thick on an iPhone 4+, we can do one that's
|
||||
* thinner using a width of `1 / PixelRatio.get()`. It's a technique that works
|
||||
* on all the devices independent of their pixel density.
|
||||
* A width of 1 is actually pretty thick on devices with high pixel density
|
||||
* (such as iPhone 4+ and many Android devices), we can make one that's
|
||||
* thinner using a width of `1 / PixelRatio.get()`.
|
||||
* It's a technique that works on all the devices independent of their
|
||||
* pixel density.
|
||||
*
|
||||
* ```
|
||||
* style={{ borderWidth: 1 / PixelRatio.get() }}
|
||||
|
@ -46,12 +48,18 @@ class PixelRatio {
|
|||
/**
|
||||
* Returns the device pixel density. Some examples:
|
||||
*
|
||||
* - PixelRatio.get() === 1
|
||||
* - mdpi Android devices (160 dpi)
|
||||
* - PixelRatio.get() === 1.5
|
||||
* - hdpi Android devices (240 dpi)
|
||||
* - PixelRatio.get() === 2
|
||||
* - iPhone 4, 4S
|
||||
* - iPhone 5, 5c, 5s
|
||||
* - iPhone 6
|
||||
* - xhdpi Android devices (320 dpi)
|
||||
* - PixelRatio.get() === 3
|
||||
* - iPhone 6 plus
|
||||
* - xxhdpi Android devices (480 dpi)
|
||||
* - PixelRatio.get() === 3.5
|
||||
* - Nexus 6
|
||||
*/
|
||||
|
@ -68,6 +76,7 @@ class PixelRatio {
|
|||
*
|
||||
* Currently this is only implemented on Android and reflects the user preference set in
|
||||
* Settings > Display > Font size, on iOS it will always return the default pixel ratio.
|
||||
* @platform android
|
||||
*/
|
||||
static getFontScale(): number {
|
||||
return Dimensions.get('window').fontScale || PixelRatio.get();
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
"dependencies": {
|
||||
"absolute-path": "0.0.0",
|
||||
"babel": "5.4.3",
|
||||
"babel-core": "^5.6.4",
|
||||
"babel-core": "5.6.4",
|
||||
"chalk": "^1.0.0",
|
||||
"connect": "2.8.3",
|
||||
"debug": "~2.1.0",
|
||||
|
|
Loading…
Reference in New Issue