mirror of
https://github.com/status-im/react-native.git
synced 2025-01-14 03:26:07 +00:00
[React Native] Save UIExplorer search state
This commit is contained in:
parent
5eca2e1d3c
commit
1a17cceb17
@ -22,6 +22,7 @@
|
||||
14AADF051AC3DBB1002390C9 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14AADF041AC3DB95002390C9 /* libReact.a */; };
|
||||
14DC67F41AB71881001358AB /* libRCTPushNotification.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14DC67F11AB71876001358AB /* libRCTPushNotification.a */; };
|
||||
58005BF21ABA80A60062E044 /* libRCTTest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58005BEE1ABA80530062E044 /* libRCTTest.a */; };
|
||||
834C36EC1AF8DED70019C93C /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 834C36D21AF8DA610019C93C /* libRCTSettings.a */; };
|
||||
D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D85B829C1AB6D5CE003F4FE2 /* libRCTVibration.a */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
@ -156,6 +157,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
834C36EC1AF8DED70019C93C /* libRCTSettings.a in Frameworks */,
|
||||
14AADF051AC3DBB1002390C9 /* libReact.a in Frameworks */,
|
||||
00D2771A1AB8C3E100DC1E48 /* libRCTWebSocketDebugger.a in Frameworks */,
|
||||
58005BF21ABA80A60062E044 /* libRCTTest.a in Frameworks */,
|
||||
|
@ -28,6 +28,7 @@ var {
|
||||
} = React;
|
||||
|
||||
var { TestModule } = React.addons;
|
||||
var Settings = require('Settings');
|
||||
|
||||
var createExamplePage = require('./createExamplePage');
|
||||
|
||||
@ -114,9 +115,14 @@ class UIExplorerList extends React.Component {
|
||||
components: COMPONENTS,
|
||||
apis: APIS,
|
||||
}),
|
||||
searchText: Settings.get('searchText'),
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this._search(this.state.searchText);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.listContainer}>
|
||||
@ -128,6 +134,7 @@ class UIExplorerList extends React.Component {
|
||||
onChangeText={this._search.bind(this)}
|
||||
placeholder="Search..."
|
||||
style={styles.searchTextInput}
|
||||
value={this.state.searchText}
|
||||
/>
|
||||
</View>
|
||||
<ListView
|
||||
@ -177,8 +184,10 @@ class UIExplorerList extends React.Component {
|
||||
dataSource: ds.cloneWithRowsAndSections({
|
||||
components: COMPONENTS.filter(filter),
|
||||
apis: APIS.filter(filter),
|
||||
})
|
||||
}),
|
||||
searchText: text,
|
||||
});
|
||||
Settings.set({searchText: text});
|
||||
}
|
||||
|
||||
_onPressRow(example) {
|
||||
|
@ -26,8 +26,8 @@ var Settings = {
|
||||
},
|
||||
|
||||
set(settings: Object) {
|
||||
this._settings = merge(this._settings, settings);
|
||||
RCTSettingsManager.set(settings);
|
||||
this._settings = Object.assign(this._settings, settings);
|
||||
RCTSettingsManager.setValues(settings);
|
||||
},
|
||||
|
||||
watchKeys(keys: string | Array<string>, callback: Function): number {
|
||||
@ -52,11 +52,11 @@ var Settings = {
|
||||
},
|
||||
|
||||
_sendObservations(body: Object) {
|
||||
var $this = this;
|
||||
var _this = this;
|
||||
Object.keys(body).forEach((key) => {
|
||||
var newValue = body[key];
|
||||
var didChange = $this._settings[key] !== newValue;
|
||||
$this._settings[key] = newValue;
|
||||
var didChange = _this._settings[key] !== newValue;
|
||||
_this._settings[key] = newValue;
|
||||
|
||||
if (didChange) {
|
||||
subscriptions.forEach((sub) => {
|
||||
@ -71,7 +71,7 @@ var Settings = {
|
||||
|
||||
RCTDeviceEventEmitter.addListener(
|
||||
'settingsUpdated',
|
||||
Settings._sendObservations,
|
||||
Settings._sendObservations.bind(Settings)
|
||||
);
|
||||
|
||||
module.exports = Settings;
|
||||
|
Loading…
x
Reference in New Issue
Block a user