Skip to content

Commit

Permalink
Restored ios:macos RNTester parity except for InputAccessoryView.
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-un committed Apr 13, 2020
1 parent bdaa8ad commit 5a67ae0
Show file tree
Hide file tree
Showing 20 changed files with 259 additions and 2,014 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ local.properties
*.iml
/android/
/ReactAndroid/packages/
.settings/

# Node
node_modules
Expand Down
9 changes: 8 additions & 1 deletion Libraries/CameraRoll/RCTCameraRollManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@

#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <React/RCTUIKit.h> // TODO(macOS ISS#2323203)
#import <Photos/Photos.h>
#import <dlfcn.h>
#import <objc/runtime.h>
#if !TARGET_OS_OSX // TODO(macOS ISS#2323203)
#import <MobileCoreServices/UTType.h>
#endif // TODO(macOS ISS#2323203)

#import <React/RCTBridge.h>
#import <React/RCTConvert.h>
Expand Down Expand Up @@ -318,6 +320,7 @@ static void RCTResolvePromise(RCTPromiseResolveBlock resolve,
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject)
{
#if !TARGET_OS_OSX // TODO(macOS ISS#2323203)
NSArray<NSURL *> *assets_ = [RCTConvert NSURLArray:assets];
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHFetchResult<PHAsset *> *fetched =
Expand All @@ -333,6 +336,10 @@ static void RCTResolvePromise(RCTPromiseResolveBlock resolve,
}
}
];
#else // [TODO(macOS ISS#2323203)
NSError *error = RCTErrorWithMessage(@"Delete image not available on macOS");
reject(@"Couldn't delete", @"Couldn't delete assets", error);
#endif // ]TODO(macOS ISS#2323203)
}

static void checkPhotoLibraryConfig()
Expand Down
2 changes: 2 additions & 0 deletions Libraries/CameraRoll/RCTPhotoLibraryImageLoader.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ - (RCTImageLoaderCancellationBlock)loadImageForURL:(NSURL *)imageURL
if (!imageURL) {
completionHandler(RCTErrorWithMessage(@"Cannot load a photo library asset with no URL"), nil);
return ^{};
#if !TARGET_OS_OSX // TODO(macOS ISS#2323203)
} else if ([imageURL.scheme caseInsensitiveCompare:@"assets-library"] == NSOrderedSame) {
assetID = [imageURL absoluteString];
results = [PHAsset fetchAssetsWithALAssetURLs:@[imageURL] options:nil];
#endif // TODO(macOS ISS#2323203)
} else {
assetID = [imageURL.absoluteString substringFromIndex:@"ph://".length];
results = [PHAsset fetchAssetsWithLocalIdentifiers:@[assetID] options:nil];
Expand Down
5 changes: 4 additions & 1 deletion Libraries/CameraRoll/React-RCTCameraRoll.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ Pod::Spec.new do |s|
s.documentation_url = "https://facebook.github.io/react-native/docs/cameraroll"
s.license = package["license"]
s.author = "Facebook, Inc. and its affiliates"
s.platforms = { :ios => "9.0", :tvos => "9.2" }
s.platforms = { :ios => "9.0", :tvos => "9.2", :osx => "10.14" } # TODO(macOS GH#214)
s.source = source
s.source_files = "*.{h,m}"
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "React"

s.dependency "React-Core", version
s.dependency "React-RCTImage", version

s.osx.exclude_files = "RCTImagePickerManager.*", "RCTAssetsLibraryRequestHandler.*" # TODO(macOS GH#214)

end
12 changes: 12 additions & 0 deletions Libraries/Image/RCTImageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,16 @@ typedef NS_ENUM(NSInteger, UIImageRenderingMode) {
@property (nonatomic, assign) CGFloat blurRadius;
@property (nonatomic, assign) RCTResizeMode resizeMode;

#if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
/**
* macOS Properties
*/
@property (nonatomic, copy) RCTDirectEventBlock onDoubleClick;
@property (nonatomic, copy) RCTDirectEventBlock onClick;
@property (nonatomic, copy) RCTDirectEventBlock onMouseEnter;
@property (nonatomic, copy) RCTDirectEventBlock onMouseLeave;
@property (nonatomic, copy) RCTDirectEventBlock onDragEnter;
@property (nonatomic, copy) RCTDirectEventBlock onDragLeave;
@property (nonatomic, copy) RCTDirectEventBlock onDrop;
#endif // ]TODO(macOS ISS#2323203)
@end
Loading

0 comments on commit 5a67ae0

Please sign in to comment.