├── .watchmanconfig ├── #.profile# ├── .DS_Store ├── .gitignore ├── app ├── .DS_Store ├── public │ ├── logo.png │ └── mch1256.png ├── screens │ ├── VinScan.js │ ├── PlateScan.js │ ├── Catalog.js │ ├── Shops.js │ ├── Login.js │ ├── Menu.js │ ├── VehicleDetail.js │ └── Vehicles.js ├── index.js ├── config │ ├── default.json │ └── router.js └── components │ ├── core │ ├── ListItem.js │ └── Header.js │ ├── SVG.js │ └── scan │ ├── ConfirmVehicle.js │ ├── VINEntry.js │ ├── index.js │ └── PTVDetail.js ├── .babelrc ├── app.json ├── App.test.js ├── package.json ├── .eslintrc ├── .flowconfig ├── App.js └── README.md /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /#.profile#: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Big-Silver/ReactNative-Oreilly-App/HEAD/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .expo/ 3 | .expo-source/ 4 | .vscode/ 5 | npm-debug.* 6 | -------------------------------------------------------------------------------- /app/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Big-Silver/ReactNative-Oreilly-App/HEAD/app/.DS_Store -------------------------------------------------------------------------------- /app/public/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Big-Silver/ReactNative-Oreilly-App/HEAD/app/public/logo.png -------------------------------------------------------------------------------- /app/public/mch1256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Big-Silver/ReactNative-Oreilly-App/HEAD/app/public/mch1256.png -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["babel-preset-expo"], 3 | "env": { 4 | "development": { 5 | "plugins": ["transform-react-jsx-source"] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "expo": { 3 | "name": "Mobile-App", 4 | "slug": "mobile-app", 5 | "sdkVersion": "24.0.0", 6 | "orientation": "portrait" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /App.test.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import renderer from "react-test-renderer" 3 | 4 | import App from "./App" 5 | 6 | it("renders without crashing", () => { 7 | const rendered = renderer.create().toJSON() 8 | expect(rendered).toBeTruthy() 9 | }) 10 | -------------------------------------------------------------------------------- /app/screens/VinScan.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Scan from '../components/scan'; 3 | 4 | export default class VinScanScreen extends React.Component { 5 | render() { 6 | const { navigation } = this.props; 7 | 8 | return ; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /app/screens/PlateScan.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Scan from '../components/scan'; 3 | 4 | export default class PlateScanScreen extends React.Component { 5 | render() { 6 | const { navigation } = this.props; 7 | 8 | return ; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /app/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, Text, View } from 'react-native'; 3 | 4 | const styles = StyleSheet.create({ 5 | container: { 6 | flex: 1, 7 | backgroundColor: '#fff', 8 | alignItems: 'center', 9 | justifyContent: 'center' 10 | } 11 | }); 12 | 13 | export default class App extends React.Component { 14 | render() { 15 | return ( 16 | 17 | I love you very much 18 | 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiBaseUrl": "http://192.168.0.129:20000/api/v1", 3 | "decodeVinApiUrl": "https://fco.firstcallonline.com//FirstCallOnline/vin-scanner/decode-vin-code.json", 4 | "decodePlateApiUrl": "https://sms-dev-int-1.firstcallonline.com/EnterpriseServices/services/plate/decode", 5 | "oauth": { 6 | "authorizationUrl": "https://localhost:8443/oauth/authorize", 7 | "tokenUrl": "https://localhost:8443/oauth/token", 8 | "clientId": "oreilly", 9 | "response_type": "code", 10 | "scope": "manage_customer_information", 11 | "state": "H12345" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/screens/Catalog.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, View, ScrollView, Platform } from 'react-native'; 3 | import Header from '../components/core/Header'; 4 | 5 | const styles = StyleSheet.create({ 6 | container: { 7 | flex: 1 8 | }, 9 | header: { 10 | marginTop: (Platform.OS === 'ios') ? 20 : 0, 11 | backgroundColor: '#0a6348', 12 | height: 65, 13 | width: '100%' 14 | }, 15 | headerText: { 16 | color: '#fff', 17 | textAlign: 'center', 18 | lineHeight: 65, 19 | fontSize: 20, 20 | fontWeight: 'bold' 21 | } 22 | }); 23 | 24 | export default class VinScanScreen extends React.Component { 25 | render() { 26 | const { navigation } = this.props; 27 | 28 | return ( 29 | 30 |
31 | 32 | 33 | 34 | 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/config/router.js: -------------------------------------------------------------------------------- 1 | import { StackNavigator, DrawerNavigator } from 'react-navigation'; 2 | import LoginScreen from '../screens/Login'; 3 | import ShopScreen from '../screens/Shops'; 4 | import VehiclesScreen from '../screens/Vehicles'; 5 | import VinScanScreen from '../screens/VinScan'; 6 | import PlateScanScreen from '../screens/PlateScan'; 7 | import CatalogScreen from '../screens/Catalog'; 8 | import MenuContainer from '../screens/Menu'; 9 | 10 | const MainMenu = DrawerNavigator( 11 | { 12 | Shops: { 13 | screen: ShopScreen 14 | }, 15 | Vehicles: { 16 | screen: VehiclesScreen 17 | }, 18 | VinScan: { 19 | screen: VinScanScreen 20 | }, 21 | PlateScan: { 22 | screen: PlateScanScreen 23 | }, 24 | Catalog: { 25 | screen: CatalogScreen 26 | }, 27 | LogOut: { 28 | screen: LoginScreen, 29 | navigationOptions: { 30 | drawerLabel: 'Log out' 31 | } 32 | } 33 | }, 34 | { 35 | drawerWidth: 300, 36 | contentComponent: MenuContainer, 37 | drawerOpenRoute: 'DrawerOpen', 38 | drawerCloseRoute: 'DrawerClose', 39 | drawerToggleRoute: 'DrawerToggle' 40 | } 41 | ); 42 | 43 | export const OReillyApp = StackNavigator({ 44 | Login: { 45 | screen: LoginScreen 46 | }, 47 | Menu: { 48 | screen: MainMenu 49 | } 50 | }, { 51 | headerMode: 'none', 52 | title: 'Menu', 53 | initialRouteName: 'Login' 54 | }); 55 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Mobile-App", 3 | "version": "0.1.0", 4 | "private": true, 5 | "devDependencies": { 6 | "babel-eslint": "^8.0.3", 7 | "eslint": "^4.12.1", 8 | "eslint-config-airbnb": "^16.1.0", 9 | "eslint-plugin-import": "^2.8.0", 10 | "eslint-plugin-jsx-a11y": "^6.0.2", 11 | "eslint-plugin-react": "^7.5.1", 12 | "eslint-plugin-react-native": "^3.2.0", 13 | "jest-expo": "^21.0.2", 14 | "react-native-scripts": "1.8.1", 15 | "react-test-renderer": "16.0.0-alpha.12" 16 | }, 17 | "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js", 18 | "scripts": { 19 | "start": "react-native-scripts start", 20 | "eject": "react-native-scripts eject", 21 | "android": "react-native-scripts android", 22 | "ios": "react-native-scripts ios", 23 | "lint": "eslint app/**/*.js", 24 | "test": "jest" 25 | }, 26 | "jest": { 27 | "preset": "jest-expo" 28 | }, 29 | "dependencies": { 30 | "expo": "24.0.0", 31 | "moment": "^2.20.1", 32 | "query-string": "^5.0.1", 33 | "react": "16.0.0", 34 | "react-native": "0.51.0", 35 | "react-native-collapsible": "^0.9.0", 36 | "react-native-elements": "^0.17.0", 37 | "react-native-material-dropdown": "^0.5.2", 38 | "react-native-scripts": "^1.8.1", 39 | "react-native-scrollable-tab-view": "^0.8.0", 40 | "react-native-side-menu": "^1.1.3", 41 | "react-navigation": "^1.0.0-beta.26" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "airbnb", 3 | "parser": "babel-eslint", 4 | "rules": { 5 | "strict": 0, 6 | "react/jsx-filename-extension": ["error", { "extensions": [".js", ".jsx"] }], 7 | "global-require": "off", 8 | "comma-dangle": "off", 9 | "indent": ["error", 2], 10 | "space-in-parens": ["error", "never"], 11 | "quotes": ["error", "single"], 12 | "semi": ["error", "always"], 13 | "no-trailing-spaces": "error", 14 | "no-whitespace-before-property": "error", 15 | "object-shorthand": ["error", "always"], 16 | "no-irregular-whitespace": 0, 17 | "react/prefer-stateless-function": [ 18 | 0, 19 | { 20 | "ignorePureComponents": false 21 | } 22 | ], 23 | "react/prop-types": [ 24 | 0, 25 | { 26 | "ignore": 2, 27 | "customValidators": 2 28 | } 29 | ], 30 | "no-multi-str": "off", 31 | "no-undef": "off", 32 | "no-console": "off", 33 | "arrow-body-style": "off", 34 | "import/prefer-default-export": "off", 35 | "max-len": [ 36 | 0 37 | ], 38 | "no-alert": "off", 39 | "react/no-multi-comp": "off", 40 | "no-nested-ternary": "off", 41 | "import/no-extraneous-dependencies": [ 42 | "off", 43 | { 44 | "devDependencies": false, 45 | "optionalDependencies": false, 46 | "peerDependencies": false 47 | } 48 | ], 49 | "consistent-return": "off", 50 | "arrow-parens": "off", 51 | "quote-props": "off" 52 | } 53 | } -------------------------------------------------------------------------------- /app/components/core/ListItem.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, Text, View, Dimensions, TouchableOpacity } from 'react-native'; 3 | import { MaterialIcons } from '@expo/vector-icons'; 4 | 5 | const WINDOW = Dimensions.get('window'); 6 | const styles = StyleSheet.create({ 7 | item: { 8 | borderStyle: 'solid', 9 | borderBottomWidth: 1, 10 | borderBottomColor: '#d5d5d5', 11 | paddingTop: 20, 12 | paddingBottom: 20, 13 | paddingLeft: 18, 14 | paddingRight: 18, 15 | flex: 1, 16 | flexDirection: 'row', 17 | justifyContent: 'space-between' 18 | }, 19 | itemTitle: { 20 | fontSize: 18, 21 | color: '#383838' 22 | }, 23 | itemContent: { 24 | fontSize: 16, 25 | color: '#8b8b8b', 26 | width: WINDOW.width - 88 27 | }, 28 | itemLink: { 29 | flexDirection: 'column', 30 | justifyContent: 'center', 31 | alignItems: 'center', 32 | paddingTop: 5, 33 | width: 32 34 | }, 35 | itemInfo: { 36 | marginRight: 20 37 | } 38 | }); 39 | 40 | export default class Item extends React.Component { 41 | render() { 42 | const { 43 | title, desc, scanAt, linkIcon, onPressItem, onPressIcon 44 | } = this.props; 45 | 46 | return ( 47 | 48 | 49 | {title} 50 | {desc} 51 | {scanAt} 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /.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 | ; Additional create-react-native-app ignores 18 | 19 | ; Ignore duplicate module providers 20 | .*/node_modules/fbemitter/lib/* 21 | 22 | ; Ignore misbehaving dev-dependencies 23 | .*/node_modules/xdl/build/* 24 | .*/node_modules/reqwest/tests/* 25 | 26 | ; Ignore missing expo-sdk dependencies (temporarily) 27 | ; https://github.com/expo/expo/issues/162 28 | .*/node_modules/expo/src/* 29 | 30 | ; Ignore react-native-fbads dependency of the expo sdk 31 | .*/node_modules/react-native-fbads/* 32 | 33 | [include] 34 | 35 | [libs] 36 | node_modules/react-native/Libraries/react-native/react-native-interface.js 37 | node_modules/react-native/flow 38 | flow/ 39 | 40 | [options] 41 | module.system=haste 42 | 43 | emoji=true 44 | 45 | experimental.strict_type_args=true 46 | 47 | munge_underscores=true 48 | 49 | 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' 50 | 51 | suppress_type=$FlowIssue 52 | suppress_type=$FlowFixMe 53 | suppress_type=$FixMe 54 | 55 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 56 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 57 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 58 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 59 | 60 | unsafe.enable_getters_and_setters=true 61 | 62 | [version] 63 | ^0.49.1 64 | -------------------------------------------------------------------------------- /app/screens/Shops.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, View, ScrollView, Platform } from 'react-native'; 3 | import Header from '../components/core/Header'; 4 | import Item from '../components/core/ListItem'; 5 | 6 | const styles = StyleSheet.create({ 7 | container: { 8 | flex: 1 9 | }, 10 | header: { 11 | marginTop: (Platform.OS === 'ios') ? 20 : 0, 12 | backgroundColor: '#0a6348', 13 | height: 65, 14 | width: '100%' 15 | }, 16 | headerText: { 17 | color: '#fff', 18 | textAlign: 'center', 19 | lineHeight: 65, 20 | fontSize: 20, 21 | fontWeight: 'bold' 22 | } 23 | }); 24 | 25 | export default class ShopScreen extends React.Component { 26 | state = { 27 | shops: [{ 28 | id: 1, 29 | title: 'Admin Shop #1', 30 | desc: '233 S. Patterson Ave, Springfield, MO 65802' 31 | }, { 32 | id: 2, 33 | title: 'Admin Shop #2', 34 | desc: '233 S. Patterson Ave, Springfield, MO 65802' 35 | }, { 36 | id: 3, 37 | title: 'Admin Shop #3', 38 | desc: '233 S. Patterson Ave, Springfield, MO 65802' 39 | }, { 40 | id: 4, 41 | title: 'Admin Shop #4', 42 | desc: '233 S. Patterson Ave, Springfield, MO 65802' 43 | }, { 44 | id: 5, 45 | title: 'Admin Shop #5', 46 | desc: '233 S. Patterson Ave, Springfield, MO 65802' 47 | }, { 48 | id: 6, 49 | title: 'Admin Shop #6', 50 | desc: '233 S. Patterson Ave, Springfield, MO 65802' 51 | }] 52 | }; 53 | 54 | goToVehicles = () => { 55 | this.props.navigation.navigate('Vehicles'); 56 | } 57 | 58 | render() { 59 | const { shops } = this.state; 60 | const { navigation } = this.props; 61 | 62 | return ( 63 | 64 |
65 | 66 | 67 | {shops.map(shop => 68 | )} 69 | 70 | 71 | 72 | ); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /app/components/SVG.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Dimensions } from 'react-native'; 3 | import { Svg } from 'expo'; 4 | 5 | const { height, width } = Dimensions.get('window'); 6 | 7 | export default class SVG extends React.Component { 8 | render() { 9 | const { name } = this.props; 10 | 11 | switch (name) { 12 | case 'vehicle_page_bg': 13 | return ( 14 | 15 | 30 | 31 | ); 32 | case 'scan_vin_bg': 33 | return ( 34 | 35 | 36 | 37 | 38 | 39 | 40 | ); 41 | case 'scan_plate_bg': 42 | return ( 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | ); 52 | default: 53 | return null; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/components/scan/ConfirmVehicle.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | StyleSheet, 4 | Text, 5 | View, 6 | ScrollView, 7 | TouchableOpacity 8 | } from 'react-native'; 9 | 10 | const styles = StyleSheet.create({ 11 | container: { 12 | flex: 1, 13 | alignItems: 'center', 14 | justifyContent: 'center', 15 | backgroundColor: 'rgba(0,0,0,0.7)', 16 | paddingHorizontal: 30, 17 | paddingVertical: 60 18 | }, 19 | content: { 20 | backgroundColor: '#fff' 21 | }, 22 | title: { 23 | textAlign: 'left', 24 | color: '#000', 25 | fontSize: 22, 26 | paddingTop: 20, 27 | paddingBottom: 20, 28 | paddingLeft: 18, 29 | paddingRight: 18, 30 | fontWeight: 'bold' 31 | }, 32 | details: { 33 | paddingHorizontal: 18, 34 | overflow: 'hidden' 35 | }, 36 | valueLine: { 37 | paddingVertical: 8 38 | }, 39 | value: { 40 | fontSize: 16, 41 | color: '#000', 42 | lineHeight: 22 43 | }, 44 | label: { 45 | fontSize: 15, 46 | color: '#777', 47 | lineHeight: 20 48 | }, 49 | actionArea: { 50 | flexDirection: 'row', 51 | justifyContent: 'flex-end', 52 | paddingVertical: 18 53 | }, 54 | action: { 55 | marginLeft: 40, 56 | marginRight: 20 57 | }, 58 | actionText: { 59 | fontSize: 15, 60 | color: '#006447', 61 | textAlign: 'right' 62 | } 63 | }); 64 | 65 | export default class ConfirmVehicle extends React.Component { 66 | render() { 67 | const { data, onCancel, onSave } = this.props; 68 | 69 | console.log(data); 70 | return ( 71 | 72 | 73 | Confirm New Vehicle 74 | 75 | 76 | 77 | { data.year } 78 | Year 79 | 80 | 81 | { data.make } 82 | Make 83 | 84 | 85 | { data.model } 86 | Model 87 | 88 | 89 | { data.subModel } 90 | Submodel 91 | 92 | 93 | { data.engine } 94 | Engine 95 | 96 | 97 | { data.vinCode } 98 | VIN Code 99 | 100 | 101 | 102 | 103 | 104 | CANCEL 105 | 106 | 107 | SAVE 108 | 109 | 110 | 111 | 112 | ); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /app/components/core/Header.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, Text, View, TouchableWithoutFeedback, TouchableOpacity } from 'react-native'; 3 | import { MaterialCommunityIcons, Ionicons, MaterialIcons } from '@expo/vector-icons'; 4 | import { Constants } from 'expo'; 5 | 6 | const HeaderHeight = 45; 7 | const styles = StyleSheet.create({ 8 | header: { 9 | marginTop: Constants.statusBarHeight, 10 | backgroundColor: '#0a6348', 11 | height: HeaderHeight, 12 | width: '100%', 13 | flexDirection: 'row', 14 | justifyContent: 'flex-start', 15 | alignItems: 'center' 16 | }, 17 | headerText: { 18 | width: '70%', 19 | color: '#fff', 20 | fontSize: 22, 21 | fontWeight: 'bold', 22 | textAlign: 'center', 23 | backgroundColor: 'transparent' 24 | }, 25 | leftSide: { 26 | width: '15%', 27 | flexDirection: 'row', 28 | justifyContent: 'flex-start' 29 | }, 30 | rightSide: { 31 | width: '15%', 32 | flexDirection: 'row', 33 | justifyContent: 'flex-end' 34 | }, 35 | leftIcon: { 36 | marginLeft: 10 37 | }, 38 | rightIcon: { 39 | marginRight: 15 40 | } 41 | }); 42 | 43 | export default class Header extends React.Component { 44 | state = { 45 | menuStatus: 'DrawerClose' 46 | }; 47 | 48 | toggleMenu = () => { 49 | const { navigation } = this.props; 50 | const { menuStatus } = this.state; 51 | const newMenuState = menuStatus === 'DrawerOpen' ? 'DrawerClose' : 'DrawerOpen'; 52 | navigation.navigate(newMenuState); 53 | } 54 | 55 | render() { 56 | const { 57 | title, leftIcon, rightIcon, rightAction 58 | } = this.props; 59 | 60 | return ( 61 | 62 | 63 | {(() => { 64 | switch (leftIcon) { 65 | case 'menu': 66 | return ( 67 | 68 | 69 | 70 | 71 | 72 | ); 73 | case 'back': 74 | return ( 75 | { this.props.navigation.navigate('Vehicles', { screenMode: 'history' }); }}> 76 | 77 | 78 | 79 | 80 | ); 81 | default: 82 | return null; 83 | } 84 | })()} 85 | 86 | {title} 87 | 88 | {(() => { 89 | switch (rightIcon) { 90 | case 'flash': case 'flash-off': case 'flash-auto': 91 | return ( 92 | { rightAction(); }}> 93 | 94 | 95 | 96 | 97 | ); 98 | case 'search': 99 | return ( 100 | { rightAction(); }}> 101 | 102 | 103 | 104 | 105 | ); 106 | default: 107 | return null; 108 | } 109 | })()} 110 | 111 | 112 | ); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, View, Linking, Platform, ActivityIndicator } from 'react-native'; 3 | import { Constants } from 'expo'; 4 | import QueryString from 'query-string'; 5 | import moment from 'moment'; 6 | import Config from './app/config/default.json'; 7 | import { OReillyApp } from './app/config/router'; 8 | 9 | const styles = StyleSheet.create({ 10 | container: { 11 | flex: 1, 12 | justifyContent: 'center' 13 | } 14 | }); 15 | 16 | export default class App extends React.Component { 17 | state = { 18 | isLoggedIn: true, 19 | }; 20 | 21 | componentDidMount() { 22 | if (!this.state.isLoggedIn) { 23 | this.authenticate(); 24 | } 25 | } 26 | 27 | componentWillUnmount() { 28 | Linking.removeEventListener('url', this.handleOpenURL); 29 | } 30 | 31 | getAuthorization = (code) => { 32 | console.log('OAuth getToken Url: ', Config.oauth.tokenUrl); 33 | const body = { 34 | redirect_uri: Constants.linkingUri, 35 | client_id: Config.oauth.clientId, 36 | grant_type: 'authorization_code', 37 | code, 38 | scope: Config.oauth.scope 39 | }; 40 | return fetch(Config.oauth.tokenUrl, { 41 | method: 'POST', 42 | body: JSON.stringify(body), 43 | headers: { 44 | 'Content-Type': 'application/x-www-form-urlencoded' 45 | } 46 | }); 47 | } 48 | 49 | checkTokenExpired = () => { 50 | if (moment().unix() > this.auth.expiresAt) { 51 | return true; 52 | } 53 | return false; 54 | } 55 | 56 | doLoginWithToken = () => { 57 | if (this.checkTokenExpired()) { 58 | console.log('The access_token has expired. try to get new token with refresh_token.'); 59 | } else { 60 | this.setState({ isLoggedIn: true }); 61 | } 62 | } 63 | 64 | handleOpenURL = (event) => { 65 | console.log(`handleOpenURL(${JSON.stringify(event)})`); 66 | const query = event.url.match(/\?(.*)/); 67 | if (query) { 68 | const { code, state } = QueryString.parse(query[1]); 69 | console.log(`code:${code}, state:${state}`); 70 | 71 | if (code && state && state === Config.oauth.state) { 72 | if (state === Config.oauth.state) { 73 | const body = { 74 | redirect_uri: Constants.linkingUri, 75 | client_id: Config.oauth.clientId, 76 | grant_type: 'authorization_code', 77 | code, 78 | scope: Config.oauth.scope 79 | }; 80 | fetch(Config.oauth.tokenUrl, { 81 | method: 'POST', 82 | body: QueryString.stringify(body), 83 | headers: { 84 | 'Content-Type': 'application/x-www-form-urlencoded' 85 | } 86 | }).then(response => { 87 | console.log('authorized:', response); 88 | this.auth = { ...response }; 89 | this.auth.expiresAt = moment().unix() + auth.expires_in; 90 | this.doLoginWithToken(); 91 | if (Platform.OS === 'ios') { 92 | // Linking.removeEventListener('url', this.handleOpenURL); 93 | } 94 | }).catch(error => { 95 | console.log('getAuthorization() error:', error.request); 96 | }); 97 | } 98 | } 99 | } 100 | } 101 | 102 | authenticate() { 103 | if (Platform.OS === 'android') { 104 | Linking.getInitialURL().then((url) => { 105 | this.handleOpenURL({ url }); 106 | }); 107 | } else { 108 | Linking.addEventListener('url', this.handleOpenURL); 109 | } 110 | 111 | const authUrl = `${Config.oauth.authorizationUrl}?${QueryString.stringify({ 112 | client_id: Config.oauth.clientId, 113 | redirect_uri: Constants.linkingUri, 114 | response_type: Config.oauth.response_type, 115 | scope: Config.oauth.scope, 116 | state: Config.oauth.state 117 | })}`; 118 | 119 | Linking.canOpenURL(authUrl).then((supported) => { 120 | if (!supported) { 121 | console.log(`Can't handle url: ${authUrl}`); 122 | } else { 123 | console.log(`Redirecting to ${authUrl}`); 124 | Linking.openURL(authUrl) 125 | .catch(error => console.log(`Can't open url: ${error}`)) 126 | .then(() => { 127 | console.log('success in linking'); 128 | }); 129 | } 130 | }).catch(err => console.error('An error occurred', err)); 131 | } 132 | 133 | render() { 134 | const { isLoggedIn } = this.state; 135 | return ( 136 | 137 | { isLoggedIn ? 138 | 139 | : 140 | 141 | } 142 | 143 | ); 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /app/components/scan/VINEntry.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | StyleSheet, 4 | Text, 5 | View, 6 | Modal, 7 | TextInput, 8 | TouchableOpacity, 9 | Platform 10 | } from 'react-native'; 11 | import { Constants } from 'expo'; 12 | import { MaterialCommunityIcons } from '@expo/vector-icons'; 13 | import moment from 'moment'; 14 | 15 | import ConfirmVehicle from './ConfirmVehicle'; 16 | import config from '../../config/default.json'; 17 | 18 | const HeaderHeight = 45; 19 | const styles = StyleSheet.create({ 20 | container: { 21 | flex: 1, 22 | top: Platform.OS === 'ios' ? Constants.statusBarHeight : 0 23 | }, 24 | header: { 25 | backgroundColor: '#006447', 26 | width: '100%', 27 | height: HeaderHeight, 28 | flexDirection: 'row', 29 | justifyContent: 'flex-start', 30 | alignContent: 'center' 31 | }, 32 | leftSide: { 33 | width: '25%', 34 | flexDirection: 'row', 35 | justifyContent: 'flex-start' 36 | }, 37 | rightSide: { 38 | width: '25%', 39 | flexDirection: 'row', 40 | justifyContent: 'flex-end' 41 | }, 42 | submitText: { 43 | fontSize: 15, 44 | color: '#fff', 45 | marginRight: 15, 46 | marginTop: 12 47 | }, 48 | leftIcon: { 49 | marginLeft: 10, 50 | marginTop: 10 51 | }, 52 | headerText: { 53 | width: '50%', 54 | color: '#fff', 55 | fontSize: 22, 56 | fontWeight: 'bold', 57 | textAlign: 'center', 58 | marginTop: 7 59 | }, 60 | details: { 61 | paddingHorizontal: 18, 62 | paddingVertical: 18, 63 | flex: 1, 64 | flexDirection: 'column', 65 | justifyContent: 'flex-start' 66 | }, 67 | inputArea: { 68 | paddingTop: 10, 69 | paddingBottom: 30 70 | }, 71 | label: { 72 | fontSize: 15, 73 | color: '#777' 74 | }, 75 | inputBox: { 76 | paddingTop: 5, 77 | paddingBottom: 5, 78 | borderBottomWidth: 1, 79 | borderColor: 'rgba(0,0,0,.38)' 80 | }, 81 | submitBtn: { 82 | marginTop: 20, 83 | paddingHorizontal: 10, 84 | paddingVertical: 13, 85 | borderColor: 'rgba(0,0,0,.6)', 86 | borderWidth: 1, 87 | borderRadius: 3, 88 | backgroundColor: '#fdb015', 89 | width: '100%' 90 | }, 91 | submitBtnText: { 92 | color: 'rgba(0,0,0,.6)', 93 | fontSize: 16, 94 | fontFamily: Platform.OS === 'ios' ? 'Helvetica-Bold' : 'Roboto', 95 | textAlign: 'center' 96 | } 97 | }); 98 | 99 | export default class VINEntry extends React.Component { 100 | state = { 101 | confirmModalVisible: false, 102 | vincode: this.props.code, 103 | notes: null, 104 | vehicleInfo: null 105 | } 106 | 107 | componentWillReceiveProps(nextProps) { 108 | this.setState({ vincode: nextProps.code }); 109 | } 110 | 111 | openConfirmModal = () => { 112 | if (!this.state.vincode) { 113 | alert('Please enter VIN Code.'); 114 | return; 115 | } 116 | // Should be implemented with O'reilly's api 117 | // The following code throws the error as ios does not support to fetch http vs local json file 118 | const body = { 119 | platform: Platform.OS, 120 | deviceId: 'mobile-id', // = Expo.Constants.deviceId 121 | accountNumber: '347974', 122 | vinCode: this.state.vincode, 123 | shopId: '1' 124 | }; 125 | fetch(config.decodeVinApiUrl, { 126 | method: 'POST', 127 | body: JSON.stringify(body), 128 | headers: { 129 | 'Content-Type': 'application/json' 130 | } 131 | }) 132 | .catch((error) => { 133 | console.log('VIN decode error:', error); 134 | alert(`Faild in decoding VIN due to the error:${error.toString()}`); 135 | }) 136 | .then(res => res.json()) 137 | .catch(error => console.log('No response from VIN decode API. error:', error)) 138 | .then((response) => { 139 | console.log('VIN decode result:', response); 140 | if (!response.result || response.result === 'false') { 141 | alert(response.message); 142 | } else { 143 | this.setState({ 144 | vehicleInfo: { 145 | ...response, 146 | scanAt: moment().format('M/D/YYYY') 147 | }, 148 | confirmModalVisible: true 149 | }); 150 | } 151 | }); 152 | } 153 | 154 | closeConfirmModal = () => { 155 | this.setState({ confirmModalVisible: false }); 156 | } 157 | 158 | saveNewVehicle = () => { 159 | const { vehicleInfo, notes } = this.state; 160 | this.setState({ confirmModalVisible: false }); 161 | this.props.onSave({ ...vehicleInfo, notes }); 162 | } 163 | 164 | render() { 165 | const { onClose } = this.props; 166 | const { 167 | vincode, 168 | notes, 169 | vehicleInfo, 170 | confirmModalVisible 171 | } = this.state; 172 | 173 | return ( 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | VIN Entry 185 | 186 | 187 | SUBMIT 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | VIN Code 196 | this.setState({ vincode: text })} 202 | style={styles.inputBox} 203 | /> 204 | 205 | 206 | 207 | Notes 208 | this.setState({ notes: text })} 214 | style={styles.inputBox} 215 | /> 216 | 217 | 218 | 219 | SUBMIT 220 | 221 | 222 | 223 | console.log('Modal has been closed.')}> 224 | 225 | 226 | 227 | 228 | ); 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /app/screens/Login.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, Text, View, ScrollView, TextInput, TouchableHighlight, TouchableWithoutFeedback, Image, Linking } from 'react-native'; 3 | import { CheckBox } from 'react-native-elements'; 4 | import { Constants } from 'expo'; 5 | 6 | const logo = require('../public/logo.png'); 7 | 8 | const styles = StyleSheet.create({ 9 | logo: { 10 | resizeMode: 'cover', 11 | width: '100%', 12 | height: '100%' 13 | }, 14 | topBanner: { 15 | height: 174, 16 | backgroundColor: '#006447' 17 | }, 18 | btmHeader: { 19 | backgroundColor: '#006447', 20 | paddingTop: 10, 21 | paddingBottom: 10, 22 | borderStyle: 'solid', 23 | borderTopColor: '#fff', 24 | borderTopWidth: 3, 25 | marginBottom: 50 26 | }, 27 | btmHeaderText: { 28 | textAlign: 'center', 29 | fontSize: 18, 30 | fontWeight: 'bold', 31 | color: '#fff' 32 | }, 33 | container: { 34 | flex: 1, 35 | top: Constants.statusBarHeight, 36 | backgroundColor: '#fff', 37 | paddingBottom: 20 38 | }, 39 | textContainer: { 40 | backgroundColor: '#f0f0f0', 41 | borderRadius: 5, 42 | paddingTop: 16, 43 | paddingBottom: 10, 44 | borderStyle: 'solid', 45 | borderBottomColor: '#929292', 46 | borderBottomWidth: 2, 47 | marginLeft: 18, 48 | marginBottom: 18, 49 | marginRight: 18 50 | }, 51 | textContainerFocused: { 52 | backgroundColor: '#f0f0f0', 53 | borderRadius: 5, 54 | paddingTop: 5, 55 | paddingBottom: 5, 56 | borderStyle: 'solid', 57 | borderBottomColor: '#006447', 58 | borderBottomWidth: 2, 59 | marginLeft: 18, 60 | marginBottom: 18, 61 | marginRight: 18 62 | }, 63 | passContainer: { 64 | marginBottom: 0 65 | }, 66 | textLabel: { 67 | color: '#006447', 68 | marginLeft: 15, 69 | marginBottom: 2, 70 | height: 14 71 | }, 72 | hideTextLabel: { 73 | display: 'none' 74 | }, 75 | textInput: { 76 | fontSize: 20, 77 | paddingBottom: 7, 78 | paddingLeft: 15, 79 | color: '#adadad', 80 | paddingRight: 15 81 | }, 82 | loginButton: { 83 | backgroundColor: '#fdb014', 84 | borderStyle: 'solid', 85 | borderRadius: 5, 86 | borderColor: '#000', 87 | borderWidth: 2, 88 | marginTop: 20, 89 | marginLeft: 18, 90 | marginRight: 18, 91 | paddingTop: 18, 92 | paddingBottom: 18 93 | }, 94 | loginAction: { 95 | flexDirection: 'row', 96 | justifyContent: 'space-between', 97 | alignItems: 'center', 98 | marginRight: 18, 99 | marginLeft: 18, 100 | paddingBottom: 10 101 | }, 102 | loginButtonText: { 103 | fontSize: 16, 104 | fontWeight: 'bold', 105 | textAlign: 'center' 106 | }, 107 | checkboxInput: { 108 | borderWidth: 0, 109 | width: 150, 110 | marginLeft: 0, 111 | paddingLeft: 0, 112 | backgroundColor: 'transparent' 113 | }, 114 | checkboxText: { 115 | fontWeight: 'normal', 116 | fontSize: 16 117 | }, 118 | forgotPassword: { 119 | color: '#006447', 120 | fontSize: 16 121 | }, 122 | bottomDisclaimer: { 123 | marginTop: 40, 124 | alignItems: 'center' 125 | }, 126 | disclaimer: { 127 | fontSize: 16 128 | }, 129 | requestAccess: { 130 | marginTop: 20, 131 | marginBottom: 25, 132 | color: '#006447', 133 | fontSize: 16, 134 | fontWeight: 'bold' 135 | } 136 | }); 137 | 138 | export default class LoginScreen extends React.Component { 139 | constructor(props) { 140 | super(props); 141 | this.state = { 142 | userTouched: false, 143 | passTouched: false, 144 | userVal: '', 145 | passVal: '', 146 | keepLoggedIn: false 147 | }; 148 | } 149 | 150 | onLogin = () => { 151 | const { userVal, passVal } = this.state; 152 | const request = { 153 | username: userVal, 154 | password: passVal 155 | }; 156 | this.props.navigation.navigate('Menu'); 157 | console.log(request); 158 | } 159 | 160 | onBlur = (prop) => { 161 | this.setState({ [prop]: false }); 162 | } 163 | 164 | onFocus = (prop) => { 165 | this.setState({ [prop]: true }); 166 | } 167 | 168 | onChange = (val, prop) => { 169 | this.setState({ [prop]: val }); 170 | } 171 | 172 | render() { 173 | const { 174 | userTouched, 175 | passTouched, 176 | userVal, 177 | passVal, 178 | keepLoggedIn 179 | } = this.state; 180 | 181 | return ( 182 | 183 | 184 | 185 | 186 | 187 | 188 | FOR PROFESSIONALS 189 | 190 | 191 | {userTouched ? 'Username' : ''} 192 | { this.onFocus('userTouched'); }} 197 | onBlur={() => { this.onBlur('userTouched'); }} 198 | onChangeText={(text) => { this.onChange(text, 'userVal'); }} 199 | value={userVal} 200 | placeholder={userTouched ? '' : 'Username'} 201 | /> 202 | 203 | 204 | {passTouched ? 'Password' : ''} 205 | { this.onFocus('passTouched'); }} 210 | onBlur={() => { this.onBlur('passTouched'); }} 211 | secureTextEntry={passTouched || passVal.length > 0} 212 | onChangeText={(text) => { this.onChange(text, 'passVal'); }} 213 | value={passVal} 214 | placeholder={passTouched ? '' : 'Password'} 215 | /> 216 | 217 | 218 | { this.onChange(!keepLoggedIn, 'keepLoggedIn'); }} 225 | checked={keepLoggedIn} 226 | /> 227 | Linking.openURL('https://www.oreillyauto.com/')}>Forgot Password? 228 | 229 | 230 | 231 | LOGIN 232 | 233 | 234 | 235 | Not signed up for First Call Online? 236 | Linking.openURL('https://www.oreillyauto.com/')}>REQUEST ACCESS > 237 | 238 | 239 | 240 | ); 241 | } 242 | } 243 | -------------------------------------------------------------------------------- /app/screens/Menu.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, Text, View, TouchableOpacity, TouchableWithoutFeedback, Dimensions } from 'react-native'; 3 | import Accordion from 'react-native-collapsible/Accordion'; 4 | import { MaterialCommunityIcons, MaterialIcons } from '@expo/vector-icons'; 5 | import { Svg, Constants } from 'expo'; 6 | import SVG from '../components/SVG'; 7 | 8 | const WINDOW = Dimensions.get('window'); 9 | 10 | const styles = StyleSheet.create({ 11 | container: { 12 | flex: 1, 13 | backgroundColor: '#333', 14 | top: Constants.statusBarHeight, 15 | position: 'relative' 16 | }, 17 | gradient: { 18 | position: 'absolute', 19 | top: 0, 20 | left: 0, 21 | right: 0, 22 | zIndex: -1 23 | }, 24 | accordionHeader: { 25 | height: 130, 26 | paddingHorizontal: 15, 27 | paddingBottom: 10, 28 | backgroundColor: 'transparent', 29 | flexDirection: 'row', 30 | alignItems: 'flex-end' 31 | }, 32 | accordionContent: { 33 | height: WINDOW.height - 130, 34 | paddingHorizontal: 15, 35 | backgroundColor: 'transparent', 36 | zIndex: 99, 37 | elevation: 99 38 | }, 39 | shopTitle: { 40 | color: '#fff', 41 | fontSize: 15, 42 | paddingBottom: 5 43 | }, 44 | shopDescArea: { 45 | flexDirection: 'row', 46 | alignItems: 'center', 47 | justifyContent: 'space-around', 48 | width: '100%' 49 | }, 50 | shopDesc: { 51 | color: '#8f8f8f', 52 | width: 250 53 | }, 54 | label: { 55 | color: '#8f8f8f', 56 | paddingTop: 20, 57 | paddingBottom: 10 58 | }, 59 | textArea: { 60 | paddingVertical: 10 61 | }, 62 | menuArea: { 63 | position: 'relative', 64 | height: WINDOW.height - 150 65 | }, 66 | menuItem: { 67 | flexDirection: 'row', 68 | alignItems: 'center', 69 | paddingHorizontal: 10, 70 | paddingVertical: 12, 71 | borderBottomWidth: 1, 72 | borderBottomColor: '#3c3c3c' 73 | }, 74 | menuIcon: { 75 | color: '#8f8f8f', 76 | width: 30, 77 | height: 30, 78 | marginRight: 10 79 | }, 80 | menuText: { 81 | color: '#8f8f8f', 82 | fontSize: 15, 83 | fontWeight: 'bold' 84 | }, 85 | logout: { 86 | position: 'absolute', 87 | width: '100%', 88 | bottom: Constants.statusBarHeight - 20, 89 | borderTopWidth: 1, 90 | borderTopColor: '#3c3c3c' 91 | }, 92 | vin_bg: { 93 | marginLeft: -5, 94 | marginTop: -5, 95 | marginRight: 10 96 | }, 97 | plate_bg: { 98 | marginLeft: -5 99 | } 100 | }); 101 | 102 | export default class MenuContainer extends React.Component { 103 | state = { 104 | shopSelected: { 105 | id: 1, 106 | title: 'Admin Shop #1', 107 | desc: '233 S. Patterson Ave, Springfield, MO 65802' 108 | }, 109 | shops: [{ 110 | id: 1, 111 | title: 'Admin Shop #1', 112 | desc: '233 S. Patterson Ave, Springfield, MO 65802' 113 | }, { 114 | id: 2, 115 | title: 'Admin Shop #2', 116 | desc: '233 S. Patterson Ave, Springfield, MO 65802' 117 | }, { 118 | id: 3, 119 | title: 'Admin Shop #3', 120 | desc: '233 S. Patterson Ave, Springfield, MO 65802' 121 | }, { 122 | id: 4, 123 | title: 'Admin Shop #4', 124 | desc: '233 S. Patterson Ave, Springfield, MO 65802' 125 | }, { 126 | id: 5, 127 | title: 'Admin Shop #5', 128 | desc: '233 S. Patterson Ave, Springfield, MO 65802' 129 | }, { 130 | id: 6, 131 | title: 'Admin Shop #6', 132 | desc: '233 S. Patterson Ave, Springfield, MO 65802' 133 | }] 134 | } 135 | 136 | handleSelectShop = (shopId) => { 137 | this.setState({ shopSelected: this.state.shops.find(shop => shop.id === shopId) }); 138 | } 139 | 140 | renderContent = (section) => { 141 | return ( 142 | 143 | Select a Shop 144 | {section.content.map(shop => ( 145 | section.onSelectShop(shop.id)}> 146 | 147 | {shop.title} 148 | {shop.desc} 149 | 150 | 151 | ))} 152 | 153 | ); 154 | } 155 | 156 | renderHeader = (section, index, isActive) => { 157 | return ( 158 | 159 | 160 | {section.header.title} 161 | 162 | {section.header.desc} 163 | 164 | 165 | 166 | 167 | ); 168 | } 169 | 170 | render() { 171 | const { navigation } = this.props; 172 | const { shopSelected, shops } = this.state; 173 | const SECTIONS = [{ 174 | header: shopSelected, 175 | content: shops.filter((shop) => { return shop.id !== shopSelected.id; }), 176 | onSelectShop: this.handleSelectShop 177 | }]; 178 | 179 | return ( 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 195 | 196 | 202 | 203 | navigation.navigate('Vehicles', { screenMode: 'history' })}> 204 | 205 | 206 | Vehicles 207 | 208 | 209 | navigation.navigate('VinScan')}> 210 | 211 | 212 | 213 | 214 | VIN Scan 215 | 216 | 217 | navigation.navigate('PlateScan')}> 218 | 219 | 220 | 221 | 222 | Plate Scan 223 | 224 | 225 | navigation.navigate('Catalog')}> 226 | 227 | 228 | Catalog 229 | 230 | 231 | navigation.navigate('LogOut')} style={styles.logout}> 232 | 233 | 234 | Log out 235 | 236 | 237 | 238 | 239 | ); 240 | } 241 | } 242 | -------------------------------------------------------------------------------- /app/screens/VehicleDetail.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | StyleSheet, 4 | Text, 5 | View, 6 | Modal, 7 | FlatList, 8 | TouchableOpacity, 9 | Platform, 10 | Dimensions 11 | } from 'react-native'; 12 | import { MaterialIcons, MaterialCommunityIcons } from '@expo/vector-icons'; 13 | import { Constants } from 'expo'; 14 | 15 | const WINDOW = Dimensions.get('window'); 16 | 17 | const styles = StyleSheet.create({ 18 | container: { 19 | flex: 1, 20 | position: 'relative', 21 | paddingTop: (Platform.OS === 'ios') ? Constants.statusBarHeight : 0 22 | }, 23 | header: { 24 | backgroundColor: '#006447', 25 | paddingVertical: 18, 26 | paddingHorizontal: 15, 27 | width: '100%', 28 | height: 140, 29 | flexDirection: 'column', 30 | justifyContent: 'space-between' 31 | }, 32 | actions: { 33 | flexDirection: 'row', 34 | justifyContent: 'space-between' 35 | }, 36 | leftActionArea: { 37 | }, 38 | rightActionArea: { 39 | width: 140, 40 | flexDirection: 'row', 41 | justifyContent: 'space-around' 42 | }, 43 | actionIcon: { 44 | color: '#fff', 45 | fontSize: 24 46 | }, 47 | cartButton: { 48 | position: 'absolute', 49 | width: 65, 50 | height: 65, 51 | top: (Platform.OS === 'ios') ? 105 + Constants.statusBarHeight : 105, 52 | right: 18, 53 | backgroundColor: '#fff', 54 | borderColor: '#006447', 55 | borderWidth: 1, 56 | borderRadius: 35, 57 | justifyContent: 'center', 58 | alignItems: 'center', 59 | shadowColor: '#000', 60 | shadowOffset: { width: 0, height: 3 }, 61 | shadowOpacity: 0.35, 62 | shadowRadius: 5, 63 | zIndex: 2 64 | }, 65 | cartIcon: { 66 | color: '#006447' 67 | }, 68 | title: { 69 | color: '#fff', 70 | fontSize: 18, 71 | fontWeight: 'bold', 72 | lineHeight: 28 73 | }, 74 | subtitle: { 75 | color: 'rgba(205,205,205,0.8)', 76 | fontSize: 16, 77 | lineHeight: 20, 78 | letterSpacing: 0.5 79 | }, 80 | details: { 81 | position: 'absolute', 82 | top: 140 + ((Platform.OS === 'ios') ? Constants.statusBarHeight : 0), 83 | paddingHorizontal: 18, 84 | paddingTop: 18, 85 | width: '100%', 86 | height: WINDOW.height - 225 - Constants.statusBarHeight, 87 | backgroundColor: '#fff', 88 | overflow: 'hidden' 89 | }, 90 | spec: { 91 | paddingBottom: 18 92 | }, 93 | value: { 94 | fontSize: 16, 95 | color: '#000', 96 | lineHeight: 22 97 | }, 98 | label: { 99 | fontSize: 15, 100 | color: '#777', 101 | lineHeight: 20 102 | }, 103 | moreInfoBtn: { 104 | position: 'absolute', 105 | width: 130, 106 | left: 18, 107 | bottom: 18, 108 | paddingHorizontal: 10, 109 | paddingVertical: 13, 110 | borderColor: '#006447', 111 | borderWidth: 1, 112 | borderRadius: 3, 113 | backgroundColor: '#fff' 114 | }, 115 | moreInfoText: { 116 | color: '#006447', 117 | fontSize: 16, 118 | fontFamily: Platform.OS === 'ios' ? 'Helvetica-Bold' : 'Roboto', 119 | textAlign: 'center' 120 | }, 121 | resendModal: { 122 | flex: 1, 123 | alignItems: 'center', 124 | justifyContent: 'center', 125 | backgroundColor: 'rgba(0,0,0,0.7)' 126 | }, 127 | resendContainer: { 128 | width: 300, 129 | height: 120, 130 | backgroundColor: '#fff', 131 | paddingHorizontal: 20, 132 | paddingVertical: 18, 133 | flexDirection: 'column', 134 | justifyContent: 'space-between' 135 | }, 136 | resendTitle: { 137 | fontSize: 16, 138 | lineHeight: 30 139 | }, 140 | modalActionArea: { 141 | flexDirection: 'row', 142 | justifyContent: 'flex-end' 143 | }, 144 | modalAction: { 145 | marginLeft: 30 146 | }, 147 | modalActionText: { 148 | fontSize: 15, 149 | color: '#006447', 150 | textAlign: 'right' 151 | } 152 | }); 153 | 154 | export default class VehicleDetail extends React.Component { 155 | state = { 156 | modalVisible: false, 157 | visibleMoreInfo: false 158 | }; 159 | 160 | toggleMoreInfo = () => { 161 | this.setState({ visibleMoreInfo: !this.state.visibleMoreInfo }); 162 | } 163 | 164 | flattenArray = (data) => { 165 | const attributes = [{ 166 | label: 'Year', 167 | value: data.year 168 | }, { 169 | label: 'Make', 170 | value: data.make 171 | }, { 172 | label: 'Model', 173 | value: data.model 174 | }, { 175 | label: 'Submodel', 176 | value: data.subModel 177 | }, { 178 | label: 'Engine', 179 | value: data.engine 180 | }, { 181 | label: 'VIN Code', 182 | value: data.vinCode 183 | }]; 184 | if (data.moreInfo && this.state.visibleMoreInfo) { 185 | attributes.push({ 186 | label: 'More Info', 187 | value: data.moreInfo 188 | }); 189 | } 190 | return attributes; 191 | } 192 | 193 | keyExtractor = (item, index) => { 194 | return index; 195 | } 196 | 197 | renderItem = ({ item }) => { 198 | return ( 199 | 200 | {item.value} 201 | {item.label} 202 | 203 | ); 204 | } 205 | 206 | render() { 207 | const { data, onClose, onAddToCart } = this.props; 208 | const { modalVisible } = this.state; 209 | 210 | return ( 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | { alert('Delete this vehicle!'); }}> 221 | 222 | 223 | { this.setState({ modalVisible: true }); }}> 224 | 225 | 226 | { alert('Will you star this vehicle?'); }}> 227 | 228 | 229 | 230 | 231 | 232 | {`${data.year} ${data.make} ${data.model}`} 233 | {`Scanned ${data.scanAt}`} 234 | 235 | 236 | 237 | 238 | 239 | 240 | { this.flatListRef = ref; }} 242 | style={styles.details} 243 | data={this.flattenArray(data)} 244 | renderItem={this.renderItem} 245 | keyExtractor={this.keyExtractor} 246 | /> 247 | 248 | {data.isMore ? 249 | 250 | MORE INFO 251 | 252 | : null} 253 | 254 | console.log('Modal has been closed.')}> 255 | 256 | 257 | Resend vehicle information? 258 | 259 | { this.setState({ modalVisible: false }); }} style={styles.modalAction}> 260 | CANCEL 261 | 262 | { this.setState({ modalVisible: false }); }} style={styles.modalAction}> 263 | SEND 264 | 265 | 266 | 267 | 268 | 269 | 270 | ); 271 | } 272 | } 273 | -------------------------------------------------------------------------------- /app/components/scan/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, View, Text, TouchableOpacity, Modal, Dimensions, Platform } from 'react-native'; 3 | import { MaterialCommunityIcons } from '@expo/vector-icons'; 4 | import { BarCodeScanner, Camera, Permissions, Constants } from 'expo'; 5 | 6 | import Header from '../core/Header'; 7 | import PTVDetail from './PTVDetail'; 8 | import VINEntry from './VINEntry'; 9 | import VehicleDetail from '../../screens/VehicleDetail'; 10 | import config from '../../config/default.json'; 11 | 12 | const WINDOW = Dimensions.get('window'); 13 | const HeaderHeight = 45; 14 | const styles = StyleSheet.create({ 15 | container: { 16 | flex: 1 17 | }, 18 | scanArea: { 19 | position: 'absolute', 20 | left: 0, 21 | top: HeaderHeight + Constants.statusBarHeight, 22 | right: 0, 23 | bottom: 0, 24 | backgroundColor: 'rgba(0,0,0,0.5)', 25 | zIndex: -1 26 | }, 27 | actionArea: { 28 | position: 'absolute', 29 | width: 65, 30 | height: 130, 31 | bottom: 20, 32 | right: 20, 33 | flexDirection: 'column', 34 | justifyContent: 'flex-end' 35 | }, 36 | cameraButton: { 37 | backgroundColor: '#fdb015', 38 | width: 65, 39 | height: 65, 40 | borderRadius: 65, 41 | marginTop: 10, 42 | justifyContent: 'center', 43 | alignItems: 'center', 44 | shadowColor: '#000', 45 | shadowOffset: { width: 0, height: 2 }, 46 | shadowOpacity: 0.3, 47 | shadowRadius: 5, 48 | zIndex: 2 49 | }, 50 | cameraIcon: { 51 | marginTop: 2, 52 | backgroundColor: 'transparent' 53 | }, 54 | editArea: { 55 | justifyContent: 'center', 56 | alignItems: 'center', 57 | marginBottom: 10 58 | }, 59 | editIcon: { 60 | width: 45, 61 | height: 45, 62 | justifyContent: 'center', 63 | alignItems: 'center', 64 | backgroundColor: '#efefef', 65 | borderRadius: 45, 66 | shadowColor: '#000', 67 | shadowOffset: { width: 0, height: 2 }, 68 | shadowOpacity: 0.3, 69 | shadowRadius: 5 70 | }, 71 | vinScanArea: { 72 | flex: 1 73 | }, 74 | scanRect: { 75 | width: (Platform.OS === 'ios') ? 100 : (WINDOW.width - 40), 76 | height: (Platform.OS === 'ios') ? (WINDOW.height - (Constants.statusBarHeight * 2) - HeaderHeight) : (WINDOW.height - Constants.statusBarHeight - HeaderHeight - 160), 77 | position: 'absolute', 78 | left: (Platform.OS === 'ios') ? (WINDOW.width - 100) / 2 : 20, 79 | top: (Platform.OS === 'ios') ? Constants.statusBarHeight * 0.5 : 80, 80 | borderWidth: 3, 81 | borderColor: 'rgba(255,0,0,.85)' 82 | }, 83 | centerLine: { 84 | width: (Platform.OS === 'ios') ? 2 : WINDOW.width, 85 | height: (Platform.OS === 'ios') ? WINDOW.height - Constants.statusBarHeight - HeaderHeight : 2, 86 | position: 'absolute', 87 | left: (Platform.OS === 'ios') ? WINDOW.width * 0.5 : 0, 88 | top: (Platform.OS === 'ios') ? 0 : (WINDOW.height - Constants.statusBarHeight - HeaderHeight) / 2, 89 | backgroundColor: 'rgba(212,0,0,0.3)' 90 | } 91 | }); 92 | 93 | export default class Scan extends React.Component { 94 | state = { 95 | flashStatus: 'off', 96 | hasCameraPermission: null, 97 | modalVisible: false, 98 | scannedCode: null, 99 | vehicleInfo: null, 100 | picture: null, 101 | detailModalVisible: false 102 | }; 103 | 104 | async componentWillMount() { 105 | const { status } = await Permissions.askAsync(Permissions.CAMERA); 106 | this.setState({ hasCameraPermission: status === 'granted' }); 107 | } 108 | 109 | handleBarCodeRead = ({ type, data }) => { 110 | console.log(type, data); 111 | this.setState({ 112 | scannedCode: data.substring(0), 113 | modalVisible: true 114 | }); 115 | } 116 | 117 | handleFlash = () => { 118 | this.setState({ flashStatus: this.state.flashStatus === 'off' ? 'on' : 'off' }); 119 | }; 120 | 121 | openDetailModal = () => { 122 | this.setState({ modalVisible: true }); 123 | } 124 | 125 | closeDetailModal = () => { 126 | this.setState({ modalVisible: false }); 127 | } 128 | 129 | handleVehicleDetailClose = () => { 130 | this.setState({ modalVisible: false }); 131 | this.props.navigation.navigate('Vehicles'); 132 | } 133 | 134 | takePicture = async () => { 135 | if (this.camera) { 136 | this.camera.takePictureAsync().then((data) => { 137 | if (data) { 138 | const formData = new FormData(); 139 | formData.append('file', { 140 | uri: data.uri, 141 | type: 'image/jpeg', 142 | name: data.uri.split('/').pop() 143 | }); 144 | 145 | fetch(`${config.apiBaseUrl}/license-plate`, { 146 | method: 'post', 147 | body: formData, 148 | headers: { 149 | 'Content-Type': 'multipart/form-data;' 150 | } 151 | }) 152 | .catch((err) => { 153 | // alert('We couldn\'t parse your plate, please try with better image'); 154 | console.log('failed in uploading image to api. error:', err); 155 | }) 156 | .then(res => res.json()) 157 | .catch(error => console.log(error)) 158 | .then((response) => { 159 | console.log('successful response: '); 160 | console.log(response); 161 | if (response && response.length > 0) { 162 | const { bestPlate } = response[0]; 163 | this.setState({ 164 | picture: data.uri, 165 | vehicleInfo: { 166 | plateNumber: bestPlate.characters, 167 | region: response[0].region 168 | }, 169 | modalVisible: true 170 | }); 171 | } else { 172 | alert('We couldn\'t find the information for your vehicle. please try again.'); 173 | console.log('The vehicle has not found.'); 174 | } 175 | }); 176 | } 177 | }); 178 | } 179 | }; 180 | 181 | handleAddToCart = () => { 182 | this.setState({ modalVisible: false }); 183 | this.props.navigation.navigate('Catalog'); 184 | } 185 | 186 | handleVehicleSave = (vehicleInfo) => { 187 | setTimeout(() => { 188 | this.setState({ vehicleInfo, modalVisible: false, detailModalVisible: true }); 189 | }, 100); 190 | } 191 | 192 | render() { 193 | const { mode, title, navigation } = this.props; 194 | const { 195 | flashStatus, hasCameraPermission, scannedCode, picture, modalVisible, vehicleInfo, detailModalVisible 196 | } = this.state; 197 | 198 | // console.log('index.js render() vehicleInfo:', vehicleInfo); 199 | if (hasCameraPermission === null) { 200 | return Requesting for camera permission; 201 | } else if (hasCameraPermission === false) { 202 | return No access to camera; 203 | } 204 | return ( 205 | 206 |
207 | 208 | { mode === 'ptv' ? 209 | { this.camera = ref; }} 211 | style={{ flex: 1 }} 212 | /> 213 | : mode === 'vin' || mode === 'shop' ? 214 | 215 | 220 | 221 | 222 | 223 | : null 224 | } 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | {mode === 'ptv' ? 235 | 236 | 237 | 238 | 239 | 240 | : null 241 | } 242 | 243 | 244 | { console.log('Modal has been closed in Scan.'); }} 249 | > 250 | {mode === 'ptv' ? 251 | 252 | : mode === 'vin' || mode === 'shop' ? 253 | 254 | : null 255 | } 256 | 257 | 258 | { console.log('Modal has been closed in Scan.'); }} 263 | > 264 | 265 | 266 | 267 | 268 | ); 269 | } 270 | } 271 | -------------------------------------------------------------------------------- /app/screens/Vehicles.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | StyleSheet, 4 | Text, 5 | View, 6 | Modal, 7 | ScrollView, 8 | TouchableWithoutFeedback, 9 | TouchableOpacity, 10 | Dimensions 11 | } from 'react-native'; 12 | import { MaterialCommunityIcons } from '@expo/vector-icons'; 13 | import ScrollableTabView from 'react-native-scrollable-tab-view'; 14 | 15 | import SVG from '../components/SVG'; 16 | import Header from '../components/core/Header'; 17 | import Item from '../components/core/ListItem'; 18 | import VehicleDetail from './VehicleDetail'; 19 | 20 | const WINDOW = Dimensions.get('window'); 21 | 22 | const styles = StyleSheet.create({ 23 | container: { 24 | flex: 1, 25 | alignItems: 'center' 26 | }, 27 | tabViewWrap: { 28 | width: '100%', 29 | flex: 1 30 | }, 31 | tabBar: { 32 | height: 80, 33 | flexDirection: 'row', 34 | marginTop: 0, 35 | borderTopWidth: 0, 36 | borderLeftWidth: 0, 37 | borderRightWidth: 0, 38 | borderBottomWidth: 2, 39 | borderBottomColor: '#e4e4e4', 40 | backgroundColor: '#fff' 41 | }, 42 | tabButton: { 43 | flex: 1, 44 | marginTop: 0, 45 | alignItems: 'center', 46 | justifyContent: 'center', 47 | borderBottomWidth: 3 48 | }, 49 | tabButtonText: { 50 | fontSize: 14 51 | }, 52 | tabViewContent: { 53 | flex: 1, 54 | backgroundColor: '#fff' 55 | }, 56 | vehicle_bg: { 57 | width: WINDOW.width, 58 | height: WINDOW.height, 59 | backgroundColor: '#f00' 60 | }, 61 | noVehicles: { 62 | fontSize: 18, 63 | textAlign: 'center', 64 | color: '#989898', 65 | width: 180, 66 | paddingTop: 20 67 | }, 68 | addVehicle: { 69 | backgroundColor: '#fbaf30', 70 | width: 70, 71 | height: 70, 72 | borderRadius: 70, 73 | position: 'absolute', 74 | bottom: 20, 75 | right: 20, 76 | justifyContent: 'center', 77 | alignItems: 'center', 78 | shadowColor: '#000', 79 | shadowOffset: { width: 0, height: 2 }, 80 | shadowOpacity: 0.3, 81 | shadowRadius: 5, 82 | zIndex: 2 83 | }, 84 | addVehicleIcon: { 85 | marginTop: 2, 86 | backgroundColor: 'transparent', 87 | fontSize: 42 88 | }, 89 | scanButton: { 90 | height: 45, 91 | width: 45, 92 | borderRadius: 45, 93 | backgroundColor: '#efefef', 94 | shadowColor: '#000', 95 | shadowOffset: { width: 0, height: 2 }, 96 | shadowOpacity: 0.3, 97 | shadowRadius: 5 98 | }, 99 | vinScan: { 100 | position: 'absolute', 101 | bottom: 160, 102 | right: 32, 103 | width: '100%', 104 | flexDirection: 'row', 105 | justifyContent: 'flex-end', 106 | zIndex: 2 107 | }, 108 | plateScan: { 109 | position: 'absolute', 110 | bottom: 100, 111 | right: 32, 112 | width: '100%', 113 | flexDirection: 'row', 114 | justifyContent: 'flex-end', 115 | zIndex: 2 116 | }, 117 | scanText: { 118 | backgroundColor: '#434343', 119 | height: 30, 120 | paddingTop: 6, 121 | paddingBottom: 5, 122 | paddingLeft: 20, 123 | paddingRight: 20, 124 | marginRight: 20, 125 | marginTop: 8, 126 | fontWeight: 'bold', 127 | textAlign: 'center', 128 | color: '#fff', 129 | borderRadius: 5 130 | }, 131 | overlay: { 132 | flex: 1, 133 | position: 'absolute', 134 | top: 0, 135 | left: 0, 136 | right: 0, 137 | bottom: 0, 138 | backgroundColor: 'rgba(0,0,0,0.5)', 139 | zIndex: 1 140 | }, 141 | vehicleIcon: { 142 | width: 34, 143 | height: 34 144 | } 145 | }); 146 | 147 | export default class VehiclesScreen extends React.Component { 148 | state = { 149 | showScanners: false, 150 | vehiclesHistory: [{ 151 | id: 1, 152 | scanAt: '6/22/2017', 153 | year: '2004', 154 | make: 'Ford', 155 | model: 'F-150', 156 | subModel: 'STX', 157 | engine: 'V8 - 4.6L 281ci GAS MFI vin W - 2 valve SOHC', 158 | vinCode: 'KNDMB233X66033879' 159 | }, { 160 | id: 2, 161 | scanAt: '6/22/2017', 162 | year: '2004', 163 | make: 'Ford', 164 | model: 'F-150', 165 | subModel: 'STX', 166 | engine: 'V8 - 4.6L 281ci GAS MFI vin W - 2 valve SOHC', 167 | vinCode: 'KNDMB233X66033879' 168 | }, { 169 | id: 3, 170 | scanAt: '6/22/2017', 171 | year: '2004', 172 | make: 'Ford', 173 | model: 'F-150', 174 | subModel: 'STX', 175 | engine: 'V8 - 4.6L 281ci GAS MFI vin W - 2 valve SOHC', 176 | vinCode: 'KNDMB233X66033879' 177 | }, { 178 | id: 4, 179 | scanAt: '6/22/2017', 180 | year: '2004', 181 | make: 'Ford', 182 | model: 'F-150', 183 | subModel: 'STX', 184 | engine: 'V8 - 4.6L 281ci GAS MFI vin W - 2 valve SOHC', 185 | vinCode: 'KNDMB233X66033879' 186 | }, { 187 | id: 5, 188 | scanAt: '6/22/2017', 189 | year: '2004', 190 | make: 'Ford', 191 | model: 'F-150', 192 | subModel: 'STX', 193 | engine: 'V8 - 4.6L 281ci GAS MFI vin W - 2 valve SOHC', 194 | vinCode: 'KNDMB233X66033879' 195 | }, { 196 | id: 6, 197 | scanAt: '6/22/2017', 198 | year: '2004', 199 | make: 'Ford', 200 | model: 'F-150', 201 | subModel: 'STX', 202 | engine: 'V8 - 4.6L 281ci GAS MFI vin W - 2 valve SOHC', 203 | vinCode: 'KNDMB233X66033879' 204 | }], 205 | modalVisible: false, 206 | chosenVehicle: null 207 | }; 208 | 209 | addVehicle = () => { 210 | const { showScanners } = this.state; 211 | this.setState({ showScanners: !showScanners }); 212 | } 213 | 214 | scanVin = () => { 215 | this.props.navigation.navigate('VinScan'); 216 | } 217 | 218 | scanPlate = () => { 219 | this.props.navigation.navigate('PlateScan'); 220 | } 221 | 222 | openDetailModal(vehicleInfo) { 223 | this.setState({ chosenVehicle: vehicleInfo, modalVisible: true }); 224 | } 225 | 226 | closeDetailModal = () => { 227 | this.setState({ modalVisible: false }); 228 | } 229 | 230 | addToCart = () => { 231 | this.props.navigation.navigate('Catalog'); 232 | } 233 | 234 | render() { 235 | const { showScanners, vehiclesHistory } = this.state; 236 | const { navigation } = this.props; 237 | return ( 238 | 239 |
240 | 241 | {navigation.state.params && navigation.state.params.screenMode === 'history' ? 242 | 243 | } 246 | > 247 | 248 | 249 | 250 | {vehiclesHistory.map(vehicleInfo => 251 | ( { this.openDetailModal(vehicleInfo); }} 258 | onPressIcon={this.addToCart} 259 | />))} 260 | 261 | 262 | 263 | 264 | 265 | 266 | {vehiclesHistory.map(vehicleInfo => 267 | ( { this.openDetailModal(vehicleInfo); }} 274 | onPressIcon={this.addToCart} 275 | />))} 276 | 277 | 278 | 279 | 280 | 281 | : 282 | 283 | 284 | You haven't scanned any vehicles yet 285 | 286 | } 287 | 288 | {showScanners ? 289 | 290 | 291 | 292 | : null 293 | } 294 | 295 | {showScanners ? 296 | 297 | 298 | Vin Scan 299 | 300 | 301 | 302 | 303 | 304 | : null 305 | } 306 | 307 | {showScanners ? 308 | 309 | 310 | Plate Scan 311 | 312 | 313 | 314 | 315 | 316 | : null 317 | } 318 | 319 | 320 | 321 | {showScanners ? 322 | 323 | : 324 | 325 | } 326 | 327 | 328 | 329 | { console.log('Modal has been closed.'); }} 334 | > 335 | 336 | 337 | 338 | ); 339 | } 340 | } 341 | 342 | class VehiclesTabBar extends React.Component { 343 | constructor(props) { 344 | super(props); 345 | this.icons = []; 346 | } 347 | getActiveColor(tabIndex) { 348 | return this.props.activeTab === tabIndex ? 'rgb(0,100,71)' : 'rgb(164,164,164)'; 349 | } 350 | 351 | icons = []; 352 | 353 | render() { 354 | return ( 355 | 356 | {this.props.tabs.map((tab, i) => ( 357 | this.props.goToPage(i)} style={[styles.tabButton, { borderBottomColor: this.props.activeTab === i ? 'rgb(0,100,1)' : 'transparent' }]}> 358 | { this.icons[i] = icon; }} 363 | /> 364 | {tab === 'history' ? 'HISTORY' : 'FAVORITES'} 365 | )) 366 | } 367 | 368 | ); 369 | } 370 | } 371 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React Native App](https://github.com/react-community/create-react-native-app). 2 | 3 | Below you'll find information about performing common tasks. The most recent version of this guide is available [here](https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/README.md). 4 | 5 | ## Table of Contents 6 | 7 | * [Updating to New Releases](#updating-to-new-releases) 8 | * [Available Scripts](#available-scripts) 9 | * [npm start](#npm-start) 10 | * [npm test](#npm-test) 11 | * [npm run ios](#npm-run-ios) 12 | * [npm run android](#npm-run-android) 13 | * [npm run eject](#npm-run-eject) 14 | * [Writing and Running Tests](#writing-and-running-tests) 15 | * [Environment Variables](#environment-variables) 16 | * [Configuring Packager IP Address](#configuring-packager-ip-address) 17 | * [Adding Flow](#adding-flow) 18 | * [Customizing App Display Name and Icon](#customizing-app-display-name-and-icon) 19 | * [Sharing and Deployment](#sharing-and-deployment) 20 | * [Publishing to Expo's React Native Community](#publishing-to-expos-react-native-community) 21 | * [Building an Expo "standalone" app](#building-an-expo-standalone-app) 22 | * [Ejecting from Create React Native App](#ejecting-from-create-react-native-app) 23 | * [Build Dependencies (Xcode & Android Studio)](#build-dependencies-xcode-android-studio) 24 | * [Should I Use ExpoKit?](#should-i-use-expokit) 25 | * [Troubleshooting](#troubleshooting) 26 | * [Networking](#networking) 27 | * [iOS Simulator won't open](#ios-simulator-wont-open) 28 | * [QR Code does not scan](#qr-code-does-not-scan) 29 | 30 | ## Updating to New Releases 31 | 32 | You should only need to update the global installation of `create-react-native-app` very rarely, ideally never. 33 | 34 | Updating the `react-native-scripts` dependency of your app should be as simple as bumping the version number in `package.json` and reinstalling your project's dependencies. 35 | 36 | Upgrading to a new version of React Native requires updating the `react-native`, `react`, and `expo` package versions, and setting the correct `sdkVersion` in `app.json`. See the [versioning guide](https://github.com/react-community/create-react-native-app/blob/master/VERSIONS.md) for up-to-date information about package version compatibility. 37 | 38 | ## Available Scripts 39 | 40 | If Yarn was installed when the project was initialized, then dependencies will have been installed via Yarn, and you should probably use it to run these commands as well. Unlike dependency installation, command running syntax is identical for Yarn and NPM at the time of this writing. 41 | 42 | ### `npm start` 43 | 44 | Runs your app in development mode. 45 | 46 | Open it in the [Expo app](https://expo.io) on your phone to view it. It will reload if you save edits to your files, and you will see build errors and logs in the terminal. 47 | 48 | Sometimes you may need to reset or clear the React Native packager's cache. To do so, you can pass the `--reset-cache` flag to the start script: 49 | 50 | ``` 51 | npm start -- --reset-cache 52 | # or 53 | yarn start -- --reset-cache 54 | ``` 55 | 56 | #### `npm test` 57 | 58 | Runs the [jest](https://github.com/facebook/jest) test runner on your tests. 59 | 60 | #### `npm run ios` 61 | 62 | Like `npm start`, but also attempts to open your app in the iOS Simulator if you're on a Mac and have it installed. 63 | 64 | #### `npm run android` 65 | 66 | Like `npm start`, but also attempts to open your app on a connected Android device or emulator. Requires an installation of Android build tools (see [React Native docs](https://facebook.github.io/react-native/docs/getting-started.html) for detailed setup). We also recommend installing Genymotion as your Android emulator. Once you've finished setting up the native build environment, there are two options for making the right copy of `adb` available to Create React Native App: 67 | 68 | ##### Using Android Studio's `adb` 69 | 70 | 1. Make sure that you can run adb from your terminal. 71 | 2. Open Genymotion and navigate to `Settings -> ADB`. Select “Use custom Android SDK tools” and update with your [Android SDK directory](https://stackoverflow.com/questions/25176594/android-sdk-location). 72 | 73 | ##### Using Genymotion's `adb` 74 | 75 | 1. Find Genymotion’s copy of adb. On macOS for example, this is normally `/Applications/Genymotion.app/Contents/MacOS/tools/`. 76 | 2. Add the Genymotion tools directory to your path (instructions for [Mac](http://osxdaily.com/2014/08/14/add-new-path-to-path-command-line/), [Linux](http://www.computerhope.com/issues/ch001647.htm), and [Windows](https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/)). 77 | 3. Make sure that you can run adb from your terminal. 78 | 79 | #### `npm run eject` 80 | 81 | This will start the process of "ejecting" from Create React Native App's build scripts. You'll be asked a couple of questions about how you'd like to build your project. 82 | 83 | **Warning:** Running eject is a permanent action (aside from whatever version control system you use). An ejected app will require you to have an [Xcode and/or Android Studio environment](https://facebook.github.io/react-native/docs/getting-started.html) set up. 84 | 85 | ## Customizing App Display Name and Icon 86 | 87 | You can edit `app.json` to include [configuration keys](https://docs.expo.io/versions/latest/guides/configuration.html) under the `expo` key. 88 | 89 | To change your app's display name, set the `expo.name` key in `app.json` to an appropriate string. 90 | 91 | To set an app icon, set the `expo.icon` key in `app.json` to be either a local path or a URL. It's recommended that you use a 512x512 png file with transparency. 92 | 93 | ## Writing and Running Tests 94 | 95 | This project is set up to use [jest](https://facebook.github.io/jest/) for tests. You can configure whatever testing strategy you like, but jest works out of the box. Create test files in directories called `__tests__` or with the `.test` extension to have the files loaded by jest. See the [the template project](https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/App.test.js) for an example test. The [jest documentation](https://facebook.github.io/jest/docs/getting-started.html) is also a wonderful resource, as is the [React Native testing tutorial](https://facebook.github.io/jest/docs/tutorial-react-native.html). 96 | 97 | ## Environment Variables 98 | 99 | You can configure some of Create React Native App's behavior using environment variables. 100 | 101 | ### Configuring Packager IP Address 102 | 103 | When starting your project, you'll see something like this for your project URL: 104 | 105 | ``` 106 | exp://192.168.0.2:19000 107 | ``` 108 | 109 | The "manifest" at that URL tells the Expo app how to retrieve and load your app's JavaScript bundle, so even if you load it in the app via a URL like `exp://localhost:19000`, the Expo client app will still try to retrieve your app at the IP address that the start script provides. 110 | 111 | In some cases, this is less than ideal. This might be the case if you need to run your project inside of a virtual machine and you have to access the packager via a different IP address than the one which prints by default. In order to override the IP address or hostname that is detected by Create React Native App, you can specify your own hostname via the `REACT_NATIVE_PACKAGER_HOSTNAME` environment variable: 112 | 113 | Mac and Linux: 114 | 115 | ``` 116 | REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname' npm start 117 | ``` 118 | 119 | Windows: 120 | ``` 121 | set REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname' 122 | npm start 123 | ``` 124 | 125 | The above example would cause the development server to listen on `exp://my-custom-ip-address-or-hostname:19000`. 126 | 127 | ## Adding Flow 128 | 129 | Flow is a static type checker that helps you write code with fewer bugs. Check out this [introduction to using static types in JavaScript](https://medium.com/@preethikasireddy/why-use-static-types-in-javascript-part-1-8382da1e0adb) if you are new to this concept. 130 | 131 | React Native works with [Flow](http://flowtype.org/) out of the box, as long as your Flow version matches the one used in the version of React Native. 132 | 133 | To add a local dependency to the correct Flow version to a Create React Native App project, follow these steps: 134 | 135 | 1. Find the Flow `[version]` at the bottom of the included [.flowconfig](.flowconfig) 136 | 2. Run `npm install --save-dev flow-bin@x.y.z` (or `yarn add --dev flow-bin@x.y.z`), where `x.y.z` is the .flowconfig version number. 137 | 3. Add `"flow": "flow"` to the `scripts` section of your `package.json`. 138 | 4. Add `// @flow` to any files you want to type check (for example, to `App.js`). 139 | 140 | Now you can run `npm run flow` (or `yarn flow`) to check the files for type errors. 141 | You can optionally use a [plugin for your IDE or editor](https://flow.org/en/docs/editors/) for a better integrated experience. 142 | 143 | To learn more about Flow, check out [its documentation](https://flow.org/). 144 | 145 | ## Sharing and Deployment 146 | 147 | Create React Native App does a lot of work to make app setup and development simple and straightforward, but it's very difficult to do the same for deploying to Apple's App Store or Google's Play Store without relying on a hosted service. 148 | 149 | ### Publishing to Expo's React Native Community 150 | 151 | Expo provides free hosting for the JS-only apps created by CRNA, allowing you to share your app through the Expo client app. This requires registration for an Expo account. 152 | 153 | Install the `exp` command-line tool, and run the publish command: 154 | 155 | ``` 156 | $ npm i -g exp 157 | $ exp publish 158 | ``` 159 | 160 | ### Building an Expo "standalone" app 161 | 162 | You can also use a service like [Expo's standalone builds](https://docs.expo.io/versions/latest/guides/building-standalone-apps.html) if you want to get an IPA/APK for distribution without having to build the native code yourself. 163 | 164 | ### Ejecting from Create React Native App 165 | 166 | If you want to build and deploy your app yourself, you'll need to eject from CRNA and use Xcode and Android Studio. 167 | 168 | This is usually as simple as running `npm run eject` in your project, which will walk you through the process. Make sure to install `react-native-cli` and follow the [native code getting started guide for React Native](https://facebook.github.io/react-native/docs/getting-started.html). 169 | 170 | #### Should I Use ExpoKit? 171 | 172 | If you have made use of Expo APIs while working on your project, then those API calls will stop working if you eject to a regular React Native project. If you want to continue using those APIs, you can eject to "React Native + ExpoKit" which will still allow you to build your own native code and continue using the Expo APIs. See the [ejecting guide](https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md) for more details about this option. 173 | 174 | ## Troubleshooting 175 | 176 | ### Networking 177 | 178 | If you're unable to load your app on your phone due to a network timeout or a refused connection, a good first step is to verify that your phone and computer are on the same network and that they can reach each other. Create React Native App needs access to ports 19000 and 19001 so ensure that your network and firewall settings allow access from your device to your computer on both of these ports. 179 | 180 | Try opening a web browser on your phone and opening the URL that the packager script prints, replacing `exp://` with `http://`. So, for example, if underneath the QR code in your terminal you see: 181 | 182 | ``` 183 | exp://192.168.0.1:19000 184 | ``` 185 | 186 | Try opening Safari or Chrome on your phone and loading 187 | 188 | ``` 189 | http://192.168.0.1:19000 190 | ``` 191 | 192 | and 193 | 194 | ``` 195 | http://192.168.0.1:19001 196 | ``` 197 | 198 | If this works, but you're still unable to load your app by scanning the QR code, please open an issue on the [Create React Native App repository](https://github.com/react-community/create-react-native-app) with details about these steps and any other error messages you may have received. 199 | 200 | If you're not able to load the `http` URL in your phone's web browser, try using the tethering/mobile hotspot feature on your phone (beware of data usage, though), connecting your computer to that WiFi network, and restarting the packager. 201 | 202 | ### iOS Simulator won't open 203 | 204 | If you're on a Mac, there are a few errors that users sometimes see when attempting to `npm run ios`: 205 | 206 | * "non-zero exit code: 107" 207 | * "You may need to install Xcode" but it is already installed 208 | * and others 209 | 210 | There are a few steps you may want to take to troubleshoot these kinds of errors: 211 | 212 | 1. Make sure Xcode is installed and open it to accept the license agreement if it prompts you. You can install it from the Mac App Store. 213 | 2. Open Xcode's Preferences, the Locations tab, and make sure that the `Command Line Tools` menu option is set to something. Sometimes when the CLI tools are first installed by Homebrew this option is left blank, which can prevent Apple utilities from finding the simulator. Make sure to re-run `npm/yarn run ios` after doing so. 214 | 3. If that doesn't work, open the Simulator, and under the app menu select `Reset Contents and Settings...`. After that has finished, quit the Simulator, and re-run `npm/yarn run ios`. 215 | 216 | ### QR Code does not scan 217 | 218 | If you're not able to scan the QR code, make sure your phone's camera is focusing correctly, and also make sure that the contrast on the two colors in your terminal is high enough. For example, WebStorm's default themes may [not have enough contrast](https://github.com/react-community/create-react-native-app/issues/49) for terminal QR codes to be scannable with the system barcode scanners that the Expo app uses. 219 | 220 | If this causes problems for you, you may want to try changing your terminal's color theme to have more contrast, or running Create React Native App from a different terminal. You can also manually enter the URL printed by the packager script in the Expo app's search bar to load it manually. 221 | -------------------------------------------------------------------------------- /app/components/scan/PTVDetail.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | StyleSheet, 4 | Text, 5 | View, 6 | Image, 7 | Modal, 8 | Platform, 9 | TextInput, 10 | Dimensions, 11 | ScrollView, 12 | TouchableOpacity 13 | } from 'react-native'; 14 | import { MaterialCommunityIcons } from '@expo/vector-icons'; 15 | import { Constants } from 'expo'; 16 | import { Dropdown } from 'react-native-material-dropdown'; 17 | import moment from 'moment'; 18 | 19 | import ConfirmVehicle from './ConfirmVehicle'; 20 | import config from '../../config/default.json'; 21 | 22 | const WINDOW = Dimensions.get('window'); 23 | const styles = StyleSheet.create({ 24 | container: { 25 | flex: 1, 26 | paddingTop: Platform.OS === 'ios' ? Constants.statusBarHeight : 0 27 | }, 28 | header: { 29 | backgroundColor: '#006447', 30 | paddingVertical: 18, 31 | paddingHorizontal: 15, 32 | width: '100%', 33 | height: 65, 34 | flexDirection: 'row', 35 | justifyContent: 'space-between', 36 | position: 'relative' 37 | }, 38 | actionIcon: { 39 | color: '#fff', 40 | fontSize: 24, 41 | }, 42 | submitText: { 43 | fontSize: 16, 44 | color: '#fff' 45 | }, 46 | headerTextArea: { 47 | position: 'absolute', 48 | width: '100%', 49 | height: 65, 50 | left: 15, 51 | justifyContent: 'center' 52 | }, 53 | headerText: { 54 | textAlign: 'center', 55 | color: '#fff', 56 | fontSize: 22, 57 | fontWeight: 'bold' 58 | }, 59 | details: { 60 | paddingHorizontal: 18, 61 | paddingVertical: 18, 62 | flex: 1, 63 | }, 64 | ptvImage: { 65 | resizeMode: 'contain', 66 | transform: [{ rotate: '0deg' }] 67 | }, 68 | inputArea: { 69 | paddingTop: 20 70 | }, 71 | label: { 72 | fontSize: 15, 73 | color: '#777', 74 | backgroundColor: 'transparent' 75 | }, 76 | inputBox: { 77 | paddingTop: 5, 78 | paddingBottom: 5, 79 | borderBottomWidth: 1, 80 | borderColor: 'rgba(0,0,0,.38)' 81 | }, 82 | submitBtn: { 83 | marginTop: 20, 84 | paddingHorizontal: 10, 85 | paddingVertical: 13, 86 | borderColor: 'rgba(0,0,0,.6)', 87 | borderWidth: 1, 88 | borderRadius: 3, 89 | backgroundColor: '#fdb015', 90 | width: '100%' 91 | }, 92 | submitBtnText: { 93 | color: 'rgba(0,0,0,.6)', 94 | fontSize: 16, 95 | fontFamily: Platform.OS === 'ios' ? 'Helvetica-Bold' : 'Roboto', 96 | textAlign: 'center' 97 | }, 98 | correctModal: { 99 | flex: 1, 100 | alignItems: 'center', 101 | justifyContent: 'center', 102 | backgroundColor: 'rgba(0,0,0,0.7)' 103 | }, 104 | correctModalContainer: { 105 | width: 300, 106 | height: 180, 107 | backgroundColor: '#fff', 108 | paddingHorizontal: 20, 109 | paddingVertical: 18, 110 | flexDirection: 'column', 111 | justifyContent: 'space-between' 112 | }, 113 | correctModalTitle: { 114 | fontSize: 20, 115 | fontWeight: 'bold', 116 | lineHeight: 30 117 | }, 118 | correctModalSubtitle: { 119 | fontSize: 16, 120 | color: 'rgba(0,0,0,.5)', 121 | lineHeight: 40 122 | }, 123 | modalActionArea: { 124 | flexDirection: 'row', 125 | justifyContent: 'flex-end' 126 | }, 127 | modalAction: { 128 | marginLeft: 40, 129 | marginRight: 20 130 | }, 131 | modalActionText: { 132 | fontSize: 15, 133 | color: '#006447', 134 | textAlign: 'right' 135 | }, 136 | verticalCenter: { 137 | height: '100%', 138 | justifyContent: 'center' 139 | } 140 | }); 141 | 142 | export default class PTVDetail extends React.Component { 143 | state = { 144 | correctModalVisible: false, 145 | confirmModalVisible: false, 146 | plateNumber: this.props.data && this.props.data.plateNumber ? this.props.data.plateNumber : '', 147 | region: this.props.data && this.props.data.region ? this.props.data.region.toUpperCase() : '', 148 | topSubmitText: 'SUBMIT', 149 | submitBtnText: 'SUBMIT', 150 | pictureWidth: 100, 151 | pictureHeight: 100, 152 | } 153 | 154 | componentDidMount() { 155 | Image.getSize(this.props.uri, (width, height) => { 156 | this.setState({ pictureWidth: width, pictureHeight: height }); 157 | }, (error) => { 158 | console.error(`Couldn't get the image size: ${error.message}`); 159 | }); 160 | } 161 | 162 | onSubmit = () => { 163 | if (this.state.topSubmitText === 'SAVE') { 164 | this.setState({ confirmModalVisible: true }); 165 | } else { 166 | const { plateNumber, region } = this.state; 167 | console.log(`${config.decodePlateApiUrl}?plateNumber=${plateNumber}&state=${region}`); 168 | fetch(`${config.decodePlateApiUrl}?plateNumber=${plateNumber}&state=${region}`) 169 | .then(result => result.json()) 170 | .then((response) => { 171 | console.log('Plate decode result:', response); 172 | if (response && response.length > 0) { 173 | const { 174 | plate, vin, vinPattern, state, year, vinQuerySet 175 | } = response[0]; 176 | const details = vinQuerySet[0]; 177 | const { vehicle, attributes } = details; 178 | this.setState({ 179 | data: { 180 | plate, 181 | vinCode: vin, 182 | vinPattern, 183 | state, 184 | year, 185 | make: vehicle.make, 186 | model: vehicle.model, 187 | vehicleId: vehicle.vehicleId, 188 | subModel: this.getDisplayDescriptionByAttributeName(attributes, 'Submodel'), 189 | engine: this.getDisplayDescriptionByAttributeName(attributes, 'Engine'), 190 | scanAt: moment().format('M/D/YYYY') 191 | }, 192 | correctModalVisible: true 193 | }); 194 | } 195 | }) 196 | .catch((error) => { 197 | console.log('Plate number decode error:', error); 198 | alert(`Failed in decoding the plate number due to the error:${error.toString()}`); 199 | }); 200 | } 201 | } 202 | 203 | getDisplayDescriptionByAttributeName = (source, attr) => { 204 | let ret = ''; 205 | if (source && attr) { 206 | const attributeData = source.find(x => x.description === attr); 207 | if (attributeData.values) { 208 | const valueData = attributeData.values.find(x => x.attributeId === attributeData.attributeId); 209 | if (valueData) { 210 | ret = valueData.displayDescription; 211 | } 212 | } 213 | } 214 | return ret; 215 | } 216 | 217 | states = [ 218 | { 219 | value: '', 220 | label: 'Select a State' 221 | }, { 222 | value: 'AL', 223 | label: 'Alabama' 224 | }, { 225 | value: 'AK', 226 | label: 'Alaska' 227 | }, { 228 | value: 'AZ', 229 | label: 'Arizona' 230 | }, { 231 | value: 'AR', 232 | label: 'Arkansas' 233 | }, { 234 | value: 'CA', 235 | label: 'California' 236 | }, { 237 | value: 'CO', 238 | label: 'Colorado' 239 | }, { 240 | value: 'CT', 241 | label: 'Connecticut' 242 | }, { 243 | value: 'DE', 244 | label: 'Delaware' 245 | }, { 246 | value: 'DC', 247 | label: 'District Of Columbia' 248 | }, { 249 | value: 'FL', 250 | label: 'Floridaz' 251 | }, { 252 | value: 'GA', 253 | label: 'Georgia' 254 | }, { 255 | value: 'HI', 256 | label: 'Hawaii' 257 | }, { 258 | value: 'ID', 259 | label: 'Idaho' 260 | }, { 261 | value: 'IL', 262 | label: 'Illinois' 263 | }, { 264 | value: 'IN', 265 | label: 'Indiana' 266 | }, { 267 | value: 'IA', 268 | label: 'Iowa' 269 | }, { 270 | value: 'KS', 271 | label: 'Kansas' 272 | }, { 273 | value: 'KY', 274 | label: 'Kentucky' 275 | }, { 276 | value: 'LA', 277 | label: 'Louisiana' 278 | }, { 279 | value: 'ME', 280 | label: 'Maine' 281 | }, { 282 | value: 'MD', 283 | label: 'Maryland' 284 | }, { 285 | value: 'MA', 286 | label: 'Massachusetts' 287 | }, { 288 | value: 'MI', 289 | label: 'Michigan' 290 | }, { 291 | value: 'MN', 292 | label: 'Minnesota' 293 | }, { 294 | value: 'MS', 295 | label: 'Mississippi' 296 | }, { 297 | value: 'MO', 298 | label: 'Missouri' 299 | }, { 300 | value: 'MT', 301 | label: 'Montana' 302 | }, { 303 | value: 'NE', 304 | label: 'Nebraska' 305 | }, { 306 | value: 'NV', 307 | label: 'Nevada' 308 | }, { 309 | value: 'NH', 310 | label: 'New Hampshire' 311 | }, { 312 | value: 'NJ', 313 | label: 'New Jersey' 314 | }, { 315 | value: 'NM', 316 | label: 'New Mexico' 317 | }, { 318 | value: 'NY', 319 | label: 'New York' 320 | }, { 321 | value: 'NC', 322 | label: 'North Carolina' 323 | }, { 324 | value: 'ND', 325 | label: 'North Dakota' 326 | }, { 327 | value: 'OH', 328 | label: 'Ohio' 329 | }, { 330 | value: 'OK', 331 | label: 'Oklahoma' 332 | }, { 333 | value: 'OR', 334 | label: 'Oregon' 335 | }, { 336 | value: 'PA', 337 | label: 'Pennsylvania' 338 | }, { 339 | value: 'RI', 340 | label: 'Rhode Island' 341 | }, { 342 | value: 'SC', 343 | label: 'South Carolina' 344 | }, { 345 | value: 'SD', 346 | label: 'South Dakota' 347 | }, { 348 | value: 'TN', 349 | label: 'Tennessee' 350 | }, { 351 | value: 'TX', 352 | label: 'Texas' 353 | }, { 354 | value: 'UT', 355 | label: 'Utah' 356 | }, { 357 | value: 'VT', 358 | label: 'Vermont' 359 | }, { 360 | value: 'VA', 361 | label: 'Virginia' 362 | }, { 363 | value: 'WA', 364 | label: 'Washington' 365 | }, { 366 | value: 'WV', 367 | label: 'West Virginia' 368 | }, { 369 | value: 'WI', 370 | label: 'Wisconsin' 371 | }, { 372 | value: 'WY', 373 | label: 'Wyoming' 374 | } 375 | ]; 376 | 377 | handleYesClick = () => { 378 | this.setState({ 379 | topSubmitText: 'SAVE', 380 | submitBtnText: 'SAVE VEHICLE', 381 | correctModalVisible: false, 382 | confirmModalVisible: true 383 | }); 384 | } 385 | 386 | closeCorrectModal = () => { 387 | this.setState({ correctModalVisible: false }); 388 | } 389 | 390 | openConfirmModal = () => { 391 | if (!this.state.plateNumber) { 392 | alert('Please enter Plate Number.'); 393 | } else { 394 | this.setState({ confirmModalVisible: true }); 395 | } 396 | } 397 | 398 | closeConfirmModal = () => { 399 | this.setState({ confirmModalVisible: false }); 400 | } 401 | 402 | saveNewVehicle = () => { 403 | const { plateNumber, region, data } = this.state; 404 | this.setState({ confirmModalVisible: false }); 405 | this.props.onSave({ ...data, plateNumber, region }); 406 | } 407 | 408 | render() { 409 | const { uri, onClose } = this.props; 410 | const { 411 | plateNumber, 412 | region, 413 | topSubmitText, 414 | submitBtnText, 415 | correctModalVisible, 416 | confirmModalVisible, 417 | data, 418 | pictureWidth, 419 | pictureHeight 420 | } = this.state; 421 | 422 | return ( 423 | 424 | 425 | 426 | 427 | 428 | PTV Details 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | { topSubmitText } 439 | 440 | 441 | 442 | 443 | 444 | 445 | {uri ? 446 | 447 | 448 | 449 | : null} 450 | 451 | 452 | Plate Number 453 | this.setState({ plateNumber: text })} 459 | style={styles.inputBox} 460 | /> 461 | 462 | 463 | 464 | ({ value: x.label }))} 468 | value={this.states.find(x => x.value === region).label} 469 | onChangeText={itemValue => this.setState({ region: this.states.find(x => x.label === itemValue).value })} 470 | rippleOpacity={0} 471 | animationDuration={0} 472 | /> 473 | 474 | 475 | 476 | {submitBtnText} 477 | 478 | 479 | 480 | 481 | console.log('Modal has been closed.')}> 482 | 483 | 484 | 485 | console.log('Modal has been closed.')}> 486 | 487 | 488 | 489 | 490 | ); 491 | } 492 | } 493 | 494 | class CorrectVehicle extends React.Component { 495 | constructor(props) { 496 | super(props); 497 | this.state = {}; 498 | } 499 | 500 | render() { 501 | const { data, onNo, onYes } = this.props; 502 | console.log(data); 503 | return ( 504 | 505 | 506 | Is this the correct vehicle? 507 | {`${data.year} ${data.make} ${data.model}`} 508 | 509 | 510 | NO 511 | 512 | 513 | YES 514 | 515 | 516 | 517 | 518 | ); 519 | } 520 | } 521 | --------------------------------------------------------------------------------