mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Add RCTDevSettings module
Summary: This decouples non-UI logic from RCTDevMenu into a new module RCTDevSettings. **Motivation**: This allows developers to change dev settings without depending on the built-in dev menu, e.g. if they want to introduce their own UI, or have other devtools logic that doesn't depend on an action sheet. It also introduces the RCTDevSettingsDataSource protocol for storing dev tools preferences. This could allow a developer to implement alternative behaviors, e.g. loading the settings from some other config, changing settings based on the user, deciding not to persist some settings, or something else. The included data source implementation, RCTDevSettingsUserDefaultsDataSource, uses NSUserDefaults and is backwards compatible with the older implementation, so **no workflows or dependent code will break, and old saved settings will persist.** The RCTDevMenu interface has not changed and is therefore also backwards-compatible, though some methods are now deprecated. In order to ensure that RCTDevSettings Closes https://github.com/facebook/react-native/pull/11613 Reviewed By: mmmulani Differential Revision: D4571773 Pulled By: javache fbshipit-source-id: 25555d0a6eaa81f694343e079ed02439e5845fbc
This commit is contained in:
committed by
Facebook Github Bot
parent
bb1f85183b
commit
6a14f0b449
@@ -20,59 +20,44 @@
|
||||
@interface RCTDevMenu : NSObject
|
||||
|
||||
/**
|
||||
* Is the menu enabled. The menu is enabled by default if RCT_DEV=1, but
|
||||
* you may wish to disable it so that you can provide your own shake handler.
|
||||
* Deprecated, use RCTDevSettings instead.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL shakeToShow;
|
||||
@property (nonatomic, assign) BOOL shakeToShow DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
* Enables performance profiling.
|
||||
* Deprecated, use RCTDevSettings instead.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL profilingEnabled;
|
||||
@property (nonatomic, assign) BOOL profilingEnabled DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
* Enables starting of profiling sampler on launch
|
||||
* Deprecated, use RCTDevSettings instead.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL startSamplingProfilerOnLaunch;
|
||||
@property (nonatomic, assign) BOOL liveReloadEnabled DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
* Enables automatic polling for JS code changes. Only applicable when
|
||||
* running the app from a server.
|
||||
* Deprecated, use RCTDevSettings instead.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL liveReloadEnabled;
|
||||
|
||||
/**
|
||||
* Enables hot loading. Currently not supported in open source.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL hotLoadingEnabled;
|
||||
|
||||
/**
|
||||
* Shows the FPS monitor for the JS and Main threads.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL showFPS;
|
||||
@property (nonatomic, assign) BOOL hotLoadingEnabled DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
* Presented items in development menu
|
||||
*/
|
||||
@property (nonatomic, copy, readonly) NSArray<RCTDevMenuItem *> *presentedItems;
|
||||
|
||||
|
||||
/**
|
||||
* Detect if actions sheet (development menu) is shown
|
||||
*/
|
||||
- (BOOL)isActionSheetShown;
|
||||
|
||||
|
||||
/**
|
||||
* Manually show the dev menu (can be called from JS).
|
||||
*/
|
||||
- (void)show;
|
||||
|
||||
/**
|
||||
* Manually reload the application. Equivalent to calling [bridge reload]
|
||||
* directly, but can be called from JS.
|
||||
* Deprecated, use -[RCTBRidge reload] instead.
|
||||
*/
|
||||
- (void)reload;
|
||||
- (void)reload DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
* Deprecated. Use the `-addItem:` method instead.
|
||||
@@ -88,6 +73,8 @@
|
||||
|
||||
@end
|
||||
|
||||
typedef NSString *(^RCTDevMenuItemTitleBlock)(void);
|
||||
|
||||
/**
|
||||
* Developer menu item, used to expose additional functionality via the menu.
|
||||
*/
|
||||
@@ -98,18 +85,16 @@
|
||||
* action.
|
||||
*/
|
||||
+ (instancetype)buttonItemWithTitle:(NSString *)title
|
||||
handler:(void(^)(void))handler;
|
||||
handler:(dispatch_block_t)handler;
|
||||
|
||||
/**
|
||||
* This creates an item with a toggle behavior. The key is used to store the
|
||||
* state of the toggle. For toggle items, the handler will be called immediately
|
||||
* after the item is added if the item was already selected when the module was
|
||||
* last loaded.
|
||||
* This creates an item with a simple push-button interface, used to trigger an
|
||||
* action. getTitleForPresentation is called each time the item is about to be
|
||||
* presented, and should return the item's title.
|
||||
*/
|
||||
+ (instancetype)toggleItemWithKey:(NSString *)key
|
||||
title:(NSString *)title
|
||||
selectedTitle:(NSString *)selectedTitle
|
||||
handler:(void(^)(BOOL selected))handler;
|
||||
+ (instancetype)buttonItemWithTitleBlock:(RCTDevMenuItemTitleBlock)titleBlock
|
||||
handler:(dispatch_block_t)handler;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user