Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

Commit 77597ad

Browse files
committed
🚧 (example) improve example with a tab bar and instructions
1 parent df1c5ed commit 77597ad

3 files changed

Lines changed: 83 additions & 40 deletions

File tree

example/src/App.tsx

Lines changed: 57 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,79 @@
11
import React, { Component } from 'react';
2-
import { Instagram } from './canals/Instagram';
3-
import { FullScreenPortal } from 'react-gondola';
42
import { View, TouchableOpacity, Text } from 'react-native';
5-
import { Navigation } from 'react-gondola/Navigation';
3+
import { Navigation } from 'react-gondola';
4+
import { FullScreenPortal, Canal, Screen } from 'react-gondola';
5+
import { Instagram } from './canals/Instagram';
6+
import { Welcome } from './Welcome';
67

78
interface State {
8-
example: null | 'Instagram';
9+
example: null | 'Instagram' | 'Welcome';
910
}
1011

11-
const EXAMPLES = { Instagram };
12+
const EXAMPLES = { Welcome, Instagram };
1213

1314
export default class App extends Component<{}, State> {
1415
state: State = {
15-
example: 'Instagram',
16+
example: 'Welcome',
1617
};
1718

1819
render() {
19-
if (!this.state.example) {
20-
return (
21-
<View style={{ alignItems: 'center', flex: 1, justifyContent: 'center' }}>
22-
{Object.keys(EXAMPLES).map(example => (
23-
<TouchableOpacity
24-
key={example}
25-
onPress={() => {
26-
// @ts-ignore
27-
this.setState({ example });
28-
}}
29-
style={{
30-
paddingHorizontal: 16,
31-
paddingVertical: 8,
32-
backgroundColor: 'cyan',
33-
borderRadius: 4,
34-
marginTop: 8,
35-
}}
36-
>
37-
<Text>{example}</Text>
38-
</TouchableOpacity>
39-
))}
40-
</View>
41-
);
42-
}
43-
44-
const Example = EXAMPLES[this.state.example];
45-
4620
return (
4721
<>
4822
<FullScreenPortal>
49-
<Example />
23+
<Canal style={{ flex: 1 }}>
24+
{Object.keys(EXAMPLES).map(example => (
25+
<Screen
26+
key={example}
27+
name={example}
28+
// @ts-ignore
29+
Component={EXAMPLES[example]}
30+
visible={this.state.example === example}
31+
onBack={() => {
32+
this.setState({ example: 'Welcome' });
33+
}}
34+
/>
35+
))}
36+
</Canal>
37+
<View
38+
style={{
39+
height: 48,
40+
justifyContent: 'space-around',
41+
flexDirection: 'row',
42+
shadowColor: '#000',
43+
shadowOffset: {
44+
width: 0,
45+
height: 2,
46+
},
47+
shadowOpacity: 0.25,
48+
shadowRadius: 3.84,
49+
elevation: 5,
50+
backgroundColor: 'white',
51+
}}
52+
>
53+
{Object.keys(EXAMPLES).map(example => (
54+
<TouchableOpacity
55+
key={example}
56+
onPress={() => {
57+
// @ts-ignore
58+
this.setState({ example });
59+
}}
60+
style={{
61+
justifyContent: 'center',
62+
borderTopWidth: 2,
63+
paddingBottom: 2,
64+
borderTopColor: this.state.example === example ? 'blue' : 'transparent',
65+
}}
66+
>
67+
<Text>{example}</Text>
68+
</TouchableOpacity>
69+
))}
70+
</View>
5071
</FullScreenPortal>
5172
<TouchableOpacity
52-
style={{ position: 'absolute', bottom: 8, right: 8 }}
73+
style={{ position: 'absolute', top: 20, left: 0 }}
5374
onPress={Navigation.instance.back}
5475
>
55-
<View style={{ backgroundColor: 'black', borderRadius: 4 }}>
76+
<View style={{ backgroundColor: 'black', borderBottomRightRadius: 4 }}>
5677
<Text style={{ color: 'white', margin: 4 }}>Go Back</Text>
5778
</View>
5879
</TouchableOpacity>

example/src/Welcome.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React, { Component } from 'react';
2+
import { View, Text } from 'react-native';
3+
4+
export class Welcome extends Component {
5+
render() {
6+
return (
7+
<View style={{ flex: 1, justifyContent: 'center', padding: 16 }}>
8+
<Text style={{ fontSize: 32, fontWeight: '500', textAlign: 'center', marginBottom: 16 }}>
9+
Welcome in React Gondola !
10+
</Text>
11+
<Text style={{ marginTop: 16 }}>
12+
Choose an example in the tab bar to explore this example app.
13+
</Text>
14+
<Text style={{ marginTop: 16 }}>
15+
To go back, press the GoBack button in the top left corner.
16+
</Text>
17+
</View>
18+
);
19+
}
20+
}

example/src/canals/Instagram/getRandomUser.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,27 @@ const users = [
55
color: 'green',
66
emoji: '💵',
77
name: 'Joe Dalton',
8-
description: "🏜 I'm a villain in the FarWest",
8+
description:
9+
"🏜 I'm a villain in the FarWest\n Try to long press a picture to see a fullscreen sneak peek !",
910
},
1011
{
1112
color: 'blue',
1213
emoji: '🛰',
1314
name: 'Luke Skywalker',
14-
description: 'Casting for a sitcom',
15+
description:
16+
'Casting for a sitcom\n Try to long press a picture to see a fullscreen sneak peek !',
1517
},
1618
{
1719
color: 'red',
1820
emoji: '👀',
1921
name: 'Mario',
20-
description: 'Looking for Peach',
22+
description: 'Looking for Peach\n Try to long press a picture to see a fullscreen sneak peek !',
2123
},
2224
{
2325
color: 'yellow',
2426
emoji: '🎤',
2527
name: 'Christophe Maé',
26-
description: "🎶 J'avoueeeeee",
28+
description: "🎶 J'avoueeeeee\n Try to long press a picture to see a fullscreen sneak peek !",
2729
},
2830
];
2931

0 commit comments

Comments
 (0)