Skip to content

Commit 421b65b

Browse files
committed
Add Expo example app
1 parent 490238b commit 421b65b

29 files changed

+13841
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"extends": [
3+
"eslint:recommended",
4+
"@react-native",
5+
"plugin:@typescript-eslint/eslint-recommended",
6+
"plugin:@typescript-eslint/strict-type-checked",
7+
"plugin:@typescript-eslint/stylistic-type-checked",
8+
"plugin:react/jsx-runtime"
9+
],
10+
"ignorePatterns": [
11+
"node_modules",
12+
".vscode",
13+
"dist",
14+
"metro.config.js",
15+
"assets",
16+
".expo",
17+
".expo-shared",
18+
"webpack.config.ts"
19+
],
20+
"parser": "@typescript-eslint/parser",
21+
"parserOptions": {
22+
"project": true,
23+
"tsconfigRootDir": "./"
24+
},
25+
"plugins": ["@typescript-eslint"],
26+
"root": true,
27+
"rules": {
28+
"@typescript-eslint/consistent-type-imports": [
29+
2,
30+
{
31+
"fixStyle": "separate-type-imports"
32+
}
33+
]
34+
},
35+
"overrides": [
36+
{
37+
"files": ["./__tests__/**/*.ts", "./__tests__/**/*.tsx"],
38+
"env": { "jest": true }
39+
}
40+
]
41+
}

examples/publish-ci/expo/.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
2+
3+
# dependencies
4+
node_modules/
5+
.yarn/
6+
7+
# Expo
8+
.expo/
9+
dist/
10+
web-build/
11+
12+
# Native
13+
*.orig.*
14+
*.jks
15+
*.p8
16+
*.p12
17+
*.key
18+
*.mobileprovision
19+
20+
# Metro
21+
.metro-health-check*
22+
23+
# debug
24+
npm-debug.*
25+
yarn-debug.*
26+
yarn-error.*
27+
28+
# macOS
29+
.DS_Store
30+
*.pem
31+
32+
# local env files
33+
.env*.local
34+
35+
# typescript
36+
*.tsbuildinfo
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"arrowParens": "avoid",
3+
"bracketSameLine": true,
4+
"singleQuote": true,
5+
"trailingComma": "all"
6+
}

examples/publish-ci/expo/App.tsx

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import type { FC } from 'react';
2+
import {
3+
SafeAreaView,
4+
ScrollView,
5+
StatusBar,
6+
StyleSheet,
7+
Text,
8+
View,
9+
useColorScheme,
10+
} from 'react-native';
11+
import { Provider } from 'react-redux';
12+
import { store } from './src/app/store';
13+
import { Counter } from './src/features/counter/Counter';
14+
15+
import {
16+
DebugInstructions,
17+
HermesBadge,
18+
LearnMoreLinks,
19+
ReloadInstructions,
20+
} from 'react-native/Libraries/NewAppScreen';
21+
import { Header } from './src/components/Header';
22+
import { LearnReduxLinks } from './src/components/LearnReduxLinks';
23+
import { Section } from './src/components/Section';
24+
import { TypedColors } from './src/constants/TypedColors';
25+
26+
export const App: FC = () => {
27+
const isDarkMode = useColorScheme() === 'dark';
28+
29+
const backgroundStyle = {
30+
backgroundColor: isDarkMode ? TypedColors.darker : TypedColors.lighter,
31+
};
32+
33+
return (
34+
<Provider store={store}>
35+
<SafeAreaView style={backgroundStyle}>
36+
<StatusBar
37+
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
38+
backgroundColor={backgroundStyle.backgroundColor}
39+
/>
40+
<ScrollView
41+
contentInsetAdjustmentBehavior="automatic"
42+
style={backgroundStyle}>
43+
<Header />
44+
<HermesBadge />
45+
<View
46+
style={{
47+
backgroundColor: isDarkMode
48+
? TypedColors.black
49+
: TypedColors.white,
50+
}}>
51+
<Counter />
52+
<Section title="Step One">
53+
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
54+
screen and then come back to see your edits.
55+
</Section>
56+
<Section title="See Your Changes">
57+
<ReloadInstructions />
58+
</Section>
59+
<Section title="Debug">
60+
<DebugInstructions />
61+
</Section>
62+
<Section title="Learn More Redux">
63+
Discover what to do next with Redux:
64+
</Section>
65+
<LearnReduxLinks />
66+
<Section title="Learn More React Native">
67+
Read the docs to discover what to do next:
68+
</Section>
69+
<LearnMoreLinks />
70+
</View>
71+
</ScrollView>
72+
</SafeAreaView>
73+
</Provider>
74+
);
75+
};
76+
77+
const styles = StyleSheet.create({
78+
highlight: {
79+
fontWeight: '700',
80+
},
81+
});
82+
83+
export default App;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { render } from '@testing-library/react-native';
2+
import renderer from 'react-test-renderer';
3+
import { App } from '../App';
4+
5+
test('renders correctly', () => {
6+
renderer.create(<App />);
7+
const element = render(<App />);
8+
expect(element).toBeDefined();
9+
});
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import type { CounterState } from '../src/features/counter/counterSlice';
2+
import {
3+
counterSlice,
4+
decrement,
5+
increment,
6+
incrementByAmount,
7+
} from '../src/features/counter/counterSlice';
8+
9+
describe('counter reducer', () => {
10+
const { reducer: counterReducer } = counterSlice;
11+
const initialState: CounterState = {
12+
value: 3,
13+
status: 'idle',
14+
};
15+
16+
test('should handle initial state', () => {
17+
expect(counterReducer(undefined, { type: 'unknown' })).toStrictEqual({
18+
value: 0,
19+
status: 'idle',
20+
});
21+
});
22+
23+
test('should handle increment', () => {
24+
const actual = counterReducer(initialState, increment());
25+
expect(actual.value).toBe(4);
26+
});
27+
28+
test('should handle decrement', () => {
29+
const actual = counterReducer(initialState, decrement());
30+
expect(actual.value).toBe(2);
31+
});
32+
33+
test('should handle incrementByAmount', () => {
34+
const actual = counterReducer(initialState, incrementByAmount(2));
35+
expect(actual.value).toBe(5);
36+
});
37+
});

examples/publish-ci/expo/app.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"expo": {
3+
"name": "expo-template-redux-typescript",
4+
"slug": "expo-template-redux-typescript",
5+
"version": "1.0.0",
6+
"orientation": "portrait",
7+
"icon": "./assets/icon.png",
8+
"userInterfaceStyle": "light",
9+
"splash": {
10+
"image": "./assets/splash.png",
11+
"resizeMode": "contain",
12+
"backgroundColor": "#ffffff"
13+
},
14+
"assetBundlePatterns": [
15+
"**/*"
16+
],
17+
"ios": {
18+
"supportsTablet": true
19+
},
20+
"android": {
21+
"adaptiveIcon": {
22+
"foregroundImage": "./assets/adaptive-icon.png",
23+
"backgroundColor": "#ffffff"
24+
}
25+
},
26+
"web": {
27+
"favicon": "./assets/favicon.png"
28+
}
29+
}
30+
}
Loading
1.43 KB
Loading
21.9 KB
Loading

0 commit comments

Comments
 (0)