├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── color-mobile ├── .babelrc ├── .buckconfig ├── .flowconfig ├── .watchmanconfig ├── ColorMobileSearchBox.js ├── MobileSearchBox.js ├── MobileSearchInput.js ├── MobileSearchResults.js ├── SearchBox.js ├── SearchView.js ├── __tests__ │ ├── index.android.js │ └── index.ios.js ├── android │ ├── app │ │ ├── BUCK │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── searchboxmobile │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── keystores │ │ ├── BUCK │ │ └── debug.keystore.properties │ └── settings.gradle ├── colors.js ├── crayola.json ├── index.android.js ├── index.ios.js ├── ios │ ├── SearchBoxMobile.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── SearchBoxMobile.xcscheme │ ├── SearchBoxMobile │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ │ └── LaunchScreen.xib │ │ ├── Images.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Info.plist │ │ └── main.m │ └── SearchBoxMobileTests │ │ ├── Info.plist │ │ └── SearchBoxMobileTests.m └── package.json ├── color-web ├── README.md ├── firebase.json ├── package.json ├── public │ ├── favicon.ico │ └── index.html └── src │ ├── ColorListItem.js │ ├── SearchBox.js │ ├── WebSearchBox.js │ ├── WebSearchInput.js │ ├── WebSearchResults.js │ ├── colors.js │ ├── crayola.json │ ├── index.css │ └── index.js ├── common ├── ColorListItem.js ├── MobileSearchBox.js ├── MobileSearchInput.js ├── MobileSearchResults.js ├── SearchBox.js ├── WebSearchBox.js ├── WebSearchBox.test.js ├── WebSearchInput.js ├── WebSearchResults.js ├── colors.js ├── crayola.json ├── package.json └── webpack.config.js ├── github-mobile ├── .babelrc ├── .buckconfig ├── .flowconfig ├── .gitattributes ├── .gitignore ├── .watchmanconfig ├── GitHubMobileSearchBox.js ├── MobileSearchBox.js ├── MobileSearchInput.js ├── MobileSearchResults.js ├── SearchBox.js ├── __tests__ │ ├── index.android.js │ └── index.ios.js ├── android │ ├── app │ │ ├── BUCK │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── githubmobile │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── keystores │ │ ├── BUCK │ │ └── debug.keystore.properties │ └── settings.gradle ├── github.js ├── index.android.js ├── index.ios.js ├── ios │ ├── GitHubMobile.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── GitHubMobile.xcscheme │ ├── GitHubMobile │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ │ └── LaunchScreen.xib │ │ ├── Images.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Info.plist │ │ └── main.m │ └── GitHubMobileTests │ │ ├── GitHubMobileTests.m │ │ └── Info.plist └── package.json └── github-web ├── README.md ├── firebase.json ├── package.json ├── public ├── favicon.ico └── index.html └── src ├── SearchBox.js ├── WebSearchBox.js ├── WebSearchInput.js ├── WebSearchResults.js ├── github.js ├── github.test.js ├── index.css └── index.js /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | color-mobile/node_modules/jest-file-exists/build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | android/app/libs 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 50 | 51 | fastlane/report.xml 52 | fastlane/Preview.html 53 | fastlane/screenshots 54 | 55 | # dependencies 56 | node_modules 57 | 58 | # testing 59 | coverage 60 | 61 | # production 62 | build 63 | 64 | .firebaserc -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Christian Sepulveda 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Search Box 2 | 3 | This repo contains the code for the [Medium tutorial](https://hackernoon.com/code-reuse-using-higher-order-hoc-and-stateless-functional-components-in-react-and-react-native-6eeb503c665) 4 | 5 | ##Code Reuse using Higher Order (HOC) and Stateless Functional Components in React and React Native 6 | 7 | 8 | The main branches are: 9 | 10 | ###master 11 | contains the final, refactored applications and reusable components 12 | 13 | ### [base-line-apps](https://github.com/csepulv/search-box/tree/baseline-apps) 14 | Contains README details for bootstrapping and building the initial React/web and React Native/mobile color search apps. 15 | 16 | 17 | ###[refactorings](https://github.com/csepulv/search-box/tree/refactorings) 18 | Contains README details and incremental refactorings to prepare components for reuse in a second set of applications. 19 | -------------------------------------------------------------------------------- /color-mobile/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"] 3 | } -------------------------------------------------------------------------------- /color-mobile/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /color-mobile/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 11 | ; Ignore duplicate module providers 12 | ; For RN Apps installed via npm, "Libraries" folder is inside 13 | ; "node_modules/react-native" but in the source repo it is in the root 14 | .*/Libraries/react-native/React.js 15 | .*/Libraries/react-native/ReactNative.js 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/Libraries/react-native/react-native-interface.js 21 | node_modules/react-native/flow 22 | flow/ 23 | 24 | [options] 25 | module.system=haste 26 | 27 | experimental.strict_type_args=true 28 | 29 | munge_underscores=true 30 | 31 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 32 | 33 | suppress_type=$FlowIssue 34 | suppress_type=$FlowFixMe 35 | suppress_type=$FixMe 36 | 37 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-6]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 38 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-6]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 39 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 40 | 41 | unsafe.enable_getters_and_setters=true 42 | 43 | [version] 44 | ^0.36.0 45 | -------------------------------------------------------------------------------- /color-mobile/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /color-mobile/ColorMobileSearchBox.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { 4 | StyleSheet, 5 | View, 6 | TextInput, 7 | ListView, 8 | Text 9 | } from 'react-native'; 10 | 11 | import MobileSearchBox from './MobileSearchBox'; 12 | 13 | const styles = StyleSheet.create({ 14 | row: { 15 | flexDirection: 'row', 16 | justifyContent: 'center', 17 | padding: 10 18 | }, 19 | text: { 20 | flex: 1, 21 | } 22 | }); 23 | 24 | const ColorListItem = ({result})=>{ 25 | return ( 26 | 27 | {result.name} 28 | 29 | ) 30 | }; 31 | const ColorSearchBox = MobileSearchBox(ColorListItem); 32 | export default ColorSearchBox; -------------------------------------------------------------------------------- /color-mobile/MobileSearchBox.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { 4 | StyleSheet, 5 | View, 6 | } from 'react-native'; 7 | 8 | import {observer} from 'mobx-react/native'; 9 | 10 | import MobileSearchInput from './MobileSearchInput'; 11 | import MobileSearchResults from './MobileSearchResults'; 12 | 13 | import SearchBox from './SearchBox' 14 | 15 | const styles = StyleSheet.create({ 16 | container: { 17 | flex: 1, 18 | backgroundColor: '#eeeeee', 19 | marginTop: 25 20 | } 21 | }); 22 | 23 | const MobileSearchFrame = ({children}) => { 24 | return ( 25 | 26 | {children} 27 | 28 | ); 29 | }; 30 | 31 | const MobileSearchBox = ListItem => observer(SearchBox(MobileSearchFrame, MobileSearchInput, MobileSearchResults(ListItem))); 32 | 33 | export default MobileSearchBox -------------------------------------------------------------------------------- /color-mobile/MobileSearchInput.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {TextInput} from 'react-native'; 3 | 4 | const MobileSearchInput = ({query, onSubmit, onQueryUpdate}) => { 5 | 6 | return ( 7 | onQueryUpdate(text)} 10 | value={query} 11 | returnKeyType={'search'} 12 | autoCapitalize={'none'} 13 | autoCorrect={false} 14 | onSubmitEditing={() => onSubmit()} 15 | /> 16 | ); 17 | 18 | }; 19 | 20 | MobileSearchInput.propTypes = { 21 | query: React.PropTypes.string.isRequired, 22 | onSubmit: React.PropTypes.func.isRequired, 23 | onQueryUpdate: React.PropTypes.func.isRequired 24 | }; 25 | 26 | export default MobileSearchInput; -------------------------------------------------------------------------------- /color-mobile/MobileSearchResults.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import { 3 | StyleSheet, 4 | View, 5 | TextInput, 6 | ListView, 7 | Text 8 | } from 'react-native'; 9 | const styles = StyleSheet.create({ 10 | separator: { 11 | flex: 1, 12 | height: 1, 13 | backgroundColor: '#8E8E8E', 14 | } 15 | }); 16 | 17 | const MobileSearchResults = ListItem => { 18 | return class extends Component { 19 | constructor(props) { 20 | super(props); 21 | this.dataSource = new ListView.DataSource({rowHasChanged: (r1, r2) => r1.name !== r2.name}); 22 | } 23 | 24 | static propTypes = { 25 | results: React.PropTypes.array.isRequired 26 | }; 27 | 28 | renderRow = (rowData, sectionId, rowID) => { 29 | return ( 30 | 31 | ); 32 | }; 33 | 34 | render() { 35 | return ( 36 | } 40 | /> 41 | ); 42 | } 43 | }; 44 | }; 45 | 46 | export default MobileSearchResults; -------------------------------------------------------------------------------- /color-mobile/SearchBox.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | 3 | const SearchBox = (SearchFrame, SearchInput, SearchResults) => { 4 | return class extends Component { 5 | static propTypes = { 6 | searchStore: React.PropTypes.object.isRequired 7 | }; 8 | 9 | render() { 10 | return ( 11 | 12 | this.props.searchStore.updateQuery(value)} 14 | onSubmit={() => this.props.searchStore.search()} 15 | /> 16 | 17 | 18 | ); 19 | } 20 | }; 21 | }; 22 | 23 | 24 | export default SearchBox -------------------------------------------------------------------------------- /color-mobile/SearchView.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import { 3 | StyleSheet, 4 | View, 5 | TextInput, 6 | ListView, 7 | Text 8 | } from 'react-native'; 9 | 10 | import {observer} from 'mobx-react/native'; 11 | 12 | const styles = StyleSheet.create({ 13 | container: { 14 | flex: 1, 15 | backgroundColor: '#eeeeee', 16 | marginTop: 25 17 | }, 18 | row: { 19 | flexDirection: 'row', 20 | justifyContent: 'center', 21 | padding: 10 22 | }, 23 | text: { 24 | flex: 1, 25 | }, 26 | separator: { 27 | flex: 1, 28 | height: 1, 29 | backgroundColor: '#8E8E8E', 30 | } 31 | }); 32 | 33 | const dataSource = new ListView.DataSource({rowHasChanged: (r1, r2) => r1.name !== r2.name}); 34 | 35 | export default observer(class SearchView extends Component { 36 | 37 | static propTypes = { 38 | colors: React.PropTypes.object.isRequired 39 | }; 40 | 41 | renderRow = (rowData, sectionId, rowID) => { 42 | return ( 43 | 44 | {rowData.name} 45 | 46 | ); 47 | }; 48 | 49 | render() { 50 | return ( 51 | 52 | this.props.colors.updateQuery(text)} 55 | value={this.props.colors.query} 56 | returnKeyType={'search'} 57 | onSubmitEditing={() => this.props.colors.search()} 58 | /> 59 | } 63 | /> 64 | 65 | 66 | ); 67 | } 68 | }); 69 | 70 | -------------------------------------------------------------------------------- /color-mobile/__tests__/index.android.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.android.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /color-mobile/__tests__/index.ios.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | 4 | 5 | // need following to fix 6 | // Invariant Violation: ReactUpdates: must inject a reconcile transaction class and batching strategy 7 | // https://wietse.loves.engineering/using-jest-with-react-native-and-mobx-34949ea7d2cf#.719t4c63f 8 | jest.mock('mobx-react/native', () => require('mobx-react/custom')); 9 | 10 | 11 | import Index from '../index.ios.js'; 12 | 13 | // Note: test renderer must be required after react-native. 14 | import renderer from 'react-test-renderer'; 15 | 16 | it('renders correctly', () => { 17 | const tree = renderer.create( 18 | 19 | ); 20 | }); 21 | -------------------------------------------------------------------------------- /color-mobile/android/app/BUCK: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | # To learn about Buck see [Docs](https://buckbuild.com/). 4 | # To run your application with Buck: 5 | # - install Buck 6 | # - `npm start` - to start the packager 7 | # - `cd android` 8 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 9 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 10 | # - `buck install -r android/app` - compile, install and run application 11 | # 12 | 13 | lib_deps = [] 14 | for jarfile in glob(['libs/*.jar']): 15 | name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) 16 | lib_deps.append(':' + name) 17 | prebuilt_jar( 18 | name = name, 19 | binary_jar = jarfile, 20 | ) 21 | 22 | for aarfile in glob(['libs/*.aar']): 23 | name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile) 24 | lib_deps.append(':' + name) 25 | android_prebuilt_aar( 26 | name = name, 27 | aar = aarfile, 28 | ) 29 | 30 | android_library( 31 | name = 'all-libs', 32 | exported_deps = lib_deps 33 | ) 34 | 35 | android_library( 36 | name = 'app-code', 37 | srcs = glob([ 38 | 'src/main/java/**/*.java', 39 | ]), 40 | deps = [ 41 | ':all-libs', 42 | ':build_config', 43 | ':res', 44 | ], 45 | ) 46 | 47 | android_build_config( 48 | name = 'build_config', 49 | package = 'com.searchboxmobile', 50 | ) 51 | 52 | android_resource( 53 | name = 'res', 54 | res = 'src/main/res', 55 | package = 'com.searchboxmobile', 56 | ) 57 | 58 | android_binary( 59 | name = 'app', 60 | package_type = 'debug', 61 | manifest = 'src/main/AndroidManifest.xml', 62 | keystore = '//android/keystores:debug', 63 | deps = [ 64 | ':app-code', 65 | ], 66 | ) 67 | -------------------------------------------------------------------------------- /color-mobile/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // the root of your project, i.e. where "package.json" lives 37 | * root: "../../", 38 | * 39 | * // where to put the JS bundle asset in debug mode 40 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 41 | * 42 | * // where to put the JS bundle asset in release mode 43 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 44 | * 45 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 46 | * // require('./image.png')), in debug mode 47 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 48 | * 49 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 50 | * // require('./image.png')), in release mode 51 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 52 | * 53 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 54 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 55 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 56 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 57 | * // for example, you might want to remove it from here. 58 | * inputExcludes: ["android/**", "ios/**"], 59 | * 60 | * // override which node gets called and with what additional arguments 61 | * nodeExecutableAndArgs: ["node"] 62 | * 63 | * // supply additional arguments to the packager 64 | * extraPackagerArgs: [] 65 | * ] 66 | */ 67 | 68 | apply from: "../../node_modules/react-native/react.gradle" 69 | 70 | /** 71 | * Set this to true to create two separate APKs instead of one: 72 | * - An APK that only works on ARM devices 73 | * - An APK that only works on x86 devices 74 | * The advantage is the size of the APK is reduced by about 4MB. 75 | * Upload all the APKs to the Play Store and people will download 76 | * the correct one based on the CPU architecture of their device. 77 | */ 78 | def enableSeparateBuildPerCPUArchitecture = false 79 | 80 | /** 81 | * Run Proguard to shrink the Java bytecode in release builds. 82 | */ 83 | def enableProguardInReleaseBuilds = false 84 | 85 | android { 86 | compileSdkVersion 23 87 | buildToolsVersion "23.0.1" 88 | 89 | defaultConfig { 90 | applicationId "com.searchboxmobile" 91 | minSdkVersion 16 92 | targetSdkVersion 22 93 | versionCode 1 94 | versionName "1.0" 95 | ndk { 96 | abiFilters "armeabi-v7a", "x86" 97 | } 98 | } 99 | splits { 100 | abi { 101 | reset() 102 | enable enableSeparateBuildPerCPUArchitecture 103 | universalApk false // If true, also generate a universal APK 104 | include "armeabi-v7a", "x86" 105 | } 106 | } 107 | buildTypes { 108 | release { 109 | minifyEnabled enableProguardInReleaseBuilds 110 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 111 | } 112 | } 113 | // applicationVariants are e.g. debug, release 114 | applicationVariants.all { variant -> 115 | variant.outputs.each { output -> 116 | // For each separate APK per architecture, set a unique version code as described here: 117 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 118 | def versionCodes = ["armeabi-v7a":1, "x86":2] 119 | def abi = output.getFilter(OutputFile.ABI) 120 | if (abi != null) { // null for the universal-debug, universal-release variants 121 | output.versionCodeOverride = 122 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 123 | } 124 | } 125 | } 126 | } 127 | 128 | dependencies { 129 | compile fileTree(dir: "libs", include: ["*.jar"]) 130 | compile "com.android.support:appcompat-v7:23.0.1" 131 | compile "com.facebook.react:react-native:+" // From node_modules 132 | } 133 | 134 | // Run this once to be able to run the application with BUCK 135 | // puts all compile dependencies into folder libs for BUCK to use 136 | task copyDownloadableDepsToLibs(type: Copy) { 137 | from configurations.compile 138 | into 'libs' 139 | } 140 | -------------------------------------------------------------------------------- /color-mobile/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Disabling obfuscation is useful if you collect stack traces from production crashes 20 | # (unless you are using a system that supports de-obfuscate the stack traces). 21 | -dontobfuscate 22 | 23 | # React Native 24 | 25 | # Keep our interfaces so they can be used by other ProGuard rules. 26 | # See http://sourceforge.net/p/proguard/bugs/466/ 27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 30 | 31 | # Do not strip any method/class that is annotated with @DoNotStrip 32 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 33 | -keep @com.facebook.common.internal.DoNotStrip class * 34 | -keepclassmembers class * { 35 | @com.facebook.proguard.annotations.DoNotStrip *; 36 | @com.facebook.common.internal.DoNotStrip *; 37 | } 38 | 39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 40 | void set*(***); 41 | *** get*(); 42 | } 43 | 44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 46 | -keepclassmembers,includedescriptorclasses class * { native ; } 47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 50 | 51 | -dontwarn com.facebook.react.** 52 | 53 | # okhttp 54 | 55 | -keepattributes Signature 56 | -keepattributes *Annotation* 57 | -keep class okhttp3.** { *; } 58 | -keep interface okhttp3.** { *; } 59 | -dontwarn okhttp3.** 60 | 61 | # okio 62 | 63 | -keep class sun.misc.Unsafe { *; } 64 | -dontwarn java.nio.file.* 65 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 66 | -dontwarn okio.** 67 | -------------------------------------------------------------------------------- /color-mobile/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /color-mobile/android/app/src/main/java/com/searchboxmobile/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.searchboxmobile; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "SearchBoxMobile"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /color-mobile/android/app/src/main/java/com/searchboxmobile/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.searchboxmobile; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactInstanceManager; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.react.shell.MainReactPackage; 11 | import com.facebook.soloader.SoLoader; 12 | 13 | import java.util.Arrays; 14 | import java.util.List; 15 | 16 | public class MainApplication extends Application implements ReactApplication { 17 | 18 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 19 | @Override 20 | protected boolean getUseDeveloperSupport() { 21 | return BuildConfig.DEBUG; 22 | } 23 | 24 | @Override 25 | protected List getPackages() { 26 | return Arrays.asList( 27 | new MainReactPackage() 28 | ); 29 | } 30 | }; 31 | 32 | @Override 33 | public ReactNativeHost getReactNativeHost() { 34 | return mReactNativeHost; 35 | } 36 | 37 | @Override 38 | public void onCreate() { 39 | super.onCreate(); 40 | SoLoader.init(this, /* native exopackage */ false); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /color-mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csepulv/search-box/7c836c4acbf2ce87e4e8596fec2bdae7b690499e/color-mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /color-mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csepulv/search-box/7c836c4acbf2ce87e4e8596fec2bdae7b690499e/color-mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /color-mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csepulv/search-box/7c836c4acbf2ce87e4e8596fec2bdae7b690499e/color-mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /color-mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csepulv/search-box/7c836c4acbf2ce87e4e8596fec2bdae7b690499e/color-mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /color-mobile/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | SearchBoxMobile 3 | 4 | -------------------------------------------------------------------------------- /color-mobile/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /color-mobile/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.3.1' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenLocal() 18 | jcenter() 19 | maven { 20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 21 | url "$rootDir/../node_modules/react-native/android" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /color-mobile/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /color-mobile/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csepulv/search-box/7c836c4acbf2ce87e4e8596fec2bdae7b690499e/color-mobile/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /color-mobile/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip 6 | -------------------------------------------------------------------------------- /color-mobile/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /color-mobile/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /color-mobile/android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = 'debug', 3 | store = 'debug.keystore', 4 | properties = 'debug.keystore.properties', 5 | visibility = [ 6 | 'PUBLIC', 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /color-mobile/android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /color-mobile/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'SearchBoxMobile' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /color-mobile/colors.js: -------------------------------------------------------------------------------- 1 | import {extendObservable, runInAction} from 'mobx'; 2 | import crayola from './crayola.json' 3 | 4 | export default class Colors { 5 | constructor() { 6 | extendObservable(this, { 7 | results: [], 8 | query: '' 9 | }); 10 | } 11 | 12 | search() { 13 | runInAction(() => { 14 | this.results = crayola.filter(color => color.name.toLowerCase().includes(this.query.toLowerCase())); 15 | }); 16 | } 17 | 18 | updateQuery(value) { 19 | runInAction(() => this.query = value); 20 | } 21 | } -------------------------------------------------------------------------------- /color-mobile/crayola.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "hex": "#EFDECD", 4 | "name": "Almond", 5 | "rgb": "(239, 222, 205)" 6 | }, 7 | { 8 | "hex": "#CD9575", 9 | "name": "Antique Brass", 10 | "rgb": "(205, 149, 117)" 11 | }, 12 | { 13 | "hex": "#FDD9B5", 14 | "name": "Apricot", 15 | "rgb": "(253, 217, 181)" 16 | }, 17 | { 18 | "hex": "#78DBE2", 19 | "name": "Aquamarine", 20 | "rgb": "(120, 219, 226)" 21 | }, 22 | { 23 | "hex": "#87A96B", 24 | "name": "Asparagus", 25 | "rgb": "(135, 169, 107)" 26 | }, 27 | { 28 | "hex": "#FFA474", 29 | "name": "Atomic Tangerine", 30 | "rgb": "(255, 164, 116)" 31 | }, 32 | { 33 | "hex": "#FAE7B5", 34 | "name": "Banana Mania", 35 | "rgb": "(250, 231, 181)" 36 | }, 37 | { 38 | "hex": "#9F8170", 39 | "name": "Beaver", 40 | "rgb": "(159, 129, 112)" 41 | }, 42 | { 43 | "hex": "#FD7C6E", 44 | "name": "Bittersweet", 45 | "rgb": "(253, 124, 110)" 46 | }, 47 | { 48 | "hex": "#000000", 49 | "name": "Black", 50 | "rgb": "(0,0,0)" 51 | }, 52 | { 53 | "hex": "#ACE5EE", 54 | "name": "Blizzard Blue", 55 | "rgb": "(172, 229, 238)" 56 | }, 57 | { 58 | "hex": "#1F75FE", 59 | "name": "Blue", 60 | "rgb": "(31, 117, 254)" 61 | }, 62 | { 63 | "hex": "#A2A2D0", 64 | "name": "Blue Bell", 65 | "rgb": "(162, 162, 208)" 66 | }, 67 | { 68 | "hex": "#6699CC", 69 | "name": "Blue Gray", 70 | "rgb": "(102, 153, 204)" 71 | }, 72 | { 73 | "hex": "#0D98BA", 74 | "name": "Blue Green", 75 | "rgb": "(13, 152, 186)" 76 | }, 77 | { 78 | "hex": "#7366BD", 79 | "name": "Blue Violet", 80 | "rgb": "(115, 102, 189)" 81 | }, 82 | { 83 | "hex": "#DE5D83", 84 | "name": "Blush", 85 | "rgb": "(222, 93, 131)" 86 | }, 87 | { 88 | "hex": "#CB4154", 89 | "name": "Brick Red", 90 | "rgb": "(203, 65, 84)" 91 | }, 92 | { 93 | "hex": "#B4674D", 94 | "name": "Brown", 95 | "rgb": "(180, 103, 77)" 96 | }, 97 | { 98 | "hex": "#FF7F49", 99 | "name": "Burnt Orange", 100 | "rgb": "(255, 127, 73)" 101 | }, 102 | { 103 | "hex": "#EA7E5D", 104 | "name": "Burnt Sienna", 105 | "rgb": "(234, 126, 93)" 106 | }, 107 | { 108 | "hex": "#B0B7C6", 109 | "name": "Cadet Blue", 110 | "rgb": "(176, 183, 198)" 111 | }, 112 | { 113 | "hex": "#FFFF99", 114 | "name": "Canary", 115 | "rgb": "(255, 255, 153)" 116 | }, 117 | { 118 | "hex": "#1CD3A2", 119 | "name": "Caribbean Green", 120 | "rgb": "(28, 211, 162)" 121 | }, 122 | { 123 | "hex": "#FFAACC", 124 | "name": "Carnation Pink", 125 | "rgb": "(255, 170, 204)" 126 | }, 127 | { 128 | "hex": "#DD4492", 129 | "name": "Cerise", 130 | "rgb": "(221, 68, 146)" 131 | }, 132 | { 133 | "hex": "#1DACD6", 134 | "name": "Cerulean", 135 | "rgb": "(29, 172, 214)" 136 | }, 137 | { 138 | "hex": "#BC5D58", 139 | "name": "Chestnut", 140 | "rgb": "(188, 93, 88)" 141 | }, 142 | { 143 | "hex": "#DD9475", 144 | "name": "Copper", 145 | "rgb": "(221, 148, 117)" 146 | }, 147 | { 148 | "hex": "#9ACEEB", 149 | "name": "Cornflower", 150 | "rgb": "(154, 206, 235)" 151 | }, 152 | { 153 | "hex": "#FFBCD9", 154 | "name": "Cotton Candy", 155 | "rgb": "(255, 188, 217)" 156 | }, 157 | { 158 | "hex": "#FDDB6D", 159 | "name": "Dandelion", 160 | "rgb": "(253, 219, 109)" 161 | }, 162 | { 163 | "hex": "#2B6CC4", 164 | "name": "Denim", 165 | "rgb": "(43, 108, 196)" 166 | }, 167 | { 168 | "hex": "#EFCDB8", 169 | "name": "Desert Sand", 170 | "rgb": "(239, 205, 184)" 171 | }, 172 | { 173 | "hex": "#6E5160", 174 | "name": "Eggplant", 175 | "rgb": "(110, 81, 96)" 176 | }, 177 | { 178 | "hex": "#CEFF1D", 179 | "name": "Electric Lime", 180 | "rgb": "(206, 255, 29)" 181 | }, 182 | { 183 | "hex": "#71BC78", 184 | "name": "Fern", 185 | "rgb": "(113, 188, 120)" 186 | }, 187 | { 188 | "hex": "#6DAE81", 189 | "name": "Forest Green", 190 | "rgb": "(109, 174, 129)" 191 | }, 192 | { 193 | "hex": "#C364C5", 194 | "name": "Fuchsia", 195 | "rgb": "(195, 100, 197)" 196 | }, 197 | { 198 | "hex": "#CC6666", 199 | "name": "Fuzzy Wuzzy", 200 | "rgb": "(204, 102, 102)" 201 | }, 202 | { 203 | "hex": "#E7C697", 204 | "name": "Gold", 205 | "rgb": "(231, 198, 151)" 206 | }, 207 | { 208 | "hex": "#FCD975", 209 | "name": "Goldenrod", 210 | "rgb": "(252, 217, 117)" 211 | }, 212 | { 213 | "hex": "#A8E4A0", 214 | "name": "Granny Smith Apple", 215 | "rgb": "(168, 228, 160)" 216 | }, 217 | { 218 | "hex": "#95918C", 219 | "name": "Gray", 220 | "rgb": "(149, 145, 140)" 221 | }, 222 | { 223 | "hex": "#1CAC78", 224 | "name": "Green", 225 | "rgb": "(28, 172, 120)" 226 | }, 227 | { 228 | "hex": "#1164B4", 229 | "name": "Green Blue", 230 | "rgb": "(17, 100, 180)" 231 | }, 232 | { 233 | "hex": "#F0E891", 234 | "name": "Green Yellow", 235 | "rgb": "(240, 232, 145)" 236 | }, 237 | { 238 | "hex": "#FF1DCE", 239 | "name": "Hot Magenta", 240 | "rgb": "(255, 29, 206)" 241 | }, 242 | { 243 | "hex": "#B2EC5D", 244 | "name": "Inchworm", 245 | "rgb": "(178, 236, 93)" 246 | }, 247 | { 248 | "hex": "#5D76CB", 249 | "name": "Indigo", 250 | "rgb": "(93, 118, 203)" 251 | }, 252 | { 253 | "hex": "#CA3767", 254 | "name": "Jazzberry Jam", 255 | "rgb": "(202, 55, 103)" 256 | }, 257 | { 258 | "hex": "#3BB08F", 259 | "name": "Jungle Green", 260 | "rgb": "(59, 176, 143)" 261 | }, 262 | { 263 | "hex": "#FEFE22", 264 | "name": "Laser Lemon", 265 | "rgb": "(254, 254, 34)" 266 | }, 267 | { 268 | "hex": "#FCB4D5", 269 | "name": "Lavender", 270 | "rgb": "(252, 180, 213)" 271 | }, 272 | { 273 | "hex": "#FFF44F", 274 | "name": "Lemon Yellow", 275 | "rgb": "(255, 244, 79)" 276 | }, 277 | { 278 | "hex": "#FFBD88", 279 | "name": "Macaroni and Cheese", 280 | "rgb": "(255, 189, 136)" 281 | }, 282 | { 283 | "hex": "#F664AF", 284 | "name": "Magenta", 285 | "rgb": "(246, 100, 175)" 286 | }, 287 | { 288 | "hex": "#AAF0D1", 289 | "name": "Magic Mint", 290 | "rgb": "(170, 240, 209)" 291 | }, 292 | { 293 | "hex": "#CD4A4C", 294 | "name": "Mahogany", 295 | "rgb": "(205, 74, 76)" 296 | }, 297 | { 298 | "hex": "#EDD19C", 299 | "name": "Maize", 300 | "rgb": "(237, 209, 156)" 301 | }, 302 | { 303 | "hex": "#979AAA", 304 | "name": "Manatee", 305 | "rgb": "(151, 154, 170)" 306 | }, 307 | { 308 | "hex": "#FF8243", 309 | "name": "Mango Tango", 310 | "rgb": "(255, 130, 67)" 311 | }, 312 | { 313 | "hex": "#C8385A", 314 | "name": "Maroon", 315 | "rgb": "(200, 56, 90)" 316 | }, 317 | { 318 | "hex": "#EF98AA", 319 | "name": "Mauvelous", 320 | "rgb": "(239, 152, 170)" 321 | }, 322 | { 323 | "hex": "#FDBCB4", 324 | "name": "Melon", 325 | "rgb": "(253, 188, 180)" 326 | }, 327 | { 328 | "hex": "#1A4876", 329 | "name": "Midnight Blue", 330 | "rgb": "(26, 72, 118)" 331 | }, 332 | { 333 | "hex": "#30BA8F", 334 | "name": "Mountain Meadow", 335 | "rgb": "(48, 186, 143)" 336 | }, 337 | { 338 | "hex": "#C54B8C", 339 | "name": "Mulberry", 340 | "rgb": "(197, 75, 140)" 341 | }, 342 | { 343 | "hex": "#1974D2", 344 | "name": "Navy Blue", 345 | "rgb": "(25, 116, 210)" 346 | }, 347 | { 348 | "hex": "#FFA343", 349 | "name": "Neon Carrot", 350 | "rgb": "(255, 163, 67)" 351 | }, 352 | { 353 | "hex": "#BAB86C", 354 | "name": "Olive Green", 355 | "rgb": "(186, 184, 108)" 356 | }, 357 | { 358 | "hex": "#FF7538", 359 | "name": "Orange", 360 | "rgb": "(255, 117, 56)" 361 | }, 362 | { 363 | "hex": "#FF2B2B", 364 | "name": "Orange Red", 365 | "rgb": "(255, 43, 43)" 366 | }, 367 | { 368 | "hex": "#F8D568", 369 | "name": "Orange Yellow", 370 | "rgb": "(248, 213, 104)" 371 | }, 372 | { 373 | "hex": "#E6A8D7", 374 | "name": "Orchid", 375 | "rgb": "(230, 168, 215)" 376 | }, 377 | { 378 | "hex": "#414A4C", 379 | "name": "Outer Space", 380 | "rgb": "(65, 74, 76)" 381 | }, 382 | { 383 | "hex": "#FF6E4A", 384 | "name": "Outrageous Orange", 385 | "rgb": "(255, 110, 74)" 386 | }, 387 | { 388 | "hex": "#1CA9C9", 389 | "name": "Pacific Blue", 390 | "rgb": "(28, 169, 201)" 391 | }, 392 | { 393 | "hex": "#FFCFAB", 394 | "name": "Peach", 395 | "rgb": "(255, 207, 171)" 396 | }, 397 | { 398 | "hex": "#C5D0E6", 399 | "name": "Periwinkle", 400 | "rgb": "(197, 208, 230)" 401 | }, 402 | { 403 | "hex": "#FDDDE6", 404 | "name": "Piggy Pink", 405 | "rgb": "(253, 221, 230)" 406 | }, 407 | { 408 | "hex": "#158078", 409 | "name": "Pine Green", 410 | "rgb": "(21, 128, 120)" 411 | }, 412 | { 413 | "hex": "#FC74FD", 414 | "name": "Pink Flamingo", 415 | "rgb": "(252, 116, 253)" 416 | }, 417 | { 418 | "hex": "#F78FA7", 419 | "name": "Pink Sherbet", 420 | "rgb": "(247, 143, 167)" 421 | }, 422 | { 423 | "hex": "#8E4585", 424 | "name": "Plum", 425 | "rgb": "(142, 69, 133)" 426 | }, 427 | { 428 | "hex": "#7442C8", 429 | "name": "Purple Heart", 430 | "rgb": "(116, 66, 200)" 431 | }, 432 | { 433 | "hex": "#9D81BA", 434 | "name": "Purple Mountain's Majesty", 435 | "rgb": "(157, 129, 186)" 436 | }, 437 | { 438 | "hex": "#FE4EDA", 439 | "name": "Purple Pizzazz", 440 | "rgb": "(254, 78, 218)" 441 | }, 442 | { 443 | "hex": "#FF496C", 444 | "name": "Radical Red", 445 | "rgb": "(255, 73, 108)" 446 | }, 447 | { 448 | "hex": "#D68A59", 449 | "name": "Raw Sienna", 450 | "rgb": "(214, 138, 89)" 451 | }, 452 | { 453 | "hex": "#714B23", 454 | "name": "Raw Umber", 455 | "rgb": "(113, 75, 35)" 456 | }, 457 | { 458 | "hex": "#FF48D0", 459 | "name": "Razzle Dazzle Rose", 460 | "rgb": "(255, 72, 208)" 461 | }, 462 | { 463 | "hex": "#E3256B", 464 | "name": "Razzmatazz", 465 | "rgb": "(227, 37, 107)" 466 | }, 467 | { 468 | "hex": "#EE204D", 469 | "name": "Red", 470 | "rgb": "(238,32 ,77 )" 471 | }, 472 | { 473 | "hex": "#FF5349", 474 | "name": "Red Orange", 475 | "rgb": "(255, 83, 73)" 476 | }, 477 | { 478 | "hex": "#C0448F", 479 | "name": "Red Violet", 480 | "rgb": "(192, 68, 143)" 481 | }, 482 | { 483 | "hex": "#1FCECB", 484 | "name": "Robin's Egg Blue", 485 | "rgb": "(31, 206, 203)" 486 | }, 487 | { 488 | "hex": "#7851A9", 489 | "name": "Royal Purple", 490 | "rgb": "(120, 81, 169)" 491 | }, 492 | { 493 | "hex": "#FF9BAA", 494 | "name": "Salmon", 495 | "rgb": "(255, 155, 170)" 496 | }, 497 | { 498 | "hex": "#FC2847", 499 | "name": "Scarlet", 500 | "rgb": "(252, 40, 71)" 501 | }, 502 | { 503 | "hex": "#76FF7A", 504 | "name": "Screamin' Green", 505 | "rgb": "(118, 255, 122)" 506 | }, 507 | { 508 | "hex": "#9FE2BF", 509 | "name": "Sea Green", 510 | "rgb": "(159, 226, 191)" 511 | }, 512 | { 513 | "hex": "#A5694F", 514 | "name": "Sepia", 515 | "rgb": "(165, 105, 79)" 516 | }, 517 | { 518 | "hex": "#8A795D", 519 | "name": "Shadow", 520 | "rgb": "(138, 121, 93)" 521 | }, 522 | { 523 | "hex": "#45CEA2", 524 | "name": "Shamrock", 525 | "rgb": "(69, 206, 162)" 526 | }, 527 | { 528 | "hex": "#FB7EFD", 529 | "name": "Shocking Pink", 530 | "rgb": "(251, 126, 253)" 531 | }, 532 | { 533 | "hex": "#CDC5C2", 534 | "name": "Silver", 535 | "rgb": "(205, 197, 194)" 536 | }, 537 | { 538 | "hex": "#80DAEB", 539 | "name": "Sky Blue", 540 | "rgb": "(128, 218, 235)" 541 | }, 542 | { 543 | "hex": "#ECEABE", 544 | "name": "Spring Green", 545 | "rgb": "(236, 234, 190)" 546 | }, 547 | { 548 | "hex": "#FFCF48", 549 | "name": "Sunglow", 550 | "rgb": "(255, 207, 72)" 551 | }, 552 | { 553 | "hex": "#FD5E53", 554 | "name": "Sunset Orange", 555 | "rgb": "(253, 94, 83)" 556 | }, 557 | { 558 | "hex": "#FAA76C", 559 | "name": "Tan", 560 | "rgb": "(250, 167, 108)" 561 | }, 562 | { 563 | "hex": "#18A7B5", 564 | "name": "Teal Blue", 565 | "rgb": "(24, 167, 181)" 566 | }, 567 | { 568 | "hex": "#EBC7DF", 569 | "name": "Thistle", 570 | "rgb": "(235, 199, 223)" 571 | }, 572 | { 573 | "hex": "#FC89AC", 574 | "name": "Tickle Me Pink", 575 | "rgb": "(252, 137, 172)" 576 | }, 577 | { 578 | "hex": "#DBD7D2", 579 | "name": "Timberwolf", 580 | "rgb": "(219, 215, 210)" 581 | }, 582 | { 583 | "hex": "#17806D", 584 | "name": "Tropical Rain Forest", 585 | "rgb": "(23, 128, 109)" 586 | }, 587 | { 588 | "hex": "#DEAA88", 589 | "name": "Tumbleweed", 590 | "rgb": "(222, 170, 136)" 591 | }, 592 | { 593 | "hex": "#77DDE7", 594 | "name": "Turquoise Blue", 595 | "rgb": "(119, 221, 231)" 596 | }, 597 | { 598 | "hex": "#FFFF66", 599 | "name": "Unmellow Yellow", 600 | "rgb": "(255, 255, 102)" 601 | }, 602 | { 603 | "hex": "#926EAE", 604 | "name": "Violet (Purple)", 605 | "rgb": "(146, 110, 174)" 606 | }, 607 | { 608 | "hex": "#324AB2", 609 | "name": "Violet Blue", 610 | "rgb": "(50, 74, 178)" 611 | }, 612 | { 613 | "hex": "#F75394", 614 | "name": "Violet Red", 615 | "rgb": "(247, 83, 148)" 616 | }, 617 | { 618 | "hex": "#FFA089", 619 | "name": "Vivid Tangerine", 620 | "rgb": "(255, 160, 137)" 621 | }, 622 | { 623 | "hex": "#8F509D", 624 | "name": "Vivid Violet", 625 | "rgb": "(143, 80, 157)" 626 | }, 627 | { 628 | "hex": "#FFFFFF", 629 | "name": "White", 630 | "rgb": "(255, 255, 255)" 631 | }, 632 | { 633 | "hex": "#A2ADD0", 634 | "name": "Wild Blue Yonder", 635 | "rgb": "(162, 173, 208)" 636 | }, 637 | { 638 | "hex": "#FF43A4", 639 | "name": "Wild Strawberry", 640 | "rgb": "(255, 67, 164)" 641 | }, 642 | { 643 | "hex": "#FC6C85", 644 | "name": "Wild Watermelon", 645 | "rgb": "(252, 108, 133)" 646 | }, 647 | { 648 | "hex": "#CDA4DE", 649 | "name": "Wisteria", 650 | "rgb": "(205, 164, 222)" 651 | }, 652 | { 653 | "hex": "#FCE883", 654 | "name": "Yellow", 655 | "rgb": "(252, 232, 131)" 656 | }, 657 | { 658 | "hex": "#C5E384", 659 | "name": "Yellow Green", 660 | "rgb": "(197, 227, 132)" 661 | }, 662 | { 663 | "hex": "#FFAE42", 664 | "name": "Yellow Orange", 665 | "rgb": "(255, 174, 66)" 666 | } 667 | ] 668 | -------------------------------------------------------------------------------- /color-mobile/index.android.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import React, { Component } from 'react'; 8 | import { 9 | AppRegistry, 10 | StyleSheet, 11 | Text, 12 | View 13 | } from 'react-native'; 14 | 15 | export default class SearchBoxMobile extends Component { 16 | render() { 17 | return ( 18 | 19 | 20 | Welcome to React Native! 21 | 22 | 23 | To get started, edit index.android.js 24 | 25 | 26 | Double tap R on your keyboard to reload,{'\n'} 27 | Shake or press menu button for dev menu 28 | 29 | 30 | ); 31 | } 32 | } 33 | 34 | const styles = StyleSheet.create({ 35 | container: { 36 | flex: 1, 37 | justifyContent: 'center', 38 | alignItems: 'center', 39 | backgroundColor: '#F5FCFF', 40 | }, 41 | welcome: { 42 | fontSize: 20, 43 | textAlign: 'center', 44 | margin: 10, 45 | }, 46 | instructions: { 47 | textAlign: 'center', 48 | color: '#333333', 49 | marginBottom: 5, 50 | }, 51 | }); 52 | 53 | AppRegistry.registerComponent('SearchBoxMobile', () => SearchBoxMobile); 54 | -------------------------------------------------------------------------------- /color-mobile/index.ios.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import React, {Component} from 'react'; 8 | import {AppRegistry} from 'react-native'; 9 | 10 | import Colors from './colors'; 11 | 12 | import ColorMobileSearchBox from './ColorMobileSearchBox'; 13 | 14 | export default class App extends Component { 15 | 16 | render() { 17 | return ( 18 | 19 | ); 20 | } 21 | } 22 | AppRegistry.registerComponent('SearchBoxMobile', () => App); 23 | -------------------------------------------------------------------------------- /color-mobile/ios/SearchBoxMobile.xcodeproj/xcshareddata/xcschemes/SearchBoxMobile.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /color-mobile/ios/SearchBoxMobile/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /color-mobile/ios/SearchBoxMobile/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "AppDelegate.h" 11 | 12 | #import 13 | #import 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 18 | { 19 | NSURL *jsCodeLocation; 20 | 21 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; 22 | 23 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 24 | moduleName:@"SearchBoxMobile" 25 | initialProperties:nil 26 | launchOptions:launchOptions]; 27 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 28 | 29 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 30 | UIViewController *rootViewController = [UIViewController new]; 31 | rootViewController.view = rootView; 32 | self.window.rootViewController = rootViewController; 33 | [self.window makeKeyAndVisible]; 34 | return YES; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /color-mobile/ios/SearchBoxMobile/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /color-mobile/ios/SearchBoxMobile/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /color-mobile/ios/SearchBoxMobile/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UIViewControllerBasedStatusBarAppearance 38 | 39 | NSLocationWhenInUseUsageDescription 40 | 41 | NSAppTransportSecurity 42 | 43 | 44 | NSExceptionDomains 45 | 46 | localhost 47 | 48 | NSExceptionAllowsInsecureHTTPLoads 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /color-mobile/ios/SearchBoxMobile/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /color-mobile/ios/SearchBoxMobileTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /color-mobile/ios/SearchBoxMobileTests/SearchBoxMobileTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | #import 14 | #import 15 | 16 | #define TIMEOUT_SECONDS 600 17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 18 | 19 | @interface SearchBoxMobileTests : XCTestCase 20 | 21 | @end 22 | 23 | @implementation SearchBoxMobileTests 24 | 25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 26 | { 27 | if (test(view)) { 28 | return YES; 29 | } 30 | for (UIView *subview in [view subviews]) { 31 | if ([self findSubviewInView:subview matching:test]) { 32 | return YES; 33 | } 34 | } 35 | return NO; 36 | } 37 | 38 | - (void)testRendersWelcomeScreen 39 | { 40 | UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; 41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 42 | BOOL foundElement = NO; 43 | 44 | __block NSString *redboxError = nil; 45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 46 | if (level >= RCTLogLevelError) { 47 | redboxError = message; 48 | } 49 | }); 50 | 51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 54 | 55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 57 | return YES; 58 | } 59 | return NO; 60 | }]; 61 | } 62 | 63 | RCTSetLogFunction(RCTDefaultLogFunction); 64 | 65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 67 | } 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /color-mobile/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SearchBoxMobile", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node node_modules/react-native/local-cli/cli.js start", 7 | "test": "jest" 8 | }, 9 | "dependencies": { 10 | "mobx": "^3.0.0", 11 | "mobx-react": "^4.1.0", 12 | "react": "15.4.2", 13 | "react-native": "0.40.0" 14 | }, 15 | "devDependencies": { 16 | "babel-jest": "18.0.0", 17 | "babel-preset-react-native": "1.9.1", 18 | "enzyme": "^2.7.0", 19 | "jest": "18.1.0", 20 | "react-addons-test-utils": "^15.4.2", 21 | "react-dom": "^15.4.2", 22 | "react-native-mock": "^0.2.9", 23 | "react-test-renderer": "15.4.2" 24 | }, 25 | "jest": { 26 | "preset": "react-native" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /color-web/firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "hosting": { 3 | "public": "build", 4 | "rewrites": [ 5 | { 6 | "source": "**", 7 | "destination": "/index.html" 8 | } 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /color-web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "color-web", 3 | "version": "0.1.0", 4 | "private": true, 5 | "devDependencies": { 6 | "enzyme": "^2.7.0", 7 | "react-addons-test-utils": "^15.4.2", 8 | "react-scripts": "0.8.5" 9 | }, 10 | "dependencies": { 11 | "material-ui": "^0.16.6", 12 | "mobx": "^3.0.0", 13 | "mobx-react": "^4.1.0", 14 | "react": "^15.4.2", 15 | "react-dom": "^15.4.2", 16 | "react-tap-event-plugin": "^2.0.1" 17 | }, 18 | "scripts": { 19 | "start": "react-scripts start", 20 | "build": "react-scripts build", 21 | "test": "react-scripts test --env=jsdom", 22 | "eject": "react-scripts eject" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /color-web/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csepulv/search-box/7c836c4acbf2ce87e4e8596fec2bdae7b690499e/color-web/public/favicon.ico -------------------------------------------------------------------------------- /color-web/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 16 | Search Box Sample 17 | 18 | 19 |
20 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /color-web/src/ColorListItem.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {ListItem, Divider} from 'material-ui' 3 | 4 | const ColorListItem = ({result}) => { 5 | return ( 6 |
7 | 8 | 9 |
10 | ); 11 | }; 12 | 13 | ColorListItem.propTypes = { 14 | result: React.PropTypes.object.isRequired 15 | }; 16 | 17 | export default ColorListItem; -------------------------------------------------------------------------------- /color-web/src/SearchBox.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | 3 | const SearchBox = (SearchFrame, SearchInput, SearchResults) => { 4 | return class extends Component { 5 | static propTypes = { 6 | searchStore: React.PropTypes.object.isRequired 7 | }; 8 | 9 | render() { 10 | return ( 11 | 12 | this.props.searchStore.updateQuery(value)} 14 | onSubmit={() => this.props.searchStore.search()} 15 | /> 16 | 17 | 18 | ); 19 | } 20 | }; 21 | }; 22 | 23 | 24 | export default SearchBox -------------------------------------------------------------------------------- /color-web/src/WebSearchBox.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; 3 | 4 | // (Make material-ui happy) 5 | // Needed for onTouchTap 6 | // http://stackoverflow.com/a/34015469/988941 7 | import injectTapEventPlugin from 'react-tap-event-plugin'; 8 | injectTapEventPlugin(); 9 | 10 | import WebSearchInput from './WebSearchInput'; 11 | import WebSearchResults from './WebSearchResults'; 12 | 13 | import SearchBox from './SearchBox' 14 | import {observer} from 'mobx-react'; 15 | 16 | const WebSearchFrame = ({children}) => { 17 | return ( 18 | 19 |
20 | {children} 21 |
22 |
23 | ); 24 | }; 25 | 26 | const WebSearchBox = ListItem => observer(SearchBox(WebSearchFrame, WebSearchInput, WebSearchResults(ListItem))); 27 | 28 | export default WebSearchBox -------------------------------------------------------------------------------- /color-web/src/WebSearchInput.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {TextField} from 'material-ui'; 3 | 4 | const WebSearchInput = ({query, onSubmit, onQueryUpdate}) => { 5 | const handleKeyDown = (event) => { 6 | const ENTER_KEY = 13; 7 | if (event.keyCode === ENTER_KEY) { 8 | event.preventDefault(); 9 | onSubmit(); 10 | } 11 | }; 12 | 13 | return ( 14 | onQueryUpdate(value)} 19 | onKeyDown={handleKeyDown}/> 20 | ); 21 | 22 | }; 23 | 24 | WebSearchInput.propTypes = { 25 | query: React.PropTypes.string.isRequired, 26 | onSubmit: React.PropTypes.func.isRequired, 27 | onQueryUpdate: React.PropTypes.func.isRequired 28 | }; 29 | 30 | export default WebSearchInput; -------------------------------------------------------------------------------- /color-web/src/WebSearchResults.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import {List} from 'material-ui' 3 | 4 | const WebSearchResults = ListItem => { 5 | return class extends Component { 6 | static propTypes = { 7 | results: React.PropTypes.array.isRequired 8 | }; 9 | 10 | render() { 11 | const listItems = this.props.results.map((result, index) => { 12 | return ( 13 | 14 | ); 15 | }); 16 | return ( 17 | 18 | {listItems} 19 | 20 | ); 21 | }; 22 | }; 23 | }; 24 | 25 | export default WebSearchResults; -------------------------------------------------------------------------------- /color-web/src/colors.js: -------------------------------------------------------------------------------- 1 | import {extendObservable, runInAction} from 'mobx'; 2 | import crayola from './crayola.json' 3 | 4 | export default class Colors { 5 | constructor() { 6 | extendObservable(this, { 7 | results: [], 8 | query: '' 9 | }); 10 | } 11 | 12 | search() { 13 | runInAction(() => { 14 | this.results = crayola.filter(color => color.name.toLowerCase().includes(this.query.toLowerCase())); 15 | }); 16 | } 17 | 18 | updateQuery(value) { 19 | runInAction(() => this.query = value); 20 | } 21 | } -------------------------------------------------------------------------------- /color-web/src/crayola.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "hex": "#EFDECD", 4 | "name": "Almond", 5 | "rgb": "(239, 222, 205)" 6 | }, 7 | { 8 | "hex": "#CD9575", 9 | "name": "Antique Brass", 10 | "rgb": "(205, 149, 117)" 11 | }, 12 | { 13 | "hex": "#FDD9B5", 14 | "name": "Apricot", 15 | "rgb": "(253, 217, 181)" 16 | }, 17 | { 18 | "hex": "#78DBE2", 19 | "name": "Aquamarine", 20 | "rgb": "(120, 219, 226)" 21 | }, 22 | { 23 | "hex": "#87A96B", 24 | "name": "Asparagus", 25 | "rgb": "(135, 169, 107)" 26 | }, 27 | { 28 | "hex": "#FFA474", 29 | "name": "Atomic Tangerine", 30 | "rgb": "(255, 164, 116)" 31 | }, 32 | { 33 | "hex": "#FAE7B5", 34 | "name": "Banana Mania", 35 | "rgb": "(250, 231, 181)" 36 | }, 37 | { 38 | "hex": "#9F8170", 39 | "name": "Beaver", 40 | "rgb": "(159, 129, 112)" 41 | }, 42 | { 43 | "hex": "#FD7C6E", 44 | "name": "Bittersweet", 45 | "rgb": "(253, 124, 110)" 46 | }, 47 | { 48 | "hex": "#000000", 49 | "name": "Black", 50 | "rgb": "(0,0,0)" 51 | }, 52 | { 53 | "hex": "#ACE5EE", 54 | "name": "Blizzard Blue", 55 | "rgb": "(172, 229, 238)" 56 | }, 57 | { 58 | "hex": "#1F75FE", 59 | "name": "Blue", 60 | "rgb": "(31, 117, 254)" 61 | }, 62 | { 63 | "hex": "#A2A2D0", 64 | "name": "Blue Bell", 65 | "rgb": "(162, 162, 208)" 66 | }, 67 | { 68 | "hex": "#6699CC", 69 | "name": "Blue Gray", 70 | "rgb": "(102, 153, 204)" 71 | }, 72 | { 73 | "hex": "#0D98BA", 74 | "name": "Blue Green", 75 | "rgb": "(13, 152, 186)" 76 | }, 77 | { 78 | "hex": "#7366BD", 79 | "name": "Blue Violet", 80 | "rgb": "(115, 102, 189)" 81 | }, 82 | { 83 | "hex": "#DE5D83", 84 | "name": "Blush", 85 | "rgb": "(222, 93, 131)" 86 | }, 87 | { 88 | "hex": "#CB4154", 89 | "name": "Brick Red", 90 | "rgb": "(203, 65, 84)" 91 | }, 92 | { 93 | "hex": "#B4674D", 94 | "name": "Brown", 95 | "rgb": "(180, 103, 77)" 96 | }, 97 | { 98 | "hex": "#FF7F49", 99 | "name": "Burnt Orange", 100 | "rgb": "(255, 127, 73)" 101 | }, 102 | { 103 | "hex": "#EA7E5D", 104 | "name": "Burnt Sienna", 105 | "rgb": "(234, 126, 93)" 106 | }, 107 | { 108 | "hex": "#B0B7C6", 109 | "name": "Cadet Blue", 110 | "rgb": "(176, 183, 198)" 111 | }, 112 | { 113 | "hex": "#FFFF99", 114 | "name": "Canary", 115 | "rgb": "(255, 255, 153)" 116 | }, 117 | { 118 | "hex": "#1CD3A2", 119 | "name": "Caribbean Green", 120 | "rgb": "(28, 211, 162)" 121 | }, 122 | { 123 | "hex": "#FFAACC", 124 | "name": "Carnation Pink", 125 | "rgb": "(255, 170, 204)" 126 | }, 127 | { 128 | "hex": "#DD4492", 129 | "name": "Cerise", 130 | "rgb": "(221, 68, 146)" 131 | }, 132 | { 133 | "hex": "#1DACD6", 134 | "name": "Cerulean", 135 | "rgb": "(29, 172, 214)" 136 | }, 137 | { 138 | "hex": "#BC5D58", 139 | "name": "Chestnut", 140 | "rgb": "(188, 93, 88)" 141 | }, 142 | { 143 | "hex": "#DD9475", 144 | "name": "Copper", 145 | "rgb": "(221, 148, 117)" 146 | }, 147 | { 148 | "hex": "#9ACEEB", 149 | "name": "Cornflower", 150 | "rgb": "(154, 206, 235)" 151 | }, 152 | { 153 | "hex": "#FFBCD9", 154 | "name": "Cotton Candy", 155 | "rgb": "(255, 188, 217)" 156 | }, 157 | { 158 | "hex": "#FDDB6D", 159 | "name": "Dandelion", 160 | "rgb": "(253, 219, 109)" 161 | }, 162 | { 163 | "hex": "#2B6CC4", 164 | "name": "Denim", 165 | "rgb": "(43, 108, 196)" 166 | }, 167 | { 168 | "hex": "#EFCDB8", 169 | "name": "Desert Sand", 170 | "rgb": "(239, 205, 184)" 171 | }, 172 | { 173 | "hex": "#6E5160", 174 | "name": "Eggplant", 175 | "rgb": "(110, 81, 96)" 176 | }, 177 | { 178 | "hex": "#CEFF1D", 179 | "name": "Electric Lime", 180 | "rgb": "(206, 255, 29)" 181 | }, 182 | { 183 | "hex": "#71BC78", 184 | "name": "Fern", 185 | "rgb": "(113, 188, 120)" 186 | }, 187 | { 188 | "hex": "#6DAE81", 189 | "name": "Forest Green", 190 | "rgb": "(109, 174, 129)" 191 | }, 192 | { 193 | "hex": "#C364C5", 194 | "name": "Fuchsia", 195 | "rgb": "(195, 100, 197)" 196 | }, 197 | { 198 | "hex": "#CC6666", 199 | "name": "Fuzzy Wuzzy", 200 | "rgb": "(204, 102, 102)" 201 | }, 202 | { 203 | "hex": "#E7C697", 204 | "name": "Gold", 205 | "rgb": "(231, 198, 151)" 206 | }, 207 | { 208 | "hex": "#FCD975", 209 | "name": "Goldenrod", 210 | "rgb": "(252, 217, 117)" 211 | }, 212 | { 213 | "hex": "#A8E4A0", 214 | "name": "Granny Smith Apple", 215 | "rgb": "(168, 228, 160)" 216 | }, 217 | { 218 | "hex": "#95918C", 219 | "name": "Gray", 220 | "rgb": "(149, 145, 140)" 221 | }, 222 | { 223 | "hex": "#1CAC78", 224 | "name": "Green", 225 | "rgb": "(28, 172, 120)" 226 | }, 227 | { 228 | "hex": "#1164B4", 229 | "name": "Green Blue", 230 | "rgb": "(17, 100, 180)" 231 | }, 232 | { 233 | "hex": "#F0E891", 234 | "name": "Green Yellow", 235 | "rgb": "(240, 232, 145)" 236 | }, 237 | { 238 | "hex": "#FF1DCE", 239 | "name": "Hot Magenta", 240 | "rgb": "(255, 29, 206)" 241 | }, 242 | { 243 | "hex": "#B2EC5D", 244 | "name": "Inchworm", 245 | "rgb": "(178, 236, 93)" 246 | }, 247 | { 248 | "hex": "#5D76CB", 249 | "name": "Indigo", 250 | "rgb": "(93, 118, 203)" 251 | }, 252 | { 253 | "hex": "#CA3767", 254 | "name": "Jazzberry Jam", 255 | "rgb": "(202, 55, 103)" 256 | }, 257 | { 258 | "hex": "#3BB08F", 259 | "name": "Jungle Green", 260 | "rgb": "(59, 176, 143)" 261 | }, 262 | { 263 | "hex": "#FEFE22", 264 | "name": "Laser Lemon", 265 | "rgb": "(254, 254, 34)" 266 | }, 267 | { 268 | "hex": "#FCB4D5", 269 | "name": "Lavender", 270 | "rgb": "(252, 180, 213)" 271 | }, 272 | { 273 | "hex": "#FFF44F", 274 | "name": "Lemon Yellow", 275 | "rgb": "(255, 244, 79)" 276 | }, 277 | { 278 | "hex": "#FFBD88", 279 | "name": "Macaroni and Cheese", 280 | "rgb": "(255, 189, 136)" 281 | }, 282 | { 283 | "hex": "#F664AF", 284 | "name": "Magenta", 285 | "rgb": "(246, 100, 175)" 286 | }, 287 | { 288 | "hex": "#AAF0D1", 289 | "name": "Magic Mint", 290 | "rgb": "(170, 240, 209)" 291 | }, 292 | { 293 | "hex": "#CD4A4C", 294 | "name": "Mahogany", 295 | "rgb": "(205, 74, 76)" 296 | }, 297 | { 298 | "hex": "#EDD19C", 299 | "name": "Maize", 300 | "rgb": "(237, 209, 156)" 301 | }, 302 | { 303 | "hex": "#979AAA", 304 | "name": "Manatee", 305 | "rgb": "(151, 154, 170)" 306 | }, 307 | { 308 | "hex": "#FF8243", 309 | "name": "Mango Tango", 310 | "rgb": "(255, 130, 67)" 311 | }, 312 | { 313 | "hex": "#C8385A", 314 | "name": "Maroon", 315 | "rgb": "(200, 56, 90)" 316 | }, 317 | { 318 | "hex": "#EF98AA", 319 | "name": "Mauvelous", 320 | "rgb": "(239, 152, 170)" 321 | }, 322 | { 323 | "hex": "#FDBCB4", 324 | "name": "Melon", 325 | "rgb": "(253, 188, 180)" 326 | }, 327 | { 328 | "hex": "#1A4876", 329 | "name": "Midnight Blue", 330 | "rgb": "(26, 72, 118)" 331 | }, 332 | { 333 | "hex": "#30BA8F", 334 | "name": "Mountain Meadow", 335 | "rgb": "(48, 186, 143)" 336 | }, 337 | { 338 | "hex": "#C54B8C", 339 | "name": "Mulberry", 340 | "rgb": "(197, 75, 140)" 341 | }, 342 | { 343 | "hex": "#1974D2", 344 | "name": "Navy Blue", 345 | "rgb": "(25, 116, 210)" 346 | }, 347 | { 348 | "hex": "#FFA343", 349 | "name": "Neon Carrot", 350 | "rgb": "(255, 163, 67)" 351 | }, 352 | { 353 | "hex": "#BAB86C", 354 | "name": "Olive Green", 355 | "rgb": "(186, 184, 108)" 356 | }, 357 | { 358 | "hex": "#FF7538", 359 | "name": "Orange", 360 | "rgb": "(255, 117, 56)" 361 | }, 362 | { 363 | "hex": "#FF2B2B", 364 | "name": "Orange Red", 365 | "rgb": "(255, 43, 43)" 366 | }, 367 | { 368 | "hex": "#F8D568", 369 | "name": "Orange Yellow", 370 | "rgb": "(248, 213, 104)" 371 | }, 372 | { 373 | "hex": "#E6A8D7", 374 | "name": "Orchid", 375 | "rgb": "(230, 168, 215)" 376 | }, 377 | { 378 | "hex": "#414A4C", 379 | "name": "Outer Space", 380 | "rgb": "(65, 74, 76)" 381 | }, 382 | { 383 | "hex": "#FF6E4A", 384 | "name": "Outrageous Orange", 385 | "rgb": "(255, 110, 74)" 386 | }, 387 | { 388 | "hex": "#1CA9C9", 389 | "name": "Pacific Blue", 390 | "rgb": "(28, 169, 201)" 391 | }, 392 | { 393 | "hex": "#FFCFAB", 394 | "name": "Peach", 395 | "rgb": "(255, 207, 171)" 396 | }, 397 | { 398 | "hex": "#C5D0E6", 399 | "name": "Periwinkle", 400 | "rgb": "(197, 208, 230)" 401 | }, 402 | { 403 | "hex": "#FDDDE6", 404 | "name": "Piggy Pink", 405 | "rgb": "(253, 221, 230)" 406 | }, 407 | { 408 | "hex": "#158078", 409 | "name": "Pine Green", 410 | "rgb": "(21, 128, 120)" 411 | }, 412 | { 413 | "hex": "#FC74FD", 414 | "name": "Pink Flamingo", 415 | "rgb": "(252, 116, 253)" 416 | }, 417 | { 418 | "hex": "#F78FA7", 419 | "name": "Pink Sherbet", 420 | "rgb": "(247, 143, 167)" 421 | }, 422 | { 423 | "hex": "#8E4585", 424 | "name": "Plum", 425 | "rgb": "(142, 69, 133)" 426 | }, 427 | { 428 | "hex": "#7442C8", 429 | "name": "Purple Heart", 430 | "rgb": "(116, 66, 200)" 431 | }, 432 | { 433 | "hex": "#9D81BA", 434 | "name": "Purple Mountain's Majesty", 435 | "rgb": "(157, 129, 186)" 436 | }, 437 | { 438 | "hex": "#FE4EDA", 439 | "name": "Purple Pizzazz", 440 | "rgb": "(254, 78, 218)" 441 | }, 442 | { 443 | "hex": "#FF496C", 444 | "name": "Radical Red", 445 | "rgb": "(255, 73, 108)" 446 | }, 447 | { 448 | "hex": "#D68A59", 449 | "name": "Raw Sienna", 450 | "rgb": "(214, 138, 89)" 451 | }, 452 | { 453 | "hex": "#714B23", 454 | "name": "Raw Umber", 455 | "rgb": "(113, 75, 35)" 456 | }, 457 | { 458 | "hex": "#FF48D0", 459 | "name": "Razzle Dazzle Rose", 460 | "rgb": "(255, 72, 208)" 461 | }, 462 | { 463 | "hex": "#E3256B", 464 | "name": "Razzmatazz", 465 | "rgb": "(227, 37, 107)" 466 | }, 467 | { 468 | "hex": "#EE204D", 469 | "name": "Red", 470 | "rgb": "(238,32 ,77 )" 471 | }, 472 | { 473 | "hex": "#FF5349", 474 | "name": "Red Orange", 475 | "rgb": "(255, 83, 73)" 476 | }, 477 | { 478 | "hex": "#C0448F", 479 | "name": "Red Violet", 480 | "rgb": "(192, 68, 143)" 481 | }, 482 | { 483 | "hex": "#1FCECB", 484 | "name": "Robin's Egg Blue", 485 | "rgb": "(31, 206, 203)" 486 | }, 487 | { 488 | "hex": "#7851A9", 489 | "name": "Royal Purple", 490 | "rgb": "(120, 81, 169)" 491 | }, 492 | { 493 | "hex": "#FF9BAA", 494 | "name": "Salmon", 495 | "rgb": "(255, 155, 170)" 496 | }, 497 | { 498 | "hex": "#FC2847", 499 | "name": "Scarlet", 500 | "rgb": "(252, 40, 71)" 501 | }, 502 | { 503 | "hex": "#76FF7A", 504 | "name": "Screamin' Green", 505 | "rgb": "(118, 255, 122)" 506 | }, 507 | { 508 | "hex": "#9FE2BF", 509 | "name": "Sea Green", 510 | "rgb": "(159, 226, 191)" 511 | }, 512 | { 513 | "hex": "#A5694F", 514 | "name": "Sepia", 515 | "rgb": "(165, 105, 79)" 516 | }, 517 | { 518 | "hex": "#8A795D", 519 | "name": "Shadow", 520 | "rgb": "(138, 121, 93)" 521 | }, 522 | { 523 | "hex": "#45CEA2", 524 | "name": "Shamrock", 525 | "rgb": "(69, 206, 162)" 526 | }, 527 | { 528 | "hex": "#FB7EFD", 529 | "name": "Shocking Pink", 530 | "rgb": "(251, 126, 253)" 531 | }, 532 | { 533 | "hex": "#CDC5C2", 534 | "name": "Silver", 535 | "rgb": "(205, 197, 194)" 536 | }, 537 | { 538 | "hex": "#80DAEB", 539 | "name": "Sky Blue", 540 | "rgb": "(128, 218, 235)" 541 | }, 542 | { 543 | "hex": "#ECEABE", 544 | "name": "Spring Green", 545 | "rgb": "(236, 234, 190)" 546 | }, 547 | { 548 | "hex": "#FFCF48", 549 | "name": "Sunglow", 550 | "rgb": "(255, 207, 72)" 551 | }, 552 | { 553 | "hex": "#FD5E53", 554 | "name": "Sunset Orange", 555 | "rgb": "(253, 94, 83)" 556 | }, 557 | { 558 | "hex": "#FAA76C", 559 | "name": "Tan", 560 | "rgb": "(250, 167, 108)" 561 | }, 562 | { 563 | "hex": "#18A7B5", 564 | "name": "Teal Blue", 565 | "rgb": "(24, 167, 181)" 566 | }, 567 | { 568 | "hex": "#EBC7DF", 569 | "name": "Thistle", 570 | "rgb": "(235, 199, 223)" 571 | }, 572 | { 573 | "hex": "#FC89AC", 574 | "name": "Tickle Me Pink", 575 | "rgb": "(252, 137, 172)" 576 | }, 577 | { 578 | "hex": "#DBD7D2", 579 | "name": "Timberwolf", 580 | "rgb": "(219, 215, 210)" 581 | }, 582 | { 583 | "hex": "#17806D", 584 | "name": "Tropical Rain Forest", 585 | "rgb": "(23, 128, 109)" 586 | }, 587 | { 588 | "hex": "#DEAA88", 589 | "name": "Tumbleweed", 590 | "rgb": "(222, 170, 136)" 591 | }, 592 | { 593 | "hex": "#77DDE7", 594 | "name": "Turquoise Blue", 595 | "rgb": "(119, 221, 231)" 596 | }, 597 | { 598 | "hex": "#FFFF66", 599 | "name": "Unmellow Yellow", 600 | "rgb": "(255, 255, 102)" 601 | }, 602 | { 603 | "hex": "#926EAE", 604 | "name": "Violet (Purple)", 605 | "rgb": "(146, 110, 174)" 606 | }, 607 | { 608 | "hex": "#324AB2", 609 | "name": "Violet Blue", 610 | "rgb": "(50, 74, 178)" 611 | }, 612 | { 613 | "hex": "#F75394", 614 | "name": "Violet Red", 615 | "rgb": "(247, 83, 148)" 616 | }, 617 | { 618 | "hex": "#FFA089", 619 | "name": "Vivid Tangerine", 620 | "rgb": "(255, 160, 137)" 621 | }, 622 | { 623 | "hex": "#8F509D", 624 | "name": "Vivid Violet", 625 | "rgb": "(143, 80, 157)" 626 | }, 627 | { 628 | "hex": "#FFFFFF", 629 | "name": "White", 630 | "rgb": "(255, 255, 255)" 631 | }, 632 | { 633 | "hex": "#A2ADD0", 634 | "name": "Wild Blue Yonder", 635 | "rgb": "(162, 173, 208)" 636 | }, 637 | { 638 | "hex": "#FF43A4", 639 | "name": "Wild Strawberry", 640 | "rgb": "(255, 67, 164)" 641 | }, 642 | { 643 | "hex": "#FC6C85", 644 | "name": "Wild Watermelon", 645 | "rgb": "(252, 108, 133)" 646 | }, 647 | { 648 | "hex": "#CDA4DE", 649 | "name": "Wisteria", 650 | "rgb": "(205, 164, 222)" 651 | }, 652 | { 653 | "hex": "#FCE883", 654 | "name": "Yellow", 655 | "rgb": "(252, 232, 131)" 656 | }, 657 | { 658 | "hex": "#C5E384", 659 | "name": "Yellow Green", 660 | "rgb": "(197, 227, 132)" 661 | }, 662 | { 663 | "hex": "#FFAE42", 664 | "name": "Yellow Orange", 665 | "rgb": "(255, 174, 66)" 666 | } 667 | ] 668 | -------------------------------------------------------------------------------- /color-web/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: sans-serif; 5 | } 6 | -------------------------------------------------------------------------------- /color-web/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import WebSearchBox from './WebSearchBox'; 4 | import './index.css'; 5 | 6 | import Colors from './colors' 7 | import ColorListItem from './ColorListItem' 8 | 9 | const ColorSearchBox = WebSearchBox(ColorListItem); 10 | 11 | ReactDOM.render( 12 | , 13 | document.getElementById('root') 14 | ); 15 | -------------------------------------------------------------------------------- /common/ColorListItem.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {ListItem, Divider} from 'material-ui' 3 | 4 | const ColorListItem = ({result}) => { 5 | return ( 6 |
7 | 8 | 9 |
10 | ); 11 | }; 12 | 13 | ColorListItem.propTypes = { 14 | result: React.PropTypes.object.isRequired 15 | }; 16 | 17 | export default ColorListItem; -------------------------------------------------------------------------------- /common/MobileSearchBox.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { 4 | StyleSheet, 5 | View, 6 | } from 'react-native'; 7 | 8 | import {observer} from 'mobx-react/native'; 9 | 10 | import MobileSearchInput from './MobileSearchInput'; 11 | import MobileSearchResults from './MobileSearchResults'; 12 | 13 | import SearchBox from './SearchBox' 14 | 15 | const styles = StyleSheet.create({ 16 | container: { 17 | flex: 1, 18 | backgroundColor: '#eeeeee', 19 | marginTop: 25 20 | } 21 | }); 22 | 23 | const MobileSearchFrame = ({children}) => { 24 | return ( 25 | 26 | {children} 27 | 28 | ); 29 | }; 30 | 31 | const MobileSearchBox = ListItem => observer(SearchBox(MobileSearchFrame, MobileSearchInput, MobileSearchResults(ListItem))); 32 | 33 | export default MobileSearchBox -------------------------------------------------------------------------------- /common/MobileSearchInput.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {TextInput} from 'react-native'; 3 | 4 | const MobileSearchInput = ({query, onSubmit, onQueryUpdate}) => { 5 | 6 | return ( 7 | onQueryUpdate(text)} 10 | value={query} 11 | returnKeyType={'search'} 12 | autoCapitalize={'none'} 13 | autoCorrect={false} 14 | onSubmitEditing={() => onSubmit()} 15 | /> 16 | ); 17 | 18 | }; 19 | 20 | MobileSearchInput.propTypes = { 21 | query: React.PropTypes.string.isRequired, 22 | onSubmit: React.PropTypes.func.isRequired, 23 | onQueryUpdate: React.PropTypes.func.isRequired 24 | }; 25 | 26 | export default MobileSearchInput; -------------------------------------------------------------------------------- /common/MobileSearchResults.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import { 3 | StyleSheet, 4 | View, 5 | TextInput, 6 | ListView, 7 | Text 8 | } from 'react-native'; 9 | const styles = StyleSheet.create({ 10 | separator: { 11 | flex: 1, 12 | height: 1, 13 | backgroundColor: '#8E8E8E', 14 | } 15 | }); 16 | 17 | const MobileSearchResults = ListItem => { 18 | return class extends Component { 19 | constructor(props) { 20 | super(props); 21 | this.dataSource = new ListView.DataSource({rowHasChanged: (r1, r2) => r1.name !== r2.name}); 22 | } 23 | 24 | static propTypes = { 25 | results: React.PropTypes.array.isRequired 26 | }; 27 | 28 | renderRow = (rowData, sectionId, rowID) => { 29 | return ( 30 | 31 | ); 32 | }; 33 | 34 | render() { 35 | return ( 36 | } 40 | /> 41 | ); 42 | } 43 | }; 44 | }; 45 | 46 | export default MobileSearchResults; -------------------------------------------------------------------------------- /common/SearchBox.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | 3 | const SearchBox = (SearchFrame, SearchInput, SearchResults) => { 4 | return class extends Component { 5 | static propTypes = { 6 | searchStore: React.PropTypes.object.isRequired 7 | }; 8 | 9 | render() { 10 | return ( 11 | 12 | this.props.searchStore.updateQuery(value)} 14 | onSubmit={() => this.props.searchStore.search()} 15 | /> 16 | 17 | 18 | ); 19 | } 20 | }; 21 | }; 22 | 23 | 24 | export default SearchBox -------------------------------------------------------------------------------- /common/WebSearchBox.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; 3 | 4 | // (Make material-ui happy) 5 | // Needed for onTouchTap 6 | // http://stackoverflow.com/a/34015469/988941 7 | import injectTapEventPlugin from 'react-tap-event-plugin'; 8 | injectTapEventPlugin(); 9 | 10 | import WebSearchInput from './WebSearchInput'; 11 | import WebSearchResults from './WebSearchResults'; 12 | 13 | import SearchBox from './SearchBox' 14 | import {observer} from 'mobx-react'; 15 | 16 | const WebSearchFrame = ({children}) => { 17 | return ( 18 | 19 |
20 | {children} 21 |
22 |
23 | ); 24 | }; 25 | 26 | const WebSearchBox = ListItem => observer(SearchBox(WebSearchFrame, WebSearchInput, WebSearchResults(ListItem))); 27 | 28 | export default WebSearchBox -------------------------------------------------------------------------------- /common/WebSearchBox.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import WebSearchBox from './WebSearchBox'; 3 | import getMuiTheme from 'material-ui/styles/getMuiTheme'; 4 | import {TextField, ListItem} from 'material-ui' 5 | 6 | import {mount} from 'enzyme'; 7 | 8 | import Colors from './colors' 9 | import ColorListItem from './ColorListItem' 10 | 11 | const muiTheme = getMuiTheme(); 12 | const mountWithContext = (node) => mount(node, {context: {muiTheme}}); 13 | 14 | it('shows search results', () => { 15 | 16 | const ColorSearchBox = WebSearchBox(ColorListItem); 17 | 18 | const wrapper = mountWithContext(); 19 | const textField = wrapper.find(TextField); 20 | textField.props().onChange(null, 'Blue G'); 21 | textField.props().onKeyDown({ 22 | keyCode: 13, preventDefault: () => { 23 | } 24 | }); 25 | 26 | const colorItems = wrapper.find(ListItem); 27 | expect(colorItems.length).toEqual(2); 28 | expect(colorItems.nodes[0].props.primaryText).toEqual('Blue Gray'); 29 | expect(colorItems.nodes[1].props.primaryText).toEqual('Blue Green'); 30 | }); 31 | -------------------------------------------------------------------------------- /common/WebSearchInput.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {TextField} from 'material-ui'; 3 | 4 | const WebSearchInput = ({query, onSubmit, onQueryUpdate}) => { 5 | const handleKeyDown = (event) => { 6 | const ENTER_KEY = 13; 7 | if (event.keyCode === ENTER_KEY) { 8 | event.preventDefault(); 9 | onSubmit(); 10 | } 11 | }; 12 | 13 | return ( 14 | onQueryUpdate(value)} 19 | onKeyDown={handleKeyDown}/> 20 | ); 21 | 22 | }; 23 | 24 | WebSearchInput.propTypes = { 25 | query: React.PropTypes.string.isRequired, 26 | onSubmit: React.PropTypes.func.isRequired, 27 | onQueryUpdate: React.PropTypes.func.isRequired 28 | }; 29 | 30 | export default WebSearchInput; -------------------------------------------------------------------------------- /common/WebSearchResults.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import {List} from 'material-ui' 3 | 4 | const WebSearchResults = ListItem => { 5 | return class extends Component { 6 | static propTypes = { 7 | results: React.PropTypes.array.isRequired 8 | }; 9 | 10 | render() { 11 | const listItems = this.props.results.map((result, index) => { 12 | return ( 13 | 14 | ); 15 | }); 16 | return ( 17 | 18 | {listItems} 19 | 20 | ); 21 | }; 22 | }; 23 | }; 24 | 25 | export default WebSearchResults; -------------------------------------------------------------------------------- /common/colors.js: -------------------------------------------------------------------------------- 1 | import {extendObservable, runInAction} from 'mobx'; 2 | import crayola from './crayola.json' 3 | 4 | export default class Colors { 5 | constructor() { 6 | extendObservable(this, { 7 | results: [], 8 | query: '' 9 | }); 10 | } 11 | 12 | search() { 13 | runInAction(() => { 14 | this.results = crayola.filter(color => color.name.toLowerCase().includes(this.query.toLowerCase())); 15 | }); 16 | } 17 | 18 | updateQuery(value) { 19 | runInAction(() => this.query = value); 20 | } 21 | } -------------------------------------------------------------------------------- /common/crayola.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "hex": "#EFDECD", 4 | "name": "Almond", 5 | "rgb": "(239, 222, 205)" 6 | }, 7 | { 8 | "hex": "#CD9575", 9 | "name": "Antique Brass", 10 | "rgb": "(205, 149, 117)" 11 | }, 12 | { 13 | "hex": "#FDD9B5", 14 | "name": "Apricot", 15 | "rgb": "(253, 217, 181)" 16 | }, 17 | { 18 | "hex": "#78DBE2", 19 | "name": "Aquamarine", 20 | "rgb": "(120, 219, 226)" 21 | }, 22 | { 23 | "hex": "#87A96B", 24 | "name": "Asparagus", 25 | "rgb": "(135, 169, 107)" 26 | }, 27 | { 28 | "hex": "#FFA474", 29 | "name": "Atomic Tangerine", 30 | "rgb": "(255, 164, 116)" 31 | }, 32 | { 33 | "hex": "#FAE7B5", 34 | "name": "Banana Mania", 35 | "rgb": "(250, 231, 181)" 36 | }, 37 | { 38 | "hex": "#9F8170", 39 | "name": "Beaver", 40 | "rgb": "(159, 129, 112)" 41 | }, 42 | { 43 | "hex": "#FD7C6E", 44 | "name": "Bittersweet", 45 | "rgb": "(253, 124, 110)" 46 | }, 47 | { 48 | "hex": "#000000", 49 | "name": "Black", 50 | "rgb": "(0,0,0)" 51 | }, 52 | { 53 | "hex": "#ACE5EE", 54 | "name": "Blizzard Blue", 55 | "rgb": "(172, 229, 238)" 56 | }, 57 | { 58 | "hex": "#1F75FE", 59 | "name": "Blue", 60 | "rgb": "(31, 117, 254)" 61 | }, 62 | { 63 | "hex": "#A2A2D0", 64 | "name": "Blue Bell", 65 | "rgb": "(162, 162, 208)" 66 | }, 67 | { 68 | "hex": "#6699CC", 69 | "name": "Blue Gray", 70 | "rgb": "(102, 153, 204)" 71 | }, 72 | { 73 | "hex": "#0D98BA", 74 | "name": "Blue Green", 75 | "rgb": "(13, 152, 186)" 76 | }, 77 | { 78 | "hex": "#7366BD", 79 | "name": "Blue Violet", 80 | "rgb": "(115, 102, 189)" 81 | }, 82 | { 83 | "hex": "#DE5D83", 84 | "name": "Blush", 85 | "rgb": "(222, 93, 131)" 86 | }, 87 | { 88 | "hex": "#CB4154", 89 | "name": "Brick Red", 90 | "rgb": "(203, 65, 84)" 91 | }, 92 | { 93 | "hex": "#B4674D", 94 | "name": "Brown", 95 | "rgb": "(180, 103, 77)" 96 | }, 97 | { 98 | "hex": "#FF7F49", 99 | "name": "Burnt Orange", 100 | "rgb": "(255, 127, 73)" 101 | }, 102 | { 103 | "hex": "#EA7E5D", 104 | "name": "Burnt Sienna", 105 | "rgb": "(234, 126, 93)" 106 | }, 107 | { 108 | "hex": "#B0B7C6", 109 | "name": "Cadet Blue", 110 | "rgb": "(176, 183, 198)" 111 | }, 112 | { 113 | "hex": "#FFFF99", 114 | "name": "Canary", 115 | "rgb": "(255, 255, 153)" 116 | }, 117 | { 118 | "hex": "#1CD3A2", 119 | "name": "Caribbean Green", 120 | "rgb": "(28, 211, 162)" 121 | }, 122 | { 123 | "hex": "#FFAACC", 124 | "name": "Carnation Pink", 125 | "rgb": "(255, 170, 204)" 126 | }, 127 | { 128 | "hex": "#DD4492", 129 | "name": "Cerise", 130 | "rgb": "(221, 68, 146)" 131 | }, 132 | { 133 | "hex": "#1DACD6", 134 | "name": "Cerulean", 135 | "rgb": "(29, 172, 214)" 136 | }, 137 | { 138 | "hex": "#BC5D58", 139 | "name": "Chestnut", 140 | "rgb": "(188, 93, 88)" 141 | }, 142 | { 143 | "hex": "#DD9475", 144 | "name": "Copper", 145 | "rgb": "(221, 148, 117)" 146 | }, 147 | { 148 | "hex": "#9ACEEB", 149 | "name": "Cornflower", 150 | "rgb": "(154, 206, 235)" 151 | }, 152 | { 153 | "hex": "#FFBCD9", 154 | "name": "Cotton Candy", 155 | "rgb": "(255, 188, 217)" 156 | }, 157 | { 158 | "hex": "#FDDB6D", 159 | "name": "Dandelion", 160 | "rgb": "(253, 219, 109)" 161 | }, 162 | { 163 | "hex": "#2B6CC4", 164 | "name": "Denim", 165 | "rgb": "(43, 108, 196)" 166 | }, 167 | { 168 | "hex": "#EFCDB8", 169 | "name": "Desert Sand", 170 | "rgb": "(239, 205, 184)" 171 | }, 172 | { 173 | "hex": "#6E5160", 174 | "name": "Eggplant", 175 | "rgb": "(110, 81, 96)" 176 | }, 177 | { 178 | "hex": "#CEFF1D", 179 | "name": "Electric Lime", 180 | "rgb": "(206, 255, 29)" 181 | }, 182 | { 183 | "hex": "#71BC78", 184 | "name": "Fern", 185 | "rgb": "(113, 188, 120)" 186 | }, 187 | { 188 | "hex": "#6DAE81", 189 | "name": "Forest Green", 190 | "rgb": "(109, 174, 129)" 191 | }, 192 | { 193 | "hex": "#C364C5", 194 | "name": "Fuchsia", 195 | "rgb": "(195, 100, 197)" 196 | }, 197 | { 198 | "hex": "#CC6666", 199 | "name": "Fuzzy Wuzzy", 200 | "rgb": "(204, 102, 102)" 201 | }, 202 | { 203 | "hex": "#E7C697", 204 | "name": "Gold", 205 | "rgb": "(231, 198, 151)" 206 | }, 207 | { 208 | "hex": "#FCD975", 209 | "name": "Goldenrod", 210 | "rgb": "(252, 217, 117)" 211 | }, 212 | { 213 | "hex": "#A8E4A0", 214 | "name": "Granny Smith Apple", 215 | "rgb": "(168, 228, 160)" 216 | }, 217 | { 218 | "hex": "#95918C", 219 | "name": "Gray", 220 | "rgb": "(149, 145, 140)" 221 | }, 222 | { 223 | "hex": "#1CAC78", 224 | "name": "Green", 225 | "rgb": "(28, 172, 120)" 226 | }, 227 | { 228 | "hex": "#1164B4", 229 | "name": "Green Blue", 230 | "rgb": "(17, 100, 180)" 231 | }, 232 | { 233 | "hex": "#F0E891", 234 | "name": "Green Yellow", 235 | "rgb": "(240, 232, 145)" 236 | }, 237 | { 238 | "hex": "#FF1DCE", 239 | "name": "Hot Magenta", 240 | "rgb": "(255, 29, 206)" 241 | }, 242 | { 243 | "hex": "#B2EC5D", 244 | "name": "Inchworm", 245 | "rgb": "(178, 236, 93)" 246 | }, 247 | { 248 | "hex": "#5D76CB", 249 | "name": "Indigo", 250 | "rgb": "(93, 118, 203)" 251 | }, 252 | { 253 | "hex": "#CA3767", 254 | "name": "Jazzberry Jam", 255 | "rgb": "(202, 55, 103)" 256 | }, 257 | { 258 | "hex": "#3BB08F", 259 | "name": "Jungle Green", 260 | "rgb": "(59, 176, 143)" 261 | }, 262 | { 263 | "hex": "#FEFE22", 264 | "name": "Laser Lemon", 265 | "rgb": "(254, 254, 34)" 266 | }, 267 | { 268 | "hex": "#FCB4D5", 269 | "name": "Lavender", 270 | "rgb": "(252, 180, 213)" 271 | }, 272 | { 273 | "hex": "#FFF44F", 274 | "name": "Lemon Yellow", 275 | "rgb": "(255, 244, 79)" 276 | }, 277 | { 278 | "hex": "#FFBD88", 279 | "name": "Macaroni and Cheese", 280 | "rgb": "(255, 189, 136)" 281 | }, 282 | { 283 | "hex": "#F664AF", 284 | "name": "Magenta", 285 | "rgb": "(246, 100, 175)" 286 | }, 287 | { 288 | "hex": "#AAF0D1", 289 | "name": "Magic Mint", 290 | "rgb": "(170, 240, 209)" 291 | }, 292 | { 293 | "hex": "#CD4A4C", 294 | "name": "Mahogany", 295 | "rgb": "(205, 74, 76)" 296 | }, 297 | { 298 | "hex": "#EDD19C", 299 | "name": "Maize", 300 | "rgb": "(237, 209, 156)" 301 | }, 302 | { 303 | "hex": "#979AAA", 304 | "name": "Manatee", 305 | "rgb": "(151, 154, 170)" 306 | }, 307 | { 308 | "hex": "#FF8243", 309 | "name": "Mango Tango", 310 | "rgb": "(255, 130, 67)" 311 | }, 312 | { 313 | "hex": "#C8385A", 314 | "name": "Maroon", 315 | "rgb": "(200, 56, 90)" 316 | }, 317 | { 318 | "hex": "#EF98AA", 319 | "name": "Mauvelous", 320 | "rgb": "(239, 152, 170)" 321 | }, 322 | { 323 | "hex": "#FDBCB4", 324 | "name": "Melon", 325 | "rgb": "(253, 188, 180)" 326 | }, 327 | { 328 | "hex": "#1A4876", 329 | "name": "Midnight Blue", 330 | "rgb": "(26, 72, 118)" 331 | }, 332 | { 333 | "hex": "#30BA8F", 334 | "name": "Mountain Meadow", 335 | "rgb": "(48, 186, 143)" 336 | }, 337 | { 338 | "hex": "#C54B8C", 339 | "name": "Mulberry", 340 | "rgb": "(197, 75, 140)" 341 | }, 342 | { 343 | "hex": "#1974D2", 344 | "name": "Navy Blue", 345 | "rgb": "(25, 116, 210)" 346 | }, 347 | { 348 | "hex": "#FFA343", 349 | "name": "Neon Carrot", 350 | "rgb": "(255, 163, 67)" 351 | }, 352 | { 353 | "hex": "#BAB86C", 354 | "name": "Olive Green", 355 | "rgb": "(186, 184, 108)" 356 | }, 357 | { 358 | "hex": "#FF7538", 359 | "name": "Orange", 360 | "rgb": "(255, 117, 56)" 361 | }, 362 | { 363 | "hex": "#FF2B2B", 364 | "name": "Orange Red", 365 | "rgb": "(255, 43, 43)" 366 | }, 367 | { 368 | "hex": "#F8D568", 369 | "name": "Orange Yellow", 370 | "rgb": "(248, 213, 104)" 371 | }, 372 | { 373 | "hex": "#E6A8D7", 374 | "name": "Orchid", 375 | "rgb": "(230, 168, 215)" 376 | }, 377 | { 378 | "hex": "#414A4C", 379 | "name": "Outer Space", 380 | "rgb": "(65, 74, 76)" 381 | }, 382 | { 383 | "hex": "#FF6E4A", 384 | "name": "Outrageous Orange", 385 | "rgb": "(255, 110, 74)" 386 | }, 387 | { 388 | "hex": "#1CA9C9", 389 | "name": "Pacific Blue", 390 | "rgb": "(28, 169, 201)" 391 | }, 392 | { 393 | "hex": "#FFCFAB", 394 | "name": "Peach", 395 | "rgb": "(255, 207, 171)" 396 | }, 397 | { 398 | "hex": "#C5D0E6", 399 | "name": "Periwinkle", 400 | "rgb": "(197, 208, 230)" 401 | }, 402 | { 403 | "hex": "#FDDDE6", 404 | "name": "Piggy Pink", 405 | "rgb": "(253, 221, 230)" 406 | }, 407 | { 408 | "hex": "#158078", 409 | "name": "Pine Green", 410 | "rgb": "(21, 128, 120)" 411 | }, 412 | { 413 | "hex": "#FC74FD", 414 | "name": "Pink Flamingo", 415 | "rgb": "(252, 116, 253)" 416 | }, 417 | { 418 | "hex": "#F78FA7", 419 | "name": "Pink Sherbet", 420 | "rgb": "(247, 143, 167)" 421 | }, 422 | { 423 | "hex": "#8E4585", 424 | "name": "Plum", 425 | "rgb": "(142, 69, 133)" 426 | }, 427 | { 428 | "hex": "#7442C8", 429 | "name": "Purple Heart", 430 | "rgb": "(116, 66, 200)" 431 | }, 432 | { 433 | "hex": "#9D81BA", 434 | "name": "Purple Mountain's Majesty", 435 | "rgb": "(157, 129, 186)" 436 | }, 437 | { 438 | "hex": "#FE4EDA", 439 | "name": "Purple Pizzazz", 440 | "rgb": "(254, 78, 218)" 441 | }, 442 | { 443 | "hex": "#FF496C", 444 | "name": "Radical Red", 445 | "rgb": "(255, 73, 108)" 446 | }, 447 | { 448 | "hex": "#D68A59", 449 | "name": "Raw Sienna", 450 | "rgb": "(214, 138, 89)" 451 | }, 452 | { 453 | "hex": "#714B23", 454 | "name": "Raw Umber", 455 | "rgb": "(113, 75, 35)" 456 | }, 457 | { 458 | "hex": "#FF48D0", 459 | "name": "Razzle Dazzle Rose", 460 | "rgb": "(255, 72, 208)" 461 | }, 462 | { 463 | "hex": "#E3256B", 464 | "name": "Razzmatazz", 465 | "rgb": "(227, 37, 107)" 466 | }, 467 | { 468 | "hex": "#EE204D", 469 | "name": "Red", 470 | "rgb": "(238,32 ,77 )" 471 | }, 472 | { 473 | "hex": "#FF5349", 474 | "name": "Red Orange", 475 | "rgb": "(255, 83, 73)" 476 | }, 477 | { 478 | "hex": "#C0448F", 479 | "name": "Red Violet", 480 | "rgb": "(192, 68, 143)" 481 | }, 482 | { 483 | "hex": "#1FCECB", 484 | "name": "Robin's Egg Blue", 485 | "rgb": "(31, 206, 203)" 486 | }, 487 | { 488 | "hex": "#7851A9", 489 | "name": "Royal Purple", 490 | "rgb": "(120, 81, 169)" 491 | }, 492 | { 493 | "hex": "#FF9BAA", 494 | "name": "Salmon", 495 | "rgb": "(255, 155, 170)" 496 | }, 497 | { 498 | "hex": "#FC2847", 499 | "name": "Scarlet", 500 | "rgb": "(252, 40, 71)" 501 | }, 502 | { 503 | "hex": "#76FF7A", 504 | "name": "Screamin' Green", 505 | "rgb": "(118, 255, 122)" 506 | }, 507 | { 508 | "hex": "#9FE2BF", 509 | "name": "Sea Green", 510 | "rgb": "(159, 226, 191)" 511 | }, 512 | { 513 | "hex": "#A5694F", 514 | "name": "Sepia", 515 | "rgb": "(165, 105, 79)" 516 | }, 517 | { 518 | "hex": "#8A795D", 519 | "name": "Shadow", 520 | "rgb": "(138, 121, 93)" 521 | }, 522 | { 523 | "hex": "#45CEA2", 524 | "name": "Shamrock", 525 | "rgb": "(69, 206, 162)" 526 | }, 527 | { 528 | "hex": "#FB7EFD", 529 | "name": "Shocking Pink", 530 | "rgb": "(251, 126, 253)" 531 | }, 532 | { 533 | "hex": "#CDC5C2", 534 | "name": "Silver", 535 | "rgb": "(205, 197, 194)" 536 | }, 537 | { 538 | "hex": "#80DAEB", 539 | "name": "Sky Blue", 540 | "rgb": "(128, 218, 235)" 541 | }, 542 | { 543 | "hex": "#ECEABE", 544 | "name": "Spring Green", 545 | "rgb": "(236, 234, 190)" 546 | }, 547 | { 548 | "hex": "#FFCF48", 549 | "name": "Sunglow", 550 | "rgb": "(255, 207, 72)" 551 | }, 552 | { 553 | "hex": "#FD5E53", 554 | "name": "Sunset Orange", 555 | "rgb": "(253, 94, 83)" 556 | }, 557 | { 558 | "hex": "#FAA76C", 559 | "name": "Tan", 560 | "rgb": "(250, 167, 108)" 561 | }, 562 | { 563 | "hex": "#18A7B5", 564 | "name": "Teal Blue", 565 | "rgb": "(24, 167, 181)" 566 | }, 567 | { 568 | "hex": "#EBC7DF", 569 | "name": "Thistle", 570 | "rgb": "(235, 199, 223)" 571 | }, 572 | { 573 | "hex": "#FC89AC", 574 | "name": "Tickle Me Pink", 575 | "rgb": "(252, 137, 172)" 576 | }, 577 | { 578 | "hex": "#DBD7D2", 579 | "name": "Timberwolf", 580 | "rgb": "(219, 215, 210)" 581 | }, 582 | { 583 | "hex": "#17806D", 584 | "name": "Tropical Rain Forest", 585 | "rgb": "(23, 128, 109)" 586 | }, 587 | { 588 | "hex": "#DEAA88", 589 | "name": "Tumbleweed", 590 | "rgb": "(222, 170, 136)" 591 | }, 592 | { 593 | "hex": "#77DDE7", 594 | "name": "Turquoise Blue", 595 | "rgb": "(119, 221, 231)" 596 | }, 597 | { 598 | "hex": "#FFFF66", 599 | "name": "Unmellow Yellow", 600 | "rgb": "(255, 255, 102)" 601 | }, 602 | { 603 | "hex": "#926EAE", 604 | "name": "Violet (Purple)", 605 | "rgb": "(146, 110, 174)" 606 | }, 607 | { 608 | "hex": "#324AB2", 609 | "name": "Violet Blue", 610 | "rgb": "(50, 74, 178)" 611 | }, 612 | { 613 | "hex": "#F75394", 614 | "name": "Violet Red", 615 | "rgb": "(247, 83, 148)" 616 | }, 617 | { 618 | "hex": "#FFA089", 619 | "name": "Vivid Tangerine", 620 | "rgb": "(255, 160, 137)" 621 | }, 622 | { 623 | "hex": "#8F509D", 624 | "name": "Vivid Violet", 625 | "rgb": "(143, 80, 157)" 626 | }, 627 | { 628 | "hex": "#FFFFFF", 629 | "name": "White", 630 | "rgb": "(255, 255, 255)" 631 | }, 632 | { 633 | "hex": "#A2ADD0", 634 | "name": "Wild Blue Yonder", 635 | "rgb": "(162, 173, 208)" 636 | }, 637 | { 638 | "hex": "#FF43A4", 639 | "name": "Wild Strawberry", 640 | "rgb": "(255, 67, 164)" 641 | }, 642 | { 643 | "hex": "#FC6C85", 644 | "name": "Wild Watermelon", 645 | "rgb": "(252, 108, 133)" 646 | }, 647 | { 648 | "hex": "#CDA4DE", 649 | "name": "Wisteria", 650 | "rgb": "(205, 164, 222)" 651 | }, 652 | { 653 | "hex": "#FCE883", 654 | "name": "Yellow", 655 | "rgb": "(252, 232, 131)" 656 | }, 657 | { 658 | "hex": "#C5E384", 659 | "name": "Yellow Green", 660 | "rgb": "(197, 227, 132)" 661 | }, 662 | { 663 | "hex": "#FFAE42", 664 | "name": "Yellow Orange", 665 | "rgb": "(255, 174, 66)" 666 | } 667 | ] 668 | -------------------------------------------------------------------------------- /common/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "common", 3 | "version": "1.0.0", 4 | "description": "Common code for search box", 5 | "scripts": { 6 | "test": "react-scripts test --env=jsdom" 7 | }, 8 | "author": "", 9 | "license": "MIT", 10 | "devDependencies": { 11 | "copy-webpack-plugin": "^4.0.1", 12 | "webpack": "^1.14.0", 13 | "enzyme": "^2.7.0", 14 | "react-addons-test-utils": "^15.4.2", 15 | "react-scripts": "0.8.5" 16 | }, 17 | "dependencies": { 18 | "material-ui": "^0.16.7", 19 | "mobx": "^3.0.1", 20 | "mobx-react": "^4.1.0", 21 | "react": "^15.4.2", 22 | "react-dom": "^15.4.2", 23 | "react-native": "^0.40.0", 24 | "react-tap-event-plugin": "^2.0.1" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /common/webpack.config.js: -------------------------------------------------------------------------------- 1 | const CopyWebpackPlugin = require('copy-webpack-plugin'); 2 | const path = require('path'); 3 | 4 | module.exports = { 5 | context: path.join(__dirname, '.'), 6 | devServer: { 7 | // This is required for older versions of webpack-dev-server 8 | // if you use absolute 'to' paths. The path should be an 9 | // absolute path to your build destination. 10 | outputPath: path.join(__dirname, 'build') 11 | }, 12 | output: { 13 | filename: 'bundle.js', 14 | path: './build' 15 | }, 16 | plugins: [ 17 | new CopyWebpackPlugin([ 18 | 19 | // {output}/to/file.txt 20 | {from: './crayola.json', to: '../../color-web/src/crayola.json'}, 21 | {from: './colors.js', to: '../../color-web/src/colors.js'}, 22 | 23 | {from: './SearchBox.js', to: '../../color-web/src/'}, 24 | {from: './Web*.js', to: '../../color-web/src/', flatten:true}, 25 | 26 | {from: './SearchBox.js', to: '../../github-web/src/'}, 27 | {from: './Web*.js', to: '../../github-web/src', flatten:true}, 28 | 29 | 30 | {from: './crayola.json', to: '../../color-mobile/crayola.json'}, 31 | {from: './colors.js', to: '../../color-mobile/colors.js'}, 32 | 33 | {from: './SearchBox.js', to: '../../color-mobile/'}, 34 | {from: './Mobile*.js', to: '../../color-mobile/', flatten:true}, 35 | 36 | {from: './SearchBox.js', to: '../../github-mobile/'}, 37 | {from: './Mobile*.js', to: '../../github-mobile/', flatten:true}, 38 | 39 | 40 | ], { 41 | 42 | ignore: [ 43 | // Doesn't copy any files with a txt extension 44 | '*.test.js', 45 | '*.config.js', 46 | ], 47 | 48 | // By default, we only copy modified files during 49 | // a watch or webpack-dev-server build. Setting this 50 | // to `true` copies all files. 51 | copyUnmodified: true 52 | }) 53 | ] 54 | }; -------------------------------------------------------------------------------- /github-mobile/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"] 3 | } -------------------------------------------------------------------------------- /github-mobile/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /github-mobile/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 11 | ; Ignore duplicate module providers 12 | ; For RN Apps installed via npm, "Libraries" folder is inside 13 | ; "node_modules/react-native" but in the source repo it is in the root 14 | .*/Libraries/react-native/React.js 15 | .*/Libraries/react-native/ReactNative.js 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/Libraries/react-native/react-native-interface.js 21 | node_modules/react-native/flow 22 | flow/ 23 | 24 | [options] 25 | module.system=haste 26 | 27 | experimental.strict_type_args=true 28 | 29 | munge_underscores=true 30 | 31 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 32 | 33 | suppress_type=$FlowIssue 34 | suppress_type=$FlowFixMe 35 | suppress_type=$FixMe 36 | 37 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-6]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 38 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-6]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 39 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 40 | 41 | unsafe.enable_getters_and_setters=true 42 | 43 | [version] 44 | ^0.36.0 45 | -------------------------------------------------------------------------------- /github-mobile/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /github-mobile/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | android/app/libs 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 50 | 51 | fastlane/report.xml 52 | fastlane/Preview.html 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /github-mobile/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /github-mobile/GitHubMobileSearchBox.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { 4 | StyleSheet, 5 | View, 6 | TextInput, 7 | ListView, 8 | Text, 9 | Image 10 | } from 'react-native'; 11 | 12 | import MobileSearchBox from './MobileSearchBox'; 13 | 14 | const styles = StyleSheet.create({ 15 | row: { 16 | flexDirection: 'row', 17 | justifyContent: 'center', 18 | padding: 10 19 | }, 20 | thumb: { 21 | width: 48, 22 | height: 48, 23 | }, 24 | text: { 25 | flex: 1, 26 | } 27 | }); 28 | 29 | const RepoListItem = ({result})=>{ 30 | return ( 31 | 32 | 33 | {result.name} 34 | 35 | ) 36 | }; 37 | const GitHubSearchBox = MobileSearchBox(RepoListItem); 38 | export default GitHubSearchBox; -------------------------------------------------------------------------------- /github-mobile/MobileSearchBox.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { 4 | StyleSheet, 5 | View, 6 | } from 'react-native'; 7 | 8 | import {observer} from 'mobx-react/native'; 9 | 10 | import MobileSearchInput from './MobileSearchInput'; 11 | import MobileSearchResults from './MobileSearchResults'; 12 | 13 | import SearchBox from './SearchBox' 14 | 15 | const styles = StyleSheet.create({ 16 | container: { 17 | flex: 1, 18 | backgroundColor: '#eeeeee', 19 | marginTop: 25 20 | } 21 | }); 22 | 23 | const MobileSearchFrame = ({children}) => { 24 | return ( 25 | 26 | {children} 27 | 28 | ); 29 | }; 30 | 31 | const MobileSearchBox = ListItem => observer(SearchBox(MobileSearchFrame, MobileSearchInput, MobileSearchResults(ListItem))); 32 | 33 | export default MobileSearchBox -------------------------------------------------------------------------------- /github-mobile/MobileSearchInput.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {TextInput} from 'react-native'; 3 | 4 | const MobileSearchInput = ({query, onSubmit, onQueryUpdate}) => { 5 | 6 | return ( 7 | onQueryUpdate(text)} 10 | value={query} 11 | returnKeyType={'search'} 12 | autoCapitalize={'none'} 13 | autoCorrect={false} 14 | onSubmitEditing={() => onSubmit()} 15 | /> 16 | ); 17 | 18 | }; 19 | 20 | MobileSearchInput.propTypes = { 21 | query: React.PropTypes.string.isRequired, 22 | onSubmit: React.PropTypes.func.isRequired, 23 | onQueryUpdate: React.PropTypes.func.isRequired 24 | }; 25 | 26 | export default MobileSearchInput; -------------------------------------------------------------------------------- /github-mobile/MobileSearchResults.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import { 3 | StyleSheet, 4 | View, 5 | TextInput, 6 | ListView, 7 | Text 8 | } from 'react-native'; 9 | const styles = StyleSheet.create({ 10 | separator: { 11 | flex: 1, 12 | height: 1, 13 | backgroundColor: '#8E8E8E', 14 | } 15 | }); 16 | 17 | const MobileSearchResults = ListItem => { 18 | return class extends Component { 19 | constructor(props) { 20 | super(props); 21 | this.dataSource = new ListView.DataSource({rowHasChanged: (r1, r2) => r1.name !== r2.name}); 22 | } 23 | 24 | static propTypes = { 25 | results: React.PropTypes.array.isRequired 26 | }; 27 | 28 | renderRow = (rowData, sectionId, rowID) => { 29 | return ( 30 | 31 | ); 32 | }; 33 | 34 | render() { 35 | return ( 36 | } 40 | /> 41 | ); 42 | } 43 | }; 44 | }; 45 | 46 | export default MobileSearchResults; -------------------------------------------------------------------------------- /github-mobile/SearchBox.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | 3 | const SearchBox = (SearchFrame, SearchInput, SearchResults) => { 4 | return class extends Component { 5 | static propTypes = { 6 | searchStore: React.PropTypes.object.isRequired 7 | }; 8 | 9 | render() { 10 | return ( 11 | 12 | this.props.searchStore.updateQuery(value)} 14 | onSubmit={() => this.props.searchStore.search()} 15 | /> 16 | 17 | 18 | ); 19 | } 20 | }; 21 | }; 22 | 23 | 24 | export default SearchBox -------------------------------------------------------------------------------- /github-mobile/__tests__/index.android.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.android.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /github-mobile/__tests__/index.ios.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.ios.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /github-mobile/android/app/BUCK: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | # To learn about Buck see [Docs](https://buckbuild.com/). 4 | # To run your application with Buck: 5 | # - install Buck 6 | # - `npm start` - to start the packager 7 | # - `cd android` 8 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 9 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 10 | # - `buck install -r android/app` - compile, install and run application 11 | # 12 | 13 | lib_deps = [] 14 | for jarfile in glob(['libs/*.jar']): 15 | name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) 16 | lib_deps.append(':' + name) 17 | prebuilt_jar( 18 | name = name, 19 | binary_jar = jarfile, 20 | ) 21 | 22 | for aarfile in glob(['libs/*.aar']): 23 | name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile) 24 | lib_deps.append(':' + name) 25 | android_prebuilt_aar( 26 | name = name, 27 | aar = aarfile, 28 | ) 29 | 30 | android_library( 31 | name = 'all-libs', 32 | exported_deps = lib_deps 33 | ) 34 | 35 | android_library( 36 | name = 'app-code', 37 | srcs = glob([ 38 | 'src/main/java/**/*.java', 39 | ]), 40 | deps = [ 41 | ':all-libs', 42 | ':build_config', 43 | ':res', 44 | ], 45 | ) 46 | 47 | android_build_config( 48 | name = 'build_config', 49 | package = 'com.githubmobile', 50 | ) 51 | 52 | android_resource( 53 | name = 'res', 54 | res = 'src/main/res', 55 | package = 'com.githubmobile', 56 | ) 57 | 58 | android_binary( 59 | name = 'app', 60 | package_type = 'debug', 61 | manifest = 'src/main/AndroidManifest.xml', 62 | keystore = '//android/keystores:debug', 63 | deps = [ 64 | ':app-code', 65 | ], 66 | ) 67 | -------------------------------------------------------------------------------- /github-mobile/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // the root of your project, i.e. where "package.json" lives 37 | * root: "../../", 38 | * 39 | * // where to put the JS bundle asset in debug mode 40 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 41 | * 42 | * // where to put the JS bundle asset in release mode 43 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 44 | * 45 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 46 | * // require('./image.png')), in debug mode 47 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 48 | * 49 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 50 | * // require('./image.png')), in release mode 51 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 52 | * 53 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 54 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 55 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 56 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 57 | * // for example, you might want to remove it from here. 58 | * inputExcludes: ["android/**", "ios/**"], 59 | * 60 | * // override which node gets called and with what additional arguments 61 | * nodeExecutableAndArgs: ["node"] 62 | * 63 | * // supply additional arguments to the packager 64 | * extraPackagerArgs: [] 65 | * ] 66 | */ 67 | 68 | apply from: "../../node_modules/react-native/react.gradle" 69 | 70 | /** 71 | * Set this to true to create two separate APKs instead of one: 72 | * - An APK that only works on ARM devices 73 | * - An APK that only works on x86 devices 74 | * The advantage is the size of the APK is reduced by about 4MB. 75 | * Upload all the APKs to the Play Store and people will download 76 | * the correct one based on the CPU architecture of their device. 77 | */ 78 | def enableSeparateBuildPerCPUArchitecture = false 79 | 80 | /** 81 | * Run Proguard to shrink the Java bytecode in release builds. 82 | */ 83 | def enableProguardInReleaseBuilds = false 84 | 85 | android { 86 | compileSdkVersion 23 87 | buildToolsVersion "23.0.1" 88 | 89 | defaultConfig { 90 | applicationId "com.githubmobile" 91 | minSdkVersion 16 92 | targetSdkVersion 22 93 | versionCode 1 94 | versionName "1.0" 95 | ndk { 96 | abiFilters "armeabi-v7a", "x86" 97 | } 98 | } 99 | splits { 100 | abi { 101 | reset() 102 | enable enableSeparateBuildPerCPUArchitecture 103 | universalApk false // If true, also generate a universal APK 104 | include "armeabi-v7a", "x86" 105 | } 106 | } 107 | buildTypes { 108 | release { 109 | minifyEnabled enableProguardInReleaseBuilds 110 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 111 | } 112 | } 113 | // applicationVariants are e.g. debug, release 114 | applicationVariants.all { variant -> 115 | variant.outputs.each { output -> 116 | // For each separate APK per architecture, set a unique version code as described here: 117 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 118 | def versionCodes = ["armeabi-v7a":1, "x86":2] 119 | def abi = output.getFilter(OutputFile.ABI) 120 | if (abi != null) { // null for the universal-debug, universal-release variants 121 | output.versionCodeOverride = 122 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 123 | } 124 | } 125 | } 126 | } 127 | 128 | dependencies { 129 | compile fileTree(dir: "libs", include: ["*.jar"]) 130 | compile "com.android.support:appcompat-v7:23.0.1" 131 | compile "com.facebook.react:react-native:+" // From node_modules 132 | } 133 | 134 | // Run this once to be able to run the application with BUCK 135 | // puts all compile dependencies into folder libs for BUCK to use 136 | task copyDownloadableDepsToLibs(type: Copy) { 137 | from configurations.compile 138 | into 'libs' 139 | } 140 | -------------------------------------------------------------------------------- /github-mobile/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Disabling obfuscation is useful if you collect stack traces from production crashes 20 | # (unless you are using a system that supports de-obfuscate the stack traces). 21 | -dontobfuscate 22 | 23 | # React Native 24 | 25 | # Keep our interfaces so they can be used by other ProGuard rules. 26 | # See http://sourceforge.net/p/proguard/bugs/466/ 27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 30 | 31 | # Do not strip any method/class that is annotated with @DoNotStrip 32 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 33 | -keep @com.facebook.common.internal.DoNotStrip class * 34 | -keepclassmembers class * { 35 | @com.facebook.proguard.annotations.DoNotStrip *; 36 | @com.facebook.common.internal.DoNotStrip *; 37 | } 38 | 39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 40 | void set*(***); 41 | *** get*(); 42 | } 43 | 44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 46 | -keepclassmembers,includedescriptorclasses class * { native ; } 47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 50 | 51 | -dontwarn com.facebook.react.** 52 | 53 | # okhttp 54 | 55 | -keepattributes Signature 56 | -keepattributes *Annotation* 57 | -keep class okhttp3.** { *; } 58 | -keep interface okhttp3.** { *; } 59 | -dontwarn okhttp3.** 60 | 61 | # okio 62 | 63 | -keep class sun.misc.Unsafe { *; } 64 | -dontwarn java.nio.file.* 65 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 66 | -dontwarn okio.** 67 | -------------------------------------------------------------------------------- /github-mobile/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /github-mobile/android/app/src/main/java/com/githubmobile/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.githubmobile; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "GitHubMobile"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /github-mobile/android/app/src/main/java/com/githubmobile/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.githubmobile; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactInstanceManager; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.react.shell.MainReactPackage; 11 | import com.facebook.soloader.SoLoader; 12 | 13 | import java.util.Arrays; 14 | import java.util.List; 15 | 16 | public class MainApplication extends Application implements ReactApplication { 17 | 18 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 19 | @Override 20 | protected boolean getUseDeveloperSupport() { 21 | return BuildConfig.DEBUG; 22 | } 23 | 24 | @Override 25 | protected List getPackages() { 26 | return Arrays.asList( 27 | new MainReactPackage() 28 | ); 29 | } 30 | }; 31 | 32 | @Override 33 | public ReactNativeHost getReactNativeHost() { 34 | return mReactNativeHost; 35 | } 36 | 37 | @Override 38 | public void onCreate() { 39 | super.onCreate(); 40 | SoLoader.init(this, /* native exopackage */ false); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /github-mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csepulv/search-box/7c836c4acbf2ce87e4e8596fec2bdae7b690499e/github-mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /github-mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csepulv/search-box/7c836c4acbf2ce87e4e8596fec2bdae7b690499e/github-mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /github-mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csepulv/search-box/7c836c4acbf2ce87e4e8596fec2bdae7b690499e/github-mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /github-mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csepulv/search-box/7c836c4acbf2ce87e4e8596fec2bdae7b690499e/github-mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /github-mobile/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | GitHubMobile 3 | 4 | -------------------------------------------------------------------------------- /github-mobile/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /github-mobile/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.3.1' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenLocal() 18 | jcenter() 19 | maven { 20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 21 | url "$rootDir/../node_modules/react-native/android" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /github-mobile/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /github-mobile/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csepulv/search-box/7c836c4acbf2ce87e4e8596fec2bdae7b690499e/github-mobile/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /github-mobile/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip 6 | -------------------------------------------------------------------------------- /github-mobile/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /github-mobile/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /github-mobile/android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = 'debug', 3 | store = 'debug.keystore', 4 | properties = 'debug.keystore.properties', 5 | visibility = [ 6 | 'PUBLIC', 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /github-mobile/android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /github-mobile/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'GitHubMobile' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /github-mobile/github.js: -------------------------------------------------------------------------------- 1 | import {extendObservable, runInAction} from 'mobx'; 2 | import qs from 'qs'; 3 | 4 | export default class GitHub { 5 | constructor() { 6 | extendObservable(this, { 7 | results: [], 8 | query: '' 9 | }); 10 | } 11 | 12 | search() { 13 | const self = this; 14 | return new Promise((resolve, reject) => { 15 | const encodedQuery = qs.stringify({q: this.query}); 16 | 17 | fetch(`https://api.github.com/search/repositories?${encodedQuery}`) 18 | .then((response) => { 19 | if (response.ok) 20 | return response.json(); 21 | else reject(`${response.status}:${response.statusText}`); 22 | }) 23 | .then((json) => { 24 | runInAction(() => { 25 | self.results = json.items; 26 | resolve(); 27 | }); 28 | }) 29 | .catch((error) => { 30 | runInAction(() => { 31 | self.results = []; 32 | reject(error); 33 | }); 34 | }); 35 | }); 36 | } 37 | 38 | updateQuery(value) { 39 | runInAction(() => this.query = value); 40 | } 41 | } -------------------------------------------------------------------------------- /github-mobile/index.android.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import React, { Component } from 'react'; 8 | import { 9 | AppRegistry, 10 | StyleSheet, 11 | Text, 12 | View 13 | } from 'react-native'; 14 | 15 | export default class GitHubMobile extends Component { 16 | render() { 17 | return ( 18 | 19 | 20 | Welcome to React Native! 21 | 22 | 23 | To get started, edit index.android.js 24 | 25 | 26 | Double tap R on your keyboard to reload,{'\n'} 27 | Shake or press menu button for dev menu 28 | 29 | 30 | ); 31 | } 32 | } 33 | 34 | const styles = StyleSheet.create({ 35 | container: { 36 | flex: 1, 37 | justifyContent: 'center', 38 | alignItems: 'center', 39 | backgroundColor: '#F5FCFF', 40 | }, 41 | welcome: { 42 | fontSize: 20, 43 | textAlign: 'center', 44 | margin: 10, 45 | }, 46 | instructions: { 47 | textAlign: 'center', 48 | color: '#333333', 49 | marginBottom: 5, 50 | }, 51 | }); 52 | 53 | AppRegistry.registerComponent('GitHubMobile', () => GitHubMobile); 54 | -------------------------------------------------------------------------------- /github-mobile/index.ios.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import React, {Component} from 'react'; 8 | import {AppRegistry} from 'react-native'; 9 | 10 | import GitHub from './github'; 11 | 12 | import GitHubMobileSearchBox from './GitHubMobileSearchBox'; 13 | 14 | export default class App extends Component { 15 | 16 | render() { 17 | return ( 18 | 19 | ); 20 | } 21 | } 22 | AppRegistry.registerComponent('GitHubMobile', () => App); 23 | -------------------------------------------------------------------------------- /github-mobile/ios/GitHubMobile.xcodeproj/xcshareddata/xcschemes/GitHubMobile.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /github-mobile/ios/GitHubMobile/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /github-mobile/ios/GitHubMobile/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "AppDelegate.h" 11 | 12 | #import 13 | #import 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 18 | { 19 | NSURL *jsCodeLocation; 20 | 21 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; 22 | 23 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 24 | moduleName:@"GitHubMobile" 25 | initialProperties:nil 26 | launchOptions:launchOptions]; 27 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 28 | 29 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 30 | UIViewController *rootViewController = [UIViewController new]; 31 | rootViewController.view = rootView; 32 | self.window.rootViewController = rootViewController; 33 | [self.window makeKeyAndVisible]; 34 | return YES; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /github-mobile/ios/GitHubMobile/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /github-mobile/ios/GitHubMobile/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /github-mobile/ios/GitHubMobile/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UIViewControllerBasedStatusBarAppearance 38 | 39 | NSLocationWhenInUseUsageDescription 40 | 41 | NSAppTransportSecurity 42 | 43 | 44 | NSExceptionDomains 45 | 46 | localhost 47 | 48 | NSExceptionAllowsInsecureHTTPLoads 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /github-mobile/ios/GitHubMobile/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /github-mobile/ios/GitHubMobileTests/GitHubMobileTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | #import 14 | #import 15 | 16 | #define TIMEOUT_SECONDS 600 17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 18 | 19 | @interface GitHubMobileTests : XCTestCase 20 | 21 | @end 22 | 23 | @implementation GitHubMobileTests 24 | 25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 26 | { 27 | if (test(view)) { 28 | return YES; 29 | } 30 | for (UIView *subview in [view subviews]) { 31 | if ([self findSubviewInView:subview matching:test]) { 32 | return YES; 33 | } 34 | } 35 | return NO; 36 | } 37 | 38 | - (void)testRendersWelcomeScreen 39 | { 40 | UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; 41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 42 | BOOL foundElement = NO; 43 | 44 | __block NSString *redboxError = nil; 45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 46 | if (level >= RCTLogLevelError) { 47 | redboxError = message; 48 | } 49 | }); 50 | 51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 54 | 55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 57 | return YES; 58 | } 59 | return NO; 60 | }]; 61 | } 62 | 63 | RCTSetLogFunction(RCTDefaultLogFunction); 64 | 65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 67 | } 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /github-mobile/ios/GitHubMobileTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /github-mobile/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GitHubMobile", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node node_modules/react-native/local-cli/cli.js start", 7 | "test": "jest" 8 | }, 9 | "dependencies": { 10 | "mobx": "^3.0.0", 11 | "mobx-react": "^4.1.0", 12 | "qs": "^6.3.0", 13 | "react": "15.4.2", 14 | "react-native": "0.40.0" 15 | }, 16 | "devDependencies": { 17 | "babel-jest": "18.0.0", 18 | "babel-preset-react-native": "1.9.1", 19 | "jest": "18.1.0", 20 | "react-test-renderer": "15.4.2" 21 | }, 22 | "jest": { 23 | "preset": "react-native" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /github-web/firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "hosting": { 3 | "public": "build", 4 | "rewrites": [ 5 | { 6 | "source": "**", 7 | "destination": "/index.html" 8 | } 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /github-web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "github-web", 3 | "version": "0.1.0", 4 | "private": true, 5 | "devDependencies": { 6 | "fetch-mock": "^5.8.1", 7 | "react-scripts": "0.8.5" 8 | }, 9 | "dependencies": { 10 | "material-ui": "^0.16.6", 11 | "mobx": "^3.0.0", 12 | "mobx-react": "^4.1.0", 13 | "qs": "^6.3.0", 14 | "react": "^15.4.2", 15 | "react-dom": "^15.4.2", 16 | "react-tap-event-plugin": "^2.0.1" 17 | }, 18 | "scripts": { 19 | "start": "react-scripts start", 20 | "build": "react-scripts build", 21 | "test": "react-scripts test --env=jsdom", 22 | "eject": "react-scripts eject" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /github-web/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csepulv/search-box/7c836c4acbf2ce87e4e8596fec2bdae7b690499e/github-web/public/favicon.ico -------------------------------------------------------------------------------- /github-web/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 16 | Search Box Sample: GitHub 17 | 18 | 19 |
20 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /github-web/src/SearchBox.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | 3 | const SearchBox = (SearchFrame, SearchInput, SearchResults) => { 4 | return class extends Component { 5 | static propTypes = { 6 | searchStore: React.PropTypes.object.isRequired 7 | }; 8 | 9 | render() { 10 | return ( 11 | 12 | this.props.searchStore.updateQuery(value)} 14 | onSubmit={() => this.props.searchStore.search()} 15 | /> 16 | 17 | 18 | ); 19 | } 20 | }; 21 | }; 22 | 23 | 24 | export default SearchBox -------------------------------------------------------------------------------- /github-web/src/WebSearchBox.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; 3 | 4 | // (Make material-ui happy) 5 | // Needed for onTouchTap 6 | // http://stackoverflow.com/a/34015469/988941 7 | import injectTapEventPlugin from 'react-tap-event-plugin'; 8 | injectTapEventPlugin(); 9 | 10 | import WebSearchInput from './WebSearchInput'; 11 | import WebSearchResults from './WebSearchResults'; 12 | 13 | import SearchBox from './SearchBox' 14 | import {observer} from 'mobx-react'; 15 | 16 | const WebSearchFrame = ({children}) => { 17 | return ( 18 | 19 |
20 | {children} 21 |
22 |
23 | ); 24 | }; 25 | 26 | const WebSearchBox = ListItem => observer(SearchBox(WebSearchFrame, WebSearchInput, WebSearchResults(ListItem))); 27 | 28 | export default WebSearchBox -------------------------------------------------------------------------------- /github-web/src/WebSearchInput.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {TextField} from 'material-ui'; 3 | 4 | const WebSearchInput = ({query, onSubmit, onQueryUpdate}) => { 5 | const handleKeyDown = (event) => { 6 | const ENTER_KEY = 13; 7 | if (event.keyCode === ENTER_KEY) { 8 | event.preventDefault(); 9 | onSubmit(); 10 | } 11 | }; 12 | 13 | return ( 14 | onQueryUpdate(value)} 19 | onKeyDown={handleKeyDown}/> 20 | ); 21 | 22 | }; 23 | 24 | WebSearchInput.propTypes = { 25 | query: React.PropTypes.string.isRequired, 26 | onSubmit: React.PropTypes.func.isRequired, 27 | onQueryUpdate: React.PropTypes.func.isRequired 28 | }; 29 | 30 | export default WebSearchInput; -------------------------------------------------------------------------------- /github-web/src/WebSearchResults.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import {List} from 'material-ui' 3 | 4 | const WebSearchResults = ListItem => { 5 | return class extends Component { 6 | static propTypes = { 7 | results: React.PropTypes.array.isRequired 8 | }; 9 | 10 | render() { 11 | const listItems = this.props.results.map((result, index) => { 12 | return ( 13 | 14 | ); 15 | }); 16 | return ( 17 | 18 | {listItems} 19 | 20 | ); 21 | }; 22 | }; 23 | }; 24 | 25 | export default WebSearchResults; -------------------------------------------------------------------------------- /github-web/src/github.js: -------------------------------------------------------------------------------- 1 | import {extendObservable, runInAction} from 'mobx'; 2 | import qs from 'qs'; 3 | 4 | export default class GitHub { 5 | constructor() { 6 | extendObservable(this, { 7 | results: [], 8 | query: '' 9 | }); 10 | } 11 | 12 | search() { 13 | const self = this; 14 | return new Promise((resolve, reject) => { 15 | const encodedQuery = qs.stringify({q: this.query}); 16 | 17 | fetch(`https://api.github.com/search/repositories?${encodedQuery}`) 18 | .then((response) => { 19 | if (response.ok) 20 | return response.json(); 21 | else reject(`${response.status}:${response.statusText}`); 22 | }) 23 | .then((json) => { 24 | runInAction(() => { 25 | self.results = json.items; 26 | resolve(); 27 | }); 28 | }) 29 | .catch((error) => { 30 | runInAction(() => { 31 | self.results = []; 32 | reject(error); 33 | }); 34 | }); 35 | }); 36 | } 37 | 38 | updateQuery(value) { 39 | runInAction(() => this.query = value); 40 | } 41 | } -------------------------------------------------------------------------------- /github-web/src/github.test.js: -------------------------------------------------------------------------------- 1 | import GitHub from './github' 2 | import FetchMock from 'fetch-mock'; 3 | 4 | describe("GitHub", () => { 5 | let gitHub; 6 | beforeEach(() => { 7 | gitHub = new GitHub(); 8 | gitHub.query = 'the-query'; 9 | FetchMock.catch(503); 10 | }); 11 | afterEach(() => FetchMock.restore()); 12 | it("succeeds", () => { 13 | const response = { 14 | items: ['a', 'b'] 15 | }; 16 | FetchMock.get('https://api.github.com/search/repositories?q=the-query', response); 17 | return gitHub.search() 18 | .then(() => { 19 | expect(gitHub.results.slice()).toEqual(['a', 'b']); 20 | }) 21 | }); 22 | it("fails", () => { 23 | FetchMock.get('https://api.github.com/search/repositories?q=the-query', {status: 500}); 24 | return gitHub.search() 25 | .then(() => { 26 | expect('').toEqual("shouldn't get here, but we got here"); 27 | }) 28 | .catch((error) => { 29 | expect(error).toEqual('500:Internal Server Error'); 30 | }); 31 | }); 32 | it("has error", () => { 33 | FetchMock.get('https://api.github.com/search/repositories?q=the-query', {throws: 'some error'}); 34 | return gitHub.search() 35 | .then(() => { 36 | expect('').toEqual("shouldn't get here, but we got here"); 37 | }) 38 | .catch((error) => { 39 | expect(error).toEqual('some error'); 40 | }); 41 | }); 42 | 43 | }); -------------------------------------------------------------------------------- /github-web/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: sans-serif; 5 | } 6 | -------------------------------------------------------------------------------- /github-web/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import WebSearchBox from './WebSearchBox'; 4 | import './index.css'; 5 | 6 | import {ListItem, Divider, Avatar} from 'material-ui' 7 | 8 | import GitHub from './github' 9 | 10 | const RepoListItem = ({result}) => { 11 | return ( 12 |
13 | }/> 14 | 15 |
16 | ); 17 | }; 18 | 19 | RepoListItem.propTypes = { 20 | result: React.PropTypes.object.isRequired 21 | }; 22 | 23 | const RepoSearchBox = WebSearchBox(RepoListItem); 24 | 25 | ReactDOM.render( 26 | , 27 | document.getElementById('root') 28 | ); 29 | --------------------------------------------------------------------------------