|
1 | 1 | import React, { Component } from 'react'; |
2 | | -import { Instagram } from './canals/Instagram'; |
3 | | -import { FullScreenPortal } from 'react-gondola'; |
4 | 2 | 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'; |
6 | 7 |
|
7 | 8 | interface State { |
8 | | - example: null | 'Instagram'; |
| 9 | + example: null | 'Instagram' | 'Welcome'; |
9 | 10 | } |
10 | 11 |
|
11 | | -const EXAMPLES = { Instagram }; |
| 12 | +const EXAMPLES = { Welcome, Instagram }; |
12 | 13 |
|
13 | 14 | export default class App extends Component<{}, State> { |
14 | 15 | state: State = { |
15 | | - example: 'Instagram', |
| 16 | + example: 'Welcome', |
16 | 17 | }; |
17 | 18 |
|
18 | 19 | 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 | | - |
46 | 20 | return ( |
47 | 21 | <> |
48 | 22 | <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> |
50 | 71 | </FullScreenPortal> |
51 | 72 | <TouchableOpacity |
52 | | - style={{ position: 'absolute', bottom: 8, right: 8 }} |
| 73 | + style={{ position: 'absolute', top: 20, left: 0 }} |
53 | 74 | onPress={Navigation.instance.back} |
54 | 75 | > |
55 | | - <View style={{ backgroundColor: 'black', borderRadius: 4 }}> |
| 76 | + <View style={{ backgroundColor: 'black', borderBottomRightRadius: 4 }}> |
56 | 77 | <Text style={{ color: 'white', margin: 4 }}>Go Back</Text> |
57 | 78 | </View> |
58 | 79 | </TouchableOpacity> |
|
0 commit comments