Skip to content

Commit c79d4c9

Browse files
committed
Add multi-platform-toolbar recipe
1 parent 3db9435 commit c79d4c9

File tree

9 files changed

+117
-0
lines changed

9 files changed

+117
-0
lines changed
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/**/*
2+
.expo/*
3+
npm-debug.*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from 'react';
2+
import { StyleSheet } from 'react-native';
3+
4+
import Toolbar from './Toolbar';
5+
6+
export default class App extends React.Component {
7+
render() {
8+
var toolbarItems = [{
9+
id: 1,
10+
title: 'Tab One',
11+
}, {
12+
id: 2,
13+
title: 'Tab Two',
14+
}, {
15+
id: 3,
16+
title: 'Tab Three',
17+
}];
18+
19+
return (
20+
<Toolbar items={toolbarItems} />
21+
);
22+
}
23+
}
24+
25+
const styles = StyleSheet.create({
26+
container: {
27+
flex: 1,
28+
backgroundColor: '#fff',
29+
alignItems: 'center',
30+
justifyContent: 'center',
31+
},
32+
});
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"expo": {
3+
"name": "multi-platform-toolbar",
4+
"description": "This project is really great.",
5+
"slug": "multi-platform-toolbar",
6+
"privacy": "public",
7+
"sdkVersion": "28.0.0",
8+
"platforms": ["ios", "android"],
9+
"version": "1.0.0",
10+
"orientation": "portrait",
11+
"icon": "./assets/icon.png",
12+
"splash": {
13+
"image": "./assets/splash.png",
14+
"resizeMode": "contain",
15+
"backgroundColor": "#ffffff"
16+
},
17+
"updates": {
18+
"fallbackToCacheTimeout": 0
19+
},
20+
"assetBundlePatterns": [
21+
"**/*"
22+
],
23+
"ios": {
24+
"supportsTablet": true
25+
}
26+
}
27+
}
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react';
2+
import {
3+
Text,
4+
View,
5+
TouchableOpacity,
6+
TouchableNativeFeedback,
7+
Platform
8+
} from 'react-native';
9+
10+
const Toolbar = ({ items }) => {
11+
if (Platform.OS === 'ios') {
12+
return <View style={{ flex: 1, flexDirection: 'row', marginTop: 24 }}>
13+
{items.map((item, idx) => (
14+
<TouchableOpacity key={idx}>
15+
<View style={{ padding: 20 }}>
16+
<Text>{item.title}</Text>
17+
</View>
18+
</TouchableOpacity>
19+
))}
20+
</View>
21+
}
22+
if (Platform.OS === 'android') {
23+
return (<View style={{ flex: 1, flexDirection: 'column' }}>
24+
{items.map((item, idx)=>{
25+
return (
26+
<TouchableNativeFeedback key={idx}>
27+
<View style={{ padding: 20 }}>
28+
<Text>{item.title}</Text>
29+
</View>
30+
</TouchableNativeFeedback>
31+
)
32+
})}
33+
</View>);
34+
}
35+
};
36+
37+
export default Toolbar;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"main": "node_modules/expo/AppEntry.js",
3+
"private": true,
4+
"dependencies": {
5+
"expo": "^28.0.0",
6+
"react": "16.3.1",
7+
"react-native": "https://github.com/expo/react-native/archive/sdk-28.0.0.tar.gz"
8+
}
9+
}

0 commit comments

Comments
 (0)