Renamed directory
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"presets": ["babel-preset-expo"],
|
||||
"env": {
|
||||
"development": {
|
||||
"plugins": ["transform-react-jsx-source"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"parser": "babel-eslint",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2017,
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
}
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"jest": true,
|
||||
"react-native/react-native": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:flowtype/recommended",
|
||||
"plugin:react/recommended",
|
||||
"plugin:react-native/all"
|
||||
],
|
||||
"plugins": ["babel", "flowtype", "react", "react-native"],
|
||||
"rules": {
|
||||
"no-console": "off",
|
||||
"no-var": "error",
|
||||
"prefer-const": "error",
|
||||
"flowtype/no-types-missing-file-annotation": 0
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
[ignore]
|
||||
.*/node_modules/.*
|
||||
|
||||
[include]
|
||||
|
||||
[libs]
|
||||
|
||||
[lints]
|
||||
all=warn
|
||||
untyped-type-import=off
|
||||
unsafe-getters-setters=off
|
||||
|
||||
[options]
|
||||
include_warnings=true
|
||||
module.file_ext=.scss
|
||||
|
||||
[strict]
|
||||
@@ -1,17 +0,0 @@
|
||||
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# expo
|
||||
.expo/
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
|
||||
# misc
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"tabWidth": 4,
|
||||
"printWidth": 75
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -1,17 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import React from "react";
|
||||
import { Provider } from "react-redux";
|
||||
|
||||
import { store } from "./src/adaptiveApp/store";
|
||||
import { Main } from "./src/adaptiveApp/main";
|
||||
|
||||
export default class App extends React.PureComponent<> {
|
||||
render() {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<Main />
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import React from "react";
|
||||
import { StatusBar } from "react-native";
|
||||
|
||||
import { MyDrawer } from "./src/routingApp/drawer";
|
||||
|
||||
class App extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<StatusBar hidden />
|
||||
<MyDrawer />
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default App;
|
||||
@@ -1,27 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import React from "react";
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
|
||||
export default class App extends React.Component<> {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text>Open up App.js to start working on your app!</Text>
|
||||
<Text>Changes you make will automatically reload.</Text>
|
||||
<Text>Shake your phone to open the developer menu.</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const white: string = "#fff";
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: white,
|
||||
alignItems: "center",
|
||||
justifyContent: "center"
|
||||
}
|
||||
});
|
||||
@@ -1,23 +0,0 @@
|
||||
import React from "react";
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
|
||||
export default class App extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text>Open up App.js to start working on your app!</Text>
|
||||
<Text>Changes you make will automatically reload.</Text>
|
||||
<Text>Shake your phone to open the developer menu.</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: "#fff",
|
||||
alignItems: "center",
|
||||
justifyContent: "center"
|
||||
}
|
||||
});
|
||||
@@ -1,17 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import React from "react";
|
||||
import { Provider } from "react-redux";
|
||||
|
||||
import { store } from "./src/regionsApp/store";
|
||||
import { Main } from "./src/regionsApp/main";
|
||||
|
||||
export default class App extends React.PureComponent<> {
|
||||
render() {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<Main />
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import React from "react";
|
||||
import { StatusBar } from "react-native";
|
||||
|
||||
import { MyDrawer } from "./src/routingApp/drawer";
|
||||
|
||||
class App extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<StatusBar hidden />
|
||||
<MyDrawer />
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default App;
|
||||
@@ -1,17 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import React from "react";
|
||||
import { Provider } from "react-redux";
|
||||
|
||||
import { store } from "./src/regionsStyledApp/store";
|
||||
import { ConnectedMain } from "./src/regionsStyledApp/main.connected";
|
||||
|
||||
export default class App extends React.PureComponent<> {
|
||||
render() {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<ConnectedMain />
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import React from 'react';
|
||||
import App from './App';
|
||||
|
||||
import renderer from 'react-test-renderer';
|
||||
|
||||
it('renders without crashing', () => {
|
||||
const rendered = renderer.create(<App />).toJSON();
|
||||
expect(rendered).toBeTruthy();
|
||||
});
|
||||
@@ -1,201 +0,0 @@
|
||||
This project was bootstrapped with [Create React Native App](https://github.com/react-community/create-react-native-app).
|
||||
|
||||
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).
|
||||
|
||||
## Table of Contents
|
||||
|
||||
* [Updating to New Releases](#updating-to-new-releases)
|
||||
* [Available Scripts](#available-scripts)
|
||||
* [npm start](#npm-start)
|
||||
* [npm test](#npm-test)
|
||||
* [npm run ios](#npm-run-ios)
|
||||
* [npm run android](#npm-run-android)
|
||||
* [npm run eject](#npm-run-eject)
|
||||
* [Writing and Running Tests](#writing-and-running-tests)
|
||||
* [Environment Variables](#environment-variables)
|
||||
* [Configuring Packager IP Address](#configuring-packager-ip-address)
|
||||
* [Customizing App Display Name and Icon](#customizing-app-display-name-and-icon)
|
||||
* [Sharing and Deployment](#sharing-and-deployment)
|
||||
* [Publishing to Expo's React Native Community](#publishing-to-expos-react-native-community)
|
||||
* [Building an Expo "standalone" app](#building-an-expo-standalone-app)
|
||||
* [Ejecting from Create React Native App](#ejecting-from-create-react-native-app)
|
||||
* [Build Dependencies (Xcode & Android Studio)](#build-dependencies-xcode-android-studio)
|
||||
* [Should I Use ExpoKit?](#should-i-use-expokit)
|
||||
* [Troubleshooting](#troubleshooting)
|
||||
* [Networking](#networking)
|
||||
* [iOS Simulator won't open](#ios-simulator-wont-open)
|
||||
* [QR Code does not scan](#qr-code-does-not-scan)
|
||||
|
||||
## Updating to New Releases
|
||||
|
||||
You should only need to update the global installation of `create-react-native-app` very rarely, ideally never.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
## Available Scripts
|
||||
|
||||
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.
|
||||
|
||||
### `npm start`
|
||||
|
||||
Runs your app in development mode.
|
||||
|
||||
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.
|
||||
|
||||
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:
|
||||
|
||||
```
|
||||
npm start --reset-cache
|
||||
# or
|
||||
yarn start --reset-cache
|
||||
```
|
||||
|
||||
#### `npm test`
|
||||
|
||||
Runs the [jest](https://github.com/facebook/jest) test runner on your tests.
|
||||
|
||||
#### `npm run ios`
|
||||
|
||||
Like `npm start`, but also attempts to open your app in the iOS Simulator if you're on a Mac and have it installed.
|
||||
|
||||
#### `npm run android`
|
||||
|
||||
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:
|
||||
|
||||
##### Using Android Studio's `adb`
|
||||
|
||||
1. Make sure that you can run adb from your terminal.
|
||||
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).
|
||||
|
||||
##### Using Genymotion's `adb`
|
||||
|
||||
1. Find Genymotion’s copy of adb. On macOS for example, this is normally `/Applications/Genymotion.app/Contents/MacOS/tools/`.
|
||||
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/)).
|
||||
3. Make sure that you can run adb from your terminal.
|
||||
|
||||
#### `npm run eject`
|
||||
|
||||
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.
|
||||
|
||||
**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.
|
||||
|
||||
## Customizing App Display Name and Icon
|
||||
|
||||
You can edit `app.json` to include [configuration keys](https://docs.expo.io/versions/latest/guides/configuration.html) under the `expo` key.
|
||||
|
||||
To change your app's display name, set the `expo.name` key in `app.json` to an appropriate string.
|
||||
|
||||
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.
|
||||
|
||||
## Writing and Running Tests
|
||||
|
||||
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/en/getting-started.html) is also a wonderful resource, as is the [React Native testing tutorial](https://facebook.github.io/jest/docs/en/tutorial-react-native.html).
|
||||
|
||||
## Environment Variables
|
||||
|
||||
You can configure some of Create React Native App's behavior using environment variables.
|
||||
|
||||
### Configuring Packager IP Address
|
||||
|
||||
When starting your project, you'll see something like this for your project URL:
|
||||
|
||||
```
|
||||
exp://192.168.0.2:19000
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
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:
|
||||
|
||||
Mac and Linux:
|
||||
|
||||
```
|
||||
REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname' npm start
|
||||
```
|
||||
|
||||
Windows:
|
||||
```
|
||||
set REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname'
|
||||
npm start
|
||||
```
|
||||
|
||||
The above example would cause the development server to listen on `exp://my-custom-ip-address-or-hostname:19000`.
|
||||
|
||||
## Sharing and Deployment
|
||||
|
||||
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.
|
||||
|
||||
### Publishing to Expo's React Native Community
|
||||
|
||||
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.
|
||||
|
||||
Install the `exp` command-line tool, and run the publish command:
|
||||
|
||||
```
|
||||
$ npm i -g exp
|
||||
$ exp publish
|
||||
```
|
||||
|
||||
### Building an Expo "standalone" app
|
||||
|
||||
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.
|
||||
|
||||
### Ejecting from Create React Native App
|
||||
|
||||
If you want to build and deploy your app yourself, you'll need to eject from CRNA and use Xcode and Android Studio.
|
||||
|
||||
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).
|
||||
|
||||
#### Should I Use ExpoKit?
|
||||
|
||||
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.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Networking
|
||||
|
||||
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.
|
||||
|
||||
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:
|
||||
|
||||
```
|
||||
exp://192.168.0.1:19000
|
||||
```
|
||||
|
||||
Try opening Safari or Chrome on your phone and loading
|
||||
|
||||
```
|
||||
http://192.168.0.1:19000
|
||||
```
|
||||
|
||||
and
|
||||
|
||||
```
|
||||
http://192.168.0.1:19001
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
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. If you are using a VPN you may need to disable it.
|
||||
|
||||
### iOS Simulator won't open
|
||||
|
||||
If you're on a Mac, there are a few errors that users sometimes see when attempting to `npm run ios`:
|
||||
|
||||
* "non-zero exit code: 107"
|
||||
* "You may need to install Xcode" but it is already installed
|
||||
* and others
|
||||
|
||||
There are a few steps you may want to take to troubleshoot these kinds of errors:
|
||||
|
||||
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.
|
||||
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.
|
||||
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`.
|
||||
|
||||
### QR Code does not scan
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"expo": {
|
||||
"sdkVersion": "27.0.0"
|
||||
}
|
||||
}
|
||||
@@ -1,287 +0,0 @@
|
||||
Device Name,Platform,OS Version,Portrait Width,Landscape Width,Release Date
|
||||
Acer Iconia Tab A1-810,Android,4.2.2,768,1024,2013-05
|
||||
Acer Iconia Tab A100,Android,4.0.3,800,1280,2011-04
|
||||
Acer Iconia Tab A101,Android,3.2.1,600,1024,2011-05
|
||||
Acer Iconia Tab A200,Android,4.0.3,800,1280,2012-01
|
||||
Acer Iconia Tab A500,Android,4.0.3,648,1280,2011-04
|
||||
Acer Iconia Tab A501,Android,3.2,800,1280,2011-04
|
||||
ACER Liquid E2,Android,4.2.1,360,640,2013-05
|
||||
Ainol Novo 7 Elf 2,Android,4.0.3,496,1024,2012-06
|
||||
Alcatel One Touch Idol X,Android,4.2.2,480,800,2013-07
|
||||
Alcatel One Touch T10,Android,4.0.3,480,800,2013-03
|
||||
Alcatel One Touch 903,Android,2.3.6,320,427,2012-08
|
||||
Alcatel (Vodafone) Smart Mini 875,Android,4.1.1,320,480,2013-07
|
||||
Amicroe 7 TouchTAB II,Android,4.0.4,480,800,2013-01
|
||||
Amicroe 9.7 TouchTAB IV,Android,4.1.1,768,1024,2013-05
|
||||
Archos 70b (it2),Android,3.2.1,600,1024,2012-02
|
||||
Archos 80G9,Android,3.2,768,1024,2011-09
|
||||
Arnova 10b G3,Android,4.0.3,600,1024,2012-05
|
||||
Arnova 7 G2,Android,2.3.1,480,800,2011-09
|
||||
Arnova 7F G3,Android,4.0.3,640,1067,2012-11
|
||||
Arnova 8C G3,Android,4.0.3,800,1067,2012-11
|
||||
ASUS B1-A71,Android,4.1.2,600,1024,2013-01
|
||||
ASUS Fonepad,Android,4.1.2,601,962,2013-04
|
||||
ASUS MeMo Pad ME172V,Android,4.1.1,600,1024,2013-01
|
||||
ASUS MeMo Pad FHD10/ME302C 10.1,Android,4.2.2,800,1280,2013-08
|
||||
ASUS Padfone,Android,4.0,800,1128,2012-06
|
||||
ASUS Transformer Pad TF300T,Android,4.0.3,800,1280,2012-04
|
||||
ASUS Transformer TF101,Android,3.1,800,1280,2011-04
|
||||
ASUS Vivo,Windows RT,8.0,768,1366,2012-11
|
||||
Barnes & Noble Nook HD,Android,4.0.4,600,960,2012-11
|
||||
BAUHN AMID-972XS,Android,4.0.3,768,1024,2012-09
|
||||
BAUHN AMID-9743G,Android,4.1.2,768,1024,2013-02
|
||||
BAUHN ASP-5000H,Android,4.2,360,640,2013-09
|
||||
BlackBerry 9520,BlackBerry OS,5,345,691,2009-11
|
||||
BlackBerry Bold 9000,BlackBerry OS,4.0.0.223,480,-,2008-08
|
||||
BlackBerry Bold 9780,BlackBerry OS,6.0.0.110,480,-,2010-11
|
||||
BlackBerry Bold 9790,BlackBerry OS,7.0.0.528,320,-,2011-12
|
||||
BlackBerry Bold 9900,BlackBerry OS,7.1.0.342,356,-,2011-08
|
||||
BlackBerry Curve 9300,BlackBerry OS,5.0.0.716,311,-,2010-08
|
||||
BlackBerry Curve 9300,BlackBerry OS,6.0.0.448,320,-,2010-08
|
||||
BlackBerry Curve 9320,BlackBerry OS,7.1.0.569,320,-,2010-05
|
||||
BlackBerry Curve 9360,BlackBerry OS,7.0.0.530,320,-,2011-08
|
||||
BlackBerry Curve 9380,BlackBerry OS,7.0.0.513,320,406,2011-12
|
||||
BlackBerry PlayBook,Blackberry Tablet OS,2.1.0,600,1024,2011-04
|
||||
BlackBerry Torch 9800,BlackBerry OS,6.0.0.353,360,480,2010-08
|
||||
BlackBerry Torch 9810,BlackBerry OS,7.0.0.296,320,-,2011-08
|
||||
BlackBerry Torch 9860,BlackBerry OS,7.0.0.579,320,505,2011-09
|
||||
BlackBerry Q10,BlackBerry OS,10.1.0.1910,346,-,2013-04
|
||||
BlackBerry Z10,BlackBerry OS,10.0.10.690,342,570,2013-02
|
||||
Dell Venue 8,Windows 8,8.1,800,1280,10-2013
|
||||
Galaxy Nexus,Android,4.1.1,360,598,2011-11
|
||||
HP Slate 7 2800,Android,4.1.1,600,1024,2013-06
|
||||
HP Slate 21,Android,4.2.2,1920,NA,2013-10
|
||||
HP Touchpad,Android,4.0.3,768,1024,2011-07
|
||||
HP Touchpad,webOS,3.0,768,1024,2011-07
|
||||
HP Veer,WebOS,2.1.1,320,545,2011-06
|
||||
HTC 7 Mozart,WP7,7.5,320,480,2010-10
|
||||
HTC 7 Trophy,WP7,7.5,320,480,2010-10
|
||||
HTC A620b,WP8,8.0,320,480,2013-01
|
||||
HTC Desire,Android,2.3.3,320,533,2010-03
|
||||
HTC Desire C,Android,4.0.3,320,480,2012-06
|
||||
HTC Desire HD,Android,2.3.5,320,533,2010-10
|
||||
HTC Desire S,Android,4.0.4,320,533,2011-03
|
||||
HTC Desire X,Android,4.1.1,320,533,2012-10
|
||||
HTC Desire 700,Android,4.1.2,360,640,2014-01
|
||||
HTC Desire Z (Vision),Android,2.2,480,800,2010-11
|
||||
HTC Droid Eris,Android,2.1,320,480,2009-11
|
||||
HTC Evo 3D,Android,4.0.3,540,960,2011-07
|
||||
HTC Incredible 2,Android ,2.3.4,320,533,2011-04
|
||||
HTC Legend,Android,2.2,320,480,2010-03
|
||||
HTC MyTouch Slide 4G,Android,2.3.4,320,533,2011-07
|
||||
HTC One,Android,4.1.2,360,640,2013-03
|
||||
HTC One Mini,Android,4.2.2,360,640,2013-07
|
||||
HTC One S,Android,4.0.3,360,640,2012-04
|
||||
HTC One SV,Android,4.0.4,320,533,2012-12
|
||||
HTC One V,Android,4.0.3,320,533,2012-04
|
||||
HTC One X,Android,4.2.2,360,640,2012-05
|
||||
HTC One X+,Android,4.3,360,640,2012-11
|
||||
HTC One XL,Android,4.0.3,360,640,2012-05
|
||||
HTC Rio 8S,WP8,8.0,320,480,2012-12
|
||||
HTC Sensation XL,Android,4.0.3,360,640,2011-11
|
||||
HTC Titan II/4G,WP7,7.5,320,480,2012-04
|
||||
HTC Velocity 4G,Android,4.0.3,360,640,2012-11
|
||||
HTC Wildfire A3333,Android,2.2.1,267,356,2010-05
|
||||
HTC Wildfire S,Android,2.3.3,320,480,2011-05
|
||||
HTC Windows Phone 8S,WP8,8.0,320,480,2012-11
|
||||
HTC Windows Phone 8X (C625b),WP8,8.0,320,480,2012-11
|
||||
Huawei Ascend G510,Android,4.1.1,320,569,2013-04
|
||||
Huawei Ascend Mate,Android,4.1.1,480,813,2013-03
|
||||
Huawei U8650 Sonic,Android,2.3.3,320,480,2011-06
|
||||
Huawei U8860,Android,4.0.3,320,544,2011-12
|
||||
Huawei Y300-0151,Android,4.1.1,320,533,2013-03
|
||||
iPad,iOS,5.0.1,768,1024,2010-03
|
||||
iPad 2,iOS,5.0.1,768,1024,2011-03
|
||||
iPad 3,iOS,5.1.1,768,1024,2012-03
|
||||
iPad Air,iOS,7.0.3,768,1024,2013-10
|
||||
iPad Mini,iOS,6.0.1,768,1024,2012-11
|
||||
iPhone,iOS,3.1.3,320,480,2007-06
|
||||
iPhone 3G,iOS,4.2.1,320,480,2008-07
|
||||
iPhone 3GS,iOS,6.0a2,320,480,2009-06
|
||||
iPhone 4,iOS,5.1.1,320,480,2010-06
|
||||
iPhone 4S,iOS,4.3.5,320,480,2011-10
|
||||
iPhone 5,iOS,6.0,320,568,2012-09
|
||||
iPhone 5c,iOS,7.0,320,568,2013-09
|
||||
iPhone 5s,iOS,7.0,320,568,2013-09
|
||||
iPhone 6,iOS,8.0,375,667,2014-09
|
||||
iPhone 6 Plus,iOS,8.0,414,736,2014-09
|
||||
iPod Touch 4th Gen,iOS,5.0.1,320,480,2010-09
|
||||
iPod Touch 5th Gen,iOS,6.0,320,568,2012-10
|
||||
Kindle 3,Kindle,3.3,600,-,2010-08
|
||||
Kindle Fire 2,Android,4.0.3,600,963,2011-11
|
||||
Kindle Fire HD,Android,4,533,801,2012-09
|
||||
Kindle Fire HD 8.9,Android,4.0.3,800,1220,2012-10
|
||||
Kindle Paperwhite,Kindle,5,758,-,2012-10
|
||||
Kobo eReader Touch,Android,2.0.0,600,-,2011-06
|
||||
Kogan 42" Smart 3D LED TV,Android,4.1.2,-,1280,2013-07
|
||||
Lenovo IdeaTab A1000,Android,4.2.2,600,1024,2013-05
|
||||
Lenovo IdeaTab S6000,Android,4.2.2,800,1280,2013-06
|
||||
Lenovo Yoga Tablet 8,Android,4.2.2,602,962,2013-10
|
||||
Lenovo Yoga Tablet 10,Android,4.2.2,800,1280,2013-11
|
||||
LG 55LW6500 TV,Proprietary (TV),5.00.07,-,1280,2011-03
|
||||
LG Ally,Android,2.2.2,320,533,2010-04
|
||||
LG G2,Android,4.2.2,360,598,2013-09
|
||||
LG Optimus 2x,Android,2.3.7,320,533,2011-02
|
||||
LG Optimus Black P970,Android,4.0.4,320,533,2011-05
|
||||
LG Optimus G E975,Android,4.1.2,384,640,2012-11
|
||||
LG Optimus L3 E400,Android,2.3.6,320,427,2012-02
|
||||
LG Optimus L3 II E425f,Android,4.1.2,320,427,2013-04
|
||||
LG Optimus L7 P700,Android,4.0.3,320,533,2012-05
|
||||
LG Optimus L9 P760,Android,4.0.4,360,640,2012-11
|
||||
LG Optimus Pad V900,Android,3.0.1,768,1280,2011-05
|
||||
LG Viewty KU990,Proprietary (Java),1.2,240,400,2008-10
|
||||
Microsoft Surface,Windows RT,8.0,768,1366,2012-11
|
||||
Microsoft Surface Pro,Windows 8,8.0,720,1280,2012-11
|
||||
Motorola Defy,Android,2.3.4,320,569,2010-10
|
||||
Motorola Defy Mini,Android,2.3.6,320,480,2012-01
|
||||
Motorola Droid Bionic,Android,4.1.2,360,640,2011-09
|
||||
Motorola Droid Razr,Android,2.3.6,360,640,2011-11
|
||||
Motorola Droid 3,Android,2.3,360,559,2011-07
|
||||
Motorola Electrify 2,Android,4.1.2,360,598,2012-07
|
||||
Motorola Fire XT,Android,2.3.5,320,480,2011-09
|
||||
Motorola FlipOut,Android,2.1,320,240,2010-06
|
||||
Motorola Milestone,Android,2.3.7,320,569,2009-11
|
||||
Motorola Moto G,Android,4.3,360,598,2013-11
|
||||
Motorola RAZR HD 4G,Android,4.0.4,360,598,2012-09
|
||||
Motorola RAZR M 4G,Android,4.0.4,360,598,2012-09
|
||||
Motorola RAZR MAXX,Android,4.0,360,640,2012-05
|
||||
Motorola Xoom,Android,4.1,800,1280,2011-05
|
||||
Motorola Xoom 2,Android,3.2.2,800,1280,2011-12
|
||||
Motorola Xoom 2 Media Edition,Android,3.2.2,800,1280,2011-12
|
||||
Nexus 10,Android,4.2.2,800,1280,2012-11
|
||||
Nexus 4,Android,4.2.1,384,598,2012-11
|
||||
Nexus 5,Android,4.4,360,598,2013-10
|
||||
Nexus 7,Android,4.1.1,603,966,2012-07
|
||||
Nexus 7,Android,4.2.1,600,961,2012-07
|
||||
Nexus 7,Android,4.3,601,962,2012-07
|
||||
Nexus 7 (LCD Density set to 175PPI),Android,4.1.1,731,1170,2012-07
|
||||
Nexus 7 (2013),Android,4.3,600,960,2013-07
|
||||
Nexus One,Android,2.3.7,320,533,2010-01
|
||||
Nexus S,Android,4.1.1,320,533,2010-10
|
||||
Nintendo 3DS,3DS,4.3.0-10E,416,-,2011-02
|
||||
Nintendo 3DS XL,3DS,1.7455.EU,416,-,2012-07
|
||||
Nintendo DSi,DSi,507; U; en-GB,256,-,2009-04
|
||||
Nintendo DSi XL,DSi,1.4.4A,240,-,2010-03
|
||||
Nintendo Wii,Wii,4.3,800,-,2007-11
|
||||
Nintendo Wii U,Wii U,1.0.0.7494,854,-,2012-11
|
||||
Nokia 2700,S40,5th Edition,240,-,2009-07
|
||||
Nokia Asha 300,Proprietary (Nokia),07.03 29-11-11 RM-781,234,-,2011-11
|
||||
Nokia Asha 302,Proprietary (Nokia),14.53 20-03-12 RM-813,314,-,2012-03
|
||||
Nokia 500,Symbian,Belle,360,640,2011-09
|
||||
Nokia 700 (Opera Mobile),Symbian,Belle FP2,240,427,2011-09
|
||||
Nokia E61i,S60,Symbian 9.1,320,-,2007-04
|
||||
Nokia E71,S60,Symbian 9.2,320,-,2007-04
|
||||
Nokia Lumia 520,WP8,8.0,320,480,2013-04
|
||||
Nokia Lumia 610,WP7,7.5,320,480,2012-04
|
||||
Nokia Lumia 710,WP7,7.5,320,480,2011-12
|
||||
Nokia Lumia 720,WP7,8.0,320,480,2013-04
|
||||
Nokia Lumia 800,WP7,7.5,320,480,2011-11
|
||||
Nokia Lumia 820,WP8,8.0,320,480,2012-11
|
||||
Nokia Lumia 900,WP7,7.5,320,480,2012-05
|
||||
Nokia Lumia 920,WP8,8.0,320,480,2012-11
|
||||
Nokia Lumia 925,WP8,8.0,320,480,2013-06
|
||||
Nokia Lumia 1520,WP8,8.0,320,480,2013-11
|
||||
Nokia N9,MeeGo,1.2,320,496,2011-09
|
||||
Nokia N900,Maemo,5,480,800,2009-11
|
||||
Nokia N95,S60,Symbian 9.2,240,-,2007-03
|
||||
Palm Pixi,WebOS,1.4.5,320,480,2009-11
|
||||
Palm Pre,WebOS,2.2,320,-,2009-10
|
||||
Panasonic Toughpad FZ-A1,Android,4.0,768,1024,2012-12
|
||||
PendoPad 7",Android,4.2.2,480,800,2013-11
|
||||
PendoPad 10",Android,4.2.2,600,1024,2013-11
|
||||
Pioneer Dreambook,Android,4.0.4,768,1024,2010-07
|
||||
Samsung Ativ S,WP8,8.0,320,480,2012-12
|
||||
Samsung E3210,Proprietary (Java),-,128,-,2011-05
|
||||
Samsung Galaxy 5/Europa I5500,Android,2.1-update1,320,427,2010-08
|
||||
Samsung Galaxy Ace S5830,Android,2.3.4,320,480,2011-02
|
||||
Samsung Galaxy Ace 2 I8160,Android,2.3.6,320,533,2012-05
|
||||
Samsung Galaxy Ace Plus S7500,Android,2.3.6,320,480,2012-02
|
||||
Samsung Galaxy Beam I8530,Android,2.3.6,320,533,2012-07
|
||||
Samsung Galaxy Camera GC100,Android,4.1.2,360,598,2012-11
|
||||
Samsung Galaxy Mini S5570,Android,2.3.4,240,320,2011-02
|
||||
Samsung Galaxy Mini 2 S6500,Android,2.3,320,480,2012-03
|
||||
Samsung Galaxy Note N700,Android,2.3.6,400,640,2011-10
|
||||
Samsung Galaxy Note 10.1 N8010,Android,4.0.4,800,1280,2012-08
|
||||
Samsung Galaxy Note 10.1 N8010 (Multiscreen Enabled),Android,4.0.4,800,637,2012-08
|
||||
Samsung Galaxy Note 10.1 (2014 Edition) P600,Android,4.3,800,1280,2013-11
|
||||
Samsung Galaxy Note 2 N7100,Android,4.1.1,360,640,2012-09
|
||||
Samsung Galaxy Note 3 N9005,Android,4.3,360,640,2013-09
|
||||
Samsung Galaxy Note 8.0 N5100,Android,4.1.2,601,962,2013-04
|
||||
Samsung Galaxy Note 8.0 N5110,Android,4.1.2,601,962,2013-04
|
||||
Samsung Galaxy S I9000,Android,2.3.6,320,533,2010-06
|
||||
Samsung Galaxy S Duos S7562,Android,4.0.4,320,533,2012-09
|
||||
Samsung Galaxy S WiFi YPG70CW,Android,2.2,320,533,2011-05
|
||||
Samsung Galaxy S2 I9100,Android,2.3.6,320,533,2011-04
|
||||
Samsung Galaxy S3 I9300,Android,4.0.4,360,640,2012-05
|
||||
Samsung Galaxy S3 Mini I8190,Android,4.1.2,320,533,2012-11
|
||||
Samsung Galaxy S4 I9500,Android,4.2.2,360,640,2013-04
|
||||
Samsung Galaxy S4 I9505,Android,4.2.2,360,640,2013-04
|
||||
Samsung Galaxy S4 Active I9295,Android,4.2.2,360,640,2013-06
|
||||
Samsung Galaxy S4 Mini I9190,Android,4.2.2,360,640,2013-07
|
||||
Samsung Galaxy S4 Zoom SM-C105,Android,4.2.2,360,640,2013-07
|
||||
Samsung Galaxy Tab 10.1 P7510,Android,3.2,800,1280,2011-07
|
||||
Samsung Galaxy Tab 2 10.1 P5110,Android,4.0.4,800,1280,2012-05
|
||||
Samsung Galaxy Tab 2 7.0 P3110,Android,4.0.3,600,1024,2012-05
|
||||
Samsung Galaxy Tab 3 7.0 T210,Android,4.1.2,600,1024,2013-07
|
||||
Samsung Galaxy Tab 3 8.0 T310,Android,4.2.2,602,962,2013-07
|
||||
Samsung Galaxy Tab 3 10.1 P5210,Android,4.2.2,800,1280,2013-07
|
||||
Samsung Galaxy Tab 3 Kids T2105,Android,4.1.2,600,1024,2013-11
|
||||
Samsung Galaxy Tab 7.7 P6810,Android,3.2,800,1280,2012-01
|
||||
Samsung Galaxy Tab 7.0 Plus P6210,Android,3.2,600,1024,2012-01
|
||||
Samsung Galaxy Tab 8.9 P7310,Android,4.0.4,800,1280,2011-05
|
||||
Samsung Galaxy Tab 8.9 4G P7320,Android,3.2,800,1280,2012-02
|
||||
Samsung Galaxy Tab P1000,Android,2.3.3,400,683,2010-10
|
||||
Samsung Galaxy X Cover 2 S7710 ,Android,4.1.2,320,533,2013-03
|
||||
Samsung Galaxy Y S5360,Android,2.3.6,320,427,2011-10
|
||||
Samsung Galaxy Young S6310,Android,4.1.2,320,480,2013-02
|
||||
Samsung Infuse 4G I997,Android,2.3,320,533,2011-05
|
||||
Samsung Omnia W I8350,WP7,7.5,320,480,2011-10
|
||||
Samsung Omnia 7 I8700,WP7,7.5,320,480,2010-10
|
||||
Samsung Wave S8500,Bada,1.0,240,400,2010-04
|
||||
Samsung Wave S8500,Bada,2.0.1,320,534,2010-04
|
||||
Scroll Excel,Android,2.3.4,480,800,2012-02
|
||||
Sony BRAVIA 40 EX520,Proprietary (TV),PKG4.012GAA-0104,-,1920,2011-01
|
||||
Sony Ericsson Elm,Proprietary (Java),1231-1917 R7CA061 100619,240,-,2010-03
|
||||
Sony Ericsson Spiro,Proprietary (Java),-,240,-,2010-08
|
||||
Sony Ericsson Xperia Arc,Android,2.3.4,320,569,2011-03
|
||||
Sony Ericsson Xperia Mini ST15i,Android,2.3.4,320,401,2011-08
|
||||
Sony Ericsson Xperia Neo,Android,4.0.4,480,854,2011-03
|
||||
Sony Ericcson Xperia Play,Android,2.3.4,425,974,2011-03
|
||||
Sony Ericsson Xperia X8,Android,2.1.1,320,480,2010-09
|
||||
Sony Ericsson Xperia X10,Android,2.3.3,320,569,2010-03
|
||||
Sony PlayStation 3,PlayStation 3,4.25,-,1824,2006-11
|
||||
Sony PlayStation Portable,PlayStation Portable,4.2,-,480,2005-03
|
||||
Sony PlayStation Vita,PlayStation Vita,1.00,-,896,2012-02
|
||||
Sony Tablet P,Android,4.0.3,-,1024,2012-09
|
||||
Sony Tablet S,Android,4.0.3,800,1280,2011-09
|
||||
Sony VAIO Tap 20,Windows 8,8.0,900,1600,2013-06
|
||||
Sony Xperia acro S,Android,4.0.4,360,640,2012-08
|
||||
Sony Xperia P,Android,2.3.7,360,640,2012-05
|
||||
Sony Xperia S,Android,2.3.7,360,640,2012-02
|
||||
Sony Xperia Sola,Android,2.3.7,320,569,2012-05
|
||||
Sony Xperia SP,Android,4.1.2,360,598,2013-04
|
||||
Sony Xperia Tablet Z,Android,4.1.2,800,1280,2013-05
|
||||
Sony Xperia Tipo,Android,4.0.4,320,480,2012-08
|
||||
Sony Xperia U,Android,2.3.7,320,569,2012-05
|
||||
Sony Xperia V,Android,4.1.2,360,598,2012-12
|
||||
Sony Xperia Z,Android,4.1.2,360,598,2013-02
|
||||
Sony Xperia Z1,Android,4.2.2,360,598,2013-09
|
||||
Telstra T-Hub 2,Android,2.3.7,400,683,2012-07
|
||||
Tesco Hudl,Android,4.2,600,799,2013-09
|
||||
Toshiba AT100,Android,4.0.4,800,1280,2011-07
|
||||
Toshiba AT1S0,Android,3.2,602,961,2012-02
|
||||
Toshiba AT200,Android,3.2.1,800,1280,2012-02
|
||||
Toshiba AT300,Android,4.0.3,800,1280,2012-06
|
||||
Toshiba AT330,Android,4.0.3,900,1600,2012-07
|
||||
Wiko Cink Slim,Android,4.1.1,320,533,2012-11
|
||||
Yarvik Xenta Tab 8c,Android,4.1.2,768,1024,2013-08
|
||||
XBOX 360,XBOX,2.0,-,1050,2005-11
|
||||
Xiaomi MI-3,Android,4.2.1,360,640,2013-09
|
||||
ZTE Open,FireFox OS,1.0.0B01,320,415,2013-07
|
||||
ZTE T22 (Telstra Urbane),Android,4.0.4,320,533,2012-08
|
||||
ZTE T28 (Telstra Active Touch),Android,2.3.5,320,533,2011-05
|
||||
ZTE T760 (Telstra Smart-Touch 2),Android,2.3.5,320,480,2012-02
|
||||
ZTE T790 (Telstra Pulse),Android,4.0.4,320,480,2013-05
|
||||
ZTE T81 (Telstra Frontier 4G),Android,4.0.4,320,533,2012-11
|
||||
ZTE T82 (Telstra Easy Touch 4G),Android,4.0.4,360,598,2012-11
|
||||
ZTE T83 (Telstra Dave 4G),Android,4.1.2,320,534,2013-10
|
||||
|
Generated
-13806
File diff suppressed because it is too large
Load Diff
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"name": "chapter11",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"eslint": "^5.5.0",
|
||||
"eslint-config-recommended": "^3.0.0",
|
||||
"eslint-plugin-babel": "^5.1.0",
|
||||
"eslint-plugin-flowtype": "^2.50.0",
|
||||
"eslint-plugin-react": "^7.11.1",
|
||||
"eslint-plugin-react-native": "^3.2.1",
|
||||
"flow": "^0.2.3",
|
||||
"flow-bin": "^0.79.1",
|
||||
"flow-coverage-report": "^0.5.0",
|
||||
"flow-typed": "^2.5.1",
|
||||
"jest-expo": "~27.0.0",
|
||||
"react-native-scripts": "1.14.0",
|
||||
"react-test-renderer": "16.3.1"
|
||||
},
|
||||
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
|
||||
"scripts": {
|
||||
"start": "react-native-scripts start",
|
||||
"eject": "react-native-scripts eject",
|
||||
"android": "react-native-scripts android",
|
||||
"ios": "react-native-scripts ios",
|
||||
"test": "jest",
|
||||
"flow": "flow",
|
||||
"addTypes": "flow-typed install"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "jest-expo"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0",
|
||||
"expo": "^27.0.1",
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "16.3.1",
|
||||
"react-native": "~0.55.2",
|
||||
"react-navigation": "^2.13.0",
|
||||
"redux-thunk": "^2.3.0"
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { getDeviceData } from "./device";
|
||||
|
||||
import type { deviceDataType } from "./device";
|
||||
|
||||
export const DEVICE_DATA = "device:data";
|
||||
|
||||
export type deviceDataAction = {
|
||||
type: string,
|
||||
deviceData: deviceDataType
|
||||
};
|
||||
|
||||
export const setDevice = (deviceData?: object) =>
|
||||
({
|
||||
type: DEVICE_DATA,
|
||||
deviceData: deviceData || getDeviceData()
|
||||
}: deviceDataAction);
|
||||
|
||||
/*
|
||||
A real app would have many more actions!
|
||||
*/
|
||||
@@ -1,56 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { View, Text, StyleSheet } from "react-native";
|
||||
|
||||
import type { deviceDataType } from "./device";
|
||||
|
||||
const textStyle = StyleSheet.create({
|
||||
bigText: {
|
||||
fontWeight: "bold",
|
||||
fontSize: 24
|
||||
}
|
||||
});
|
||||
|
||||
export class AdaptiveView extends React.PureComponent<{
|
||||
deviceData: deviceDataType
|
||||
}> {
|
||||
static propTypes = {
|
||||
deviceData: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
renderHandset() {
|
||||
return (
|
||||
<View>
|
||||
<Text style={textStyle.bigText}>
|
||||
I believe I am a HANDSET currently in
|
||||
{this.props.deviceData.isPortrait
|
||||
? " PORTRAIT "
|
||||
: " LANDSCAPE "}
|
||||
orientation
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
renderTablet() {
|
||||
return (
|
||||
<View>
|
||||
<Text style={textStyle.bigText}>
|
||||
I think I am a
|
||||
{this.props.deviceData.isPortrait
|
||||
? " PORTRAIT "
|
||||
: " LANDSCAPE "}
|
||||
TABLET
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
return this.props.deviceData.isTablet
|
||||
? this.renderTablet()
|
||||
: this.renderHandset();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { connect } from "react-redux";
|
||||
|
||||
import { AdaptiveView } from "./adaptiveView.component";
|
||||
|
||||
const getProps = state => ({
|
||||
deviceData: state.deviceData
|
||||
});
|
||||
|
||||
export const ConnectedAdaptiveView = connect(getProps)(AdaptiveView);
|
||||
@@ -1,25 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { Dimensions } from "react-native";
|
||||
|
||||
export type deviceDataType = {
|
||||
isTablet: boolean,
|
||||
isPortrait: boolean,
|
||||
height: number,
|
||||
width: number,
|
||||
scale: number,
|
||||
fontScale: number
|
||||
};
|
||||
|
||||
export const getDeviceData = (): deviceDataType => {
|
||||
const { height, width, scale, fontScale } = Dimensions.get("screen");
|
||||
|
||||
return {
|
||||
isTablet: Math.max(height, width) / Math.min(height, width) <= 1.6,
|
||||
isPortrait: height > width,
|
||||
height,
|
||||
width,
|
||||
scale,
|
||||
fontScale
|
||||
};
|
||||
};
|
||||
@@ -1,21 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { View } from "react-native";
|
||||
|
||||
class DeviceHandler extends React.PureComponent<{
|
||||
setDevice: () => any
|
||||
}> {
|
||||
static propTypes = {
|
||||
setDevice: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
onLayoutHandler = () => this.props.setDevice();
|
||||
|
||||
render() {
|
||||
return <View hidden onLayout={this.onLayoutHandler} />;
|
||||
}
|
||||
}
|
||||
|
||||
export { DeviceHandler };
|
||||
@@ -1,15 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { connect } from "react-redux";
|
||||
|
||||
import { DeviceHandler } from "./deviceHandler.component";
|
||||
import { setDevice } from "./actions";
|
||||
|
||||
const getDispatch = dispatch => ({
|
||||
setDevice: () => dispatch(setDevice())
|
||||
});
|
||||
|
||||
export const ConnectedDeviceHandler = connect(
|
||||
null,
|
||||
getDispatch
|
||||
)(DeviceHandler);
|
||||
@@ -1,19 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import React from "react";
|
||||
import { View, StatusBar } from "react-native";
|
||||
|
||||
import { ConnectedAdaptiveView } from "./adaptiveView.connected";
|
||||
import { ConnectedDeviceHandler } from "./deviceHandler.connected";
|
||||
|
||||
export class Main extends React.PureComponent<> {
|
||||
render() {
|
||||
return (
|
||||
<View>
|
||||
<StatusBar hidden />
|
||||
<ConnectedDeviceHandler />
|
||||
<ConnectedAdaptiveView />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { getDeviceData } from "./device";
|
||||
|
||||
import { DEVICE_DATA } from "./actions";
|
||||
|
||||
import type { deviceAction } from "./actions";
|
||||
|
||||
export const reducer = (
|
||||
state: object = {
|
||||
// initial state: more app data, plus
|
||||
deviceData: getDeviceData()
|
||||
},
|
||||
action: deviceAction
|
||||
) => {
|
||||
switch (action.type) {
|
||||
case DEVICE_DATA:
|
||||
return {
|
||||
...state,
|
||||
deviceData: action.deviceData
|
||||
};
|
||||
|
||||
/*
|
||||
In a real app, here there would
|
||||
be plenty more "case"s
|
||||
*/
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
@@ -1,8 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { createStore, applyMiddleware } from "redux";
|
||||
import thunk from "redux-thunk";
|
||||
|
||||
import { reducer } from "./reducer";
|
||||
|
||||
export const store = createStore(reducer, applyMiddleware(thunk));
|
||||
@@ -1,63 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { View, Text, Picker } from "react-native";
|
||||
|
||||
export class CountrySelect extends React.PureComponent<{
|
||||
dispatch: ({}) => any
|
||||
}> {
|
||||
static propTypes = {
|
||||
loading: PropTypes.bool.isRequired,
|
||||
currentCountry: PropTypes.string.isRequired,
|
||||
list: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
onSelect: PropTypes.func.isRequired,
|
||||
getCountries: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
if (this.props.list.length === 0) {
|
||||
this.props.getCountries();
|
||||
}
|
||||
}
|
||||
|
||||
onSelect = value => this.props.onSelect(value);
|
||||
|
||||
render() {
|
||||
if (this.props.loading) {
|
||||
return (
|
||||
<View>
|
||||
<Text>Loading countries...</Text>
|
||||
</View>
|
||||
);
|
||||
} else {
|
||||
const sortedCountries = [...this.props.list].sort(
|
||||
(a, b) => (a.countryName < b.countryName ? -1 : 1)
|
||||
);
|
||||
|
||||
return (
|
||||
<View>
|
||||
<Text>Country:</Text>
|
||||
<Picker
|
||||
onValueChange={this.onSelect}
|
||||
prompt="Country"
|
||||
selectedValue={this.props.currentCountry}
|
||||
>
|
||||
<Picker.Item
|
||||
key={"00"}
|
||||
label={"Select a country:"}
|
||||
value={""}
|
||||
/>
|
||||
{sortedCountries.map(x => (
|
||||
<Picker.Item
|
||||
key={x.countryCode}
|
||||
label={x.countryName}
|
||||
value={x.countryCode}
|
||||
/>
|
||||
))}
|
||||
</Picker>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { connect } from "react-redux";
|
||||
|
||||
import { CountrySelect } from "./countrySelect.component";
|
||||
import { getCountries, getRegions } from "./world.actions";
|
||||
|
||||
const getProps = state => ({
|
||||
list: state.countries,
|
||||
currentCountry: state.currentCountry,
|
||||
loading: state.loadingCountries
|
||||
});
|
||||
|
||||
const getDispatch = dispatch => ({
|
||||
getCountries: () => dispatch(getCountries()),
|
||||
onSelect: c => dispatch(getRegions(c))
|
||||
});
|
||||
|
||||
export const ConnectedCountrySelect = connect(
|
||||
getProps,
|
||||
getDispatch
|
||||
)(CountrySelect);
|
||||
@@ -1,6 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { ConnectedCountrySelect } from "./countrySelect.connected.js";
|
||||
import { ConnectedRegionsTable } from "./regionsTable.connected.js";
|
||||
|
||||
export { ConnectedCountrySelect, ConnectedRegionsTable };
|
||||
@@ -1,18 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import React from "react";
|
||||
import { View, StatusBar } from "react-native";
|
||||
|
||||
import { ConnectedCountrySelect, ConnectedRegionsTable } from ".";
|
||||
|
||||
export class Main extends React.PureComponent<> {
|
||||
render() {
|
||||
return (
|
||||
<View>
|
||||
<StatusBar hidden />
|
||||
<ConnectedCountrySelect />
|
||||
<ConnectedRegionsTable />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { View, Text } from "react-native";
|
||||
|
||||
export class RegionsTable extends React.PureComponent<{
|
||||
list: Array<{
|
||||
regionCode: string,
|
||||
regionName: string
|
||||
}>
|
||||
}> {
|
||||
static propTypes = {
|
||||
list: PropTypes.arrayOf(PropTypes.object).isRequired
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
list: []
|
||||
};
|
||||
|
||||
render() {
|
||||
if (this.props.list.length === 0) {
|
||||
return (
|
||||
<View>
|
||||
<Text>No regions.</Text>
|
||||
</View>
|
||||
);
|
||||
} else {
|
||||
const ordered = [...this.props.list].sort(
|
||||
(a, b) => (a.regionName < b.regionName ? -1 : 1)
|
||||
);
|
||||
|
||||
return (
|
||||
<View>
|
||||
{ordered.map(x => (
|
||||
<View key={`${x.countryCode}-${x.regionCode}`}>
|
||||
<Text>{x.regionName}</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { connect } from "react-redux";
|
||||
|
||||
import { RegionsTable } from "./regionsTable.component";
|
||||
|
||||
const getProps = state => ({
|
||||
list: state.regions,
|
||||
loading: state.loadingRegions
|
||||
});
|
||||
|
||||
export const ConnectedRegionsTable = connect(getProps)(RegionsTable);
|
||||
@@ -1,9 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import axios from "axios";
|
||||
|
||||
export const getCountriesAPI = () =>
|
||||
axios.get(`http://192.168.1.200:8080/countries`);
|
||||
|
||||
export const getRegionsAPI = country =>
|
||||
axios.get(`http://192.168.1.200:8080/regions/${country}`);
|
||||
@@ -1,8 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { createStore, applyMiddleware } from "redux";
|
||||
import thunk from "redux-thunk";
|
||||
|
||||
import { reducer } from "./world.reducer";
|
||||
|
||||
export const store = createStore(reducer, applyMiddleware(thunk));
|
||||
@@ -1,106 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { getCountriesAPI, getRegionsAPI } from "./serviceApi";
|
||||
|
||||
// Countries actions
|
||||
|
||||
export const COUNTRIES_REQUEST = "countries:request";
|
||||
export const COUNTRIES_SUCCESS = "countries:success";
|
||||
export const COUNTRIES_FAILURE = "countries:failure";
|
||||
|
||||
export type CountriesAction = {
|
||||
type: string,
|
||||
country?: string,
|
||||
listOfCountries?: [object]
|
||||
};
|
||||
|
||||
export const countriesRequest = () =>
|
||||
({
|
||||
type: COUNTRIES_REQUEST
|
||||
}: CountriesActions);
|
||||
|
||||
export const countriesSuccess = (listOfCountries: []) =>
|
||||
({
|
||||
type: COUNTRIES_SUCCESS,
|
||||
listOfCountries
|
||||
}: CountriesActions);
|
||||
|
||||
export const countriesFailure = () =>
|
||||
({
|
||||
type: COUNTRIES_FAILURE
|
||||
}: CountriesActions);
|
||||
|
||||
// Regions actions
|
||||
|
||||
export const REGIONS_REQUEST = "regions:request";
|
||||
export const REGIONS_SUCCESS = "regions:success";
|
||||
export const REGIONS_FAILURE = "regions:failure";
|
||||
|
||||
export type RegionsAction = {
|
||||
type: string,
|
||||
listOfRegions?: [object]
|
||||
};
|
||||
|
||||
export const regionsRequest = (country: string) =>
|
||||
({
|
||||
type: REGIONS_REQUEST,
|
||||
country
|
||||
}: RegionsActions);
|
||||
|
||||
export const regionsSuccess = (listOfRegions: [{}]) =>
|
||||
({
|
||||
type: REGIONS_SUCCESS,
|
||||
listOfRegions
|
||||
}: RegionsActions);
|
||||
|
||||
export const regionsFailure = () =>
|
||||
({
|
||||
type: REGIONS_FAILURE
|
||||
}: RegionsActions);
|
||||
|
||||
// Complex Actions:
|
||||
|
||||
export const getCountries = () => async dispatch => {
|
||||
try {
|
||||
dispatch(countriesRequest());
|
||||
const result = await getCountriesAPI();
|
||||
dispatch(countriesSuccess(result.data));
|
||||
} catch (e) {
|
||||
dispatch(countriesFailure());
|
||||
}
|
||||
};
|
||||
|
||||
export const getRegions = (country: string) => async dispatch => {
|
||||
if (country) {
|
||||
try {
|
||||
dispatch(regionsRequest(country));
|
||||
const result = await getRegionsAPI(country);
|
||||
dispatch(regionsSuccess(result.data));
|
||||
} catch (e) {
|
||||
dispatch(regionsFailure());
|
||||
}
|
||||
} else {
|
||||
dispatch(regionsFailure());
|
||||
}
|
||||
};
|
||||
|
||||
export const getRegions2 = (country: string) => async (
|
||||
dispatch,
|
||||
getState
|
||||
) => {
|
||||
if (country === getState().currentCountry) {
|
||||
console.log("Hey! You are getting the same country as before!");
|
||||
}
|
||||
|
||||
if (country) {
|
||||
try {
|
||||
dispatch(regionsRequest(country));
|
||||
const result = await getRegionsAPI(country);
|
||||
dispatch(regionsSuccess(result.data));
|
||||
} catch (e) {
|
||||
dispatch(regionsFailure());
|
||||
}
|
||||
} else {
|
||||
dispatch(regionsFailure());
|
||||
}
|
||||
};
|
||||
@@ -1,74 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import {
|
||||
COUNTRIES_REQUEST,
|
||||
COUNTRIES_SUCCESS,
|
||||
COUNTRIES_FAILURE,
|
||||
REGIONS_REQUEST,
|
||||
REGIONS_SUCCESS,
|
||||
REGIONS_FAILURE
|
||||
} from "./world.actions";
|
||||
|
||||
import type { CountriesAction, RegionsAction } from "./world.actions";
|
||||
|
||||
// import type { CounterAction } from "./world.actions.js";
|
||||
|
||||
export const reducer = (
|
||||
state: object = {
|
||||
// initial state
|
||||
loadingCountries: false,
|
||||
currentCountry: "",
|
||||
countries: [],
|
||||
loadingRegions: false,
|
||||
regions: []
|
||||
},
|
||||
action: CountriesAction | RegionsAction
|
||||
) => {
|
||||
switch (action.type) {
|
||||
case COUNTRIES_REQUEST:
|
||||
return {
|
||||
...state,
|
||||
loadingCountries: true,
|
||||
countries: []
|
||||
};
|
||||
|
||||
case COUNTRIES_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
loadingCountries: false,
|
||||
countries: action.listOfCountries
|
||||
};
|
||||
|
||||
case COUNTRIES_FAILURE:
|
||||
return {
|
||||
...state,
|
||||
loadingCountries: false,
|
||||
countries: []
|
||||
};
|
||||
|
||||
case REGIONS_REQUEST:
|
||||
return {
|
||||
...state,
|
||||
loadingRegions: true,
|
||||
currentCountry: action.country,
|
||||
regions: []
|
||||
};
|
||||
|
||||
case REGIONS_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
loadingRegions: false,
|
||||
regions: action.listOfRegions
|
||||
};
|
||||
|
||||
case REGIONS_FAILURE:
|
||||
return {
|
||||
...state,
|
||||
loadingRegions: false,
|
||||
regions: []
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
@@ -1,71 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { View, Text, Picker } from "react-native";
|
||||
|
||||
import type { deviceDataType } from "./device";
|
||||
|
||||
export class CountrySelect extends React.PureComponent<{
|
||||
deviceData: deviceDataType,
|
||||
loading: boolean,
|
||||
currentCountry: string,
|
||||
list: Array<object>,
|
||||
onSelect: string => void,
|
||||
getCountries: () => void
|
||||
}> {
|
||||
static propTypes = {
|
||||
deviceData: PropTypes.object.isRequired, // deviceDataType,
|
||||
loading: PropTypes.bool.isRequired,
|
||||
currentCountry: PropTypes.string.isRequired,
|
||||
list: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
onSelect: PropTypes.func.isRequired,
|
||||
getCountries: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
if (this.props.list.length === 0) {
|
||||
this.props.getCountries();
|
||||
}
|
||||
}
|
||||
|
||||
onSelect = value => this.props.onSelect(value);
|
||||
|
||||
render() {
|
||||
if (this.props.loading) {
|
||||
return (
|
||||
<View>
|
||||
<Text>Loading countries...</Text>
|
||||
</View>
|
||||
);
|
||||
} else {
|
||||
const sortedCountries = [...this.props.list].sort(
|
||||
(a, b) => (a.countryName < b.countryName ? -1 : 1)
|
||||
);
|
||||
|
||||
return (
|
||||
<View>
|
||||
<Text>Country:</Text>
|
||||
<Picker
|
||||
onValueChange={this.onSelect}
|
||||
prompt="Country"
|
||||
selectedValue={this.props.currentCountry || "TV"}
|
||||
>
|
||||
<Picker.Item
|
||||
key={"00"}
|
||||
label={"Select a country:"}
|
||||
value={""}
|
||||
/>
|
||||
{sortedCountries.map(x => (
|
||||
<Picker.Item
|
||||
key={x.countryCode}
|
||||
label={x.countryName}
|
||||
value={x.countryCode}
|
||||
/>
|
||||
))}
|
||||
</Picker>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { connect } from "react-redux";
|
||||
|
||||
import { CountrySelect } from "./countrySelect.component";
|
||||
import { getCountries, getRegions } from "./world.actions";
|
||||
|
||||
const getProps = state => ({
|
||||
deviceData: state.deviceData,
|
||||
list: state.countries,
|
||||
currentCountry: state.currentCountry,
|
||||
loading: state.loadingCountries
|
||||
});
|
||||
|
||||
const getDispatch = dispatch => ({
|
||||
getCountries: () => dispatch(getCountries()),
|
||||
onSelect: c => dispatch(getRegions(c))
|
||||
});
|
||||
|
||||
export const ConnectedCountrySelect = connect(
|
||||
getProps,
|
||||
getDispatch
|
||||
)(CountrySelect);
|
||||
@@ -1,25 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { Dimensions } from "react-native";
|
||||
|
||||
export type deviceDataType = {
|
||||
isTablet: boolean,
|
||||
isPortrait: boolean,
|
||||
height: number,
|
||||
width: number,
|
||||
scale: number,
|
||||
fontScale: number
|
||||
};
|
||||
|
||||
export const getDeviceData = (): deviceDataType => {
|
||||
const { height, width, scale, fontScale } = Dimensions.get("screen");
|
||||
|
||||
return {
|
||||
isTablet: Math.max(height, width) / Math.min(height, width) <= 1.6,
|
||||
isPortrait: height > width,
|
||||
height,
|
||||
width,
|
||||
scale,
|
||||
fontScale
|
||||
};
|
||||
};
|
||||
@@ -1,21 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { View } from "react-native";
|
||||
|
||||
class DeviceHandler extends React.PureComponent<{
|
||||
setDevice: () => any
|
||||
}> {
|
||||
static propTypes = {
|
||||
setDevice: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
onLayoutHandler = () => this.props.setDevice();
|
||||
|
||||
render() {
|
||||
return <View hidden onLayout={this.onLayoutHandler} />;
|
||||
}
|
||||
}
|
||||
|
||||
export { DeviceHandler };
|
||||
@@ -1,15 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { connect } from "react-redux";
|
||||
|
||||
import { DeviceHandler } from "./deviceHandler.component";
|
||||
import { setDevice } from "./world.actions";
|
||||
|
||||
const getDispatch = dispatch => ({
|
||||
setDevice: () => dispatch(setDevice())
|
||||
});
|
||||
|
||||
export const ConnectedDeviceHandler = connect(
|
||||
null,
|
||||
getDispatch
|
||||
)(DeviceHandler);
|
||||
@@ -1,11 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { ConnectedCountrySelect } from "./countrySelect.connected.js";
|
||||
import { ConnectedRegionsTable } from "./regionsTable.connected.js";
|
||||
import { ConnectedDeviceHandler } from "./deviceHandler.connected";
|
||||
|
||||
export {
|
||||
ConnectedCountrySelect,
|
||||
ConnectedRegionsTable,
|
||||
ConnectedDeviceHandler
|
||||
};
|
||||
@@ -1,57 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import React from "react";
|
||||
import { View, StatusBar } from "react-native";
|
||||
|
||||
import {
|
||||
ConnectedCountrySelect,
|
||||
ConnectedRegionsTable,
|
||||
ConnectedDeviceHandler
|
||||
} from ".";
|
||||
import type { deviceDataType } from "./device";
|
||||
|
||||
/* eslint-disable react-native/no-inline-styles */
|
||||
|
||||
export class Main extends React.PureComponent<{
|
||||
deviceData: deviceDataType
|
||||
}> {
|
||||
render() {
|
||||
if (this.props.deviceData.isPortrait) {
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
<StatusBar hidden />
|
||||
<ConnectedDeviceHandler />
|
||||
<View style={{ flex: 1, flexDirection: "column" }}>
|
||||
<View>
|
||||
<ConnectedCountrySelect />
|
||||
</View>
|
||||
<View style={{ flex: 1 }}>
|
||||
<ConnectedRegionsTable />
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
<StatusBar hidden />
|
||||
<ConnectedDeviceHandler />
|
||||
<View style={{ flex: 1, flexDirection: "row" }}>
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
flexDirection: "column",
|
||||
justifyContent: "center"
|
||||
}}
|
||||
>
|
||||
<ConnectedCountrySelect />
|
||||
</View>
|
||||
<View style={{ flex: 1 }}>
|
||||
<ConnectedRegionsTable />
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { connect } from "react-redux";
|
||||
|
||||
import { Main } from "./main.component";
|
||||
|
||||
const getProps = state => ({
|
||||
deviceData: state.deviceData
|
||||
});
|
||||
|
||||
export const ConnectedMain = connect(getProps)(Main);
|
||||
@@ -1,88 +0,0 @@
|
||||
/* sssssflow */
|
||||
/* eslint-disable */
|
||||
|
||||
import React, { Component } from "react";
|
||||
import { Text, View, StatusBar, Button, StyleSheet } from "react-native";
|
||||
import { createDrawerNavigator } from "react-navigation";
|
||||
|
||||
// import { store } from "./src/routingApp/store";
|
||||
|
||||
const myStyles = StyleSheet.create({
|
||||
fullView: {
|
||||
flex: 1,
|
||||
flexDirection: "column",
|
||||
justifyContent: "center",
|
||||
alignItems: "center"
|
||||
},
|
||||
bigText: {
|
||||
fontSize: 24,
|
||||
fontWeight: "bold"
|
||||
}
|
||||
});
|
||||
|
||||
const makeSimpleView = text =>
|
||||
class extends Component<{}> {
|
||||
displayName = `View:${text}`;
|
||||
render() {
|
||||
return (
|
||||
<View style={myStyles.fullView}>
|
||||
<Text style={myStyles.bigText}>{text}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const JumpButton = props => (
|
||||
<Button
|
||||
onPress={() => this.props.navigation.navigate("Charlie")}
|
||||
title="Gotocharlie"
|
||||
/>
|
||||
);
|
||||
|
||||
const Home = makeSimpleView("Home!");
|
||||
const Alpha = makeSimpleView("Alpha");
|
||||
const Bravo = makeSimpleView("Bravo");
|
||||
const Charlie = makeSimpleView("Charlie");
|
||||
const Zulu = makeSimpleView("Zulu");
|
||||
const Help = makeSimpleView("Help");
|
||||
|
||||
const LinkJump = props => (
|
||||
<View style={{ flex: 1 }}>
|
||||
<Button
|
||||
onPress={() => props.navigation.navigate("Alpha")}
|
||||
title="Go to Alpha"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => props.navigation.navigate("Bravo")}
|
||||
title="Go to Bravo"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => props.navigation.navigate("Charlie")}
|
||||
title="Go to Charlie"
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
|
||||
const MyDrawer = createDrawerNavigator({
|
||||
Home: { screen: Home },
|
||||
Alpha: { screen: Alpha },
|
||||
Bravo: { screen: Bravo },
|
||||
Charlie: { screen: Charlie },
|
||||
Zulu: { screen: Zulu },
|
||||
Help: { screen: Help },
|
||||
LinkJump: { screen: LinkJump }
|
||||
});
|
||||
|
||||
class App extends Component {
|
||||
render() {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<StatusBar hidden />
|
||||
<Text>Something in the top bar...!</Text>
|
||||
<MyDrawer />
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default App;
|
||||
@@ -1,13 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { connect } from "react-redux";
|
||||
|
||||
import { RegionsTable } from "./regionsTable.component";
|
||||
|
||||
const getProps = state => ({
|
||||
deviceData: state.deviceData,
|
||||
list: state.regions,
|
||||
loading: state.loadingRegions
|
||||
});
|
||||
|
||||
export const ConnectedRegionsTable = connect(getProps)(RegionsTable);
|
||||
@@ -1,9 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import axios from "axios";
|
||||
|
||||
export const getCountriesAPI = () =>
|
||||
axios.get(`http://192.168.1.200:8080/countries`);
|
||||
|
||||
export const getRegionsAPI = country =>
|
||||
axios.get(`http://192.168.1.200:8080/regions/${country}`);
|
||||
@@ -1,8 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { createStore, applyMiddleware } from "redux";
|
||||
import thunk from "redux-thunk";
|
||||
|
||||
import { reducer } from "./world.reducer";
|
||||
|
||||
export const store = createStore(reducer, applyMiddleware(thunk));
|
||||
@@ -1,11 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { StyleSheet } from "react-native";
|
||||
|
||||
export const styles = StyleSheet.create({
|
||||
fullSize: {
|
||||
flex: 1
|
||||
}
|
||||
});
|
||||
|
||||
export const lowColor = "lightgray";
|
||||
@@ -1,122 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { getCountriesAPI, getRegionsAPI } from "./serviceApi";
|
||||
import { getDeviceData } from "./device";
|
||||
|
||||
// Device layout action
|
||||
|
||||
export const DEVICE_DATA = "device:data";
|
||||
|
||||
export type deviceDataAction = {
|
||||
type: string,
|
||||
deviceData: any // deviceDataType
|
||||
};
|
||||
|
||||
export const setDevice = (deviceData?: object) =>
|
||||
({
|
||||
type: DEVICE_DATA,
|
||||
deviceData: deviceData || getDeviceData()
|
||||
}: deviceDataAction);
|
||||
|
||||
// Countries actions
|
||||
|
||||
export const COUNTRIES_REQUEST = "countries:request";
|
||||
export const COUNTRIES_SUCCESS = "countries:success";
|
||||
export const COUNTRIES_FAILURE = "countries:failure";
|
||||
|
||||
export type CountriesAction = {
|
||||
type: string,
|
||||
country?: string,
|
||||
listOfCountries?: [object]
|
||||
};
|
||||
|
||||
export const countriesRequest = () =>
|
||||
({
|
||||
type: COUNTRIES_REQUEST
|
||||
}: CountriesActions);
|
||||
|
||||
export const countriesSuccess = (listOfCountries: []) =>
|
||||
({
|
||||
type: COUNTRIES_SUCCESS,
|
||||
listOfCountries
|
||||
}: CountriesActions);
|
||||
|
||||
export const countriesFailure = () =>
|
||||
({
|
||||
type: COUNTRIES_FAILURE
|
||||
}: CountriesActions);
|
||||
|
||||
// Regions actions
|
||||
|
||||
export const REGIONS_REQUEST = "regions:request";
|
||||
export const REGIONS_SUCCESS = "regions:success";
|
||||
export const REGIONS_FAILURE = "regions:failure";
|
||||
|
||||
export type RegionsAction = {
|
||||
type: string,
|
||||
listOfRegions?: [object]
|
||||
};
|
||||
|
||||
export const regionsRequest = (country: string) =>
|
||||
({
|
||||
type: REGIONS_REQUEST,
|
||||
country
|
||||
}: RegionsActions);
|
||||
|
||||
export const regionsSuccess = (listOfRegions: [{}]) =>
|
||||
({
|
||||
type: REGIONS_SUCCESS,
|
||||
listOfRegions
|
||||
}: RegionsActions);
|
||||
|
||||
export const regionsFailure = () =>
|
||||
({
|
||||
type: REGIONS_FAILURE
|
||||
}: RegionsActions);
|
||||
|
||||
// Complex Actions:
|
||||
|
||||
export const getCountries = () => async dispatch => {
|
||||
try {
|
||||
dispatch(countriesRequest());
|
||||
const result = await getCountriesAPI();
|
||||
dispatch(countriesSuccess(result.data));
|
||||
} catch (e) {
|
||||
dispatch(countriesFailure());
|
||||
}
|
||||
};
|
||||
|
||||
export const getRegions = (country: string) => async dispatch => {
|
||||
if (country) {
|
||||
try {
|
||||
dispatch(regionsRequest(country));
|
||||
const result = await getRegionsAPI(country);
|
||||
dispatch(regionsSuccess(result.data));
|
||||
} catch (e) {
|
||||
dispatch(regionsFailure());
|
||||
}
|
||||
} else {
|
||||
dispatch(regionsFailure());
|
||||
}
|
||||
};
|
||||
|
||||
export const getRegions2 = (country: string) => async (
|
||||
dispatch,
|
||||
getState
|
||||
) => {
|
||||
if (country === getState().currentCountry) {
|
||||
console.log("Hey! You are getting the same country as before!");
|
||||
}
|
||||
|
||||
if (country) {
|
||||
try {
|
||||
dispatch(regionsRequest(country));
|
||||
const result = await getRegionsAPI(country);
|
||||
dispatch(regionsSuccess(result.data));
|
||||
} catch (e) {
|
||||
dispatch(regionsFailure());
|
||||
}
|
||||
} else {
|
||||
dispatch(regionsFailure());
|
||||
}
|
||||
};
|
||||
@@ -1,81 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import {
|
||||
DEVICE_DATA,
|
||||
COUNTRIES_REQUEST,
|
||||
COUNTRIES_SUCCESS,
|
||||
COUNTRIES_FAILURE,
|
||||
REGIONS_REQUEST,
|
||||
REGIONS_SUCCESS,
|
||||
REGIONS_FAILURE
|
||||
} from "./world.actions";
|
||||
|
||||
import { getDeviceData } from "./device";
|
||||
import type { CountriesAction, RegionsAction } from "./world.actions";
|
||||
|
||||
export const reducer = (
|
||||
state: object = {
|
||||
// initial state
|
||||
deviceData: getDeviceData(),
|
||||
loadingCountries: false,
|
||||
currentCountry: "",
|
||||
countries: [],
|
||||
loadingRegions: false,
|
||||
regions: []
|
||||
},
|
||||
action: CountriesAction | RegionsAction
|
||||
) => {
|
||||
switch (action.type) {
|
||||
case DEVICE_DATA:
|
||||
return {
|
||||
...state,
|
||||
deviceData: action.deviceData
|
||||
};
|
||||
|
||||
case COUNTRIES_REQUEST:
|
||||
return {
|
||||
...state,
|
||||
loadingCountries: true,
|
||||
countries: []
|
||||
};
|
||||
|
||||
case COUNTRIES_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
loadingCountries: false,
|
||||
countries: action.listOfCountries
|
||||
};
|
||||
|
||||
case COUNTRIES_FAILURE:
|
||||
return {
|
||||
...state,
|
||||
loadingCountries: false,
|
||||
countries: []
|
||||
};
|
||||
|
||||
case REGIONS_REQUEST:
|
||||
return {
|
||||
...state,
|
||||
loadingRegions: true,
|
||||
currentCountry: action.country,
|
||||
regions: []
|
||||
};
|
||||
|
||||
case REGIONS_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
loadingRegions: false,
|
||||
regions: action.listOfRegions
|
||||
};
|
||||
|
||||
case REGIONS_FAILURE:
|
||||
return {
|
||||
...state,
|
||||
loadingRegions: false,
|
||||
regions: []
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
@@ -1,29 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import { createDrawerNavigator } from "react-navigation";
|
||||
|
||||
import {
|
||||
Home,
|
||||
Alpha,
|
||||
Bravo,
|
||||
Charlie,
|
||||
Zulu,
|
||||
Help,
|
||||
SomeJumps
|
||||
} from "./screens";
|
||||
|
||||
export const MyDrawer = createDrawerNavigator(
|
||||
{
|
||||
Home: { screen: Home },
|
||||
Alpha: { screen: Alpha },
|
||||
Bravo: { screen: Bravo },
|
||||
Charlie: { screen: Charlie },
|
||||
Zulu: { screen: Zulu },
|
||||
["Get Help"]: { screen: Help },
|
||||
["Some jumps"]: { screen: SomeJumps }
|
||||
},
|
||||
{
|
||||
drawerBackgroundColor: "lightcyan",
|
||||
drawerWidth: 140
|
||||
}
|
||||
);
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB |
@@ -1,84 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
import React, { Component } from "react";
|
||||
import {
|
||||
Button,
|
||||
Image,
|
||||
StyleSheet,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View
|
||||
} from "react-native";
|
||||
|
||||
const myStyles = StyleSheet.create({
|
||||
fullSize: {
|
||||
flex: 1
|
||||
},
|
||||
fullCenteredView: {
|
||||
flex: 1,
|
||||
flexDirection: "column",
|
||||
justifyContent: "center",
|
||||
alignItems: "center"
|
||||
},
|
||||
bigText: {
|
||||
fontSize: 24,
|
||||
fontWeight: "bold"
|
||||
},
|
||||
hamburger: {
|
||||
width: 22,
|
||||
height: 22,
|
||||
alignSelf: "flex-end"
|
||||
}
|
||||
});
|
||||
|
||||
const makeSimpleView = text =>
|
||||
class extends Component<{ navigation: object }> {
|
||||
displayName = `View:${text}`;
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={myStyles.fullSize}>
|
||||
<TouchableOpacity
|
||||
onPress={this.props.navigation.toggleDrawer}
|
||||
>
|
||||
<Image
|
||||
source={require("./hamburger.png")}
|
||||
style={myStyles.hamburger}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
<View style={myStyles.fullCenteredView}>
|
||||
<Text style={myStyles.bigText}>{text}</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const Home = makeSimpleView("Home");
|
||||
|
||||
export const Alpha = makeSimpleView("Alpha");
|
||||
|
||||
export const Bravo = makeSimpleView("Bravo");
|
||||
|
||||
export const Charlie = makeSimpleView("Charlie");
|
||||
|
||||
export const Zulu = makeSimpleView("Zulu");
|
||||
|
||||
export const Help = makeSimpleView("Help!");
|
||||
|
||||
export const SomeJumps = (props: object) => (
|
||||
<View style={myStyles.fullSize}>
|
||||
<Button
|
||||
onPress={() => props.navigation.navigate("Alpha")}
|
||||
title="Go to Alpha"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => props.navigation.navigate("Bravo")}
|
||||
title="Leap to Bravo"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => props.navigation.navigate("Charlie")}
|
||||
title="Jump to Charlie"
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
Reference in New Issue
Block a user