Skip to content

Commit cdc435a

Browse files
committed
first commit
0 parents  commit cdc435a

File tree

126 files changed

+40594
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+40594
-0
lines changed

.babelrc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": ["babel-preset-expo"],
3+
"env": {
4+
"development": {
5+
"plugins": ["transform-react-jsx-source"]
6+
}
7+
}
8+
}

.expo/packager-info.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"expoServerPort": null,
3+
"packagerPort": null,
4+
"packagerPid": null
5+
}

.expo/settings.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"hostType": "tunnel",
3+
"lanType": "ip",
4+
"dev": true,
5+
"minify": false,
6+
"urlRandomness": null
7+
}

.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# See https://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
6+
# testing
7+
/coverage
8+
9+
# production
10+
/build
11+
12+
# Jest
13+
.jest/
14+
15+
# misc
16+
.DS_Store
17+
.env.local
18+
.env.development.local
19+
.env.test.local
20+
.env.production.local
21+
22+
npm-debug.log*
23+
yarn-debug.log*
24+
yarn-error.log*

.watchmanconfig

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

App.tsx

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import * as Expo from 'expo';
2+
import * as React from 'react';
3+
import { StyleProvider } from 'native-base';
4+
import { Provider } from 'react-redux';
5+
6+
import App from './src/App/index.native';
7+
import getTheme from './src/App/theme/components';
8+
import variables from './src/App/theme/variables/platform';
9+
import configureStore from './src/App/store';
10+
11+
export interface IProps {}
12+
export interface IState {
13+
store: {};
14+
isLoading: boolean;
15+
isReady: boolean;
16+
}
17+
18+
export default class Setup extends React.Component<IProps, IState> {
19+
constructor(props) {
20+
super(props);
21+
this.state = {
22+
isLoading: false,
23+
store: configureStore(() => this.setState({ isLoading: false })),
24+
isReady: false
25+
};
26+
}
27+
28+
componentWillMount() {
29+
this.loadFonts();
30+
}
31+
32+
async loadFonts() {
33+
await Expo.Font.loadAsync({
34+
Roboto: require('native-base/Fonts/Roboto.ttf'),
35+
Roboto_medium: require('native-base/Fonts/Roboto_medium.ttf'),
36+
Ionicons: require('@expo/vector-icons/fonts/Ionicons.ttf')
37+
});
38+
39+
this.setState({ isReady: true });
40+
}
41+
42+
render() {
43+
if (!this.state.isReady || this.state.isLoading) {
44+
return <Expo.AppLoading />;
45+
}
46+
return (
47+
<StyleProvider style={getTheme(variables)}>
48+
<Provider store={this.state.store}>
49+
<App />
50+
</Provider>
51+
</StyleProvider>
52+
);
53+
}
54+
}

README.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
## React and React Native app + Typescript
2+
3+
React and React Native app provide magic platform-splitting functionality based on special file extensions. Just the component for the target platform is compiled at build time.
4+
5+
Follow these practice:
6+
7+
* Put the component in a folder
8+
* Break out the shared interface into a separate `.d.ts` file.
9+
* Name the web/default file `index.tsx` (not `index.web.tsx`)
10+
* Name the native file `index.native.tsx` (both `ios` and `android`)
11+
* For android splitting, add `index.android.tsx` which will override `.native`
12+
13+
The `.d.ts` file enables VS Code code hinting for JSX props, and helps manage the project cross-platform by ensuring the consumers of the component have a unified interface.
14+
15+
---
16+
17+
### Install
18+
19+
```
20+
npm install
21+
```
22+
23+
### Run Web
24+
25+
```
26+
npm start
27+
```
28+
29+
### Run iOS
30+
31+
```
32+
npm run ios
33+
```
34+
35+
### Run Android
36+
37+
```
38+
npm run android
39+
```
40+
41+
---
42+
43+
### Caution:
44+
45+
Beware auto-imports! It's easy to accidentally import a file like this:
46+
47+
```js
48+
import Header from './Header/index.android';
49+
```
50+
51+
instead of the correct generic way:
52+
53+
```js
54+
import Header from './Header';
55+
```
56+
57+
Also, when working on the native app, be mindful that VS Code's `Go To Definition` will always jump to the `index.tsx` (web) file.

app.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"expo": {
3+
"sdkVersion": "27.0.0",
4+
"packagerOpts": {
5+
"sourceExts": ["ts", "tsx"],
6+
"transformer": "node_modules/react-native-typescript-transformer/index.js"
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)