From 1a17cceb17ea9eaa820b0ecbedb10266980ba1ce Mon Sep 17 00:00:00 2001 From: Alex Akers Date: Tue, 5 May 2015 05:34:39 -0700 Subject: [PATCH] [React Native] Save UIExplorer search state --- .../UIExplorer/UIExplorer.xcodeproj/project.pbxproj | 2 ++ Examples/UIExplorer/UIExplorerList.js | 11 ++++++++++- Libraries/Settings/Settings.ios.js | 12 ++++++------ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj b/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj index 0d16e33e3..698fd3b3f 100644 --- a/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj +++ b/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj @@ -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 */, diff --git a/Examples/UIExplorer/UIExplorerList.js b/Examples/UIExplorer/UIExplorerList.js index a10d291bd..a24ec1a54 100644 --- a/Examples/UIExplorer/UIExplorerList.js +++ b/Examples/UIExplorer/UIExplorerList.js @@ -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 ( @@ -128,6 +134,7 @@ class UIExplorerList extends React.Component { onChangeText={this._search.bind(this)} placeholder="Search..." style={styles.searchTextInput} + value={this.state.searchText} /> , 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;