Replaced RCTSparseArray with NSDictionary
Reviewed By: jspahrsummers Differential Revision: D2651920 fb-gh-sync-id: 953e2ea33abfc7a3a553da95b13e9ab2bccc5a1c
This commit is contained in:
parent
5a34a097f2
commit
fa0b45c58b
|
@ -32,7 +32,6 @@
|
|||
1497CFAF1B21F5E400C1F8F2 /* RCTConvert_NSURLTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFA71B21F5E400C1F8F2 /* RCTConvert_NSURLTests.m */; };
|
||||
1497CFB01B21F5E400C1F8F2 /* RCTConvert_UIFontTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFA81B21F5E400C1F8F2 /* RCTConvert_UIFontTests.m */; };
|
||||
1497CFB11B21F5E400C1F8F2 /* RCTEventDispatcherTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFA91B21F5E400C1F8F2 /* RCTEventDispatcherTests.m */; };
|
||||
1497CFB21B21F5E400C1F8F2 /* RCTSparseArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFAA1B21F5E400C1F8F2 /* RCTSparseArrayTests.m */; };
|
||||
1497CFB31B21F5E400C1F8F2 /* RCTUIManagerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFAB1B21F5E400C1F8F2 /* RCTUIManagerTests.m */; };
|
||||
14AADF051AC3DBB1002390C9 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14AADF041AC3DB95002390C9 /* libReact.a */; };
|
||||
14B6DA821B276C5900BF4DD1 /* libRCTTest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58005BEE1ABA80530062E044 /* libRCTTest.a */; };
|
||||
|
@ -209,7 +208,6 @@
|
|||
1497CFA71B21F5E400C1F8F2 /* RCTConvert_NSURLTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTConvert_NSURLTests.m; sourceTree = "<group>"; };
|
||||
1497CFA81B21F5E400C1F8F2 /* RCTConvert_UIFontTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTConvert_UIFontTests.m; sourceTree = "<group>"; };
|
||||
1497CFA91B21F5E400C1F8F2 /* RCTEventDispatcherTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTEventDispatcherTests.m; sourceTree = "<group>"; };
|
||||
1497CFAA1B21F5E400C1F8F2 /* RCTSparseArrayTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTSparseArrayTests.m; sourceTree = "<group>"; };
|
||||
1497CFAB1B21F5E400C1F8F2 /* RCTUIManagerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTUIManagerTests.m; sourceTree = "<group>"; };
|
||||
14AADEFF1AC3DB95002390C9 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = ../../React/React.xcodeproj; sourceTree = "<group>"; };
|
||||
14D6D7021B220AE3001FB087 /* NSNotificationCenter+OCMAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNotificationCenter+OCMAdditions.h"; sourceTree = "<group>"; };
|
||||
|
@ -400,7 +398,6 @@
|
|||
13DF61B51B67A45000EDB188 /* RCTMethodArgumentTests.m */,
|
||||
1393D0371B68CD1300E1B601 /* RCTModuleMethodTests.m */,
|
||||
138D6A161B53CD440074A87E /* RCTShadowViewTests.m */,
|
||||
1497CFAA1B21F5E400C1F8F2 /* RCTSparseArrayTests.m */,
|
||||
1497CFAB1B21F5E400C1F8F2 /* RCTUIManagerTests.m */,
|
||||
143BC57E1B21E18100462512 /* Info.plist */,
|
||||
14D6D7101B220EB3001FB087 /* libOCMock.a */,
|
||||
|
@ -852,7 +849,6 @@
|
|||
1497CFB01B21F5E400C1F8F2 /* RCTConvert_UIFontTests.m in Sources */,
|
||||
144D21241B2204C5006DB32B /* RCTImageUtilTests.m in Sources */,
|
||||
1393D0381B68CD1300E1B601 /* RCTModuleMethodTests.m in Sources */,
|
||||
1497CFB21B21F5E400C1F8F2 /* RCTSparseArrayTests.m in Sources */,
|
||||
1300627F1B59179B0043FE5A /* RCTGzipTests.m in Sources */,
|
||||
1497CFAF1B21F5E400C1F8F2 /* RCTConvert_NSURLTests.m in Sources */,
|
||||
1497CFAE1B21F5E400C1F8F2 /* RCTContextExecutorTests.m in Sources */,
|
||||
|
@ -991,6 +987,12 @@
|
|||
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.internal.uiexplorer.local;
|
||||
PRODUCT_NAME = UIExplorer;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
WARNING_CFLAGS = (
|
||||
"-Wextra",
|
||||
"-Wall",
|
||||
"-Wincompatible-pointer-types",
|
||||
"-Wincompatible-pointer-types-discards-qualifiers",
|
||||
);
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -1011,6 +1013,12 @@
|
|||
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.internal.uiexplorer.local;
|
||||
PRODUCT_NAME = UIExplorer;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
WARNING_CFLAGS = (
|
||||
"-Wextra",
|
||||
"-Wall",
|
||||
"-Wincompatible-pointer-types",
|
||||
"-Wincompatible-pointer-types-discards-qualifiers",
|
||||
);
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTUIManager.h"
|
||||
#import "UIView+React.h"
|
||||
|
||||
|
@ -26,9 +25,9 @@
|
|||
addChildReactTags:(NSArray *)addChildReactTags
|
||||
addAtIndices:(NSArray *)addAtIndices
|
||||
removeAtIndices:(NSArray *)removeAtIndices
|
||||
registry:(RCTSparseArray *)registry;
|
||||
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)registry;
|
||||
|
||||
@property (nonatomic, readonly) RCTSparseArray *viewRegistry;
|
||||
@property (nonatomic, readonly) NSMutableDictionary<NSNumber *, UIView *> *viewRegistry;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -50,13 +49,13 @@
|
|||
for (NSInteger i = 1; i <= 20; i++) {
|
||||
UIView *registeredView = [UIView new];
|
||||
registeredView.reactTag = @(i);
|
||||
_uiManager.viewRegistry[i] = registeredView;
|
||||
_uiManager.viewRegistry[@(i)] = registeredView;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testManagingChildrenToAddViews
|
||||
{
|
||||
UIView *containerView = _uiManager.viewRegistry[20];
|
||||
UIView *containerView = _uiManager.viewRegistry[@20];
|
||||
NSMutableArray *addedViews = [NSMutableArray array];
|
||||
|
||||
NSArray *tagsToAdd = @[@1, @2, @3, @4, @5];
|
||||
|
@ -72,7 +71,7 @@
|
|||
addChildReactTags:tagsToAdd
|
||||
addAtIndices:addAtIndices
|
||||
removeAtIndices:nil
|
||||
registry:_uiManager.viewRegistry];
|
||||
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)_uiManager.viewRegistry];
|
||||
|
||||
XCTAssertTrue([[containerView reactSubviews] count] == 5,
|
||||
@"Expect to have 5 react subviews after calling manage children \
|
||||
|
@ -86,7 +85,7 @@
|
|||
|
||||
- (void)testManagingChildrenToRemoveViews
|
||||
{
|
||||
UIView *containerView = _uiManager.viewRegistry[20];
|
||||
UIView *containerView = _uiManager.viewRegistry[@20];
|
||||
NSMutableArray *removedViews = [NSMutableArray array];
|
||||
|
||||
NSArray *removeAtIndices = @[@0, @4, @8, @12, @16];
|
||||
|
@ -95,7 +94,7 @@
|
|||
[removedViews addObject:_uiManager.viewRegistry[reactTag]];
|
||||
}
|
||||
for (NSInteger i = 2; i < 20; i++) {
|
||||
UIView *view = _uiManager.viewRegistry[i];
|
||||
UIView *view = _uiManager.viewRegistry[@(i)];
|
||||
[containerView addSubview:view];
|
||||
}
|
||||
|
||||
|
@ -106,7 +105,7 @@
|
|||
addChildReactTags:nil
|
||||
addAtIndices:nil
|
||||
removeAtIndices:removeAtIndices
|
||||
registry:_uiManager.viewRegistry];
|
||||
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)_uiManager.viewRegistry];
|
||||
|
||||
XCTAssertEqual(containerView.reactSubviews.count, (NSUInteger)13,
|
||||
@"Expect to have 13 react subviews after calling manage children\
|
||||
|
@ -119,7 +118,7 @@
|
|||
_uiManager.viewRegistry[view.reactTag] = view;
|
||||
}
|
||||
for (NSInteger i = 2; i < 20; i++) {
|
||||
UIView *view = _uiManager.viewRegistry[i];
|
||||
UIView *view = _uiManager.viewRegistry[@(i)];
|
||||
if (![removedViews containsObject:view]) {
|
||||
XCTAssertTrue([view superview] == containerView,
|
||||
@"Should not have removed view with react tag %ld during delete but did", (long)i);
|
||||
|
@ -138,7 +137,7 @@
|
|||
// [11,5,1,2,7,8,12,10]
|
||||
- (void)testManagingChildrenToAddRemoveAndMove
|
||||
{
|
||||
UIView *containerView = _uiManager.viewRegistry[20];
|
||||
UIView *containerView = _uiManager.viewRegistry[@20];
|
||||
|
||||
NSArray *removeAtIndices = @[@2, @3, @5, @8];
|
||||
NSArray *addAtIndices = @[@0, @6];
|
||||
|
@ -155,7 +154,7 @@
|
|||
}
|
||||
|
||||
for (NSInteger i = 1; i < 11; i++) {
|
||||
UIView *view = _uiManager.viewRegistry[i];
|
||||
UIView *view = _uiManager.viewRegistry[@(i)];
|
||||
[containerView addSubview:view];
|
||||
}
|
||||
|
||||
|
@ -165,7 +164,7 @@
|
|||
addChildReactTags:tagsToAdd
|
||||
addAtIndices:addAtIndices
|
||||
removeAtIndices:removeAtIndices
|
||||
registry:_uiManager.viewRegistry];
|
||||
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)_uiManager.viewRegistry];
|
||||
|
||||
XCTAssertTrue([[containerView reactSubviews] count] == 8,
|
||||
@"Expect to have 8 react subviews after calling manage children,\
|
||||
|
@ -180,7 +179,7 @@
|
|||
|
||||
// Clean up after ourselves
|
||||
for (NSInteger i = 1; i < 13; i++) {
|
||||
UIView *view = _uiManager.viewRegistry[i];
|
||||
UIView *view = _uiManager.viewRegistry[@(i)];
|
||||
[view removeFromSuperview];
|
||||
}
|
||||
for (UIView *view in viewsToRemove) {
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
@interface TestExecutor : NSObject <RCTJavaScriptExecutor>
|
||||
|
||||
@property (nonatomic, readonly, copy) NSMutableDictionary *injectedStuff;
|
||||
@property (nonatomic, readonly, copy) NSMutableDictionary<NSString *, id> *injectedStuff;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -137,7 +137,7 @@ _Pragma("clang diagnostic pop")
|
|||
RUN_RUNLOOP_WHILE(!(injectedStuff = executor.injectedStuff[@"__fbBatchedBridgeConfig"]));
|
||||
|
||||
__block NSNumber *testModuleID = nil;
|
||||
__block NSDictionary *testConstants = nil;
|
||||
__block NSDictionary<NSString *, id> *testConstants = nil;
|
||||
__block NSNumber *testMethodID = nil;
|
||||
|
||||
NSArray *remoteModuleConfig = RCTJSONParse(injectedStuff, NULL)[@"remoteModuleConfig"];
|
||||
|
@ -165,7 +165,7 @@ _Pragma("clang diagnostic pop")
|
|||
RUN_RUNLOOP_WHILE(!(injectedStuff = executor.injectedStuff[@"__fbBatchedBridgeConfig"]));
|
||||
|
||||
__block NSNumber *testModuleID = nil;
|
||||
__block NSDictionary *testConstants = nil;
|
||||
__block NSDictionary<NSString *, id> *testConstants = nil;
|
||||
__block NSNumber *testMethodID = nil;
|
||||
|
||||
NSArray *remoteModuleConfig = RCTJSONParse(injectedStuff, NULL)[@"remoteModuleConfig"];
|
||||
|
@ -211,7 +211,7 @@ RCT_EXPORT_METHOD(testMethod:(NSInteger)integer
|
|||
XCTAssertNotNil(callback);
|
||||
}
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
return @{@"eleventyMillion": @42};
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
@implementation RCTTestEvent
|
||||
|
||||
- (instancetype)initWithViewTag:(NSNumber *)viewTag eventName:(NSString *)eventName body:(NSDictionary *)body
|
||||
- (instancetype)initWithViewTag:(NSNumber *)viewTag eventName:(NSString *)eventName body:(NSDictionary<NSString *, id> *)body
|
||||
{
|
||||
if (self = [super initWithViewTag:viewTag eventName:eventName body:body]) {
|
||||
self.canCoalesce = YES;
|
||||
|
@ -50,7 +50,7 @@
|
|||
RCTEventDispatcher *_eventDispatcher;
|
||||
|
||||
NSString *_eventName;
|
||||
NSDictionary *_body;
|
||||
NSDictionary<NSString *, id> *_body;
|
||||
RCTTestEvent *_testEvent;
|
||||
NSString *_JSMethod;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ extern BOOL RCTIsGzippedData(NSData *data);
|
|||
|
||||
@interface RCTNetworking (Private)
|
||||
|
||||
- (void)buildRequest:(NSDictionary *)query
|
||||
- (void)buildRequest:(NSDictionary<NSString *, id> *)query
|
||||
completionBlock:(void (^)(NSURLRequest *request))block;
|
||||
|
||||
@end
|
||||
|
|
|
@ -23,14 +23,14 @@
|
|||
|
||||
- (void)testEncodingObject
|
||||
{
|
||||
NSDictionary *obj = @{@"foo": @"bar"};
|
||||
NSDictionary<NSString *, id> *obj = @{@"foo": @"bar"};
|
||||
NSString *json = @"{\"foo\":\"bar\"}";
|
||||
XCTAssertEqualObjects(json, RCTJSONStringify(obj, NULL));
|
||||
}
|
||||
|
||||
- (void)testEncodingArray
|
||||
{
|
||||
NSArray *array = @[@"foo", @"bar"];
|
||||
NSArray<id> *array = @[@"foo", @"bar"];
|
||||
NSString *json = @"[\"foo\",\"bar\"]";
|
||||
XCTAssertEqualObjects(json, RCTJSONStringify(array, NULL));
|
||||
}
|
||||
|
@ -44,14 +44,14 @@
|
|||
|
||||
- (void)testDecodingObject
|
||||
{
|
||||
NSDictionary *obj = @{@"foo": @"bar"};
|
||||
NSDictionary<NSString *, id> *obj = @{@"foo": @"bar"};
|
||||
NSString *json = @"{\"foo\":\"bar\"}";
|
||||
XCTAssertEqualObjects(obj, RCTJSONParse(json, NULL));
|
||||
}
|
||||
|
||||
- (void)testDecodingArray
|
||||
{
|
||||
NSArray *array = @[@"foo", @"bar"];
|
||||
NSArray<id> *array = @[@"foo", @"bar"];
|
||||
NSString *json = @"[\"foo\",\"bar\"]";
|
||||
XCTAssertEqualObjects(array, RCTJSONParse(json, NULL));
|
||||
}
|
||||
|
@ -66,14 +66,14 @@
|
|||
- (void)testDecodingMutableArray
|
||||
{
|
||||
NSString *json = @"[1,2,3]";
|
||||
NSMutableArray *array = RCTJSONParseMutable(json, NULL);
|
||||
NSMutableArray<id> *array = RCTJSONParseMutable(json, NULL);
|
||||
XCTAssertNoThrow([array addObject:@4]);
|
||||
XCTAssertEqualObjects(array, (@[@1, @2, @3, @4]));
|
||||
}
|
||||
|
||||
- (void)testLeadingWhitespace
|
||||
{
|
||||
NSDictionary *obj = @{@"foo": @"bar"};
|
||||
NSDictionary<NSString *, id> *obj = @{@"foo": @"bar"};
|
||||
NSString *json = @" \r\n\t{\"foo\":\"bar\"}";
|
||||
XCTAssertEqualObjects(obj, RCTJSONParse(json, NULL));
|
||||
}
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
/**
|
||||
* The examples provided by Facebook are for non-commercial testing and
|
||||
* evaluation purposes only.
|
||||
*
|
||||
* Facebook reserves all rights not expressly granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
|
||||
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "RCTSparseArray.h"
|
||||
#import "UIView+React.h"
|
||||
|
||||
@interface RCTSparseArrayTests : XCTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTSparseArrayTests
|
||||
|
||||
- (void)testDictionary
|
||||
{
|
||||
id<RCTComponent> myView = [UIView new];
|
||||
myView.reactTag = @4;
|
||||
|
||||
id<RCTComponent> myOtherView = [UIView new];
|
||||
myOtherView.reactTag = @5;
|
||||
|
||||
RCTSparseArray *registry = [RCTSparseArray new];
|
||||
XCTAssertNil(registry[@4], @"how did you have a view when none are registered?");
|
||||
XCTAssertNil(registry[@5], @"how did you have a view when none are registered?");
|
||||
|
||||
registry[myView.reactTag] = myView;
|
||||
XCTAssertEqual(registry[@4], myView);
|
||||
XCTAssertNil(registry[@5], @"didn't register other view yet");
|
||||
|
||||
registry[myOtherView.reactTag] = myOtherView;
|
||||
XCTAssertEqual(registry[@4], myView);
|
||||
XCTAssertEqual(registry[@5], myOtherView);
|
||||
|
||||
registry[myView.reactTag] = nil;
|
||||
XCTAssertNil(registry[@4]);
|
||||
XCTAssertEqual(registry[@5], myOtherView);
|
||||
|
||||
registry[myOtherView.reactTag] = nil;
|
||||
XCTAssertNil(registry[@4], @"how did you have a view when none are registered?");
|
||||
XCTAssertNil(registry[@5], @"how did you have a view when none are registered?");
|
||||
}
|
||||
|
||||
@end
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTUIManager.h"
|
||||
#import "UIView+React.h"
|
||||
|
||||
|
@ -26,9 +25,9 @@
|
|||
addChildReactTags:(NSArray *)addChildReactTags
|
||||
addAtIndices:(NSArray *)addAtIndices
|
||||
removeAtIndices:(NSArray *)removeAtIndices
|
||||
registry:(RCTSparseArray *)registry;
|
||||
registry:(NSDictionary<NSNumber *, id<RCTComponent>> *)registry;
|
||||
|
||||
@property (nonatomic, readonly) RCTSparseArray *viewRegistry;
|
||||
@property (nonatomic, copy, readonly) NSMutableDictionary<NSNumber *, UIView *> *viewRegistry;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -50,13 +49,13 @@
|
|||
for (NSInteger i = 1; i <= 20; i++) {
|
||||
UIView *registeredView = [UIView new];
|
||||
registeredView.reactTag = @(i);
|
||||
_uiManager.viewRegistry[i] = registeredView;
|
||||
_uiManager.viewRegistry[@(i)] = registeredView;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testManagingChildrenToAddViews
|
||||
{
|
||||
UIView *containerView = _uiManager.viewRegistry[20];
|
||||
UIView *containerView = _uiManager.viewRegistry[@20];
|
||||
NSMutableArray *addedViews = [NSMutableArray array];
|
||||
|
||||
NSArray *tagsToAdd = @[@1, @2, @3, @4, @5];
|
||||
|
@ -86,7 +85,7 @@
|
|||
|
||||
- (void)testManagingChildrenToRemoveViews
|
||||
{
|
||||
UIView *containerView = _uiManager.viewRegistry[20];
|
||||
UIView *containerView = _uiManager.viewRegistry[@20];
|
||||
NSMutableArray *removedViews = [NSMutableArray array];
|
||||
|
||||
NSArray *removeAtIndices = @[@0, @4, @8, @12, @16];
|
||||
|
@ -95,7 +94,7 @@
|
|||
[removedViews addObject:_uiManager.viewRegistry[reactTag]];
|
||||
}
|
||||
for (NSInteger i = 2; i < 20; i++) {
|
||||
UIView *view = _uiManager.viewRegistry[i];
|
||||
UIView *view = _uiManager.viewRegistry[@(i)];
|
||||
[containerView addSubview:view];
|
||||
}
|
||||
|
||||
|
@ -119,7 +118,7 @@
|
|||
_uiManager.viewRegistry[view.reactTag] = view;
|
||||
}
|
||||
for (NSInteger i = 2; i < 20; i++) {
|
||||
UIView *view = _uiManager.viewRegistry[i];
|
||||
UIView *view = _uiManager.viewRegistry[@(i)];
|
||||
if (![removedViews containsObject:view]) {
|
||||
XCTAssertTrue([view superview] == containerView,
|
||||
@"Should not have removed view with react tag %ld during delete but did", (long)i);
|
||||
|
@ -138,7 +137,7 @@
|
|||
// [11,5,1,2,7,8,12,10]
|
||||
- (void)testManagingChildrenToAddRemoveAndMove
|
||||
{
|
||||
UIView *containerView = _uiManager.viewRegistry[20];
|
||||
UIView *containerView = _uiManager.viewRegistry[@20];
|
||||
|
||||
NSArray *removeAtIndices = @[@2, @3, @5, @8];
|
||||
NSArray *addAtIndices = @[@0, @6];
|
||||
|
@ -155,7 +154,7 @@
|
|||
}
|
||||
|
||||
for (NSInteger i = 1; i < 11; i++) {
|
||||
UIView *view = _uiManager.viewRegistry[i];
|
||||
UIView *view = _uiManager.viewRegistry[@(i)];
|
||||
[containerView addSubview:view];
|
||||
}
|
||||
|
||||
|
@ -180,7 +179,7 @@
|
|||
|
||||
// Clean up after ourselves
|
||||
for (NSInteger i = 1; i < 13; i++) {
|
||||
UIView *view = _uiManager.viewRegistry[i];
|
||||
UIView *view = _uiManager.viewRegistry[@(i)];
|
||||
[view removeFromSuperview];
|
||||
}
|
||||
for (UIView *view in viewsToRemove) {
|
||||
|
|
|
@ -46,7 +46,7 @@ RCT_ENUM_CONVERTER(ALAssetsGroupType, (@{
|
|||
|
||||
+ (ALAssetsFilter *)ALAssetsFilter:(id)json
|
||||
{
|
||||
static NSDictionary *options;
|
||||
static NSDictionary<NSString *, ALAssetsFilter *> *options;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
options = @{
|
||||
|
@ -102,29 +102,31 @@ RCT_EXPORT_METHOD(saveImageWithTag:(NSString *)imageTag
|
|||
}];
|
||||
}
|
||||
|
||||
- (void)callCallback:(RCTResponseSenderBlock)callback
|
||||
withAssets:(NSArray<NSDictionary *> *)assets
|
||||
hasNextPage:(BOOL)hasNextPage
|
||||
static void RCTCallCallback(RCTResponseSenderBlock callback,
|
||||
NSArray<NSDictionary<NSString *, id> *> *assets,
|
||||
BOOL hasNextPage)
|
||||
{
|
||||
if (!assets.count) {
|
||||
callback(@[@{
|
||||
@"edges": assets,
|
||||
@"page_info": @{
|
||||
@"has_next_page": @NO}
|
||||
}]);
|
||||
@"edges": assets,
|
||||
@"page_info": @{
|
||||
@"has_next_page": @NO,
|
||||
}
|
||||
}]);
|
||||
return;
|
||||
}
|
||||
callback(@[@{
|
||||
@"edges": assets,
|
||||
@"page_info": @{
|
||||
@"start_cursor": assets[0][@"node"][@"image"][@"uri"],
|
||||
@"end_cursor": assets[assets.count - 1][@"node"][@"image"][@"uri"],
|
||||
@"has_next_page": @(hasNextPage)}
|
||||
}]);
|
||||
@"edges": assets,
|
||||
@"page_info": @{
|
||||
@"start_cursor": assets[0][@"node"][@"image"][@"uri"],
|
||||
@"end_cursor": assets[assets.count - 1][@"node"][@"image"][@"uri"],
|
||||
@"has_next_page": @(hasNextPage),
|
||||
}
|
||||
}]);
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params
|
||||
callback:(RCTResponseSenderBlock)callback
|
||||
successCallback:(RCTResponseSenderBlock)successCallback
|
||||
errorCallback:(RCTResponseErrorBlock)errorCallback)
|
||||
{
|
||||
NSUInteger first = [RCTConvert NSInteger:params[@"first"]];
|
||||
|
@ -136,7 +138,7 @@ RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params
|
|||
BOOL __block foundAfter = NO;
|
||||
BOOL __block hasNextPage = NO;
|
||||
BOOL __block calledCallback = NO;
|
||||
NSMutableArray<NSDictionary *> *assets = [NSMutableArray new];
|
||||
NSMutableArray<NSDictionary<NSString *, id> *> *assets = [NSMutableArray new];
|
||||
|
||||
[_bridge.assetsLibrary enumerateGroupsWithTypes:groupTypes usingBlock:^(ALAssetsGroup *group, BOOL *stopGroups) {
|
||||
if (group && (groupName == nil || [groupName isEqualToString:[group valueForProperty:ALAssetsGroupPropertyName]])) {
|
||||
|
@ -156,7 +158,7 @@ RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params
|
|||
*stopGroups = YES;
|
||||
hasNextPage = YES;
|
||||
RCTAssert(calledCallback == NO, @"Called the callback before we finished processing the results.");
|
||||
[self callCallback:callback withAssets:assets hasNextPage:hasNextPage];
|
||||
RCTCallCallback(successCallback, assets, hasNextPage);
|
||||
calledCallback = YES;
|
||||
return;
|
||||
}
|
||||
|
@ -164,33 +166,32 @@ RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params
|
|||
CLLocation *loc = [result valueForProperty:ALAssetPropertyLocation];
|
||||
NSDate *date = [result valueForProperty:ALAssetPropertyDate];
|
||||
[assets addObject:@{
|
||||
@"node": @{
|
||||
@"type": [result valueForProperty:ALAssetPropertyType],
|
||||
@"group_name": [group valueForProperty:ALAssetsGroupPropertyName],
|
||||
@"image": @{
|
||||
@"uri": uri,
|
||||
@"height": @(dimensions.height),
|
||||
@"width": @(dimensions.width),
|
||||
@"isStored": @YES,
|
||||
},
|
||||
@"timestamp": @(date.timeIntervalSince1970),
|
||||
@"location": loc ?
|
||||
@{
|
||||
@"latitude": @(loc.coordinate.latitude),
|
||||
@"longitude": @(loc.coordinate.longitude),
|
||||
@"altitude": @(loc.altitude),
|
||||
@"heading": @(loc.course),
|
||||
@"speed": @(loc.speed),
|
||||
} : @{},
|
||||
}
|
||||
}];
|
||||
@"node": @{
|
||||
@"type": [result valueForProperty:ALAssetPropertyType],
|
||||
@"group_name": [group valueForProperty:ALAssetsGroupPropertyName],
|
||||
@"image": @{
|
||||
@"uri": uri,
|
||||
@"height": @(dimensions.height),
|
||||
@"width": @(dimensions.width),
|
||||
@"isStored": @YES,
|
||||
},
|
||||
@"timestamp": @(date.timeIntervalSince1970),
|
||||
@"location": loc ? @{
|
||||
@"latitude": @(loc.coordinate.latitude),
|
||||
@"longitude": @(loc.coordinate.longitude),
|
||||
@"altitude": @(loc.altitude),
|
||||
@"heading": @(loc.course),
|
||||
@"speed": @(loc.speed),
|
||||
} : @{},
|
||||
}
|
||||
}];
|
||||
}
|
||||
}];
|
||||
} else {
|
||||
// Sometimes the enumeration continues even if we set stop above, so we guard against calling the callback
|
||||
// multiple times here.
|
||||
if (!calledCallback) {
|
||||
[self callCallback:callback withAssets:assets hasNextPage:hasNextPage];
|
||||
RCTCallCallback(successCallback, assets, hasNextPage);
|
||||
calledCallback = YES;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
*/
|
||||
|
||||
#import "RCTImagePickerManager.h"
|
||||
|
||||
#import "RCTConvert.h"
|
||||
#import "RCTRootView.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTUtils.h"
|
||||
|
@ -66,7 +68,7 @@ RCT_EXPORT_METHOD(openCameraDialog:(NSDictionary *)config
|
|||
imagePicker.delegate = self;
|
||||
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
|
||||
|
||||
if ([config[@"videoMode"] boolValue]) {
|
||||
if ([RCTConvert BOOL:config[@"videoMode"]]) {
|
||||
imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
|
||||
}
|
||||
|
||||
|
@ -93,10 +95,10 @@ RCT_EXPORT_METHOD(openSelectDialog:(NSDictionary *)config
|
|||
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
|
||||
|
||||
NSMutableArray<NSString *> *allowedTypes = [NSMutableArray new];
|
||||
if ([config[@"showImages"] boolValue]) {
|
||||
if ([RCTConvert BOOL:config[@"showImages"]]) {
|
||||
[allowedTypes addObject:(NSString *)kUTTypeImage];
|
||||
}
|
||||
if ([config[@"showVideos"] boolValue]) {
|
||||
if ([RCTConvert BOOL:config[@"showVideos"]]) {
|
||||
[allowedTypes addObject:(NSString *)kUTTypeMovie];
|
||||
}
|
||||
|
||||
|
@ -110,7 +112,7 @@ RCT_EXPORT_METHOD(openSelectDialog:(NSDictionary *)config
|
|||
}
|
||||
|
||||
- (void)imagePickerController:(UIImagePickerController *)picker
|
||||
didFinishPickingMediaWithInfo:(NSDictionary *)info
|
||||
didFinishPickingMediaWithInfo:(NSDictionary<NSString *, id> *)info
|
||||
{
|
||||
NSUInteger index = [_pickers indexOfObject:picker];
|
||||
RCTResponseSenderBlock callback = _pickerCallbacks[index];
|
||||
|
|
|
@ -50,7 +50,7 @@ RCT_EXPORT_MODULE()
|
|||
PHImageRequestOptions *imageOptions = [PHImageRequestOptions new];
|
||||
|
||||
if (progressHandler) {
|
||||
imageOptions.progressHandler = ^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {
|
||||
imageOptions.progressHandler = ^(double progress, NSError *error, BOOL *stop, NSDictionary<NSString *, id> *info) {
|
||||
static const double multiplier = 1e6;
|
||||
progressHandler(progress * multiplier, multiplier);
|
||||
};
|
||||
|
@ -80,7 +80,7 @@ RCT_EXPORT_MODULE()
|
|||
targetSize:targetSize
|
||||
contentMode:contentMode
|
||||
options:imageOptions
|
||||
resultHandler:^(UIImage *result, NSDictionary *info) {
|
||||
resultHandler:^(UIImage *result, NSDictionary<NSString *, id> *info) {
|
||||
if (result) {
|
||||
completionHandler(nil, result);
|
||||
} else {
|
||||
|
|
|
@ -37,7 +37,7 @@ typedef struct {
|
|||
|
||||
+ (RCTLocationOptions)RCTLocationOptions:(id)json
|
||||
{
|
||||
NSDictionary *options = [RCTConvert NSDictionary:json];
|
||||
NSDictionary<NSString *, id> *options = [RCTConvert NSDictionary:json];
|
||||
return (RCTLocationOptions){
|
||||
.timeout = [RCTConvert NSTimeInterval:options[@"timeout"]] ?: INFINITY,
|
||||
.maximumAge = [RCTConvert NSTimeInterval:options[@"maximumAge"]] ?: INFINITY,
|
||||
|
@ -47,7 +47,7 @@ typedef struct {
|
|||
|
||||
@end
|
||||
|
||||
static NSDictionary *RCTPositionError(RCTPositionErrorCode code, NSString *msg /* nil for default */)
|
||||
static NSDictionary<NSString *, id> *RCTPositionError(RCTPositionErrorCode code, NSString *msg /* nil for default */)
|
||||
{
|
||||
if (!msg) {
|
||||
switch (code) {
|
||||
|
@ -99,7 +99,7 @@ static NSDictionary *RCTPositionError(RCTPositionErrorCode code, NSString *msg /
|
|||
@implementation RCTLocationObserver
|
||||
{
|
||||
CLLocationManager *_locationManager;
|
||||
NSDictionary *_lastLocationEvent;
|
||||
NSDictionary<NSString *, id> *_lastLocationEvent;
|
||||
NSMutableArray<RCTLocationRequest *> *_pendingRequests;
|
||||
BOOL _observingLocation;
|
||||
RCTLocationOptions _observerOptions;
|
||||
|
@ -295,7 +295,7 @@ RCT_EXPORT_METHOD(getCurrentPosition:(RCTLocationOptions)options
|
|||
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
|
||||
{
|
||||
// Check error type
|
||||
NSDictionary *jsError = nil;
|
||||
NSDictionary<NSString *, id> *jsError = nil;
|
||||
switch (error.code) {
|
||||
case kCLErrorDenied:
|
||||
jsError = RCTPositionError(RCTPositionErrorDenied, nil);
|
||||
|
|
|
@ -34,7 +34,7 @@ RCT_EXPORT_MODULE()
|
|||
completionHandler:(RCTImageLoaderCompletionBlock)completionHandler
|
||||
{
|
||||
CGImageSourceRef imageSource = CGImageSourceCreateWithData((CFDataRef)imageData, NULL);
|
||||
NSDictionary *properties = (__bridge_transfer NSDictionary *)CGImageSourceCopyProperties(imageSource, NULL);
|
||||
NSDictionary<NSString *, id> *properties = (__bridge_transfer NSDictionary *)CGImageSourceCopyProperties(imageSource, NULL);
|
||||
NSUInteger loopCount = [properties[(id)kCGImagePropertyGIFDictionary][(id)kCGImagePropertyGIFLoopCount] unsignedIntegerValue];
|
||||
|
||||
UIImage *image = nil;
|
||||
|
@ -51,8 +51,8 @@ RCT_EXPORT_MODULE()
|
|||
image = [UIImage imageWithCGImage:imageRef scale:scale orientation:UIImageOrientationUp];
|
||||
}
|
||||
|
||||
NSDictionary *frameProperties = (__bridge_transfer NSDictionary *)CGImageSourceCopyPropertiesAtIndex(imageSource, i, NULL);
|
||||
NSDictionary *frameGIFProperties = frameProperties[(id)kCGImagePropertyGIFDictionary];
|
||||
NSDictionary<NSString *, id> *frameProperties = (__bridge_transfer NSDictionary *)CGImageSourceCopyPropertiesAtIndex(imageSource, i, NULL);
|
||||
NSDictionary<NSString *, id> *frameGIFProperties = frameProperties[(id)kCGImagePropertyGIFDictionary];
|
||||
|
||||
const NSTimeInterval kDelayTimeIntervalDefault = 0.1;
|
||||
NSNumber *delayTime = frameGIFProperties[(id)kCGImagePropertyGIFUnclampedDelayTime] ?: frameGIFProperties[(id)kCGImagePropertyGIFDelayTime];
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
@implementation RCTImageStoreManager
|
||||
{
|
||||
NSMutableDictionary *_store;
|
||||
NSMutableDictionary<NSString *, UIImage *> *_store;
|
||||
}
|
||||
|
||||
@synthesize methodQueue = _methodQueue;
|
||||
|
|
|
@ -237,7 +237,7 @@ RCT_EXTERN UIImage *RCTDecodeImageWithData(NSData *data,
|
|||
CGFloat maxPixelSize = fmax(fmin(sourceSize.width, targetPixelSize.width),
|
||||
fmin(sourceSize.height, targetPixelSize.height));
|
||||
|
||||
NSDictionary *options = @{
|
||||
NSDictionary<NSString *, NSNumber *> *options = @{
|
||||
(id)kCGImageSourceShouldAllowFloat: @YES,
|
||||
(id)kCGImageSourceCreateThumbnailWithTransform: @YES,
|
||||
(id)kCGImageSourceCreateThumbnailFromImageAlways: @YES,
|
||||
|
|
|
@ -42,7 +42,7 @@ RCT_EXPORT_MODULE()
|
|||
sourceApplication:(NSString *)sourceApplication
|
||||
annotation:(id)annotation
|
||||
{
|
||||
NSDictionary *payload = @{@"url": URL.absoluteString};
|
||||
NSDictionary<NSString *, id> *payload = @{@"url": URL.absoluteString};
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTOpenURLNotification
|
||||
object:self
|
||||
userInfo:payload];
|
||||
|
@ -75,7 +75,7 @@ RCT_EXPORT_METHOD(canOpenURL:(NSURL *)URL
|
|||
callback(@[@(canOpen)]);
|
||||
}
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
NSURL *initialURL = _bridge.launchOptions[UIApplicationLaunchOptionsURLKey];
|
||||
return @{@"initialURL": RCTNullIfNil(initialURL.absoluteString)};
|
||||
|
|
|
@ -48,7 +48,7 @@ RCT_EXPORT_MODULE()
|
|||
// Get content length
|
||||
NSError *error = nil;
|
||||
NSFileManager *fileManager = [NSFileManager new];
|
||||
NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:request.URL.path error:&error];
|
||||
NSDictionary<NSString *, id> *fileAttributes = [fileManager attributesOfItemAtPath:request.URL.path error:&error];
|
||||
if (error) {
|
||||
[delegate URLRequest:weakOp didCompleteWithError:error];
|
||||
return;
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
#import "RCTLog.h"
|
||||
#import "RCTUtils.h"
|
||||
|
||||
typedef RCTURLRequestCancellationBlock (^RCTHTTPQueryResult)(NSError *error, NSDictionary *result);
|
||||
typedef RCTURLRequestCancellationBlock (^RCTHTTPQueryResult)(NSError *error, NSDictionary<NSString *, id> *result);
|
||||
|
||||
@interface RCTNetworking ()
|
||||
|
||||
- (RCTURLRequestCancellationBlock)processDataForHTTPQuery:(NSDictionary *)data
|
||||
- (RCTURLRequestCancellationBlock)processDataForHTTPQuery:(NSDictionary<NSString *, id> *)data
|
||||
callback:(RCTHTTPQueryResult)callback;
|
||||
@end
|
||||
|
||||
|
@ -37,7 +37,7 @@ typedef RCTURLRequestCancellationBlock (^RCTHTTPQueryResult)(NSError *error, NSD
|
|||
|
||||
@implementation RCTHTTPFormDataHelper
|
||||
{
|
||||
NSMutableArray<NSDictionary *> *_parts;
|
||||
NSMutableArray<NSDictionary<NSString *, id> *> *_parts;
|
||||
NSMutableData *_multipartBody;
|
||||
RCTHTTPQueryResult _callback;
|
||||
NSString *_boundary;
|
||||
|
@ -68,12 +68,12 @@ static NSString *RCTGenerateFormBoundary()
|
|||
_multipartBody = [NSMutableData new];
|
||||
_boundary = RCTGenerateFormBoundary();
|
||||
|
||||
return [_networker processDataForHTTPQuery:_parts[0] callback:^(NSError *error, NSDictionary *result) {
|
||||
return [_networker processDataForHTTPQuery:_parts[0] callback:^(NSError *error, NSDictionary<NSString *, id> *result) {
|
||||
return [self handleResult:result error:error];
|
||||
}];
|
||||
}
|
||||
|
||||
- (RCTURLRequestCancellationBlock)handleResult:(NSDictionary *)result
|
||||
- (RCTURLRequestCancellationBlock)handleResult:(NSDictionary<NSString *, id> *)result
|
||||
error:(NSError *)error
|
||||
{
|
||||
if (error) {
|
||||
|
@ -85,7 +85,7 @@ static NSString *RCTGenerateFormBoundary()
|
|||
dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
|
||||
// Print headers.
|
||||
NSMutableDictionary *headers = [_parts[0][@"headers"] mutableCopy];
|
||||
NSMutableDictionary<NSString *, NSString *> *headers = [_parts[0][@"headers"] mutableCopy];
|
||||
NSString *partContentType = result[@"contentType"];
|
||||
if (partContentType != nil) {
|
||||
headers[@"content-type"] = partContentType;
|
||||
|
@ -102,7 +102,7 @@ static NSString *RCTGenerateFormBoundary()
|
|||
|
||||
[_parts removeObjectAtIndex:0];
|
||||
if (_parts.count) {
|
||||
return [_networker processDataForHTTPQuery:_parts[0] callback:^(NSError *err, NSDictionary *res) {
|
||||
return [_networker processDataForHTTPQuery:_parts[0] callback:^(NSError *err, NSDictionary<NSString *, id> *res) {
|
||||
return [self handleResult:res error:err];
|
||||
}];
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ static NSString *RCTGenerateFormBoundary()
|
|||
*/
|
||||
@implementation RCTNetworking
|
||||
{
|
||||
NSMutableDictionary *_tasksByRequestID;
|
||||
NSMutableDictionary<NSNumber *, RCTNetworkTask *> *_tasksByRequestID;
|
||||
NSArray<id<RCTURLRequestHandler>> *_handlers;
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ RCT_EXPORT_MODULE()
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (RCTURLRequestCancellationBlock)buildRequest:(NSDictionary *)query
|
||||
- (RCTURLRequestCancellationBlock)buildRequest:(NSDictionary<NSString *, id> *)query
|
||||
completionBlock:(void (^)(NSURLRequest *request))block
|
||||
{
|
||||
NSURL *URL = [RCTConvert NSURL:query[@"url"]]; // this is marked as nullable in JS, but should not be null
|
||||
|
@ -199,8 +199,8 @@ RCT_EXPORT_MODULE()
|
|||
request.HTTPMethod = [RCTConvert NSString:RCTNilIfNull(query[@"method"])].uppercaseString ?: @"GET";
|
||||
request.allHTTPHeaderFields = [RCTConvert NSDictionary:query[@"headers"]];
|
||||
|
||||
NSDictionary *data = [RCTConvert NSDictionary:RCTNilIfNull(query[@"data"])];
|
||||
return [self processDataForHTTPQuery:data callback:^(NSError *error, NSDictionary *result) {
|
||||
NSDictionary<NSString *, id> *data = [RCTConvert NSDictionary:RCTNilIfNull(query[@"data"])];
|
||||
return [self processDataForHTTPQuery:data callback:^(NSError *error, NSDictionary<NSString *, id> *result) {
|
||||
if (error) {
|
||||
RCTLogError(@"Error processing request body: %@", error);
|
||||
// Ideally we'd circle back to JS here and notify an error/abort on the request.
|
||||
|
@ -246,8 +246,8 @@ RCT_EXPORT_MODULE()
|
|||
* - @"contentType" (NSString): the content type header of the request
|
||||
*
|
||||
*/
|
||||
- (RCTURLRequestCancellationBlock)processDataForHTTPQuery:(nullable NSDictionary *)query callback:
|
||||
(RCTURLRequestCancellationBlock (^)(NSError *error, NSDictionary *result))callback
|
||||
- (RCTURLRequestCancellationBlock)processDataForHTTPQuery:(nullable NSDictionary<NSString *, id> *)query callback:
|
||||
(RCTURLRequestCancellationBlock (^)(NSError *error, NSDictionary<NSString *, id> *result))callback
|
||||
{
|
||||
if (!query) {
|
||||
return callback(nil, nil);
|
||||
|
@ -322,7 +322,7 @@ RCT_EXPORT_MODULE()
|
|||
}
|
||||
}
|
||||
|
||||
NSArray *responseJSON = @[task.requestID, responseText ?: @""];
|
||||
NSArray<id> *responseJSON = @[task.requestID, responseText ?: @""];
|
||||
[_bridge.eventDispatcher sendDeviceEventWithName:@"didReceiveNetworkData"
|
||||
body:responseJSON];
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ RCT_EXPORT_MODULE()
|
|||
|
||||
void (^responseBlock)(NSURLResponse *) = ^(NSURLResponse *response) {
|
||||
dispatch_async(_methodQueue, ^{
|
||||
NSDictionary *headers;
|
||||
NSDictionary<NSString *, NSString *> *headers;
|
||||
NSInteger status;
|
||||
if ([response isKindOfClass:[NSHTTPURLResponse class]]) { // Might be a local file request
|
||||
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
|
||||
|
@ -352,7 +352,7 @@ RCT_EXPORT_MODULE()
|
|||
headers = response.MIMEType ? @{@"Content-Type": response.MIMEType} : @{};
|
||||
status = 200;
|
||||
}
|
||||
NSArray *responseJSON = @[task.requestID, @(status), headers];
|
||||
NSArray<id> *responseJSON = @[task.requestID, @(status), headers];
|
||||
[_bridge.eventDispatcher sendDeviceEventWithName:@"didReceiveNetworkResponse"
|
||||
body:responseJSON];
|
||||
});
|
||||
|
|
|
@ -31,7 +31,7 @@ NSString *const RCTRemoteNotificationsRegistered = @"RemoteNotificationsRegister
|
|||
|
||||
+ (UILocalNotification *)UILocalNotification:(id)json
|
||||
{
|
||||
NSDictionary *details = [self NSDictionary:json];
|
||||
NSDictionary<NSString *, id> *details = [self NSDictionary:json];
|
||||
UILocalNotification *notification = [UILocalNotification new];
|
||||
notification.fireDate = [RCTConvert NSDate:details[@"fireDate"]] ?: [NSDate date];
|
||||
notification.alertBody = [RCTConvert NSString:details[@"alertBody"]];
|
||||
|
@ -42,7 +42,7 @@ NSString *const RCTRemoteNotificationsRegistered = @"RemoteNotificationsRegister
|
|||
|
||||
@implementation RCTPushNotificationManager
|
||||
{
|
||||
NSDictionary *_initialNotification;
|
||||
NSDictionary<NSString *, id> *_initialNotification;
|
||||
}
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
@ -90,7 +90,7 @@ RCT_EXPORT_MODULE()
|
|||
for (NSUInteger i = 0; i < deviceTokenLength; i++) {
|
||||
[hexString appendFormat:@"%02x", bytes[i]];
|
||||
}
|
||||
NSDictionary *userInfo = @{
|
||||
NSDictionary<NSString *, id> *userInfo = @{
|
||||
@"deviceToken" : [hexString copy]
|
||||
};
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTRemoteNotificationsRegistered
|
||||
|
@ -174,7 +174,7 @@ RCT_EXPORT_METHOD(abandonPermissions)
|
|||
RCT_EXPORT_METHOD(checkPermissions:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
if (RCTRunningInAppExtension()) {
|
||||
NSDictionary *permissions = @{@"alert": @(NO), @"badge": @(NO), @"sound": @(NO)};
|
||||
NSDictionary<NSString *, NSNumber *> *permissions = @{@"alert": @NO, @"badge": @NO, @"sound": @NO};
|
||||
callback(@[permissions]);
|
||||
return;
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ RCT_EXPORT_METHOD(checkPermissions:(RCTResponseSenderBlock)callback)
|
|||
|
||||
}
|
||||
|
||||
NSMutableDictionary *permissions = [NSMutableDictionary new];
|
||||
NSMutableDictionary<NSString *, NSNumber *> *permissions = [NSMutableDictionary new];
|
||||
permissions[@"alert"] = @((types & UIUserNotificationTypeAlert) > 0);
|
||||
permissions[@"badge"] = @((types & UIUserNotificationTypeBadge) > 0);
|
||||
permissions[@"sound"] = @((types & UIUserNotificationTypeSound) > 0);
|
||||
|
@ -200,7 +200,7 @@ RCT_EXPORT_METHOD(checkPermissions:(RCTResponseSenderBlock)callback)
|
|||
callback(@[permissions]);
|
||||
}
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
return @{
|
||||
@"initialNotification": RCTNullIfNil(_initialNotification),
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
@implementation RCTTestModule
|
||||
{
|
||||
NSMutableDictionary *_snapshotCounter;
|
||||
NSMutableDictionary<NSString *, NSString *> *_snapshotCounter;
|
||||
}
|
||||
|
||||
@synthesize bridge = _bridge;
|
||||
|
@ -41,7 +41,7 @@ RCT_EXPORT_METHOD(verifySnapshot:(RCTResponseSenderBlock)callback)
|
|||
{
|
||||
RCTAssert(_controller != nil, @"No snapshot controller configured.");
|
||||
|
||||
[_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
[_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
|
||||
NSString *testName = NSStringFromSelector(_testSelector);
|
||||
_snapshotCounter[testName] = (@([_snapshotCounter[testName] integerValue] + 1)).stringValue;
|
||||
|
@ -77,7 +77,7 @@ RCT_EXPORT_METHOD(markTestCompleted)
|
|||
|
||||
RCT_EXPORT_METHOD(markTestPassed:(BOOL)success)
|
||||
{
|
||||
[_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
[_bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, __unused NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
_status = success ? RCTTestStatusPassed : RCTTestStatusFailed;
|
||||
}];
|
||||
}
|
||||
|
|
|
@ -69,8 +69,9 @@
|
|||
* @param initialProps props that are passed into the component when rendered.
|
||||
* @param configurationBlock A block that takes the hosting root view and performs arbitrary manipulation after its creation.
|
||||
*/
|
||||
|
||||
- (void)runTest:(SEL)test module:(NSString *)moduleName initialProps:(NSDictionary *)initialProps configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock;
|
||||
- (void)runTest:(SEL)test module:(NSString *)moduleName
|
||||
initialProps:(NSDictionary<NSString *, id> *)initialProps
|
||||
configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock;
|
||||
|
||||
/**
|
||||
* Same as runTest:, but allows for passing initialProps for providing mock data
|
||||
|
@ -83,7 +84,10 @@
|
|||
* @param configurationBlock A block that takes the hosting root view and performs arbitrary manipulation after its creation.
|
||||
* @param expectErrorRegex A regex that must match the error thrown. If no error is thrown, the test fails.
|
||||
*/
|
||||
- (void)runTest:(SEL)test module:(NSString *)moduleName initialProps:(NSDictionary *)initialProps configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock expectErrorRegex:(NSString *)expectErrorRegex;
|
||||
- (void)runTest:(SEL)test module:(NSString *)moduleName
|
||||
initialProps:(NSDictionary<NSString *, id> *)initialProps
|
||||
configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock
|
||||
expectErrorRegex:(NSString *)expectErrorRegex;
|
||||
|
||||
/**
|
||||
* Same as runTest:, but allows for passing initialProps for providing mock data
|
||||
|
@ -97,6 +101,9 @@
|
|||
* @param configurationBlock A block that takes the hosting root view and performs arbitrary manipulation after its creation.
|
||||
* @param expectErrorBlock A block that takes the error message and returns NO to fail the test.
|
||||
*/
|
||||
- (void)runTest:(SEL)test module:(NSString *)moduleName initialProps:(NSDictionary *)initialProps configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock;
|
||||
- (void)runTest:(SEL)test module:(NSString *)moduleName
|
||||
initialProps:(NSDictionary<NSString *, id> *)initialProps
|
||||
configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock
|
||||
expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock;
|
||||
|
||||
@end
|
||||
|
|
|
@ -71,12 +71,17 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
[self runTest:test module:moduleName initialProps:nil configurationBlock:nil expectErrorBlock:nil];
|
||||
}
|
||||
|
||||
- (void)runTest:(SEL)test module:(NSString *)moduleName initialProps:(NSDictionary *)initialProps configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock
|
||||
- (void)runTest:(SEL)test module:(NSString *)moduleName
|
||||
initialProps:(NSDictionary<NSString *, id> *)initialProps
|
||||
configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock
|
||||
{
|
||||
[self runTest:test module:moduleName initialProps:initialProps configurationBlock:configurationBlock expectErrorBlock:nil];
|
||||
}
|
||||
|
||||
- (void)runTest:(SEL)test module:(NSString *)moduleName initialProps:(NSDictionary *)initialProps configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock expectErrorRegex:(NSString *)errorRegex
|
||||
- (void)runTest:(SEL)test module:(NSString *)moduleName
|
||||
initialProps:(NSDictionary<NSString *, id> *)initialProps
|
||||
configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock
|
||||
expectErrorRegex:(NSString *)errorRegex
|
||||
{
|
||||
BOOL(^expectErrorBlock)(NSString *error) = ^BOOL(NSString *error){
|
||||
return [error rangeOfString:errorRegex options:NSRegularExpressionSearch].location != NSNotFound;
|
||||
|
@ -85,7 +90,10 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
[self runTest:test module:moduleName initialProps:initialProps configurationBlock:configurationBlock expectErrorBlock:expectErrorBlock];
|
||||
}
|
||||
|
||||
- (void)runTest:(SEL)test module:(NSString *)moduleName initialProps:(NSDictionary *)initialProps configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock
|
||||
- (void)runTest:(SEL)test module:(NSString *)moduleName
|
||||
initialProps:(NSDictionary<NSString *, id> *)initialProps
|
||||
configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock
|
||||
expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock
|
||||
{
|
||||
__weak id weakJSContext;
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ RCT_EXPORT_MODULE()
|
|||
body:RCTJSONClean([_defaults dictionaryRepresentation])];
|
||||
}
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
return @{
|
||||
@"settings": RCTJSONClean([_defaults dictionaryRepresentation])
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#import "RCTImageComponent.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTShadowRawText.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTText.h"
|
||||
#import "RCTUtils.h"
|
||||
|
||||
|
@ -81,17 +80,17 @@ static css_dim_t RCTMeasure(void *context, float width)
|
|||
[self dirtyText];
|
||||
}
|
||||
|
||||
- (NSDictionary *)processUpdatedProperties:(NSMutableSet<RCTApplierBlock> *)applierBlocks
|
||||
parentProperties:(NSDictionary *)parentProperties
|
||||
- (NSDictionary<NSString *, id> *)processUpdatedProperties:(NSMutableSet<RCTApplierBlock> *)applierBlocks
|
||||
parentProperties:(NSDictionary<NSString *, id> *)parentProperties
|
||||
{
|
||||
parentProperties = [super processUpdatedProperties:applierBlocks
|
||||
parentProperties:parentProperties];
|
||||
|
||||
UIEdgeInsets padding = self.paddingAsInsets;
|
||||
CGFloat width = self.frame.size.width - (padding.left + padding.right);
|
||||
|
||||
|
||||
NSTextStorage *textStorage = [self buildTextStorageForWidth:width];
|
||||
[applierBlocks addObject:^(RCTSparseArray *viewRegistry) {
|
||||
[applierBlocks addObject:^(NSDictionary<NSNumber *, RCTText *> *viewRegistry) {
|
||||
RCTText *view = viewRegistry[self.reactTag];
|
||||
view.textStorage = textStorage;
|
||||
}];
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTShadowView.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTTextField.h"
|
||||
|
||||
@interface RCTTextFieldManager() <UITextFieldDelegate>
|
||||
|
@ -117,8 +116,8 @@ RCT_EXPORT_VIEW_PROPERTY(mostRecentEventCount, NSInteger)
|
|||
{
|
||||
NSNumber *reactTag = shadowView.reactTag;
|
||||
UIEdgeInsets padding = shadowView.paddingAsInsets;
|
||||
return ^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
((RCTTextField *)viewRegistry[reactTag]).contentInset = padding;
|
||||
return ^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTTextField *> *viewRegistry) {
|
||||
viewRegistry[reactTag].contentInset = padding;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#import "RCTLog.h"
|
||||
#import "RCTShadowRawText.h"
|
||||
#import "RCTShadowText.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTText.h"
|
||||
#import "RCTTextView.h"
|
||||
#import "UIView+React.h"
|
||||
|
@ -61,10 +60,10 @@ RCT_EXPORT_SHADOW_PROPERTY(writingDirection, NSWritingDirection)
|
|||
RCT_EXPORT_SHADOW_PROPERTY(allowFontScaling, BOOL)
|
||||
RCT_EXPORT_SHADOW_PROPERTY(opacity, CGFloat)
|
||||
|
||||
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(RCTSparseArray *)shadowViewRegistry
|
||||
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(NSDictionary<NSNumber *, RCTShadowView *> *)shadowViewRegistry
|
||||
{
|
||||
NSMutableSet *textViewTagsToUpdate = [NSMutableSet new];
|
||||
for (RCTShadowView *rootView in shadowViewRegistry.allObjects) {
|
||||
for (RCTShadowView *rootView in shadowViewRegistry.allValues) {
|
||||
if (![rootView isReactRootView]) {
|
||||
// This isn't a root view
|
||||
continue;
|
||||
|
@ -135,7 +134,7 @@ RCT_EXPORT_SHADOW_PROPERTY(opacity, CGFloat)
|
|||
CGFloat width = shadowText.frame.size.width - (padding.left + padding.right);
|
||||
NSTextStorage *textStorage = [shadowText buildTextStorageForWidth:width];
|
||||
|
||||
[uiBlocks addObject:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
[uiBlocks addObject:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTTextView *> *viewRegistry) {
|
||||
RCTTextView *textView = viewRegistry[reactTag];
|
||||
RCTText *text;
|
||||
for (RCTText *subview in textView.reactSubviews) {
|
||||
|
@ -150,7 +149,7 @@ RCT_EXPORT_SHADOW_PROPERTY(opacity, CGFloat)
|
|||
}];
|
||||
}
|
||||
|
||||
return ^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
return ^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
for (RCTViewManagerUIBlock uiBlock in uiBlocks) {
|
||||
uiBlock(uiManager, viewRegistry);
|
||||
}
|
||||
|
@ -165,7 +164,7 @@ RCT_EXPORT_SHADOW_PROPERTY(opacity, CGFloat)
|
|||
NSNumber *reactTag = shadowView.reactTag;
|
||||
UIEdgeInsets padding = shadowView.paddingAsInsets;
|
||||
|
||||
return ^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
return ^(RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTText *> *viewRegistry) {
|
||||
RCTText *text = viewRegistry[reactTag];
|
||||
text.contentInset = padding;
|
||||
};
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
NSInteger _nativeEventCount;
|
||||
RCTText *_richTextView;
|
||||
NSAttributedString *_pendingAttributedText;
|
||||
NSMutableArray<UIView<RCTComponent> *> *_subviews;
|
||||
NSMutableArray<UIView *> *_subviews;
|
||||
BOOL _blockTextShouldChange;
|
||||
UITextRange *_previousSelectionRange;
|
||||
}
|
||||
|
@ -71,12 +71,12 @@
|
|||
RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
||||
RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
|
||||
- (NSArray<UIView<RCTComponent> *> *)reactSubviews
|
||||
- (NSArray<UIView *> *)reactSubviews
|
||||
{
|
||||
return _subviews;
|
||||
}
|
||||
|
||||
- (void)insertReactSubview:(UIView<RCTComponent> *)subview atIndex:(NSInteger)index
|
||||
- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)index
|
||||
{
|
||||
if ([subview isKindOfClass:[RCTText class]]) {
|
||||
if (_richTextView) {
|
||||
|
@ -90,7 +90,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
|||
}
|
||||
}
|
||||
|
||||
- (void)removeReactSubview:(UIView<RCTComponent> *)subview
|
||||
- (void)removeReactSubview:(UIView *)subview
|
||||
{
|
||||
if (_richTextView == subview) {
|
||||
[_subviews removeObject:_richTextView];
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#import "RCTBridge.h"
|
||||
#import "RCTConvert.h"
|
||||
#import "RCTShadowView.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTTextView.h"
|
||||
|
||||
@implementation RCTTextViewManager
|
||||
|
@ -61,8 +60,8 @@ RCT_EXPORT_VIEW_PROPERTY(mostRecentEventCount, NSInteger)
|
|||
{
|
||||
NSNumber *reactTag = shadowView.reactTag;
|
||||
UIEdgeInsets padding = shadowView.paddingAsInsets;
|
||||
return ^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
((RCTTextView *)viewRegistry[reactTag]).contentInset = padding;
|
||||
return ^(RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTTextView *> *viewRegistry) {
|
||||
viewRegistry[reactTag].contentInset = padding;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -506,7 +506,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
|
||||
|
||||
if (_secure) {
|
||||
NSMutableDictionary *SSLOptions = [NSMutableDictionary new];
|
||||
NSMutableDictionary<NSString *, id> *SSLOptions = [NSMutableDictionary new];
|
||||
|
||||
[_outputStream setProperty:(__bridge id)kCFStreamSocketSecurityLevelNegotiatedSSL forKey:(__bridge id)kCFStreamPropertySocketSecurityLevel];
|
||||
|
||||
|
|
|
@ -15,11 +15,10 @@
|
|||
|
||||
#import "RCTConvert.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTUtils.h"
|
||||
#import "RCTSRWebSocket.h"
|
||||
|
||||
typedef void (^RCTWSMessageCallback)(NSError *error, NSDictionary *reply);
|
||||
typedef void (^RCTWSMessageCallback)(NSError *error, NSDictionary<NSString *, id> *reply);
|
||||
|
||||
@interface RCTWebSocketExecutor () <RCTSRWebSocketDelegate>
|
||||
|
||||
|
@ -29,9 +28,9 @@ typedef void (^RCTWSMessageCallback)(NSError *error, NSDictionary *reply);
|
|||
{
|
||||
RCTSRWebSocket *_socket;
|
||||
dispatch_queue_t _jsQueue;
|
||||
RCTSparseArray *_callbacks;
|
||||
NSMutableDictionary<NSNumber *, RCTWSMessageCallback> *_callbacks;
|
||||
dispatch_semaphore_t _socketOpenSemaphore;
|
||||
NSMutableDictionary *_injectedObjects;
|
||||
NSMutableDictionary<NSString *, NSString *> *_injectedObjects;
|
||||
NSURL *_url;
|
||||
}
|
||||
|
||||
|
@ -60,7 +59,7 @@ RCT_EXPORT_MODULE()
|
|||
_jsQueue = dispatch_queue_create("com.facebook.React.WebSocketExecutor", DISPATCH_QUEUE_SERIAL);
|
||||
_socket = [[RCTSRWebSocket alloc] initWithURL:_url];
|
||||
_socket.delegate = self;
|
||||
_callbacks = [RCTSparseArray new];
|
||||
_callbacks = [NSMutableDictionary new];
|
||||
_injectedObjects = [NSMutableDictionary new];
|
||||
[_socket setDelegateDispatchQueue:_jsQueue];
|
||||
|
||||
|
@ -101,7 +100,7 @@ RCT_EXPORT_MODULE()
|
|||
{
|
||||
__block NSError *initError;
|
||||
dispatch_semaphore_t s = dispatch_semaphore_create(0);
|
||||
[self sendMessage:@{@"method": @"prepareJSRuntime"} waitForReply:^(NSError *error, NSDictionary *reply) {
|
||||
[self sendMessage:@{@"method": @"prepareJSRuntime"} waitForReply:^(NSError *error, NSDictionary<NSString *, id> *reply) {
|
||||
initError = error;
|
||||
dispatch_semaphore_signal(s);
|
||||
}];
|
||||
|
@ -112,7 +111,7 @@ RCT_EXPORT_MODULE()
|
|||
- (void)webSocket:(RCTSRWebSocket *)webSocket didReceiveMessage:(id)message
|
||||
{
|
||||
NSError *error = nil;
|
||||
NSDictionary *reply = RCTJSONParse(message, &error);
|
||||
NSDictionary<NSString *, id> *reply = RCTJSONParse(message, &error);
|
||||
NSNumber *messageID = reply[@"replyID"];
|
||||
RCTWSMessageCallback callback = _callbacks[messageID];
|
||||
if (callback) {
|
||||
|
@ -130,7 +129,7 @@ RCT_EXPORT_MODULE()
|
|||
RCTLogError(@"WebSocket connection failed with error %@", error);
|
||||
}
|
||||
|
||||
- (void)sendMessage:(NSDictionary *)message waitForReply:(RCTWSMessageCallback)callback
|
||||
- (void)sendMessage:(NSDictionary<NSString *, id> *)message waitForReply:(RCTWSMessageCallback)callback
|
||||
{
|
||||
static NSUInteger lastID = 10000;
|
||||
|
||||
|
@ -145,7 +144,7 @@ RCT_EXPORT_MODULE()
|
|||
|
||||
NSNumber *expectedID = @(lastID++);
|
||||
_callbacks[expectedID] = [callback copy];
|
||||
NSMutableDictionary *messageWithID = [message mutableCopy];
|
||||
NSMutableDictionary<NSString *, id> *messageWithID = [message mutableCopy];
|
||||
messageWithID[@"id"] = expectedID;
|
||||
[_socket send:RCTJSONStringify(messageWithID, NULL)];
|
||||
});
|
||||
|
@ -153,12 +152,12 @@ RCT_EXPORT_MODULE()
|
|||
|
||||
- (void)executeApplicationScript:(NSData *)script sourceURL:(NSURL *)URL onComplete:(RCTJavaScriptCompleteBlock)onComplete
|
||||
{
|
||||
NSDictionary *message = @{
|
||||
NSDictionary<NSString *, id> *message = @{
|
||||
@"method": @"executeApplicationScript",
|
||||
@"url": RCTNullIfNil(URL.absoluteString),
|
||||
@"inject": _injectedObjects,
|
||||
};
|
||||
[self sendMessage:message waitForReply:^(NSError *error, NSDictionary *reply) {
|
||||
[self sendMessage:message waitForReply:^(NSError *error, NSDictionary<NSString *, id> *reply) {
|
||||
onComplete(error);
|
||||
}];
|
||||
}
|
||||
|
@ -166,13 +165,13 @@ RCT_EXPORT_MODULE()
|
|||
- (void)executeJSCall:(NSString *)name method:(NSString *)method arguments:(NSArray *)arguments callback:(RCTJavaScriptCallback)onComplete
|
||||
{
|
||||
RCTAssert(onComplete != nil, @"callback was missing for exec JS call");
|
||||
NSDictionary *message = @{
|
||||
NSDictionary<NSString *, id> *message = @{
|
||||
@"method": @"executeJSCall",
|
||||
@"moduleName": name,
|
||||
@"moduleMethod": method,
|
||||
@"arguments": arguments
|
||||
};
|
||||
[self sendMessage:message waitForReply:^(NSError *socketError, NSDictionary *reply) {
|
||||
[self sendMessage:message waitForReply:^(NSError *socketError, NSDictionary<NSString *, id> *reply) {
|
||||
if (socketError) {
|
||||
onComplete(nil, socketError);
|
||||
return;
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#import "RCTBridge.h"
|
||||
#import "RCTEventDispatcher.h"
|
||||
#import "RCTSRWebSocket.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTUtils.h"
|
||||
|
||||
@implementation RCTSRWebSocket (React)
|
||||
|
@ -35,7 +34,7 @@
|
|||
|
||||
@implementation RCTWebSocketModule
|
||||
{
|
||||
RCTSparseArray *_sockets;
|
||||
NSMutableDictionary<NSNumber *, RCTSRWebSocket *> *_sockets;
|
||||
}
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
@ -45,14 +44,14 @@ RCT_EXPORT_MODULE()
|
|||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_sockets = [RCTSparseArray new];
|
||||
_sockets = [NSMutableDictionary new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
for (RCTSRWebSocket *socket in _sockets.allObjects) {
|
||||
for (RCTSRWebSocket *socket in _sockets.allValues) {
|
||||
socket.delegate = nil;
|
||||
[socket close];
|
||||
}
|
||||
|
@ -75,7 +74,7 @@ RCT_EXPORT_METHOD(send:(NSString *)message socketID:(nonnull NSNumber *)socketID
|
|||
RCT_EXPORT_METHOD(close:(nonnull NSNumber *)socketID)
|
||||
{
|
||||
[_sockets[socketID] close];
|
||||
_sockets[socketID] = nil;
|
||||
[_sockets removeObjectForKey:socketID];
|
||||
}
|
||||
|
||||
#pragma mark - RCTSRWebSocketDelegate methods
|
||||
|
|
|
@ -115,7 +115,7 @@ RCT_EXTERN NSString *RCTCurrentThreadName(void);
|
|||
/**
|
||||
* Helper to get generate exception message from NSError
|
||||
*/
|
||||
RCT_EXTERN NSString *RCTFormatError(NSString *message, NSArray *stacktrace, NSUInteger maxMessageLength);
|
||||
RCT_EXTERN NSString *RCTFormatError(NSString *message, NSArray<NSDictionary<NSString *, id> *> *stacktrace, NSUInteger maxMessageLength);
|
||||
|
||||
/**
|
||||
* Convenience macro to assert which thread is currently running (DEBUG mode only)
|
||||
|
|
|
@ -146,7 +146,7 @@ RCTFatalHandler RCTGetFatalHandler(void)
|
|||
return RCTCurrentFatalHandler;
|
||||
}
|
||||
|
||||
NSString *RCTFormatError(NSString *message, NSArray *stackTrace, NSUInteger maxMessageLength)
|
||||
NSString *RCTFormatError(NSString *message, NSArray<NSDictionary<NSString *, id> *> *stackTrace, NSUInteger maxMessageLength)
|
||||
{
|
||||
if (maxMessageLength > 0 && message.length > maxMessageLength) {
|
||||
message = [[message substringToIndex:maxMessageLength] stringByAppendingString:@"..."];
|
||||
|
@ -155,7 +155,7 @@ NSString *RCTFormatError(NSString *message, NSArray *stackTrace, NSUInteger maxM
|
|||
NSMutableString *prettyStack = [NSMutableString string];
|
||||
if (stackTrace) {
|
||||
[prettyStack appendString:@", stack:\n"];
|
||||
for (NSDictionary *frame in stackTrace) {
|
||||
for (NSDictionary<NSString *, id> *frame in stackTrace) {
|
||||
[prettyStack appendFormat:@"%@@%@:%@\n", frame[@"methodName"], frame[@"lineNumber"], frame[@"column"]];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#import "RCTPerformanceLogger.h"
|
||||
#import "RCTProfile.h"
|
||||
#import "RCTSourceCode.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTUtils.h"
|
||||
|
||||
#define RCTAssertJSThread() \
|
||||
|
@ -730,7 +729,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
|||
|
||||
dispatch_block_t block = ^{
|
||||
RCTProfileEndFlowEvent();
|
||||
|
||||
|
||||
#if RCT_DEV
|
||||
NSString *_threadName = RCTCurrentThreadName();
|
||||
RCT_PROFILE_BEGIN_EVENT(0, _threadName, nil);
|
||||
|
|
|
@ -228,7 +228,7 @@ RCT_EXTERN void RCTRegisterModule(Class); \
|
|||
* for long-lived values such as session keys, that are regenerated only as
|
||||
* part of a reload of the entire React application.
|
||||
*/
|
||||
- (NSDictionary *)constantsToExport;
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport;
|
||||
|
||||
/**
|
||||
* Notifies the module that a batch of JS method invocations has just completed.
|
||||
|
|
|
@ -53,7 +53,7 @@ void RCTSetLogThreshold(RCTLogLevel threshold) {
|
|||
|
||||
RCTLogFunction RCTDefaultLogFunction = ^(
|
||||
RCTLogLevel level,
|
||||
RCTLogSource source,
|
||||
__unused RCTLogSource source,
|
||||
NSString *fileName,
|
||||
NSNumber *lineNumber,
|
||||
NSString *message
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface RCTSparseArray : NSObject <NSCopying>
|
||||
|
||||
- (instancetype)initWithCapacity:(NSUInteger)capacity NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithSparseArray:(RCTSparseArray *)sparseArray NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
+ (instancetype)sparseArray;
|
||||
+ (instancetype)sparseArrayWithCapacity:(NSUInteger)capacity;
|
||||
+ (instancetype)sparseArrayWithSparseArray:(RCTSparseArray *)sparseArray;
|
||||
|
||||
// Use nil object to remove at idx.
|
||||
- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx;
|
||||
- (id)objectAtIndexedSubscript:(NSUInteger)idx;
|
||||
|
||||
// Use nil obj to remove at key.
|
||||
- (void)setObject:(id)obj forKeyedSubscript:(NSNumber *)key;
|
||||
- (id)objectForKeyedSubscript:(NSNumber *)key;
|
||||
|
||||
@property (readonly, nonatomic) NSUInteger count;
|
||||
@property (readonly, nonatomic, copy) NSArray<NSNumber *> *allIndexes;
|
||||
@property (readonly, nonatomic, copy) NSArray *allObjects;
|
||||
|
||||
- (void)enumerateObjectsUsingBlock:(void (^)(id obj, NSNumber *idx, BOOL *stop))block;
|
||||
- (void)enumerateObjectsWithOptions:(NSEnumerationOptions)opts usingBlock:(void (^)(id obj, NSNumber *idx, BOOL *stop))block;
|
||||
|
||||
- (void)removeAllObjects;
|
||||
|
||||
@end
|
|
@ -1,123 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import "RCTSparseArray.h"
|
||||
|
||||
@implementation RCTSparseArray
|
||||
{
|
||||
NSMutableDictionary *_storage;
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
return [self initWithCapacity:0];
|
||||
}
|
||||
|
||||
- (instancetype)initWithCapacity:(NSUInteger)capacity
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_storage = [NSMutableDictionary dictionaryWithCapacity:capacity];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithSparseArray:(RCTSparseArray *)sparseArray
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_storage = [sparseArray->_storage copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)sparseArray
|
||||
{
|
||||
return [self new];
|
||||
}
|
||||
|
||||
+ (instancetype)sparseArrayWithCapacity:(NSUInteger)capacity
|
||||
{
|
||||
return [[self alloc] initWithCapacity:capacity];
|
||||
}
|
||||
|
||||
+ (instancetype)sparseArrayWithSparseArray:(RCTSparseArray *)sparseArray
|
||||
{
|
||||
return [[self alloc] initWithSparseArray:sparseArray];
|
||||
}
|
||||
|
||||
- (id)objectAtIndexedSubscript:(NSUInteger)idx
|
||||
{
|
||||
return _storage[@(idx)];
|
||||
}
|
||||
|
||||
- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx
|
||||
{
|
||||
self[@(idx)] = obj;
|
||||
}
|
||||
|
||||
- (id)objectForKeyedSubscript:(NSNumber *)key
|
||||
{
|
||||
return _storage[key];
|
||||
}
|
||||
|
||||
- (void)setObject:(id)obj forKeyedSubscript:(NSNumber *)key
|
||||
{
|
||||
if (obj) {
|
||||
_storage[key] = obj;
|
||||
} else {
|
||||
[_storage removeObjectForKey:key];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSUInteger)count
|
||||
{
|
||||
return _storage.count;
|
||||
}
|
||||
|
||||
- (NSArray<NSNumber *> *)allIndexes
|
||||
{
|
||||
return _storage.allKeys;
|
||||
}
|
||||
|
||||
- (NSArray *)allObjects
|
||||
{
|
||||
return _storage.allValues;
|
||||
}
|
||||
|
||||
- (void)enumerateObjectsUsingBlock:(void (^)(id obj, NSNumber *idx, BOOL *stop))block
|
||||
{
|
||||
NSParameterAssert(block != nil);
|
||||
[_storage enumerateKeysAndObjectsUsingBlock:^(NSNumber *key, id obj, BOOL *stop) {
|
||||
block(obj, key, stop);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)enumerateObjectsWithOptions:(NSEnumerationOptions)opts usingBlock:(void (^)(id obj, NSNumber *idx, BOOL *stop))block
|
||||
{
|
||||
NSParameterAssert(block != nil);
|
||||
[_storage enumerateKeysAndObjectsWithOptions:opts usingBlock:^(NSNumber *key, id obj, BOOL *stop) {
|
||||
block(obj, key, stop);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)removeAllObjects
|
||||
{
|
||||
[_storage removeAllObjects];
|
||||
}
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone
|
||||
{
|
||||
return [[[self class] allocWithZone:zone] initWithSparseArray:self];
|
||||
}
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
return [super.description stringByAppendingString:_storage.description];
|
||||
}
|
||||
|
||||
@end
|
|
@ -45,9 +45,9 @@ RCT_EXTERN BOOL RCTClassOverridesClassMethod(Class cls, SEL selector);
|
|||
RCT_EXTERN BOOL RCTClassOverridesInstanceMethod(Class cls, SEL selector);
|
||||
|
||||
// Creates a standardized error object
|
||||
RCT_EXTERN NSDictionary *RCTMakeError(NSString *message, id toStringify, NSDictionary *extraData);
|
||||
RCT_EXTERN NSDictionary *RCTMakeAndLogError(NSString *message, id toStringify, NSDictionary *extraData);
|
||||
RCT_EXTERN NSDictionary *RCTJSErrorFromNSError(NSError *error);
|
||||
RCT_EXTERN NSDictionary<NSString *, id> *RCTMakeError(NSString *message, id toStringify, NSDictionary<NSString *, id> *extraData);
|
||||
RCT_EXTERN NSDictionary<NSString *, id> *RCTMakeAndLogError(NSString *message, id toStringify, NSDictionary<NSString *, id> *extraData);
|
||||
RCT_EXTERN NSDictionary<NSString *, id> *RCTJSErrorFromNSError(NSError *error);
|
||||
|
||||
// Returns YES if React is running in a test environment
|
||||
RCT_EXTERN BOOL RCTRunningInTestEnvironment(void);
|
||||
|
|
|
@ -137,7 +137,7 @@ id RCTJSONClean(id object)
|
|||
|
||||
if ([object isKindOfClass:[NSDictionary class]]) {
|
||||
__block BOOL copy = NO;
|
||||
NSMutableDictionary *values = [[NSMutableDictionary alloc] initWithCapacity:[object count]];
|
||||
NSMutableDictionary<NSString *, id> *values = [[NSMutableDictionary alloc] initWithCapacity:[object count]];
|
||||
[object enumerateKeysAndObjectsUsingBlock:^(NSString *key, id item, __unused BOOL *stop) {
|
||||
id value = RCTJSONClean(item);
|
||||
values[key] = value;
|
||||
|
@ -288,30 +288,30 @@ BOOL RCTClassOverridesInstanceMethod(Class cls, SEL selector)
|
|||
return NO;
|
||||
}
|
||||
|
||||
NSDictionary *RCTMakeError(NSString *message, id toStringify, NSDictionary *extraData)
|
||||
NSDictionary<NSString *, id> *RCTMakeError(NSString *message, id toStringify, NSDictionary<NSString *, id> *extraData)
|
||||
{
|
||||
if (toStringify) {
|
||||
message = [message stringByAppendingString:[toStringify description]];
|
||||
}
|
||||
|
||||
NSMutableDictionary *error = [NSMutableDictionary dictionaryWithDictionary:extraData];
|
||||
NSMutableDictionary<NSString *, id> *error = [NSMutableDictionary dictionaryWithDictionary:extraData];
|
||||
error[@"message"] = message;
|
||||
return error;
|
||||
}
|
||||
|
||||
NSDictionary *RCTMakeAndLogError(NSString *message, id toStringify, NSDictionary *extraData)
|
||||
NSDictionary<NSString *, id> *RCTMakeAndLogError(NSString *message, id toStringify, NSDictionary<NSString *, id> *extraData)
|
||||
{
|
||||
NSDictionary *error = RCTMakeError(message, toStringify, extraData);
|
||||
NSDictionary<NSString *, id> *error = RCTMakeError(message, toStringify, extraData);
|
||||
RCTLogError(@"\nError: %@", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
// TODO: Can we just replace RCTMakeError with this function instead?
|
||||
NSDictionary *RCTJSErrorFromNSError(NSError *error)
|
||||
NSDictionary<NSString *, id> *RCTJSErrorFromNSError(NSError *error)
|
||||
{
|
||||
NSString *errorMessage;
|
||||
NSArray<NSString *> *stackTrace = [NSThread callStackSymbols];
|
||||
NSMutableDictionary *errorInfo =
|
||||
NSMutableDictionary<NSString *, id> *errorInfo =
|
||||
[NSMutableDictionary dictionaryWithObject:stackTrace forKey:@"nativeStackIOS"];
|
||||
|
||||
if (error) {
|
||||
|
@ -399,7 +399,7 @@ BOOL RCTImageHasAlpha(CGImageRef image)
|
|||
|
||||
NSError *RCTErrorWithMessage(NSString *message)
|
||||
{
|
||||
NSDictionary *errorInfo = @{NSLocalizedDescriptionKey: message};
|
||||
NSDictionary<NSString *, id> *errorInfo = @{NSLocalizedDescriptionKey: message};
|
||||
return [[NSError alloc] initWithDomain:RCTErrorDomain code:0 userInfo:errorInfo];
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ extern NSString *const RCTAccessibilityManagerDidUpdateMultiplierNotification; /
|
|||
@property (nonatomic, readonly) CGFloat multiplier;
|
||||
|
||||
/// map from UIKit categories to multipliers
|
||||
@property (nonatomic, copy) NSDictionary *multipliers;
|
||||
@property (nonatomic, copy) NSDictionary<NSString *, NSNumber *> *multipliers;
|
||||
|
||||
@property (nonatomic, assign) BOOL isVoiceOverEnabled;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#import "RCTAccessibilityManager.h"
|
||||
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTConvert.h"
|
||||
#import "RCTEventDispatcher.h"
|
||||
#import "RCTLog.h"
|
||||
|
||||
|
@ -29,7 +30,7 @@ NSString *const RCTAccessibilityManagerDidUpdateMultiplierNotification = @"RCTAc
|
|||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
+ (NSDictionary *)JSToUIKitMap
|
||||
+ (NSDictionary<NSString *, NSString *> *)JSToUIKitMap
|
||||
{
|
||||
static NSDictionary *map = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
|
@ -52,13 +53,12 @@ RCT_EXPORT_MODULE()
|
|||
|
||||
+ (NSString *)UIKitCategoryFromJSCategory:(NSString *)JSCategory
|
||||
{
|
||||
return self.JSToUIKitMap[JSCategory];
|
||||
return [self JSToUIKitMap][JSCategory];
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
if ((self = [super init])) {
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(didReceiveNewContentSizeCategory:)
|
||||
name:UIContentSizeCategoryDidChangeNotification
|
||||
|
@ -119,7 +119,7 @@ RCT_EXPORT_MODULE()
|
|||
return m.doubleValue;
|
||||
}
|
||||
|
||||
- (void)setMultipliers:(NSDictionary *)multipliers
|
||||
- (void)setMultipliers:(NSDictionary<NSString *, NSNumber *> *)multipliers
|
||||
{
|
||||
if (_multipliers != multipliers) {
|
||||
_multipliers = [multipliers copy];
|
||||
|
@ -127,7 +127,7 @@ RCT_EXPORT_MODULE()
|
|||
}
|
||||
}
|
||||
|
||||
- (NSDictionary *)multipliers
|
||||
- (NSDictionary<NSString *, NSNumber *> *)multipliers
|
||||
{
|
||||
if (_multipliers == nil) {
|
||||
_multipliers = @{UIContentSizeCategoryExtraSmall: @0.823,
|
||||
|
@ -148,10 +148,10 @@ RCT_EXPORT_MODULE()
|
|||
|
||||
RCT_EXPORT_METHOD(setAccessibilityContentSizeMultipliers:(NSDictionary *)JSMultipliers)
|
||||
{
|
||||
NSMutableDictionary *multipliers = [NSMutableDictionary new];
|
||||
NSMutableDictionary<NSString *, NSNumber *> *multipliers = [NSMutableDictionary new];
|
||||
for (NSString *__nonnull JSCategory in JSMultipliers) {
|
||||
NSNumber *m = JSMultipliers[JSCategory];
|
||||
NSString *UIKitCategory = [self.class UIKitCategoryFromJSCategory:JSCategory];
|
||||
NSNumber *m = [RCTConvert NSNumber:JSMultipliers[JSCategory]];
|
||||
NSString *UIKitCategory = [[self class] UIKitCategoryFromJSCategory:JSCategory];
|
||||
multipliers[UIKitCategory] = m;
|
||||
}
|
||||
self.multipliers = multipliers;
|
||||
|
|
|
@ -36,7 +36,7 @@ RCT_EXPORT_METHOD(getScriptText:(RCTResponseSenderBlock)successCallback
|
|||
}
|
||||
}
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
NSString *URL = self.bridge.bundleURL.absoluteString ?: @"";
|
||||
return @{@"scriptURL": URL};
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#import "RCTAssert.h"
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTUtils.h"
|
||||
|
||||
@interface RCTBridge (Private)
|
||||
|
@ -66,7 +65,7 @@
|
|||
|
||||
@implementation RCTTiming
|
||||
{
|
||||
RCTSparseArray *_timers;
|
||||
NSMutableDictionary<NSNumber *, RCTTimer *> *_timers;
|
||||
}
|
||||
|
||||
@synthesize bridge = _bridge;
|
||||
|
@ -79,7 +78,7 @@ RCT_EXPORT_MODULE()
|
|||
{
|
||||
if ((self = [super init])) {
|
||||
_paused = YES;
|
||||
_timers = [RCTSparseArray new];
|
||||
_timers = [NSMutableDictionary new];
|
||||
|
||||
for (NSString *name in @[UIApplicationWillResignActiveNotification,
|
||||
UIApplicationDidEnterBackgroundNotification,
|
||||
|
@ -146,12 +145,12 @@ RCT_EXPORT_MODULE()
|
|||
- (void)didUpdateFrame:(__unused RCTFrameUpdate *)update
|
||||
{
|
||||
NSMutableArray<NSNumber *> *timersToCall = [NSMutableArray new];
|
||||
for (RCTTimer *timer in _timers.allObjects) {
|
||||
for (RCTTimer *timer in _timers.allValues) {
|
||||
if ([timer updateFoundNeedsJSUpdate]) {
|
||||
[timersToCall addObject:timer.callbackID];
|
||||
}
|
||||
if (!timer.target) {
|
||||
_timers[timer.callbackID] = nil;
|
||||
[_timers removeObjectForKey:timer.callbackID];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,7 +207,7 @@ RCT_EXPORT_METHOD(createTimer:(nonnull NSNumber *)callbackID
|
|||
|
||||
RCT_EXPORT_METHOD(deleteTimer:(nonnull NSNumber *)timerID)
|
||||
{
|
||||
_timers[timerID] = nil;
|
||||
[_timers removeObjectForKey:timerID];
|
||||
if (_timers.count == 0) {
|
||||
[self stopTimers];
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#import "RCTRootViewInternal.h"
|
||||
#import "RCTScrollableProtocol.h"
|
||||
#import "RCTShadowView.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTUtils.h"
|
||||
#import "RCTView.h"
|
||||
#import "RCTViewManager.h"
|
||||
|
@ -183,9 +182,8 @@ static UIViewAnimationOptions UIViewAnimationOptionsFromRCTAnimationType(RCTAnim
|
|||
@interface RCTUIManager ()
|
||||
|
||||
// NOTE: these are properties so that they can be accessed by unit tests
|
||||
@property (nonatomic, strong) RCTSparseArray *viewManagerRegistry; // RCT thread only
|
||||
@property (nonatomic, strong) RCTSparseArray *shadowViewRegistry; // RCT thread only
|
||||
@property (nonatomic, strong) RCTSparseArray *viewRegistry; // Main thread only
|
||||
@property (nonatomic, strong) NSMutableDictionary<NSNumber *, RCTShadowView *> *shadowViewRegistry; // RCT thread only
|
||||
@property (nonatomic, strong) NSMutableDictionary<NSNumber *, UIView *> *viewRegistry; // Main thread only
|
||||
|
||||
@end
|
||||
|
||||
|
@ -229,8 +227,8 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
|||
dispatch_set_target_queue(_shadowQueue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0));
|
||||
}
|
||||
|
||||
_shadowViewRegistry = [RCTSparseArray new];
|
||||
_viewRegistry = [RCTSparseArray new];
|
||||
_shadowViewRegistry = [NSMutableDictionary new];
|
||||
_viewRegistry = [NSMutableDictionary new];
|
||||
|
||||
// Internal resources
|
||||
_pendingUIBlocks = [NSMutableArray new];
|
||||
|
@ -265,7 +263,7 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
|||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
for (NSNumber *rootViewTag in _rootViewTags) {
|
||||
[_viewRegistry[rootViewTag] invalidate];
|
||||
[(id<RCTInvalidating>)_viewRegistry[rootViewTag] invalidate];
|
||||
}
|
||||
|
||||
_rootViewTags = nil;
|
||||
|
@ -283,7 +281,7 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
|||
RCTAssert(_bridge == nil, @"Should not re-use same UIIManager instance");
|
||||
|
||||
_bridge = bridge;
|
||||
_shadowViewRegistry = [RCTSparseArray new];
|
||||
_shadowViewRegistry = [NSMutableDictionary new];
|
||||
|
||||
// Get view managers from bridge
|
||||
NSMutableDictionary *componentDataByName = [NSMutableDictionary new];
|
||||
|
@ -407,7 +405,7 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
|||
* Unregisters views from registries
|
||||
*/
|
||||
- (void)_purgeChildren:(NSArray<id<RCTComponent>> *)children
|
||||
fromRegistry:(RCTSparseArray *)registry
|
||||
fromRegistry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)registry
|
||||
{
|
||||
for (id<RCTComponent> child in children) {
|
||||
RCTTraverseViewNodes(registry[child.reactTag], ^(id<RCTComponent> subview) {
|
||||
|
@ -415,9 +413,9 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
|||
if ([subview conformsToProtocol:@protocol(RCTInvalidating)]) {
|
||||
[(id<RCTInvalidating>)subview invalidate];
|
||||
}
|
||||
registry[subview.reactTag] = nil;
|
||||
[registry removeObjectForKey:subview.reactTag];
|
||||
|
||||
if (registry == _viewRegistry) {
|
||||
if (registry == (NSMutableDictionary<NSNumber *, id<RCTComponent>> *)_viewRegistry) {
|
||||
[_bridgeTransactionListeners removeObject:subview];
|
||||
}
|
||||
});
|
||||
|
@ -528,7 +526,7 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
|||
return nil;
|
||||
}
|
||||
// Perform layout (possibly animated)
|
||||
return ^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
return ^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
RCTResponseSenderBlock callback = self->_layoutAnimation.callback;
|
||||
|
||||
// It's unsafe to call this callback more than once, so we nil it out here
|
||||
|
@ -602,7 +600,7 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
|||
[topView collectUpdatedProperties:applierBlocks parentProperties:@{}];
|
||||
|
||||
if (applierBlocks.count) {
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
for (RCTApplierBlock block in applierBlocks) {
|
||||
block(viewRegistry);
|
||||
}
|
||||
|
@ -676,15 +674,17 @@ RCT_EXPORT_METHOD(removeRootView:(nonnull NSNumber *)rootReactTag)
|
|||
{
|
||||
RCTShadowView *rootShadowView = _shadowViewRegistry[rootReactTag];
|
||||
RCTAssert(rootShadowView.superview == nil, @"root view cannot have superview (ID %@)", rootReactTag);
|
||||
[self _purgeChildren:(NSArray<id<RCTComponent>> *)rootShadowView.reactSubviews fromRegistry:_shadowViewRegistry];
|
||||
_shadowViewRegistry[rootReactTag] = nil;
|
||||
[self _purgeChildren:(NSArray<id<RCTComponent>> *)rootShadowView.reactSubviews
|
||||
fromRegistry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)_shadowViewRegistry];
|
||||
[_shadowViewRegistry removeObjectForKey:rootReactTag];
|
||||
[_rootViewTags removeObject:rootReactTag];
|
||||
|
||||
[self addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry){
|
||||
[self addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry){
|
||||
RCTAssertMainThread();
|
||||
UIView *rootView = viewRegistry[rootReactTag];
|
||||
[uiManager _purgeChildren:(NSArray<id<RCTComponent>> *)rootView.reactSubviews fromRegistry:viewRegistry];
|
||||
viewRegistry[rootReactTag] = nil;
|
||||
[uiManager _purgeChildren:(NSArray<id<RCTComponent>> *)rootView.reactSubviews
|
||||
fromRegistry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)viewRegistry];
|
||||
[(NSMutableDictionary<NSNumber *, UIView *> *)viewRegistry removeObjectForKey:rootReactTag];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTUIManagerDidRemoveRootViewNotification
|
||||
object:uiManager
|
||||
|
@ -726,16 +726,16 @@ RCT_EXPORT_METHOD(manageChildren:(nonnull NSNumber *)containerReactTag
|
|||
addChildReactTags:addChildReactTags
|
||||
addAtIndices:addAtIndices
|
||||
removeAtIndices:removeAtIndices
|
||||
registry:_shadowViewRegistry];
|
||||
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)_shadowViewRegistry];
|
||||
|
||||
[self addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry){
|
||||
[self addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry){
|
||||
[uiManager _manageChildren:containerReactTag
|
||||
moveFromIndices:moveFromIndices
|
||||
moveToIndices:moveToIndices
|
||||
addChildReactTags:addChildReactTags
|
||||
addAtIndices:addAtIndices
|
||||
removeAtIndices:removeAtIndices
|
||||
registry:viewRegistry];
|
||||
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)viewRegistry];
|
||||
}];
|
||||
}
|
||||
|
||||
|
@ -745,7 +745,7 @@ RCT_EXPORT_METHOD(manageChildren:(nonnull NSNumber *)containerReactTag
|
|||
addChildReactTags:(NSArray<NSNumber *> *)addChildReactTags
|
||||
addAtIndices:(NSArray<NSNumber *> *)addAtIndices
|
||||
removeAtIndices:(NSArray<NSNumber *> *)removeAtIndices
|
||||
registry:(RCTSparseArray *)registry
|
||||
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)registry
|
||||
{
|
||||
id<RCTComponent> container = registry[containerReactTag];
|
||||
RCTAssert(moveFromIndices.count == moveToIndices.count, @"moveFromIndices had size %tu, moveToIndices had size %tu", moveFromIndices.count, moveToIndices.count);
|
||||
|
@ -803,8 +803,8 @@ RCT_EXPORT_METHOD(createView:(nonnull NSNumber *)reactTag
|
|||
// the view, but it's the only way that makes sense given our threading model
|
||||
UIColor *backgroundColor = shadowView.backgroundColor;
|
||||
|
||||
[self addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry){
|
||||
id<RCTComponent> view = [componentData createViewWithTag:reactTag props:props];
|
||||
[self addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry){
|
||||
UIView *view = [componentData createViewWithTag:reactTag props:props];
|
||||
if ([view respondsToSelector:@selector(setBackgroundColor:)]) {
|
||||
((UIView *)view).backgroundColor = backgroundColor;
|
||||
}
|
||||
|
@ -812,7 +812,7 @@ RCT_EXPORT_METHOD(createView:(nonnull NSNumber *)reactTag
|
|||
if ([view respondsToSelector:@selector(reactBridgeDidFinishTransaction)]) {
|
||||
[uiManager->_bridgeTransactionListeners addObject:view];
|
||||
}
|
||||
viewRegistry[reactTag] = view;
|
||||
((NSMutableDictionary<NSNumber *, UIView *> *)viewRegistry)[reactTag] = view;
|
||||
}];
|
||||
}
|
||||
|
||||
|
@ -824,7 +824,7 @@ RCT_EXPORT_METHOD(updateView:(nonnull NSNumber *)reactTag
|
|||
RCTComponentData *componentData = _componentDataByName[shadowView.viewName ?: viewName];
|
||||
[componentData setProps:props forShadowView:shadowView];
|
||||
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
UIView *view = viewRegistry[reactTag];
|
||||
[componentData setProps:props forView:view];
|
||||
}];
|
||||
|
@ -832,7 +832,7 @@ RCT_EXPORT_METHOD(updateView:(nonnull NSNumber *)reactTag
|
|||
|
||||
RCT_EXPORT_METHOD(focus:(nonnull NSNumber *)reactTag)
|
||||
{
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
UIView *newResponder = viewRegistry[reactTag];
|
||||
[newResponder reactWillMakeFirstResponder];
|
||||
[newResponder becomeFirstResponder];
|
||||
|
@ -842,7 +842,7 @@ RCT_EXPORT_METHOD(focus:(nonnull NSNumber *)reactTag)
|
|||
|
||||
RCT_EXPORT_METHOD(blur:(nonnull NSNumber *)reactTag)
|
||||
{
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry){
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry){
|
||||
UIView *currentResponder = viewRegistry[reactTag];
|
||||
[currentResponder resignFirstResponder];
|
||||
}];
|
||||
|
@ -850,7 +850,7 @@ RCT_EXPORT_METHOD(blur:(nonnull NSNumber *)reactTag)
|
|||
|
||||
RCT_EXPORT_METHOD(findSubviewIn:(nonnull NSNumber *)reactTag atPoint:(CGPoint)point callback:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
UIView *view = viewRegistry[reactTag];
|
||||
UIView *target = [view hitTest:point withEvent:nil];
|
||||
CGRect frame = [target convertRect:target.bounds toView:view];
|
||||
|
@ -881,7 +881,7 @@ RCT_EXPORT_METHOD(findSubviewIn:(nonnull NSNumber *)reactTag atPoint:(CGPoint)po
|
|||
// Set up next layout animation
|
||||
if (_nextLayoutAnimation) {
|
||||
RCTLayoutAnimation *layoutAnimation = _nextLayoutAnimation;
|
||||
[self addUIBlock:^(RCTUIManager *uiManager, __unused RCTSparseArray *viewRegistry) {
|
||||
[self addUIBlock:^(RCTUIManager *uiManager, __unused NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
uiManager->_layoutAnimation = layoutAnimation;
|
||||
}];
|
||||
}
|
||||
|
@ -895,7 +895,7 @@ RCT_EXPORT_METHOD(findSubviewIn:(nonnull NSNumber *)reactTag atPoint:(CGPoint)po
|
|||
|
||||
// Clear layout animations
|
||||
if (_nextLayoutAnimation) {
|
||||
[self addUIBlock:^(RCTUIManager *uiManager, __unused RCTSparseArray *viewRegistry) {
|
||||
[self addUIBlock:^(RCTUIManager *uiManager, __unused NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
uiManager->_layoutAnimation = nil;
|
||||
}];
|
||||
_nextLayoutAnimation = nil;
|
||||
|
@ -944,7 +944,7 @@ RCT_EXPORT_METHOD(findSubviewIn:(nonnull NSNumber *)reactTag atPoint:(CGPoint)po
|
|||
RCT_EXPORT_METHOD(measure:(nonnull NSNumber *)reactTag
|
||||
callback:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
UIView *view = viewRegistry[reactTag];
|
||||
if (!view) {
|
||||
// this view was probably collapsed out
|
||||
|
@ -1091,7 +1091,7 @@ RCT_EXPORT_METHOD(measureViewsInRect:(CGRect)rect
|
|||
|
||||
RCT_EXPORT_METHOD(setMainScrollViewTag:(nonnull NSNumber *)reactTag)
|
||||
{
|
||||
[self addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
[self addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
// - There should be at most one designated "main scroll view"
|
||||
// - There should be at most one designated "`nativeMainScrollDelegate`"
|
||||
// - The one designated main scroll view should have the one designated
|
||||
|
@ -1118,7 +1118,7 @@ RCT_EXPORT_METHOD(scrollTo:(nonnull NSNumber *)reactTag
|
|||
withOffsetX:(CGFloat)offsetX
|
||||
offsetY:(CGFloat)offsetY)
|
||||
{
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry){
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry){
|
||||
UIView *view = viewRegistry[reactTag];
|
||||
if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) {
|
||||
[(id<RCTScrollableProtocol>)view scrollToOffset:(CGPoint){offsetX, offsetY} animated:YES];
|
||||
|
@ -1133,7 +1133,7 @@ RCT_EXPORT_METHOD(scrollWithoutAnimationTo:(nonnull NSNumber *)reactTag
|
|||
offsetX:(CGFloat)offsetX
|
||||
offsetY:(CGFloat)offsetY)
|
||||
{
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry){
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry){
|
||||
UIView *view = viewRegistry[reactTag];
|
||||
if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) {
|
||||
[(id<RCTScrollableProtocol>)view scrollToOffset:(CGPoint){offsetX, offsetY} animated:NO];
|
||||
|
@ -1146,7 +1146,7 @@ RCT_EXPORT_METHOD(scrollWithoutAnimationTo:(nonnull NSNumber *)reactTag
|
|||
RCT_EXPORT_METHOD(zoomToRect:(nonnull NSNumber *)reactTag
|
||||
withRect:(CGRect)rect)
|
||||
{
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry){
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry){
|
||||
UIView *view = viewRegistry[reactTag];
|
||||
if ([view conformsToProtocol:@protocol(RCTScrollableProtocol)]) {
|
||||
[(id<RCTScrollableProtocol>)view zoomToRect:rect animated:YES];
|
||||
|
@ -1163,7 +1163,7 @@ RCT_EXPORT_METHOD(zoomToRect:(nonnull NSNumber *)reactTag
|
|||
RCT_EXPORT_METHOD(setJSResponder:(nonnull NSNumber *)reactTag
|
||||
blockNativeResponder:(__unused BOOL)blockNativeResponder)
|
||||
{
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
_jsResponder = viewRegistry[reactTag];
|
||||
if (!_jsResponder) {
|
||||
RCTLogError(@"Invalid view set to be the JS responder - tag %zd", reactTag);
|
||||
|
@ -1173,27 +1173,27 @@ RCT_EXPORT_METHOD(setJSResponder:(nonnull NSNumber *)reactTag
|
|||
|
||||
RCT_EXPORT_METHOD(clearJSResponder)
|
||||
{
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, __unused RCTSparseArray *viewRegistry) {
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, __unused NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
_jsResponder = nil;
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
NSMutableDictionary *allJSConstants = [NSMutableDictionary new];
|
||||
NSMutableDictionary *directEvents = [NSMutableDictionary new];
|
||||
NSMutableDictionary *bubblingEvents = [NSMutableDictionary new];
|
||||
NSMutableDictionary<NSString *, NSDictionary *> *allJSConstants = [NSMutableDictionary new];
|
||||
NSMutableDictionary<NSString *, NSDictionary *> *directEvents = [NSMutableDictionary new];
|
||||
NSMutableDictionary<NSString *, NSDictionary *> *bubblingEvents = [NSMutableDictionary new];
|
||||
|
||||
[_componentDataByName enumerateKeysAndObjectsUsingBlock:
|
||||
^(NSString *name, RCTComponentData *componentData, __unused BOOL *stop) {
|
||||
|
||||
RCTViewManager *manager = componentData.manager;
|
||||
NSMutableDictionary *constantsNamespace =
|
||||
[NSMutableDictionary dictionaryWithDictionary:allJSConstants[name]];
|
||||
NSMutableDictionary<NSString *, id> *constantsNamespace =
|
||||
[NSMutableDictionary dictionaryWithDictionary:allJSConstants[name]];
|
||||
|
||||
// Add custom constants
|
||||
// TODO: should these be inherited?
|
||||
NSDictionary *constants = RCTClassOverridesInstanceMethod([manager class], @selector(constantsToExport)) ? [manager constantsToExport] : nil;
|
||||
NSDictionary<NSString *, id> *constants = RCTClassOverridesInstanceMethod([manager class], @selector(constantsToExport)) ? [manager constantsToExport] : nil;
|
||||
if (constants.count) {
|
||||
RCTAssert(constantsNamespace[@"Constants"] == nil , @"Cannot redefine Constants in namespace: %@", name);
|
||||
// add an additional 'Constants' namespace for each class
|
||||
|
@ -1201,7 +1201,7 @@ RCT_EXPORT_METHOD(clearJSResponder)
|
|||
}
|
||||
|
||||
// Add native props
|
||||
NSDictionary *viewConfig = [componentData viewConfig];
|
||||
NSDictionary<NSString *, id> *viewConfig = [componentData viewConfig];
|
||||
constantsNamespace[@"NativeProps"] = viewConfig[@"propTypes"];
|
||||
|
||||
// Add direct events
|
||||
|
@ -1234,7 +1234,7 @@ RCT_EXPORT_METHOD(clearJSResponder)
|
|||
}
|
||||
}
|
||||
|
||||
allJSConstants[name] = [constantsNamespace copy];
|
||||
allJSConstants[name] = constantsNamespace;
|
||||
}];
|
||||
|
||||
[allJSConstants addEntriesFromDictionary:@{
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#import "RCTJavaScriptExecutor.h"
|
||||
#import "RCTPerformanceLogger.h"
|
||||
#import "RCTRootView.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTUIManager.h"
|
||||
|
||||
static NSString *const RCTPerfMonitorKey = @"RCTPerfMonitorKey";
|
||||
|
@ -441,10 +440,10 @@ RCT_EXPORT_MODULE()
|
|||
|
||||
- (void)updateStats
|
||||
{
|
||||
RCTSparseArray *views = [_bridge.uiManager valueForKey:@"viewRegistry"];
|
||||
NSDictionary<NSNumber *, UIView *> *views = [_bridge.uiManager valueForKey:@"viewRegistry"];
|
||||
NSUInteger viewCount = views.count;
|
||||
NSUInteger visibleViewCount = 0;
|
||||
for (UIView *view in views.allObjects) {
|
||||
for (UIView *view in views.allValues) {
|
||||
if (view.window || view.superview.window) {
|
||||
visibleViewCount++;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
133CAE8E1B8E5CFD00F6AD92 /* RCTDatePicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 133CAE8D1B8E5CFD00F6AD92 /* RCTDatePicker.m */; };
|
||||
13456E931ADAD2DE009F94A7 /* RCTConvert+CoreLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = 13456E921ADAD2DE009F94A7 /* RCTConvert+CoreLocation.m */; };
|
||||
13456E961ADAD482009F94A7 /* RCTConvert+MapKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 13456E951ADAD482009F94A7 /* RCTConvert+MapKit.m */; };
|
||||
134FCB361A6D42D900051CC8 /* RCTSparseArray.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BEE46D1A6D19BC00B5863B /* RCTSparseArray.m */; };
|
||||
134FCB3D1A6E7F0800051CC8 /* RCTContextExecutor.m in Sources */ = {isa = PBXBuildFile; fileRef = 134FCB3A1A6E7F0800051CC8 /* RCTContextExecutor.m */; };
|
||||
13513F3C1B1F43F400FCE529 /* RCTProgressViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13513F3B1B1F43F400FCE529 /* RCTProgressViewManager.m */; };
|
||||
13723B501A82FD3C00F88898 /* RCTStatusBarManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13723B4F1A82FD3C00F88898 /* RCTStatusBarManager.m */; };
|
||||
|
@ -246,8 +245,6 @@
|
|||
83A1FE8B1B62640A00BE0E65 /* RCTModalHostView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTModalHostView.m; sourceTree = "<group>"; };
|
||||
83A1FE8D1B62643A00BE0E65 /* RCTModalHostViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTModalHostViewManager.h; sourceTree = "<group>"; };
|
||||
83A1FE8E1B62643A00BE0E65 /* RCTModalHostViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTModalHostViewManager.m; sourceTree = "<group>"; };
|
||||
83BEE46C1A6D19BC00B5863B /* RCTSparseArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTSparseArray.h; sourceTree = "<group>"; };
|
||||
83BEE46D1A6D19BC00B5863B /* RCTSparseArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTSparseArray.m; sourceTree = "<group>"; };
|
||||
83CBBA2E1A601D0E00E9B192 /* libReact.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libReact.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
83CBBA4A1A601E3B00E9B192 /* RCTAssert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAssert.h; sourceTree = "<group>"; };
|
||||
83CBBA4B1A601E3B00E9B192 /* RCTAssert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTAssert.m; sourceTree = "<group>"; };
|
||||
|
@ -510,8 +507,6 @@
|
|||
142014171B32094000CC17BA /* RCTPerformanceLogger.m */,
|
||||
830A229C1A66C68A008503DA /* RCTRootView.h */,
|
||||
830A229D1A66C68A008503DA /* RCTRootView.m */,
|
||||
83BEE46C1A6D19BC00B5863B /* RCTSparseArray.h */,
|
||||
83BEE46D1A6D19BC00B5863B /* RCTSparseArray.m */,
|
||||
83CBBA961A6020BB00E9B192 /* RCTTouchHandler.h */,
|
||||
83CBBA971A6020BB00E9B192 /* RCTTouchHandler.m */,
|
||||
1345A83A1B265A0E00583190 /* RCTURLRequestDelegate.h */,
|
||||
|
@ -660,7 +655,6 @@
|
|||
13E067571A70F44B002CDEE1 /* RCTView.m in Sources */,
|
||||
13456E931ADAD2DE009F94A7 /* RCTConvert+CoreLocation.m in Sources */,
|
||||
137327E91AA5CF210034F82E /* RCTTabBarItemManager.m in Sources */,
|
||||
134FCB361A6D42D900051CC8 /* RCTSparseArray.m in Sources */,
|
||||
13A1F71E1A75392D00D3D453 /* RCTKeyCommands.m in Sources */,
|
||||
83CBBA531A601E3B00E9B192 /* RCTUtils.m in Sources */,
|
||||
14435CE61AAC4AE100FC20F4 /* RCTMapManager.m in Sources */,
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
@class RCTShadowView;
|
||||
@class RCTViewManager;
|
||||
@class UIView;
|
||||
|
||||
@interface RCTComponentData : NSObject
|
||||
|
||||
|
@ -22,11 +23,11 @@
|
|||
|
||||
- (instancetype)initWithManager:(RCTViewManager *)manager NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (id<RCTComponent>)createViewWithTag:(NSNumber *)tag props:(NSDictionary *)props;
|
||||
- (UIView *)createViewWithTag:(NSNumber *)tag props:(NSDictionary<NSString *, id> *)props;
|
||||
- (RCTShadowView *)createShadowViewWithTag:(NSNumber *)tag;
|
||||
- (void)setProps:(NSDictionary *)props forView:(id<RCTComponent>)view;
|
||||
- (void)setProps:(NSDictionary *)props forShadowView:(RCTShadowView *)shadowView;
|
||||
- (void)setProps:(NSDictionary<NSString *, id> *)props forView:(id<RCTComponent>)view;
|
||||
- (void)setProps:(NSDictionary<NSString *, id> *)props forShadowView:(RCTShadowView *)shadowView;
|
||||
|
||||
- (NSDictionary *)viewConfig;
|
||||
- (NSDictionary<NSString *, id> *)viewConfig;
|
||||
|
||||
@end
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#import "RCTShadowView.h"
|
||||
#import "RCTUtils.h"
|
||||
#import "RCTViewManager.h"
|
||||
#import "UIView+React.h"
|
||||
|
||||
typedef void (^RCTPropBlock)(id<RCTComponent> view, id json);
|
||||
|
||||
|
@ -41,8 +42,8 @@ typedef void (^RCTPropBlock)(id<RCTComponent> view, id json);
|
|||
{
|
||||
id<RCTComponent> _defaultView;
|
||||
RCTShadowView *_defaultShadowView;
|
||||
NSMutableDictionary *_viewPropBlocks;
|
||||
NSMutableDictionary *_shadowPropBlocks;
|
||||
NSMutableDictionary<NSString *, RCTPropBlock> *_viewPropBlocks;
|
||||
NSMutableDictionary<NSString *, RCTPropBlock> *_shadowPropBlocks;
|
||||
}
|
||||
|
||||
- (instancetype)initWithManager:(RCTViewManager *)manager
|
||||
|
@ -63,17 +64,15 @@ typedef void (^RCTPropBlock)(id<RCTComponent> view, id json);
|
|||
|
||||
RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
|
||||
- (id<RCTComponent>)createViewWithTag:(NSNumber *)tag props:(NSDictionary *)props
|
||||
- (UIView *)createViewWithTag:(NSNumber *)tag props:(NSDictionary<NSString *, id> *)props
|
||||
{
|
||||
RCTAssertMainThread();
|
||||
|
||||
id<RCTComponent> view = (id<RCTComponent>)(props ? [_manager viewWithProps:props] : [_manager view]);
|
||||
UIView *view = (UIView *)(props ? [_manager viewWithProps:props] : [_manager view]);
|
||||
view.reactTag = tag;
|
||||
if ([view isKindOfClass:[UIView class]]) {
|
||||
((UIView *)view).multipleTouchEnabled = YES;
|
||||
((UIView *)view).userInteractionEnabled = YES; // required for touch handling
|
||||
((UIView *)view).layer.allowsGroupOpacity = YES; // required for touch handling
|
||||
}
|
||||
view.multipleTouchEnabled = YES;
|
||||
view.userInteractionEnabled = YES; // required for touch handling
|
||||
view.layer.allowsGroupOpacity = YES; // required for touch handling
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -88,7 +87,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
- (RCTPropBlock)propBlockForKey:(NSString *)name defaultView:(id)defaultView
|
||||
{
|
||||
BOOL shadowView = [defaultView isKindOfClass:[RCTShadowView class]];
|
||||
NSMutableDictionary *propBlocks = shadowView ? _shadowPropBlocks : _viewPropBlocks;
|
||||
NSMutableDictionary<NSString *, RCTPropBlock> *propBlocks = shadowView ? _shadowPropBlocks : _viewPropBlocks;
|
||||
RCTPropBlock propBlock = propBlocks[name];
|
||||
if (!propBlock) {
|
||||
|
||||
|
@ -277,7 +276,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
return propBlock;
|
||||
}
|
||||
|
||||
- (void)setProps:(NSDictionary *)props forView:(id<RCTComponent>)view
|
||||
- (void)setProps:(NSDictionary<NSString *, id> *)props forView:(id<RCTComponent>)view
|
||||
{
|
||||
if (!view) {
|
||||
return;
|
||||
|
@ -292,7 +291,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
}];
|
||||
}
|
||||
|
||||
- (void)setProps:(NSDictionary *)props forShadowView:(RCTShadowView *)shadowView
|
||||
- (void)setProps:(NSDictionary<NSString *, id> *)props forShadowView:(RCTShadowView *)shadowView
|
||||
{
|
||||
if (!shadowView) {
|
||||
return;
|
||||
|
@ -309,7 +308,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
[shadowView updateLayout];
|
||||
}
|
||||
|
||||
- (NSDictionary *)viewConfig
|
||||
- (NSDictionary<NSString *, id> *)viewConfig
|
||||
{
|
||||
Class managerClass = [_manager class];
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
|
|||
RCT_REMAP_VIEW_PROPERTY(mode, datePickerMode, UIDatePickerMode)
|
||||
RCT_REMAP_VIEW_PROPERTY(timeZoneOffsetInMinutes, timeZone, NSTimeZone)
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
UIDatePicker *view = [UIDatePicker new];
|
||||
return @{
|
||||
|
|
|
@ -51,18 +51,18 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:coder)
|
|||
}
|
||||
}
|
||||
|
||||
- (NSArray<UIView<RCTComponent> *> *)reactSubviews
|
||||
- (NSArray<UIView *> *)reactSubviews
|
||||
{
|
||||
return _modalViewController.view ? @[_modalViewController.view] : @[];
|
||||
}
|
||||
|
||||
- (void)insertReactSubview:(UIView<RCTComponent> *)subview atIndex:(__unused NSInteger)atIndex
|
||||
- (void)insertReactSubview:(UIView *)subview atIndex:(__unused NSInteger)atIndex
|
||||
{
|
||||
[subview addGestureRecognizer:_touchHandler];
|
||||
_modalViewController.view = subview;
|
||||
}
|
||||
|
||||
- (void)removeReactSubview:(UIView<RCTComponent> *)subview
|
||||
- (void)removeReactSubview:(UIView *)subview
|
||||
{
|
||||
RCTAssert(subview == _modalViewController.view, @"Cannot remove view other than modal view");
|
||||
_modalViewController.view = nil;
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
#import "RCTBridge.h"
|
||||
#import "RCTConvert.h"
|
||||
#import "RCTNavigator.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTUIManager.h"
|
||||
#import "UIView+React.h"
|
||||
|
||||
@implementation RCTNavigatorManager
|
||||
|
||||
|
@ -34,7 +34,7 @@ RCT_EXPORT_METHOD(requestSchedulingJavaScriptNavigation:(nonnull NSNumber *)reac
|
|||
callback:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
[self.bridge.uiManager addUIBlock:
|
||||
^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry){
|
||||
^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTNavigator *> *viewRegistry){
|
||||
RCTNavigator *navigator = viewRegistry[reactTag];
|
||||
if ([navigator isKindOfClass:[RCTNavigator class]]) {
|
||||
BOOL wasAcquired = [navigator requestSchedulingJavaScriptNavigation];
|
||||
|
|
|
@ -26,7 +26,7 @@ RCT_EXPORT_VIEW_PROPERTY(items, NSDictionaryArray)
|
|||
RCT_EXPORT_VIEW_PROPERTY(selectedIndex, NSInteger)
|
||||
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
UIPickerView *view = [UIPickerView new];
|
||||
return @{
|
||||
|
|
|
@ -36,7 +36,7 @@ RCT_EXPORT_VIEW_PROPERTY(trackTintColor, UIColor)
|
|||
RCT_EXPORT_VIEW_PROPERTY(progressImage, UIImage)
|
||||
RCT_EXPORT_VIEW_PROPERTY(trackImage, UIImage)
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
UIProgressView *view = [UIProgressView new];
|
||||
return @{
|
||||
|
|
|
@ -412,7 +412,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
|||
[subview removeFromSuperview];
|
||||
}
|
||||
|
||||
- (NSArray<UIView<RCTComponent> *> *)reactSubviews
|
||||
- (NSArray<UIView *> *)reactSubviews
|
||||
{
|
||||
return _contentView ? @[_contentView] : @[];
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTScrollView.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTUIManager.h"
|
||||
|
||||
@interface RCTScrollView (Private)
|
||||
|
@ -67,7 +66,7 @@ RCT_EXPORT_VIEW_PROPERTY(snapToInterval, int)
|
|||
RCT_EXPORT_VIEW_PROPERTY(snapToAlignment, NSString)
|
||||
RCT_REMAP_VIEW_PROPERTY(contentOffset, scrollView.contentOffset, CGPoint)
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
return @{
|
||||
// TODO: unused - remove these?
|
||||
|
@ -81,7 +80,7 @@ RCT_REMAP_VIEW_PROPERTY(contentOffset, scrollView.contentOffset, CGPoint)
|
|||
RCT_EXPORT_METHOD(getContentSize:(nonnull NSNumber *)reactTag
|
||||
callback:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTScrollView *> *viewRegistry) {
|
||||
|
||||
RCTScrollView *view = viewRegistry[reactTag];
|
||||
if (!view || ![view isKindOfClass:[RCTScrollView class]]) {
|
||||
|
@ -100,7 +99,7 @@ RCT_EXPORT_METHOD(getContentSize:(nonnull NSNumber *)reactTag
|
|||
RCT_EXPORT_METHOD(calculateChildFrames:(nonnull NSNumber *)reactTag
|
||||
callback:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTScrollView *> *viewRegistry) {
|
||||
|
||||
RCTScrollView *view = viewRegistry[reactTag];
|
||||
if (!view || ![view isKindOfClass:[RCTScrollView class]]) {
|
||||
|
|
|
@ -29,7 +29,7 @@ RCT_EXPORT_VIEW_PROPERTY(momentary, BOOL)
|
|||
RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
RCTSegmentedControl *view = [RCTSegmentedControl new];
|
||||
return @{
|
||||
|
|
|
@ -21,7 +21,7 @@ typedef NS_ENUM(NSUInteger, RCTUpdateLifecycle) {
|
|||
RCTUpdateLifecycleDirtied,
|
||||
};
|
||||
|
||||
typedef void (^RCTApplierBlock)(RCTSparseArray *viewRegistry);
|
||||
typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, UIView *> *viewRegistry);
|
||||
|
||||
/**
|
||||
* ShadowView tree mirrors RCT view tree. Every node is highly stateful.
|
||||
|
@ -124,14 +124,14 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *viewRegistry);
|
|||
* on the main thread in order to update the view.
|
||||
*/
|
||||
- (void)collectUpdatedProperties:(NSMutableSet<RCTApplierBlock> *)applierBlocks
|
||||
parentProperties:(NSDictionary *)parentProperties;
|
||||
parentProperties:(NSDictionary<NSString *, id> *)parentProperties;
|
||||
|
||||
/**
|
||||
* Process the updated properties and apply them to view. Shadow view classes
|
||||
* that add additional propagating properties should override this method.
|
||||
*/
|
||||
- (NSDictionary *)processUpdatedProperties:(NSMutableSet<RCTApplierBlock> *)applierBlocks
|
||||
parentProperties:(NSDictionary *)parentProperties NS_REQUIRES_SUPER;
|
||||
- (NSDictionary<NSString *, id> *)processUpdatedProperties:(NSMutableSet<RCTApplierBlock> *)applierBlocks
|
||||
parentProperties:(NSDictionary<NSString *, id> *)parentProperties NS_REQUIRES_SUPER;
|
||||
|
||||
/**
|
||||
* Calculate all views whose frame needs updating after layout has been calculated.
|
||||
|
|
|
@ -11,14 +11,13 @@
|
|||
|
||||
#import "RCTConvert.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTUtils.h"
|
||||
#import "UIView+React.h"
|
||||
|
||||
typedef void (^RCTActionBlock)(RCTShadowView *shadowViewSelf, id value);
|
||||
typedef void (^RCTResetActionBlock)(RCTShadowView *shadowViewSelf);
|
||||
|
||||
const NSString *const RCTBackgroundColorProp = @"backgroundColor";
|
||||
static NSString *const RCTBackgroundColorProp = @"backgroundColor";
|
||||
|
||||
typedef NS_ENUM(unsigned int, meta_prop_t) {
|
||||
META_PROP_LEFT,
|
||||
|
@ -171,8 +170,8 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st
|
|||
}
|
||||
}
|
||||
|
||||
- (NSDictionary *)processUpdatedProperties:(NSMutableSet<RCTApplierBlock> *)applierBlocks
|
||||
parentProperties:(NSDictionary *)parentProperties
|
||||
- (NSDictionary<NSString *, id> *)processUpdatedProperties:(NSMutableSet<RCTApplierBlock> *)applierBlocks
|
||||
parentProperties:(NSDictionary<NSString *, id> *)parentProperties
|
||||
{
|
||||
// TODO: we always refresh all propagated properties when propagation is
|
||||
// dirtied, but really we should track which properties have changed and
|
||||
|
@ -181,14 +180,14 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st
|
|||
if (!_backgroundColor) {
|
||||
UIColor *parentBackgroundColor = parentProperties[RCTBackgroundColorProp];
|
||||
if (parentBackgroundColor) {
|
||||
[applierBlocks addObject:^(RCTSparseArray *viewRegistry) {
|
||||
[applierBlocks addObject:^(NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
UIView *view = viewRegistry[_reactTag];
|
||||
[view reactSetInheritedBackgroundColor:parentBackgroundColor];
|
||||
}];
|
||||
}
|
||||
} else {
|
||||
// Update parent properties for children
|
||||
NSMutableDictionary *properties = [NSMutableDictionary dictionaryWithDictionary:parentProperties];
|
||||
NSMutableDictionary<NSString *, id> *properties = [NSMutableDictionary dictionaryWithDictionary:parentProperties];
|
||||
CGFloat alpha = CGColorGetAlpha(_backgroundColor.CGColor);
|
||||
if (alpha < 1.0) {
|
||||
// If bg is non-opaque, don't propagate further
|
||||
|
@ -202,14 +201,14 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st
|
|||
}
|
||||
|
||||
- (void)collectUpdatedProperties:(NSMutableSet<RCTApplierBlock> *)applierBlocks
|
||||
parentProperties:(NSDictionary *)parentProperties
|
||||
parentProperties:(NSDictionary<NSString *, id> *)parentProperties
|
||||
{
|
||||
if (_propagationLifecycle == RCTUpdateLifecycleComputed && [parentProperties isEqualToDictionary:_lastParentProperties]) {
|
||||
return;
|
||||
}
|
||||
_propagationLifecycle = RCTUpdateLifecycleComputed;
|
||||
_lastParentProperties = parentProperties;
|
||||
NSDictionary *nextProps = [self processUpdatedProperties:applierBlocks parentProperties:parentProperties];
|
||||
NSDictionary<NSString *, id> *nextProps = [self processUpdatedProperties:applierBlocks parentProperties:parentProperties];
|
||||
for (RCTShadowView *child in _reactSubviews) {
|
||||
[child collectUpdatedProperties:applierBlocks parentProperties:nextProps];
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ static NSString *RCTRecursiveAccessibilityLabel(UIView *view)
|
|||
|
||||
@implementation RCTView
|
||||
{
|
||||
NSMutableArray<UIView<RCTComponent> *> *_reactSubviews;
|
||||
NSMutableArray<UIView *> *_reactSubviews;
|
||||
UIColor *_backgroundColor;
|
||||
}
|
||||
|
||||
|
@ -413,7 +413,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:unused)
|
|||
[subview removeFromSuperview];
|
||||
}
|
||||
|
||||
- (NSArray<UIView<RCTComponent> *> *)reactSubviews
|
||||
- (NSArray<UIView *> *)reactSubviews
|
||||
{
|
||||
// The _reactSubviews array is only used when we have hidden
|
||||
// offscreen views. If _reactSubviews is nil, we can assume
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
@class RCTSparseArray;
|
||||
@class RCTUIManager;
|
||||
|
||||
typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, RCTSparseArray *viewRegistry);
|
||||
typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry);
|
||||
|
||||
@interface RCTViewManager : NSObject <RCTBridgeModule>
|
||||
|
||||
|
@ -39,7 +39,7 @@ typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, RCTSparseArray *v
|
|||
* return a fresh instance each time. The view module MUST NOT cache the returned
|
||||
* view and return the same instance for subsequent calls.
|
||||
*/
|
||||
- (UIView<RCTComponent> *)view;
|
||||
- (UIView *)view;
|
||||
|
||||
/**
|
||||
* This method instantiates a native view using the props passed into the component.
|
||||
|
@ -48,7 +48,7 @@ typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, RCTSparseArray *v
|
|||
* still be set individually, after the view is created. Like the -view method,
|
||||
* -viewWithProps: should return a fresh instance each time it is called.
|
||||
*/
|
||||
- (UIView *)viewWithProps:(NSDictionary *)props;
|
||||
- (UIView *)viewWithProps:(NSDictionary<NSString *, id> *)props;
|
||||
|
||||
/**
|
||||
* This method instantiates a shadow view to be managed by the module. If omitted,
|
||||
|
@ -97,7 +97,7 @@ typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, RCTSparseArray *v
|
|||
* custo layout logic or tasks that involve walking the view hierarchy.
|
||||
* To be deprecated, hopefully.
|
||||
*/
|
||||
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(RCTSparseArray *)shadowViewRegistry;
|
||||
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(NSDictionary<NSNumber *, RCTShadowView *> *)shadowViewRegistry;
|
||||
|
||||
/**
|
||||
* This handles the simple case, where JS and native property names match.
|
||||
|
|
|
@ -54,7 +54,7 @@ RCT_EXPORT_MODULE()
|
|||
return _bridge.uiManager.methodQueue;
|
||||
}
|
||||
|
||||
- (UIView *)viewWithProps:(__unused NSDictionary *)props
|
||||
- (UIView *)viewWithProps:(__unused NSDictionary<NSString *, id> *)props
|
||||
{
|
||||
return [self view];
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ RCT_EXPORT_MODULE()
|
|||
return @[];
|
||||
}
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ RCT_EXPORT_MODULE()
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(__unused RCTSparseArray *)shadowViewRegistry
|
||||
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(__unused NSDictionary<NSNumber *, RCTShadowView *> *)shadowViewRegistry
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ extern NSString *const RCTJSNavigationScheme;
|
|||
@protocol RCTWebViewDelegate <NSObject>
|
||||
|
||||
- (BOOL)webView:(RCTWebView *)webView
|
||||
shouldStartLoadForRequest:(NSMutableDictionary *)request
|
||||
shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
|
||||
withCallback:(RCTDirectEventBlock)callback;
|
||||
|
||||
@end
|
||||
|
|
|
@ -118,9 +118,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
|||
return _webView.backgroundColor;
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)baseEvent
|
||||
- (NSMutableDictionary<NSString *, id> *)baseEvent
|
||||
{
|
||||
NSMutableDictionary *event = [[NSMutableDictionary alloc] initWithDictionary:@{
|
||||
NSMutableDictionary<NSString *, id> *event = [[NSMutableDictionary alloc] initWithDictionary:@{
|
||||
@"url": _webView.request.URL.absoluteString ?: @"",
|
||||
@"loading" : @(_webView.loading),
|
||||
@"title": [_webView stringByEvaluatingJavaScriptFromString:@"document.title"],
|
||||
|
@ -147,7 +147,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
|||
|
||||
// skip this for the JS Navigation handler
|
||||
if (!isJSNavigation && _onShouldStartLoadWithRequest) {
|
||||
NSMutableDictionary *event = [self baseEvent];
|
||||
NSMutableDictionary<NSString *, id> *event = [self baseEvent];
|
||||
[event addEntriesFromDictionary: @{
|
||||
@"url": (request.URL).absoluteString,
|
||||
@"navigationType": @(navigationType)
|
||||
|
@ -163,7 +163,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
|||
// We have this check to filter out iframe requests and whatnot
|
||||
BOOL isTopFrame = [request.URL isEqual:request.mainDocumentURL];
|
||||
if (isTopFrame) {
|
||||
NSMutableDictionary *event = [self baseEvent];
|
||||
NSMutableDictionary<NSString *, id> *event = [self baseEvent];
|
||||
[event addEntriesFromDictionary: @{
|
||||
@"url": (request.URL).absoluteString,
|
||||
@"navigationType": @(navigationType)
|
||||
|
@ -187,7 +187,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
|||
return;
|
||||
}
|
||||
|
||||
NSMutableDictionary *event = [self baseEvent];
|
||||
NSMutableDictionary<NSString *, id> *event = [self baseEvent];
|
||||
[event addEntriesFromDictionary:@{
|
||||
@"domain": error.domain,
|
||||
@"code": @(error.code),
|
||||
|
@ -202,7 +202,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
|||
if (_injectedJavaScript != nil) {
|
||||
NSString *jsEvaluationValue = [webView stringByEvaluatingJavaScriptFromString:_injectedJavaScript];
|
||||
|
||||
NSMutableDictionary *event = [self baseEvent];
|
||||
NSMutableDictionary<NSString *, id> *event = [self baseEvent];
|
||||
event[@"jsEvaluationValue"] = jsEvaluationValue;
|
||||
|
||||
_onLoadingFinish(event);
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#import "RCTWebViewManager.h"
|
||||
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTUIManager.h"
|
||||
#import "RCTWebView.h"
|
||||
#import "UIView+React.h"
|
||||
|
||||
@interface RCTWebViewManager () <RCTWebViewDelegate>
|
||||
|
||||
|
@ -45,7 +45,7 @@ RCT_EXPORT_VIEW_PROPERTY(onLoadingFinish, RCTDirectEventBlock);
|
|||
RCT_EXPORT_VIEW_PROPERTY(onLoadingError, RCTDirectEventBlock);
|
||||
RCT_EXPORT_VIEW_PROPERTY(onShouldStartLoadWithRequest, RCTDirectEventBlock);
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
- (NSDictionary<NSString *, id> *)constantsToExport
|
||||
{
|
||||
return @{
|
||||
@"JSNavigationScheme": RCTJSNavigationScheme,
|
||||
|
@ -62,7 +62,7 @@ RCT_EXPORT_VIEW_PROPERTY(onShouldStartLoadWithRequest, RCTDirectEventBlock);
|
|||
|
||||
RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
|
||||
{
|
||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWebView *> *viewRegistry) {
|
||||
RCTWebView *view = viewRegistry[reactTag];
|
||||
if (![view isKindOfClass:[RCTWebView class]]) {
|
||||
RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
||||
|
@ -74,7 +74,7 @@ RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
|
|||
|
||||
RCT_EXPORT_METHOD(goForward:(nonnull NSNumber *)reactTag)
|
||||
{
|
||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
id view = viewRegistry[reactTag];
|
||||
if (![view isKindOfClass:[RCTWebView class]]) {
|
||||
RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
||||
|
@ -86,7 +86,7 @@ RCT_EXPORT_METHOD(goForward:(nonnull NSNumber *)reactTag)
|
|||
|
||||
RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
|
||||
{
|
||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWebView *> *viewRegistry) {
|
||||
RCTWebView *view = viewRegistry[reactTag];
|
||||
if (![view isKindOfClass:[RCTWebView class]]) {
|
||||
RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
||||
|
@ -99,7 +99,7 @@ RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
|
|||
#pragma mark - Exported synchronous methods
|
||||
|
||||
- (BOOL)webView:(__unused RCTWebView *)webView
|
||||
shouldStartLoadForRequest:(NSMutableDictionary *)request
|
||||
shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
|
||||
withCallback:(RCTDirectEventBlock)callback
|
||||
{
|
||||
_shouldStartLoadLock = [[NSConditionLock alloc] initWithCondition:arc4random()];
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
@interface UIView (React) <RCTComponent>
|
||||
|
||||
- (NSArray<UIView<RCTComponent> *> *)reactSubviews;
|
||||
- (UIView<RCTComponent> *)reactSuperview;
|
||||
- (NSArray<UIView *> *)reactSubviews;
|
||||
- (UIView *)reactSuperview;
|
||||
|
||||
/**
|
||||
* Used by the UIIManager to set the view frame.
|
||||
|
|
|
@ -51,12 +51,12 @@
|
|||
[subview removeFromSuperview];
|
||||
}
|
||||
|
||||
- (NSArray<UIView<RCTComponent> *> *)reactSubviews
|
||||
- (NSArray<UIView *> *)reactSubviews
|
||||
{
|
||||
return self.subviews;
|
||||
}
|
||||
|
||||
- (UIView<RCTComponent> *)reactSuperview
|
||||
- (UIView *)reactSuperview
|
||||
{
|
||||
return self.superview;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue