Updates from Mon Mar 2

- [ReactNative] Move merge & mergeInto from downstream to vendor | Christopher Chedeau
- [ReactNative] Replace all the call sites of mergeInto by Object.assign | Christopher Chedeau
- [WIP] Migrated View Managers over to new architecture | Nick Lockwood
- [ReactNative] Replace all the call sites of copyProperties by Object.assign | Christopher Chedeau
- [ReactNative] Migrate navigator.geolocation to open source | Christopher Chedeau
- [ReactNative] Remove README.md, LICENSE and .travis.yml from fbobjc | Christopher Chedeau
- [react-packager] Better transform errors | Amjad Masad
- [React Native][react-packager] Fix test runner and fialing tests | Amjad Masad
This commit is contained in:
Christopher Chedeau
2015-03-02 11:36:55 -08:00
parent 0b09ed0667
commit 7060141247
109 changed files with 9051 additions and 8540 deletions

View File

@@ -6,7 +6,8 @@
@interface RCTNetworkImageView : UIView
- (instancetype)initWithFrame:(CGRect)frame imageDownloader:(RCTImageDownloader *)imageDownloader;
- (instancetype)initWithFrame:(CGRect)frame
imageDownloader:(RCTImageDownloader *)imageDownloader NS_DESIGNATED_INITIALIZER;
/**
* An image that will appear while the view is loading the image from the network,

View File

@@ -6,32 +6,16 @@
@class RCTBridge;
@class RCTEventDispatcher;
@class RCTRootView;
/**
* Utilities for constructing common response objects. When sending a
* systemError back to JS, it's important to describe whether or not it was a
* system error, or API usage error. System errors should never happen and are
* therefore logged using `RCTLogError()`. API usage errors are expected if the
* API is misused and will therefore not be logged using `RCTLogError()`. The JS
* application code is expected to handle them. Regardless of type, each error
* should be logged at most once.
*/
static inline NSDictionary *RCTSystemErrorObject(NSString *msg)
{
return @{@"systemError": msg ?: @""};
}
static inline NSDictionary *RCTAPIErrorObject(NSString *msg)
{
return @{@"apiError": msg ?: @""};
}
/**
* This block can be used to instantiate modules that require additional
* init parameters, or additional configuration prior to being used.
* The bridge will call this block to instatiate the modules, and will
* be responsible for invalidating/releasing them when the bridge is destroyed.
* For this reason, the block should always return new module instances, and
* module instances should not be shared between bridges.
*/
typedef NSArray *(^RCTBridgeModuleProviderBlock)(RCTBridge *bridge);
typedef NSArray *(^RCTBridgeModuleProviderBlock)(void);
/**
* Async batched bridge used to communicate with the JavaScript application.
@@ -42,12 +26,12 @@ typedef NSArray *(^RCTBridgeModuleProviderBlock)(RCTBridge *bridge);
* The designated initializer. This creates a new bridge on top of the specified
* executor. The bridge should then be used for all subsequent communication
* with the JavaScript code running in the executor. Modules will be automatically
* instantiated using the default contructor, but you can optionally pass in a
* module provider block to manually instantiate modules that require additional
* init parameters or configuration.
* instantiated using the default contructor, but you can optionally pass in an
* array of pre-initialized module instances if they require additional init
* parameters or configuration.
*/
- (instancetype)initWithJavaScriptExecutor:(id<RCTJavaScriptExecutor>)javaScriptExecutor
moduleProvider:(RCTBridgeModuleProviderBlock)block NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithExecutor:(id<RCTJavaScriptExecutor>)executor
moduleProvider:(RCTBridgeModuleProviderBlock)block NS_DESIGNATED_INITIALIZER;
/**
* This method is used to call functions in the JavaScript application context.
@@ -81,16 +65,6 @@ typedef NSArray *(^RCTBridgeModuleProviderBlock)(RCTBridge *bridge);
*/
@property (nonatomic, readonly) dispatch_queue_t shadowQueue;
// For use in implementing delegates, which may need to queue responses.
- (RCTResponseSenderBlock)createResponseSenderBlock:(NSInteger)callbackID;
/**
* Register a root view with the bridge. Theorectically, a single bridge can
* support multiple root views, however this feature is not currently exposed
* and may eventually be removed.
*/
- (void)registerRootView:(RCTRootView *)rootView;
/**
* Global logging function that will print to both xcode and JS debugger consoles.
*

View File

@@ -19,10 +19,12 @@ typedef void (^RCTResponseSenderBlock)(NSArray *response);
@optional
/**
* Optional initializer for modules that require access
* to bridge features, such as sending events or making JS calls
* A reference to the RCTBridge. Useful for modules that require access
* to bridge features, such as sending events or making JS calls. This
* will be set automatically by the bridge when it initializes the module.
* To implement this in your module, just add @synthesize bridge = _bridge;
*/
- (instancetype)initWithBridge:(RCTBridge *)bridge;
@property (nonatomic, strong) RCTBridge *bridge;
/**
* The module name exposed to JS. If omitted, this will be inferred
@@ -42,17 +44,11 @@ typedef void (^RCTResponseSenderBlock)(NSArray *response);
/**
* Injects constants into JS. These constants are made accessible via
* NativeModules.moduleName.X. Note that this method is not inherited when you
* subclass a module, and you should not call [super constantsToExport] when
* implementing it.
*/
+ (NSDictionary *)constantsToExport;
/**
* Some "constants" are not really constant, and need to be re-generated
* each time the bridge module is created. Support for this feature is
* deprecated and may be going away or changing, but for now you can use
* the -constantsToExport instance method to register these "pseudo-constants".
* NativeModules.ModuleName.X. This method is called when the module is
* registered by the bridge. It is only called once for the lifetime of the
* bridge, so it is not suitable for returning dynamic values, but may be
* used for long-lived values such as session keys, that are regenerated only
* as part of a reload of the entire React application.
*/
- (NSDictionary *)constantsToExport;

View File

@@ -5,7 +5,7 @@
#import "RCTInvalidating.h"
typedef void (^RCTJavaScriptCompleteBlock)(NSError *error);
typedef void (^RCTJavaScriptCallback)(id objcValue, NSError *error);
typedef void (^RCTJavaScriptCallback)(id json, NSError *error);
/**
* Abstracts away a JavaScript execution context - we may be running code in a

View File

@@ -0,0 +1,7 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#import "RCTBridgeModule.h"
@interface RCTLocationObserver : NSObject<RCTBridgeModule>
@end

View File

@@ -20,28 +20,22 @@
// If defined, only log messages that match this regex will fatal
#define RCTLOG_FATAL_REGEX nil
#define _RCTLog(__RCTLog__level, ...) do { \
NSString *__RCTLog__levelStr; \
switch(__RCTLog__level) { \
case RCTLOG_INFO: __RCTLog__levelStr = @"info"; break; \
case RCTLOG_WARN: __RCTLog__levelStr = @"warn"; break; \
case RCTLOG_ERROR: __RCTLog__levelStr = @"error"; break; \
case RCTLOG_MUSTFIX: __RCTLog__levelStr = @"mustfix"; break; \
} \
NSString *__RCTLog__msg = _RCTLogObjects(RCTLogFormat(__VA_ARGS__), __RCTLog__levelStr); \
if (__RCTLog__level >= RCTLOG_FATAL_LEVEL) { \
BOOL __RCTLog__fail = YES; \
if (RCTLOG_FATAL_REGEX) { \
NSError *__RCTLog__e; \
NSRegularExpression *__RCTLog__regex = [NSRegularExpression regularExpressionWithPattern:RCTLOG_FATAL_REGEX options:0 error:&__RCTLog__e]; \
__RCTLog__fail = [__RCTLog__regex numberOfMatchesInString:__RCTLog__msg options:0 range:NSMakeRange(0, [__RCTLog__msg length])] > 0; \
} \
RCTCAssert(!__RCTLog__fail, @"RCTLOG_FATAL_LEVEL %@: %@", __RCTLog__levelStr, __RCTLog__msg); \
} \
if (__RCTLog__level >= RCTLOG_REDBOX_LEVEL) { \
RCTRedBox *__RCTLog__redBox = [RCTRedBox sharedInstance]; \
[__RCTLog__redBox showErrorMessage:__RCTLog__msg]; \
} \
extern __unsafe_unretained NSString *RCTLogLevels[];
#define _RCTLog(_level, ...) do { \
NSString *__RCTLog__levelStr = RCTLogLevels[_level - 1]; \
NSString *__RCTLog__msg = RCTLogObjects(RCTLogFormat(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__), __RCTLog__levelStr); \
if (_level >= RCTLOG_FATAL_LEVEL) { \
BOOL __RCTLog__fail = YES; \
if (RCTLOG_FATAL_REGEX) { \
NSRegularExpression *__RCTLog__regex = [NSRegularExpression regularExpressionWithPattern:RCTLOG_FATAL_REGEX options:0 error:NULL]; \
__RCTLog__fail = [__RCTLog__regex numberOfMatchesInString:__RCTLog__msg options:0 range:NSMakeRange(0, [__RCTLog__msg length])] > 0; \
} \
RCTCAssert(!__RCTLog__fail, @"RCTLOG_FATAL_LEVEL %@: %@", __RCTLog__levelStr, __RCTLog__msg); \
} \
if (_level >= RCTLOG_REDBOX_LEVEL) { \
[[RCTRedBox sharedInstance] showErrorMessage:__RCTLog__msg]; \
} \
} while (0)
#define RCTLog(...) _RCTLog(RCTLOG_INFO, __VA_ARGS__)
@@ -50,20 +44,15 @@
#define RCTLogError(...) _RCTLog(RCTLOG_ERROR, __VA_ARGS__)
#define RCTLogMustFix(...) _RCTLog(RCTLOG_MUSTFIX, __VA_ARGS__)
#define RCTLogFormat(...) _RCTLogFormat(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
#define RCTLogFormatString(...) _RCTLogFormatString(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
#ifdef __cplusplus
extern "C" {
#endif
NSString *_RCTLogObjects(NSArray *objects, NSString *level);
NSArray *_RCTLogFormat(const char *file, int lineNumber, const char *funcName, NSString *format, ...) NS_FORMAT_FUNCTION(4,5);
NSString *_RCTLogFormatString(const char *file, int lineNumber, const char *funcName, NSString *format, ...) NS_FORMAT_FUNCTION(4,5);
NSString *RCTLogObjects(NSArray *objects, NSString *level);
NSArray *RCTLogFormat(const char *file, int lineNumber, const char *funcName, NSString *format, ...) NS_FORMAT_FUNCTION(4,5);
void RCTInjectLogFunction(void (^logFunction)(NSString *msg));
#ifdef __cplusplus
}
#endif
typedef void (^RCTLogFunction)(NSString *format, NSString *str);
void RCTInjectLogFunction(RCTLogFunction func);

View File

@@ -11,7 +11,7 @@
@property (nonatomic, strong) UIView *reactNavSuperviewLink;
@property (nonatomic, assign) NSInteger requestedTopOfStack;
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher;
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
/**
* Schedules a JavaScript navigation and prevents `UIKit` from navigating until

View File

@@ -12,6 +12,8 @@
@interface RCTScrollView : RCTView <UIScrollViewDelegate, RCTScrollableProtocol, RCTAutoInsetsProtocol>
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
/**
* If the `contentSize` is not provided, then the `contentSize` will
* automatically be determined by the size of the `RKScrollView` subview.
@@ -32,6 +34,4 @@
@property (nonatomic, assign) BOOL centerContent;
@property (nonatomic, copy) NSArray *stickyHeaderIndices;
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher;
@end

View File

@@ -3,29 +3,15 @@
#import <UIKit/UIKit.h>
#import "Layout.h"
#import "RCTUIManager.h"
#import "RCTViewNodeProtocol.h"
@class RCTSparseArray;
// TODO: amalgamate these enums?
typedef NS_ENUM(NSUInteger, RCTLayoutLifecycle) {
RCTLayoutLifecycleUninitialized = 0,
RCTLayoutLifecycleComputed,
RCTLayoutLifecycleDirtied,
};
// TODO: is this still needed?
typedef NS_ENUM(NSUInteger, RCTPropagationLifecycle) {
RCTPropagationLifecycleUninitialized = 0,
RCTPropagationLifecycleComputed,
RCTPropagationLifecycleDirtied,
};
// TODO: move this to text node?
typedef NS_ENUM(NSUInteger, RCTTextLifecycle) {
RCTTextLifecycleUninitialized = 0,
RCTTextLifecycleComputed,
RCTTextLifecycleDirtied,
typedef NS_ENUM(NSUInteger, RCTUpdateLifecycle) {
RCTUpdateLifecycleUninitialized = 0,
RCTUpdateLifecycleComputed,
RCTUpdateLifecycleDirtied,
};
// TODO: is this redundact now?
@@ -48,7 +34,7 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *);
@property (nonatomic, copy) NSString *moduleName;
@property (nonatomic, assign) BOOL isBGColorExplicitlySet; // Used to propogate to children
@property (nonatomic, strong) UIColor *backgroundColor; // Used to propogate to children
@property (nonatomic, assign) RCTLayoutLifecycle layoutLifecycle;
@property (nonatomic, assign) RCTUpdateLifecycle layoutLifecycle;
/**
* isNewView - Used to track the first time the view is introduced into the hierarchy. It is initialized YES, then is
@@ -122,11 +108,23 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *);
@property (nonatomic, assign) css_wrap_type_t flexWrap;
@property (nonatomic, assign) CGFloat flex;
- (void)collectUpdatedProperties:(NSMutableSet *)viewsWithNewProperties parentProperties:(NSDictionary *)parentProperties;
- (void)collectRootUpdatedFrames:(NSMutableSet *)viewsWithNewFrame parentConstraint:(CGSize)parentConstraint;
- (void)fillCSSNode:(css_node_t *)node;
/**
* Calculate property changes that need to be propagated to the view.
* The applierBlocks set contains RCTApplierBlock functions that must be applied
* on the main thread in order to update the view.
*/
- (void)collectUpdatedProperties:(NSMutableSet *)applierBlocks parentProperties:(NSDictionary *)parentProperties;
// The following are implementation details exposed to subclasses. Do not call them directly
/**
* Calculate all views whose frame needs updating after layout has been calculated.
* The viewsWithNewFrame set contains the reactTags of the views that need updating.
*/
- (void)collectRootUpdatedFrames:(NSMutableSet *)viewsWithNewFrame parentConstraint:(CGSize)parentConstraint;
/**
* The following are implementation details exposed to subclasses. Do not call them directly
*/
- (void)fillCSSNode:(css_node_t *)node;
- (void)dirtyLayout;
- (BOOL)isLayoutDirty;

View File

@@ -10,6 +10,6 @@
@property (nonatomic, assign) BOOL autoCorrect;
@property (nonatomic, assign) UIEdgeInsets paddingEdgeInsets; // TODO: contentInset
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher;
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
@end

View File

@@ -8,7 +8,7 @@
@interface RCTTouchHandler : UIGestureRecognizer<RCTInvalidating>
- (instancetype)initWithBridge:(RCTBridge *)bridge;
- (instancetype)initWithBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;
- (void)startOrResetInteractionTiming;
- (NSDictionary *)endAndResetInteractionTiming;

View File

@@ -2,13 +2,18 @@
#import <UIKit/UIKit.h>
#import "RCTBridge.h"
#import "RCTBridgeModule.h"
#import "RCTInvalidating.h"
#import "RCTViewManager.h"
@class RCTRootView;
@protocol RCTScrollableProtocol;
/**
* The RCTUIManager is the module responsible for updating the view hierarchy.
*/
@interface RCTUIManager : NSObject <RCTBridgeModule, RCTInvalidating>
@property (nonatomic, weak) id<RCTScrollableProtocol> mainScrollView;
@@ -19,8 +24,33 @@
*/
@property (nonatomic, readwrite, weak) id<UIScrollViewDelegate> nativeMainScrollDelegate;
/**
* Register a root view with the RCTUIManager. Theoretically, a single manager
* can support multiple root views, however this feature is not currently exposed
* and may eventually be removed.
*/
- (void)registerRootView:(RCTRootView *)rootView;
/**
* Schedule a block to be executed on the UI thread. Useful if you need to execute
* view logic after all currently queued view updates have completed.
*/
- (void)addUIBlock:(RCTViewManagerUIBlock)block;
/**
* The view that is currently first responder, according to the JS context.
*/
+ (UIView *)JSResponder;
@end
/**
* This category makes the current RCTUIManager instance available via the
* RCTBridge, which is useful for RCTBridgeModules or RCTViewManagers that
* need to access the RCTUIManager.
*/
@interface RCTBridge (RCTUIManager)
@property (nonatomic, readonly) RCTUIManager *uiManager;
@end

View File

@@ -1,17 +1,15 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#import <tgmath.h>
#import <CoreGraphics/CoreGraphics.h>
#import <Foundation/Foundation.h>
#import <tgmath.h>
#import "RCTAssert.h"
// Macro to indicate when inherited initializer is not to be used
#define RCT_NOT_DESIGNATED_INITIALIZER() \
do { \
RCTAssert(NO, @"%@ is not the designated initializer for instances of %@.", NSStringFromSelector(_cmd), [self class]); \
return nil; \
} while (0)
#ifdef __cplusplus
extern "C" {
#endif
// Utility functions for JSON object <-> string serialization/deserialization
NSString *RCTJSONStringify(id jsonObject, NSError **error);
@@ -39,3 +37,10 @@ void RCTSwapInstanceMethods(Class cls, SEL original, SEL replacement);
// Module subclass support
BOOL RCTClassOverridesClassMethod(Class cls, SEL selector);
BOOL RCTClassOverridesInstanceMethod(Class cls, SEL selector);
// Enumerate all classes that conform to NSObject protocol
void RCTEnumerateClasses(void (^block)(Class cls));
#ifdef __cplusplus
}
#endif

View File

@@ -11,7 +11,6 @@
@interface RCTView : UIView
@property (nonatomic, assign) RCTPointerEvents pointerEvents;
@property (nonatomic, copy) NSString *overrideAccessibilityLabel;
+ (void)autoAdjustInsetsForView:(UIView<RCTAutoInsetsProtocol> *)parentView
withScrollView:(UIScrollView *)scrollView

View File

@@ -2,9 +2,11 @@
#import <UIKit/UIKit.h>
#import "RCTBridgeModule.h"
#import "RCTConvert.h"
#import "RCTLog.h"
@class RCTBridge;
@class RCTEventDispatcher;
@class RCTShadowView;
@class RCTSparseArray;
@@ -12,19 +14,22 @@
typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, RCTSparseArray *viewRegistry);
@interface RCTViewManager : NSObject
@interface RCTViewManager : NSObject <RCTBridgeModule>
/**
* Designated initializer for view modules. Override this when subclassing.
* The bridge can be used to access both the RCTUIIManager and the RCTEventDispatcher,
* allowing the manager (or the views that it manages) to manipulate the view
* hierarchy and send events back to the JS context.
*/
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
@property (nonatomic, strong) RCTBridge *bridge;
/**
* The event dispatcher is used to send events back to the JavaScript application.
* It can either be used directly by the module, or passed on to instantiated
* view subclasses so that they can handle their own events.
*/
@property (nonatomic, readonly, weak) RCTEventDispatcher *eventDispatcher;
// TODO: remove this, as it can be accessed directly from bridge
@property (nonatomic, readonly) RCTEventDispatcher *eventDispatcher;
/**
* The module name exposed to React JS. If omitted, this will be inferred
@@ -88,34 +93,19 @@ typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, RCTSparseArray *v
+ (NSDictionary *)customDirectEventTypes;
/**
* Injects constants into JS. These constants are made accessible via
* NativeModules.moduleName.X. Note that this method is not inherited when you
* subclass a view module, and you should not call [super constantsToExport]
* when overriding it.
* Called to notify manager that layout has finished, in case any calculated
* properties need to be copied over from shadow view to view.
*/
+ (NSDictionary *)constantsToExport;
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTShadowView *)shadowView;
/**
* To deprecate, hopefully
* Called after view hierarchy manipulation has finished, and all shadow props
* have been set, but before layout has been performed. Useful for performing
* custo layout logic or tasks that involve walking the view hierarchy.
* To be deprecated, hopefully.
*/
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(RCTSparseArray *)shadowViewRegistry;
/**
* Informal protocol for setting view and shadowView properties.
* Implement methods matching these patterns to set any properties that
* require special treatment (e.g. where the type or name cannot be inferred).
*
* - (void)set_<propertyName>:(id)property
* forView:(UIView *)view
* withDefaultView:(UIView *)defaultView;
*
* - (void)set_<propertyName>:(id)property
* forShadowView:(RCTShadowView *)view
* withDefaultView:(RCTShadowView *)defaultView;
*
* For simple cases, use the macros below:
*/
/**
* This handles the simple case, where JS and native property names match
* And the type can be automatically inferred.
@@ -131,10 +121,21 @@ RCT_REMAP_VIEW_PROPERTY(name, name)
- (void)set_##name:(id)json forView:(id)view withDefaultView:(id)defaultView { \
if ((json && !RCTSetProperty(view, @#keypath, json)) || \
(!json && !RCTCopyProperty(view, defaultView, @#keypath))) { \
RCTLogMustFix(@"%@ does not have setter for `%s` property", [view class], #name); \
RCTLogError(@"%@ does not have setter for `%s` property", [view class], #name); \
} \
}
/**
* These macros can be used when you need to provide custom logic for setting
* view properties. The macro should be followed by a method body, which can
* refer to "json", "view" and "defaultView" to implement the required logic.
*/
#define RCT_CUSTOM_VIEW_PROPERTY(name, viewType) \
- (void)set_##name:(id)json forView:(viewType)view withDefaultView:(viewType)defaultView
#define RCT_CUSTOM_SHADOW_PROPERTY(name, viewType) \
- (void)set_##name:(id)json forShadowView:(viewType)view withDefaultView:(viewType)defaultView
/**
* These are useful in cases where the module's superclass handles a
* property, but you wish to "unhandle" it, so it will be ignored.

View File

@@ -8,7 +8,7 @@
*/
@protocol RCTViewNodeProtocol <NSObject>
@property (nonatomic, strong) NSNumber *reactTag;
@property (nonatomic, copy) NSNumber *reactTag;
- (void)insertReactSubview:(id<RCTViewNodeProtocol>)subview atIndex:(NSInteger)atIndex;
- (void)removeReactSubview:(id<RCTViewNodeProtocol>)subview;
@@ -21,6 +21,8 @@
@optional
// TODO: Deprecate this
// This method is called after layout has been performed for all views known
// to the RCTViewManager. It is only called on UIViews, not shadow views.
- (void)reactBridgeDidFinishTransaction;
@end

View File

@@ -15,8 +15,11 @@ didMoveToNavigationController:(UINavigationController *)navigationController;
@interface RCTWrapperViewController : UIViewController
- (instancetype)initWithContentView:(UIView *)contentView eventDispatcher:(RCTEventDispatcher *)eventDispatcher;
- (instancetype)initWithNavItem:(RCTNavItem *)navItem eventDispatcher:(RCTEventDispatcher *)eventDispatcher;
- (instancetype)initWithContentView:(UIView *)contentView
eventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithNavItem:(RCTNavItem *)navItem
eventDispatcher:(RCTEventDispatcher *)eventDispatcher;
@property (nonatomic, readwrite, weak) id<RCTWrapperViewControllerNavigationListener> navigationListener;
@property (nonatomic, strong, readwrite) RCTNavItem *navItem;

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,8 @@
@interface RCTNetworkImageView : UIView
- (instancetype)initWithFrame:(CGRect)frame imageDownloader:(RCTImageDownloader *)imageDownloader;
- (instancetype)initWithFrame:(CGRect)frame
imageDownloader:(RCTImageDownloader *)imageDownloader NS_DESIGNATED_INITIALIZER;
/**
* An image that will appear while the view is loading the image from the network,

View File

@@ -6,32 +6,16 @@
@class RCTBridge;
@class RCTEventDispatcher;
@class RCTRootView;
/**
* Utilities for constructing common response objects. When sending a
* systemError back to JS, it's important to describe whether or not it was a
* system error, or API usage error. System errors should never happen and are
* therefore logged using `RCTLogError()`. API usage errors are expected if the
* API is misused and will therefore not be logged using `RCTLogError()`. The JS
* application code is expected to handle them. Regardless of type, each error
* should be logged at most once.
*/
static inline NSDictionary *RCTSystemErrorObject(NSString *msg)
{
return @{@"systemError": msg ?: @""};
}
static inline NSDictionary *RCTAPIErrorObject(NSString *msg)
{
return @{@"apiError": msg ?: @""};
}
/**
* This block can be used to instantiate modules that require additional
* init parameters, or additional configuration prior to being used.
* The bridge will call this block to instatiate the modules, and will
* be responsible for invalidating/releasing them when the bridge is destroyed.
* For this reason, the block should always return new module instances, and
* module instances should not be shared between bridges.
*/
typedef NSArray *(^RCTBridgeModuleProviderBlock)(RCTBridge *bridge);
typedef NSArray *(^RCTBridgeModuleProviderBlock)(void);
/**
* Async batched bridge used to communicate with the JavaScript application.
@@ -42,12 +26,12 @@ typedef NSArray *(^RCTBridgeModuleProviderBlock)(RCTBridge *bridge);
* The designated initializer. This creates a new bridge on top of the specified
* executor. The bridge should then be used for all subsequent communication
* with the JavaScript code running in the executor. Modules will be automatically
* instantiated using the default contructor, but you can optionally pass in a
* module provider block to manually instantiate modules that require additional
* init parameters or configuration.
* instantiated using the default contructor, but you can optionally pass in an
* array of pre-initialized module instances if they require additional init
* parameters or configuration.
*/
- (instancetype)initWithJavaScriptExecutor:(id<RCTJavaScriptExecutor>)javaScriptExecutor
moduleProvider:(RCTBridgeModuleProviderBlock)block NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithExecutor:(id<RCTJavaScriptExecutor>)executor
moduleProvider:(RCTBridgeModuleProviderBlock)block NS_DESIGNATED_INITIALIZER;
/**
* This method is used to call functions in the JavaScript application context.
@@ -81,16 +65,6 @@ typedef NSArray *(^RCTBridgeModuleProviderBlock)(RCTBridge *bridge);
*/
@property (nonatomic, readonly) dispatch_queue_t shadowQueue;
// For use in implementing delegates, which may need to queue responses.
- (RCTResponseSenderBlock)createResponseSenderBlock:(NSInteger)callbackID;
/**
* Register a root view with the bridge. Theorectically, a single bridge can
* support multiple root views, however this feature is not currently exposed
* and may eventually be removed.
*/
- (void)registerRootView:(RCTRootView *)rootView;
/**
* Global logging function that will print to both xcode and JS debugger consoles.
*

View File

@@ -19,10 +19,12 @@ typedef void (^RCTResponseSenderBlock)(NSArray *response);
@optional
/**
* Optional initializer for modules that require access
* to bridge features, such as sending events or making JS calls
* A reference to the RCTBridge. Useful for modules that require access
* to bridge features, such as sending events or making JS calls. This
* will be set automatically by the bridge when it initializes the module.
* To implement this in your module, just add @synthesize bridge = _bridge;
*/
- (instancetype)initWithBridge:(RCTBridge *)bridge;
@property (nonatomic, strong) RCTBridge *bridge;
/**
* The module name exposed to JS. If omitted, this will be inferred
@@ -42,17 +44,11 @@ typedef void (^RCTResponseSenderBlock)(NSArray *response);
/**
* Injects constants into JS. These constants are made accessible via
* NativeModules.moduleName.X. Note that this method is not inherited when you
* subclass a module, and you should not call [super constantsToExport] when
* implementing it.
*/
+ (NSDictionary *)constantsToExport;
/**
* Some "constants" are not really constant, and need to be re-generated
* each time the bridge module is created. Support for this feature is
* deprecated and may be going away or changing, but for now you can use
* the -constantsToExport instance method to register these "pseudo-constants".
* NativeModules.ModuleName.X. This method is called when the module is
* registered by the bridge. It is only called once for the lifetime of the
* bridge, so it is not suitable for returning dynamic values, but may be
* used for long-lived values such as session keys, that are regenerated only
* as part of a reload of the entire React application.
*/
- (NSDictionary *)constantsToExport;

View File

@@ -5,7 +5,7 @@
#import "RCTInvalidating.h"
typedef void (^RCTJavaScriptCompleteBlock)(NSError *error);
typedef void (^RCTJavaScriptCallback)(id objcValue, NSError *error);
typedef void (^RCTJavaScriptCallback)(id json, NSError *error);
/**
* Abstracts away a JavaScript execution context - we may be running code in a

View File

@@ -0,0 +1,7 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#import "RCTBridgeModule.h"
@interface RCTLocationObserver : NSObject<RCTBridgeModule>
@end

View File

@@ -20,28 +20,22 @@
// If defined, only log messages that match this regex will fatal
#define RCTLOG_FATAL_REGEX nil
#define _RCTLog(__RCTLog__level, ...) do { \
NSString *__RCTLog__levelStr; \
switch(__RCTLog__level) { \
case RCTLOG_INFO: __RCTLog__levelStr = @"info"; break; \
case RCTLOG_WARN: __RCTLog__levelStr = @"warn"; break; \
case RCTLOG_ERROR: __RCTLog__levelStr = @"error"; break; \
case RCTLOG_MUSTFIX: __RCTLog__levelStr = @"mustfix"; break; \
} \
NSString *__RCTLog__msg = _RCTLogObjects(RCTLogFormat(__VA_ARGS__), __RCTLog__levelStr); \
if (__RCTLog__level >= RCTLOG_FATAL_LEVEL) { \
BOOL __RCTLog__fail = YES; \
if (RCTLOG_FATAL_REGEX) { \
NSError *__RCTLog__e; \
NSRegularExpression *__RCTLog__regex = [NSRegularExpression regularExpressionWithPattern:RCTLOG_FATAL_REGEX options:0 error:&__RCTLog__e]; \
__RCTLog__fail = [__RCTLog__regex numberOfMatchesInString:__RCTLog__msg options:0 range:NSMakeRange(0, [__RCTLog__msg length])] > 0; \
} \
RCTCAssert(!__RCTLog__fail, @"RCTLOG_FATAL_LEVEL %@: %@", __RCTLog__levelStr, __RCTLog__msg); \
} \
if (__RCTLog__level >= RCTLOG_REDBOX_LEVEL) { \
RCTRedBox *__RCTLog__redBox = [RCTRedBox sharedInstance]; \
[__RCTLog__redBox showErrorMessage:__RCTLog__msg]; \
} \
extern __unsafe_unretained NSString *RCTLogLevels[];
#define _RCTLog(_level, ...) do { \
NSString *__RCTLog__levelStr = RCTLogLevels[_level - 1]; \
NSString *__RCTLog__msg = RCTLogObjects(RCTLogFormat(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__), __RCTLog__levelStr); \
if (_level >= RCTLOG_FATAL_LEVEL) { \
BOOL __RCTLog__fail = YES; \
if (RCTLOG_FATAL_REGEX) { \
NSRegularExpression *__RCTLog__regex = [NSRegularExpression regularExpressionWithPattern:RCTLOG_FATAL_REGEX options:0 error:NULL]; \
__RCTLog__fail = [__RCTLog__regex numberOfMatchesInString:__RCTLog__msg options:0 range:NSMakeRange(0, [__RCTLog__msg length])] > 0; \
} \
RCTCAssert(!__RCTLog__fail, @"RCTLOG_FATAL_LEVEL %@: %@", __RCTLog__levelStr, __RCTLog__msg); \
} \
if (_level >= RCTLOG_REDBOX_LEVEL) { \
[[RCTRedBox sharedInstance] showErrorMessage:__RCTLog__msg]; \
} \
} while (0)
#define RCTLog(...) _RCTLog(RCTLOG_INFO, __VA_ARGS__)
@@ -50,20 +44,15 @@
#define RCTLogError(...) _RCTLog(RCTLOG_ERROR, __VA_ARGS__)
#define RCTLogMustFix(...) _RCTLog(RCTLOG_MUSTFIX, __VA_ARGS__)
#define RCTLogFormat(...) _RCTLogFormat(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
#define RCTLogFormatString(...) _RCTLogFormatString(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
#ifdef __cplusplus
extern "C" {
#endif
NSString *_RCTLogObjects(NSArray *objects, NSString *level);
NSArray *_RCTLogFormat(const char *file, int lineNumber, const char *funcName, NSString *format, ...) NS_FORMAT_FUNCTION(4,5);
NSString *_RCTLogFormatString(const char *file, int lineNumber, const char *funcName, NSString *format, ...) NS_FORMAT_FUNCTION(4,5);
NSString *RCTLogObjects(NSArray *objects, NSString *level);
NSArray *RCTLogFormat(const char *file, int lineNumber, const char *funcName, NSString *format, ...) NS_FORMAT_FUNCTION(4,5);
void RCTInjectLogFunction(void (^logFunction)(NSString *msg));
#ifdef __cplusplus
}
#endif
typedef void (^RCTLogFunction)(NSString *format, NSString *str);
void RCTInjectLogFunction(RCTLogFunction func);

View File

@@ -11,7 +11,7 @@
@property (nonatomic, strong) UIView *reactNavSuperviewLink;
@property (nonatomic, assign) NSInteger requestedTopOfStack;
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher;
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
/**
* Schedules a JavaScript navigation and prevents `UIKit` from navigating until

View File

@@ -12,6 +12,8 @@
@interface RCTScrollView : RCTView <UIScrollViewDelegate, RCTScrollableProtocol, RCTAutoInsetsProtocol>
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
/**
* If the `contentSize` is not provided, then the `contentSize` will
* automatically be determined by the size of the `RKScrollView` subview.
@@ -32,6 +34,4 @@
@property (nonatomic, assign) BOOL centerContent;
@property (nonatomic, copy) NSArray *stickyHeaderIndices;
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher;
@end

View File

@@ -3,29 +3,15 @@
#import <UIKit/UIKit.h>
#import "Layout.h"
#import "RCTUIManager.h"
#import "RCTViewNodeProtocol.h"
@class RCTSparseArray;
// TODO: amalgamate these enums?
typedef NS_ENUM(NSUInteger, RCTLayoutLifecycle) {
RCTLayoutLifecycleUninitialized = 0,
RCTLayoutLifecycleComputed,
RCTLayoutLifecycleDirtied,
};
// TODO: is this still needed?
typedef NS_ENUM(NSUInteger, RCTPropagationLifecycle) {
RCTPropagationLifecycleUninitialized = 0,
RCTPropagationLifecycleComputed,
RCTPropagationLifecycleDirtied,
};
// TODO: move this to text node?
typedef NS_ENUM(NSUInteger, RCTTextLifecycle) {
RCTTextLifecycleUninitialized = 0,
RCTTextLifecycleComputed,
RCTTextLifecycleDirtied,
typedef NS_ENUM(NSUInteger, RCTUpdateLifecycle) {
RCTUpdateLifecycleUninitialized = 0,
RCTUpdateLifecycleComputed,
RCTUpdateLifecycleDirtied,
};
// TODO: is this redundact now?
@@ -48,7 +34,7 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *);
@property (nonatomic, copy) NSString *moduleName;
@property (nonatomic, assign) BOOL isBGColorExplicitlySet; // Used to propogate to children
@property (nonatomic, strong) UIColor *backgroundColor; // Used to propogate to children
@property (nonatomic, assign) RCTLayoutLifecycle layoutLifecycle;
@property (nonatomic, assign) RCTUpdateLifecycle layoutLifecycle;
/**
* isNewView - Used to track the first time the view is introduced into the hierarchy. It is initialized YES, then is
@@ -122,11 +108,23 @@ typedef void (^RCTApplierBlock)(RCTSparseArray *);
@property (nonatomic, assign) css_wrap_type_t flexWrap;
@property (nonatomic, assign) CGFloat flex;
- (void)collectUpdatedProperties:(NSMutableSet *)viewsWithNewProperties parentProperties:(NSDictionary *)parentProperties;
- (void)collectRootUpdatedFrames:(NSMutableSet *)viewsWithNewFrame parentConstraint:(CGSize)parentConstraint;
- (void)fillCSSNode:(css_node_t *)node;
/**
* Calculate property changes that need to be propagated to the view.
* The applierBlocks set contains RCTApplierBlock functions that must be applied
* on the main thread in order to update the view.
*/
- (void)collectUpdatedProperties:(NSMutableSet *)applierBlocks parentProperties:(NSDictionary *)parentProperties;
// The following are implementation details exposed to subclasses. Do not call them directly
/**
* Calculate all views whose frame needs updating after layout has been calculated.
* The viewsWithNewFrame set contains the reactTags of the views that need updating.
*/
- (void)collectRootUpdatedFrames:(NSMutableSet *)viewsWithNewFrame parentConstraint:(CGSize)parentConstraint;
/**
* The following are implementation details exposed to subclasses. Do not call them directly
*/
- (void)fillCSSNode:(css_node_t *)node;
- (void)dirtyLayout;
- (BOOL)isLayoutDirty;

View File

@@ -10,6 +10,6 @@
@property (nonatomic, assign) BOOL autoCorrect;
@property (nonatomic, assign) UIEdgeInsets paddingEdgeInsets; // TODO: contentInset
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher;
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
@end

View File

@@ -8,7 +8,7 @@
@interface RCTTouchHandler : UIGestureRecognizer<RCTInvalidating>
- (instancetype)initWithBridge:(RCTBridge *)bridge;
- (instancetype)initWithBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;
- (void)startOrResetInteractionTiming;
- (NSDictionary *)endAndResetInteractionTiming;

View File

@@ -2,13 +2,18 @@
#import <UIKit/UIKit.h>
#import "RCTBridge.h"
#import "RCTBridgeModule.h"
#import "RCTInvalidating.h"
#import "RCTViewManager.h"
@class RCTRootView;
@protocol RCTScrollableProtocol;
/**
* The RCTUIManager is the module responsible for updating the view hierarchy.
*/
@interface RCTUIManager : NSObject <RCTBridgeModule, RCTInvalidating>
@property (nonatomic, weak) id<RCTScrollableProtocol> mainScrollView;
@@ -19,8 +24,33 @@
*/
@property (nonatomic, readwrite, weak) id<UIScrollViewDelegate> nativeMainScrollDelegate;
/**
* Register a root view with the RCTUIManager. Theoretically, a single manager
* can support multiple root views, however this feature is not currently exposed
* and may eventually be removed.
*/
- (void)registerRootView:(RCTRootView *)rootView;
/**
* Schedule a block to be executed on the UI thread. Useful if you need to execute
* view logic after all currently queued view updates have completed.
*/
- (void)addUIBlock:(RCTViewManagerUIBlock)block;
/**
* The view that is currently first responder, according to the JS context.
*/
+ (UIView *)JSResponder;
@end
/**
* This category makes the current RCTUIManager instance available via the
* RCTBridge, which is useful for RCTBridgeModules or RCTViewManagers that
* need to access the RCTUIManager.
*/
@interface RCTBridge (RCTUIManager)
@property (nonatomic, readonly) RCTUIManager *uiManager;
@end

View File

@@ -1,17 +1,15 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#import <tgmath.h>
#import <CoreGraphics/CoreGraphics.h>
#import <Foundation/Foundation.h>
#import <tgmath.h>
#import "RCTAssert.h"
// Macro to indicate when inherited initializer is not to be used
#define RCT_NOT_DESIGNATED_INITIALIZER() \
do { \
RCTAssert(NO, @"%@ is not the designated initializer for instances of %@.", NSStringFromSelector(_cmd), [self class]); \
return nil; \
} while (0)
#ifdef __cplusplus
extern "C" {
#endif
// Utility functions for JSON object <-> string serialization/deserialization
NSString *RCTJSONStringify(id jsonObject, NSError **error);
@@ -39,3 +37,10 @@ void RCTSwapInstanceMethods(Class cls, SEL original, SEL replacement);
// Module subclass support
BOOL RCTClassOverridesClassMethod(Class cls, SEL selector);
BOOL RCTClassOverridesInstanceMethod(Class cls, SEL selector);
// Enumerate all classes that conform to NSObject protocol
void RCTEnumerateClasses(void (^block)(Class cls));
#ifdef __cplusplus
}
#endif

View File

@@ -11,7 +11,6 @@
@interface RCTView : UIView
@property (nonatomic, assign) RCTPointerEvents pointerEvents;
@property (nonatomic, copy) NSString *overrideAccessibilityLabel;
+ (void)autoAdjustInsetsForView:(UIView<RCTAutoInsetsProtocol> *)parentView
withScrollView:(UIScrollView *)scrollView

View File

@@ -2,9 +2,11 @@
#import <UIKit/UIKit.h>
#import "RCTBridgeModule.h"
#import "RCTConvert.h"
#import "RCTLog.h"
@class RCTBridge;
@class RCTEventDispatcher;
@class RCTShadowView;
@class RCTSparseArray;
@@ -12,19 +14,22 @@
typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, RCTSparseArray *viewRegistry);
@interface RCTViewManager : NSObject
@interface RCTViewManager : NSObject <RCTBridgeModule>
/**
* Designated initializer for view modules. Override this when subclassing.
* The bridge can be used to access both the RCTUIIManager and the RCTEventDispatcher,
* allowing the manager (or the views that it manages) to manipulate the view
* hierarchy and send events back to the JS context.
*/
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
@property (nonatomic, strong) RCTBridge *bridge;
/**
* The event dispatcher is used to send events back to the JavaScript application.
* It can either be used directly by the module, or passed on to instantiated
* view subclasses so that they can handle their own events.
*/
@property (nonatomic, readonly, weak) RCTEventDispatcher *eventDispatcher;
// TODO: remove this, as it can be accessed directly from bridge
@property (nonatomic, readonly) RCTEventDispatcher *eventDispatcher;
/**
* The module name exposed to React JS. If omitted, this will be inferred
@@ -88,34 +93,19 @@ typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, RCTSparseArray *v
+ (NSDictionary *)customDirectEventTypes;
/**
* Injects constants into JS. These constants are made accessible via
* NativeModules.moduleName.X. Note that this method is not inherited when you
* subclass a view module, and you should not call [super constantsToExport]
* when overriding it.
* Called to notify manager that layout has finished, in case any calculated
* properties need to be copied over from shadow view to view.
*/
+ (NSDictionary *)constantsToExport;
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTShadowView *)shadowView;
/**
* To deprecate, hopefully
* Called after view hierarchy manipulation has finished, and all shadow props
* have been set, but before layout has been performed. Useful for performing
* custo layout logic or tasks that involve walking the view hierarchy.
* To be deprecated, hopefully.
*/
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(RCTSparseArray *)shadowViewRegistry;
/**
* Informal protocol for setting view and shadowView properties.
* Implement methods matching these patterns to set any properties that
* require special treatment (e.g. where the type or name cannot be inferred).
*
* - (void)set_<propertyName>:(id)property
* forView:(UIView *)view
* withDefaultView:(UIView *)defaultView;
*
* - (void)set_<propertyName>:(id)property
* forShadowView:(RCTShadowView *)view
* withDefaultView:(RCTShadowView *)defaultView;
*
* For simple cases, use the macros below:
*/
/**
* This handles the simple case, where JS and native property names match
* And the type can be automatically inferred.
@@ -131,10 +121,21 @@ RCT_REMAP_VIEW_PROPERTY(name, name)
- (void)set_##name:(id)json forView:(id)view withDefaultView:(id)defaultView { \
if ((json && !RCTSetProperty(view, @#keypath, json)) || \
(!json && !RCTCopyProperty(view, defaultView, @#keypath))) { \
RCTLogMustFix(@"%@ does not have setter for `%s` property", [view class], #name); \
RCTLogError(@"%@ does not have setter for `%s` property", [view class], #name); \
} \
}
/**
* These macros can be used when you need to provide custom logic for setting
* view properties. The macro should be followed by a method body, which can
* refer to "json", "view" and "defaultView" to implement the required logic.
*/
#define RCT_CUSTOM_VIEW_PROPERTY(name, viewType) \
- (void)set_##name:(id)json forView:(viewType)view withDefaultView:(viewType)defaultView
#define RCT_CUSTOM_SHADOW_PROPERTY(name, viewType) \
- (void)set_##name:(id)json forShadowView:(viewType)view withDefaultView:(viewType)defaultView
/**
* These are useful in cases where the module's superclass handles a
* property, but you wish to "unhandle" it, so it will be ignored.

View File

@@ -8,7 +8,7 @@
*/
@protocol RCTViewNodeProtocol <NSObject>
@property (nonatomic, strong) NSNumber *reactTag;
@property (nonatomic, copy) NSNumber *reactTag;
- (void)insertReactSubview:(id<RCTViewNodeProtocol>)subview atIndex:(NSInteger)atIndex;
- (void)removeReactSubview:(id<RCTViewNodeProtocol>)subview;
@@ -21,6 +21,8 @@
@optional
// TODO: Deprecate this
// This method is called after layout has been performed for all views known
// to the RCTViewManager. It is only called on UIViews, not shadow views.
- (void)reactBridgeDidFinishTransaction;
@end

View File

@@ -15,8 +15,11 @@ didMoveToNavigationController:(UINavigationController *)navigationController;
@interface RCTWrapperViewController : UIViewController
- (instancetype)initWithContentView:(UIView *)contentView eventDispatcher:(RCTEventDispatcher *)eventDispatcher;
- (instancetype)initWithNavItem:(RCTNavItem *)navItem eventDispatcher:(RCTEventDispatcher *)eventDispatcher;
- (instancetype)initWithContentView:(UIView *)contentView
eventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithNavItem:(RCTNavItem *)navItem
eventDispatcher:(RCTEventDispatcher *)eventDispatcher;
@property (nonatomic, readwrite, weak) id<RCTWrapperViewControllerNavigationListener> navigationListener;
@property (nonatomic, strong, readwrite) RCTNavItem *navItem;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,72 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
*
* @providesModule GeoLocationExample
*/
/* eslint no-console: 0 */
'use strict';
var React = require('react-native');
var {
StyleSheet,
Text,
View,
} = React;
exports.framework = 'React';
exports.title = 'GeoLocation';
exports.description = 'Examples of using the GeoLocation API.';
exports.examples = [
{
title: 'navigator.geolocation',
render: function() {
return <GeoLocationExample />;
},
}
];
var GeoLocationExample = React.createClass({
getInitialState: function() {
return {
initialPosition: 'unknown',
lastPosition: 'unknown',
};
},
componentDidMount: function() {
navigator.geolocation.getCurrentPosition(
(initialPosition) => this.setState({initialPosition}),
(error) => console.error(error)
);
this.watchID = navigator.geolocation.watchPosition((lastPosition) => {
this.setState({lastPosition});
});
},
componentWillUnmount: function() {
navigator.geolocation.clearWatch(this.watchID);
},
render: function() {
return (
<View>
<Text>
<Text style={styles.title}>Initial position: </Text>
{JSON.stringify(this.state.initialPosition)}
</Text>
<Text>
<Text style={styles.title}>Current position: </Text>
{JSON.stringify(this.state.lastPosition)}
</Text>
</View>
);
}
});
var styles = StyleSheet.create({
title: {
fontWeight: 'bold',
},
});

View File

@@ -34,6 +34,8 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>NSLocationWhenInUseUsageDescription</key>
<string>You need to add NSLocationWhenInUseUsageDescription key in Info.plist to enable geolocation, otherwise it is going to *fail silently*!</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>

View File

@@ -7,46 +7,46 @@
objects = {
/* Begin PBXBuildFile section */
1316A21A1AA397CA00C0188E /* libRCTNetworkImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1316A2101AA3871A00C0188E /* libRCTNetworkImage.a */; };
1316A21B1AA397CA00C0188E /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1316A2081AA386C700C0188E /* libRCTText.a */; };
1316A21C1AA397CA00C0188E /* libReactKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1316A2171AA3875D00C0188E /* libReactKit.a */; };
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
587651361A9EB175008B8F17 /* libRCTNetworkImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 587651281A9EB168008B8F17 /* libRCTNetworkImage.a */; };
587651371A9EB175008B8F17 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 587651301A9EB168008B8F17 /* libRCTText.a */; };
587651381A9EB175008B8F17 /* libReactKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 587651351A9EB168008B8F17 /* libReactKit.a */; };
587651571A9F862F008B8F17 /* libRCTDataManager.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5876514F1A9F8619008B8F17 /* libRCTDataManager.a */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
587651271A9EB168008B8F17 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 5876511C1A9EB168008B8F17 /* RCTNetworkImage.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 58B5115D1A9E6B3D00147676;
remoteInfo = RCTNetworkImage;
};
587651291A9EB168008B8F17 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 5876511C1A9EB168008B8F17 /* RCTNetworkImage.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 58B511681A9E6B3D00147676;
remoteInfo = RCTNetworkImageTests;
};
5876512F1A9EB168008B8F17 /* PBXContainerItemProxy */ = {
1316A2071AA386C700C0188E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 5876511F1A9EB168008B8F17 /* RCTText.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 58B5119B1A9E6C1200147676;
remoteInfo = RCTText;
};
587651311A9EB168008B8F17 /* PBXContainerItemProxy */ = {
1316A2091AA386C700C0188E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 5876511F1A9EB168008B8F17 /* RCTText.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 58B511A61A9E6C1300147676;
remoteInfo = RCTTextTests;
};
587651341A9EB168008B8F17 /* PBXContainerItemProxy */ = {
1316A20F1AA3871A00C0188E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 5876511C1A9EB168008B8F17 /* RCTNetworkImage.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 58B5115D1A9E6B3D00147676;
remoteInfo = RCTNetworkImage;
};
1316A2111AA3871A00C0188E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 5876511C1A9EB168008B8F17 /* RCTNetworkImage.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 58B511681A9E6B3D00147676;
remoteInfo = RCTNetworkImageTests;
};
1316A2161AA3875D00C0188E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 587651221A9EB168008B8F17 /* ReactKit.xcodeproj */;
proxyType = 2;
@@ -77,9 +77,9 @@
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
5876511C1A9EB168008B8F17 /* RCTNetworkImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetworkImage.xcodeproj; path = "/Users/sahrens/src/fbobjc-hg/Libraries/FBReactKit/js/react-native-github/Libraries/RCTStandardLibrary/../Image/RCTNetworkImage.xcodeproj"; sourceTree = "<absolute>"; };
5876511F1A9EB168008B8F17 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "/Users/sahrens/src/fbobjc-hg/Libraries/FBReactKit/js/react-native-github/Libraries/RCTStandardLibrary/../Text/RCTText.xcodeproj"; sourceTree = "<absolute>"; };
587651221A9EB168008B8F17 /* ReactKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactKit.xcodeproj; path = "/Users/sahrens/src/fbobjc-hg/Libraries/FBReactKit/js/react-native-github/Libraries/RCTStandardLibrary/../../ReactKit/ReactKit.xcodeproj"; sourceTree = "<absolute>"; };
5876511C1A9EB168008B8F17 /* RCTNetworkImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetworkImage.xcodeproj; path = ../../Libraries/Image/RCTNetworkImage.xcodeproj; sourceTree = SOURCE_ROOT; };
5876511F1A9EB168008B8F17 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = ../../Libraries/Text/RCTText.xcodeproj; sourceTree = SOURCE_ROOT; };
587651221A9EB168008B8F17 /* ReactKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactKit.xcodeproj; path = ../../ReactKit/ReactKit.xcodeproj; sourceTree = SOURCE_ROOT; };
587651491A9F8619008B8F17 /* RCTDataManager.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTDataManager.xcodeproj; path = ../../Libraries/Network/RCTDataManager.xcodeproj; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -88,16 +88,53 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
1316A21A1AA397CA00C0188E /* libRCTNetworkImage.a in Frameworks */,
1316A21B1AA397CA00C0188E /* libRCTText.a in Frameworks */,
1316A21C1AA397CA00C0188E /* libReactKit.a in Frameworks */,
587651571A9F862F008B8F17 /* libRCTDataManager.a in Frameworks */,
587651361A9EB175008B8F17 /* libRCTNetworkImage.a in Frameworks */,
587651371A9EB175008B8F17 /* libRCTText.a in Frameworks */,
587651381A9EB175008B8F17 /* libReactKit.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
1316A2031AA386C700C0188E /* Products */ = {
isa = PBXGroup;
children = (
1316A2081AA386C700C0188E /* libRCTText.a */,
1316A20A1AA386C700C0188E /* RCTTextTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
1316A20B1AA3871A00C0188E /* Products */ = {
isa = PBXGroup;
children = (
1316A2101AA3871A00C0188E /* libRCTNetworkImage.a */,
1316A2121AA3871A00C0188E /* RCTNetworkImageTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
1316A2131AA3875D00C0188E /* Products */ = {
isa = PBXGroup;
children = (
1316A2171AA3875D00C0188E /* libReactKit.a */,
);
name = Products;
sourceTree = "<group>";
};
1316A21D1AA397F400C0188E /* Libraries */ = {
isa = PBXGroup;
children = (
587651221A9EB168008B8F17 /* ReactKit.xcodeproj */,
587651491A9F8619008B8F17 /* RCTDataManager.xcodeproj */,
5876511C1A9EB168008B8F17 /* RCTNetworkImage.xcodeproj */,
5876511F1A9EB168008B8F17 /* RCTText.xcodeproj */,
);
name = Libraries;
sourceTree = "<group>";
};
13B07FAE1A68108700A75B9A /* UIExplorer */ = {
isa = PBXGroup;
children = (
@@ -111,32 +148,6 @@
name = UIExplorer;
sourceTree = "<group>";
};
5876511D1A9EB168008B8F17 /* Products */ = {
isa = PBXGroup;
children = (
587651281A9EB168008B8F17 /* libRCTNetworkImage.a */,
5876512A1A9EB168008B8F17 /* RCTNetworkImageTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
587651201A9EB168008B8F17 /* Products */ = {
isa = PBXGroup;
children = (
587651301A9EB168008B8F17 /* libRCTText.a */,
587651321A9EB168008B8F17 /* RCTTextTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
587651231A9EB168008B8F17 /* Products */ = {
isa = PBXGroup;
children = (
587651351A9EB168008B8F17 /* libReactKit.a */,
);
name = Products;
sourceTree = "<group>";
};
5876514A1A9F8619008B8F17 /* Products */ = {
isa = PBXGroup;
children = (
@@ -150,10 +161,7 @@
isa = PBXGroup;
children = (
13B07FAE1A68108700A75B9A /* UIExplorer */,
587651491A9F8619008B8F17 /* RCTDataManager.xcodeproj */,
5876511C1A9EB168008B8F17 /* RCTNetworkImage.xcodeproj */,
5876511F1A9EB168008B8F17 /* RCTText.xcodeproj */,
587651221A9EB168008B8F17 /* ReactKit.xcodeproj */,
1316A21D1AA397F400C0188E /* Libraries */,
83CBBA001A601CBA00E9B192 /* Products */,
);
sourceTree = "<group>";
@@ -212,15 +220,15 @@
ProjectRef = 587651491A9F8619008B8F17 /* RCTDataManager.xcodeproj */;
},
{
ProductGroup = 5876511D1A9EB168008B8F17 /* Products */;
ProductGroup = 1316A20B1AA3871A00C0188E /* Products */;
ProjectRef = 5876511C1A9EB168008B8F17 /* RCTNetworkImage.xcodeproj */;
},
{
ProductGroup = 587651201A9EB168008B8F17 /* Products */;
ProductGroup = 1316A2031AA386C700C0188E /* Products */;
ProjectRef = 5876511F1A9EB168008B8F17 /* RCTText.xcodeproj */;
},
{
ProductGroup = 587651231A9EB168008B8F17 /* Products */;
ProductGroup = 1316A2131AA3875D00C0188E /* Products */;
ProjectRef = 587651221A9EB168008B8F17 /* ReactKit.xcodeproj */;
},
);
@@ -232,39 +240,39 @@
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
587651281A9EB168008B8F17 /* libRCTNetworkImage.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTNetworkImage.a;
remoteRef = 587651271A9EB168008B8F17 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
5876512A1A9EB168008B8F17 /* RCTNetworkImageTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = RCTNetworkImageTests.xctest;
remoteRef = 587651291A9EB168008B8F17 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
587651301A9EB168008B8F17 /* libRCTText.a */ = {
1316A2081AA386C700C0188E /* libRCTText.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTText.a;
remoteRef = 5876512F1A9EB168008B8F17 /* PBXContainerItemProxy */;
remoteRef = 1316A2071AA386C700C0188E /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
587651321A9EB168008B8F17 /* RCTTextTests.xctest */ = {
1316A20A1AA386C700C0188E /* RCTTextTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = RCTTextTests.xctest;
remoteRef = 587651311A9EB168008B8F17 /* PBXContainerItemProxy */;
remoteRef = 1316A2091AA386C700C0188E /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
587651351A9EB168008B8F17 /* libReactKit.a */ = {
1316A2101AA3871A00C0188E /* libRCTNetworkImage.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTNetworkImage.a;
remoteRef = 1316A20F1AA3871A00C0188E /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
1316A2121AA3871A00C0188E /* RCTNetworkImageTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = RCTNetworkImageTests.xctest;
remoteRef = 1316A2111AA3871A00C0188E /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
1316A2171AA3875D00C0188E /* libReactKit.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libReactKit.a;
remoteRef = 587651341A9EB168008B8F17 /* PBXContainerItemProxy */;
remoteRef = 1316A2161AA3875D00C0188E /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
5876514F1A9F8619008B8F17 /* libRCTDataManager.a */ = {

View File

@@ -31,6 +31,7 @@ var EXAMPLES = [
require('./TouchableExample'),
require('./ActivityIndicatorExample'),
require('./ScrollViewExample'),
require('./GeoLocationExample'),
];
var UIExplorerList = React.createClass({