|
| 1 | +import React from 'react'; |
| 2 | +import { StyleSheet, Platform, Image, Text, View, ScrollView } from 'react-native'; |
| 3 | + |
| 4 | +import firebase from 'react-native-firebase'; |
| 5 | + |
| 6 | +export default class App extends React.Component { |
| 7 | + constructor() { |
| 8 | + super(); |
| 9 | + this.state = {}; |
| 10 | + } |
| 11 | + |
| 12 | + async componentDidMount() { |
| 13 | + // TODO: You: Do firebase things |
| 14 | + // const { user } = await firebase.auth().signInAnonymously(); |
| 15 | + // console.warn('User -> ', user.toJSON()); |
| 16 | + |
| 17 | + // await firebase.analytics().logEvent('foo', { bar: '123'}); |
| 18 | + } |
| 19 | + |
| 20 | + render() { |
| 21 | + return ( |
| 22 | + <ScrollView> |
| 23 | + <View style={styles.container}> |
| 24 | + <Image source={require('./assets/ReactNativeFirebase.png')} style={[styles.logo]}/> |
| 25 | + <Text style={styles.welcome}> |
| 26 | + Welcome to {'\n'} React Native Firebase |
| 27 | + </Text> |
| 28 | + <Text style={styles.instructions}> |
| 29 | + To get started, edit App.js |
| 30 | + </Text> |
| 31 | + {Platform.OS === 'ios' ? ( |
| 32 | + <Text style={styles.instructions}> |
| 33 | + Press Cmd+R to reload,{'\n'} |
| 34 | + Cmd+D or shake for dev menu |
| 35 | + </Text> |
| 36 | + ) : ( |
| 37 | + <Text style={styles.instructions}> |
| 38 | + Double tap R on your keyboard to reload,{'\n'} |
| 39 | + Cmd+M or shake for dev menu |
| 40 | + </Text> |
| 41 | + )} |
| 42 | + <View style={styles.modules}> |
| 43 | + <Text style={styles.modulesHeader}>The following Firebase modules are pre-installed:</Text> |
| 44 | + {firebase.admob.nativeModuleExists && <Text style={styles.module}>admob()</Text>} |
| 45 | + {firebase.analytics.nativeModuleExists && <Text style={styles.module}>analytics()</Text>} |
| 46 | + {firebase.auth.nativeModuleExists && <Text style={styles.module}>auth()</Text>} |
| 47 | + {firebase.config.nativeModuleExists && <Text style={styles.module}>config()</Text>} |
| 48 | + {firebase.crashlytics.nativeModuleExists && <Text style={styles.module}>crashlytics()</Text>} |
| 49 | + {firebase.database.nativeModuleExists && <Text style={styles.module}>database()</Text>} |
| 50 | + {firebase.firestore.nativeModuleExists && <Text style={styles.module}>firestore()</Text>} |
| 51 | + {firebase.functions.nativeModuleExists && <Text style={styles.module}>functions()</Text>} |
| 52 | + {firebase.iid.nativeModuleExists && <Text style={styles.module}>iid()</Text>} |
| 53 | + {firebase.invites.nativeModuleExists && <Text style={styles.module}>invites()</Text>} |
| 54 | + {firebase.links.nativeModuleExists && <Text style={styles.module}>links()</Text>} |
| 55 | + {firebase.messaging.nativeModuleExists && <Text style={styles.module}>messaging()</Text>} |
| 56 | + {firebase.notifications.nativeModuleExists && <Text style={styles.module}>notifications()</Text>} |
| 57 | + {firebase.perf.nativeModuleExists && <Text style={styles.module}>perf()</Text>} |
| 58 | + {firebase.storage.nativeModuleExists && <Text style={styles.module}>storage()</Text>} |
| 59 | + </View> |
| 60 | + </View> |
| 61 | + </ScrollView> |
| 62 | + ); |
| 63 | + } |
| 64 | +} |
| 65 | + |
| 66 | +const styles = StyleSheet.create({ |
| 67 | + container: { |
| 68 | + flex: 1, |
| 69 | + justifyContent: 'center', |
| 70 | + alignItems: 'center', |
| 71 | + backgroundColor: '#F5FCFF', |
| 72 | + }, |
| 73 | + logo: { |
| 74 | + height: 120, |
| 75 | + marginBottom: 16, |
| 76 | + marginTop: 64, |
| 77 | + padding: 10, |
| 78 | + width: 135, |
| 79 | + }, |
| 80 | + welcome: { |
| 81 | + fontSize: 20, |
| 82 | + textAlign: 'center', |
| 83 | + margin: 10, |
| 84 | + }, |
| 85 | + instructions: { |
| 86 | + textAlign: 'center', |
| 87 | + color: '#333333', |
| 88 | + marginBottom: 5, |
| 89 | + }, |
| 90 | + modules: { |
| 91 | + margin: 20, |
| 92 | + }, |
| 93 | + modulesHeader: { |
| 94 | + fontSize: 16, |
| 95 | + marginBottom: 8, |
| 96 | + }, |
| 97 | + module: { |
| 98 | + fontSize: 14, |
| 99 | + marginTop: 4, |
| 100 | + textAlign: 'center', |
| 101 | + } |
| 102 | +}); |
0 commit comments