Skip to content

Commit 5a67ae0

Browse files
committed
Restored ios:macos RNTester parity except for InputAccessoryView.
1 parent bdaa8ad commit 5a67ae0

20 files changed

+259
-2014
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ local.properties
5151
*.iml
5252
/android/
5353
/ReactAndroid/packages/
54+
.settings/
5455

5556
# Node
5657
node_modules

Libraries/CameraRoll/RCTCameraRollManager.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99

1010
#import <CoreLocation/CoreLocation.h>
1111
#import <Foundation/Foundation.h>
12-
#import <UIKit/UIKit.h>
12+
#import <React/RCTUIKit.h> // TODO(macOS ISS#2323203)
1313
#import <Photos/Photos.h>
1414
#import <dlfcn.h>
1515
#import <objc/runtime.h>
16+
#if !TARGET_OS_OSX // TODO(macOS ISS#2323203)
1617
#import <MobileCoreServices/UTType.h>
18+
#endif // TODO(macOS ISS#2323203)
1719

1820
#import <React/RCTBridge.h>
1921
#import <React/RCTConvert.h>
@@ -318,6 +320,7 @@ static void RCTResolvePromise(RCTPromiseResolveBlock resolve,
318320
resolve:(RCTPromiseResolveBlock)resolve
319321
reject:(RCTPromiseRejectBlock)reject)
320322
{
323+
#if !TARGET_OS_OSX // TODO(macOS ISS#2323203)
321324
NSArray<NSURL *> *assets_ = [RCTConvert NSURLArray:assets];
322325
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
323326
PHFetchResult<PHAsset *> *fetched =
@@ -333,6 +336,10 @@ static void RCTResolvePromise(RCTPromiseResolveBlock resolve,
333336
}
334337
}
335338
];
339+
#else // [TODO(macOS ISS#2323203)
340+
NSError *error = RCTErrorWithMessage(@"Delete image not available on macOS");
341+
reject(@"Couldn't delete", @"Couldn't delete assets", error);
342+
#endif // ]TODO(macOS ISS#2323203)
336343
}
337344

338345
static void checkPhotoLibraryConfig()

Libraries/CameraRoll/RCTPhotoLibraryImageLoader.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ - (RCTImageLoaderCancellationBlock)loadImageForURL:(NSURL *)imageURL
4545
if (!imageURL) {
4646
completionHandler(RCTErrorWithMessage(@"Cannot load a photo library asset with no URL"), nil);
4747
return ^{};
48+
#if !TARGET_OS_OSX // TODO(macOS ISS#2323203)
4849
} else if ([imageURL.scheme caseInsensitiveCompare:@"assets-library"] == NSOrderedSame) {
4950
assetID = [imageURL absoluteString];
5051
results = [PHAsset fetchAssetsWithALAssetURLs:@[imageURL] options:nil];
52+
#endif // TODO(macOS ISS#2323203)
5153
} else {
5254
assetID = [imageURL.absoluteString substringFromIndex:@"ph://".length];
5355
results = [PHAsset fetchAssetsWithLocalIdentifiers:@[assetID] options:nil];

Libraries/CameraRoll/React-RCTCameraRoll.podspec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ Pod::Spec.new do |s|
2525
s.documentation_url = "https://facebook.github.io/react-native/docs/cameraroll"
2626
s.license = package["license"]
2727
s.author = "Facebook, Inc. and its affiliates"
28-
s.platforms = { :ios => "9.0", :tvos => "9.2" }
28+
s.platforms = { :ios => "9.0", :tvos => "9.2", :osx => "10.14" } # TODO(macOS GH#214)
2929
s.source = source
3030
s.source_files = "*.{h,m}"
3131
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
3232
s.header_dir = "React"
3333

3434
s.dependency "React-Core", version
3535
s.dependency "React-RCTImage", version
36+
37+
s.osx.exclude_files = "RCTImagePickerManager.*", "RCTAssetsLibraryRequestHandler.*" # TODO(macOS GH#214)
38+
3639
end

Libraries/Image/RCTImageView.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,16 @@ typedef NS_ENUM(NSInteger, UIImageRenderingMode) {
3737
@property (nonatomic, assign) CGFloat blurRadius;
3838
@property (nonatomic, assign) RCTResizeMode resizeMode;
3939

40+
#if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
41+
/**
42+
* macOS Properties
43+
*/
44+
@property (nonatomic, copy) RCTDirectEventBlock onDoubleClick;
45+
@property (nonatomic, copy) RCTDirectEventBlock onClick;
46+
@property (nonatomic, copy) RCTDirectEventBlock onMouseEnter;
47+
@property (nonatomic, copy) RCTDirectEventBlock onMouseLeave;
48+
@property (nonatomic, copy) RCTDirectEventBlock onDragEnter;
49+
@property (nonatomic, copy) RCTDirectEventBlock onDragLeave;
50+
@property (nonatomic, copy) RCTDirectEventBlock onDrop;
51+
#endif // ]TODO(macOS ISS#2323203)
4052
@end

0 commit comments

Comments
 (0)