HomeScreen.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. import * as WebBrowser from 'expo-web-browser';
  2. import * as React from 'react';
  3. import { Image, Platform, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
  4. import { ScrollView } from 'react-native-gesture-handler';
  5. import { MonoText } from '../components/StyledText';
  6. export default function HomeScreen() {
  7. return (
  8. <View style={styles.container}>
  9. <ScrollView style={styles.container} contentContainerStyle={styles.contentContainer}>
  10. <View style={styles.welcomeContainer}>
  11. <Image
  12. source={
  13. __DEV__
  14. ? require('../assets/images/robot-dev.png')
  15. : require('../assets/images/robot-prod.png')
  16. }
  17. style={styles.welcomeImage}
  18. />
  19. </View>
  20. <View style={styles.getStartedContainer}>
  21. <DevelopmentModeNotice />
  22. <Text style={styles.getStartedText}>Open up the code for this screen:</Text>
  23. <View style={[styles.codeHighlightContainer, styles.homeScreenFilename]}>
  24. <MonoText>screens/HomeScreen.js</MonoText>
  25. </View>
  26. <Text style={styles.getStartedText}>
  27. Change any of the text, save the file, and your app will automatically reload.
  28. </Text>
  29. </View>
  30. <View style={styles.helpContainer}>
  31. <TouchableOpacity onPress={handleHelpPress} style={styles.helpLink}>
  32. <Text style={styles.helpLinkText}>Help, it didn’t automatically reload!</Text>
  33. </TouchableOpacity>
  34. </View>
  35. </ScrollView>
  36. <View style={styles.tabBarInfoContainer}>
  37. <Text style={styles.tabBarInfoText}>This is a tab bar. You can edit it in:</Text>
  38. <View style={[styles.codeHighlightContainer, styles.navigationFilename]}>
  39. <MonoText style={styles.codeHighlightText}>navigation/BottomTabNavigator.js</MonoText>
  40. </View>
  41. </View>
  42. </View>
  43. );
  44. }
  45. HomeScreen.navigationOptions = {
  46. header: null,
  47. };
  48. function DevelopmentModeNotice() {
  49. if (__DEV__) {
  50. const learnMoreButton = (
  51. <Text onPress={handleLearnMorePress} style={styles.helpLinkText}>
  52. Learn more
  53. </Text>
  54. );
  55. return (
  56. <Text style={styles.developmentModeText}>
  57. Development mode is enabled: your app will be slower but you can use useful development
  58. tools. {learnMoreButton}
  59. </Text>
  60. );
  61. } else {
  62. return (
  63. <Text style={styles.developmentModeText}>
  64. You are not in development mode: your app will run at full speed.
  65. </Text>
  66. );
  67. }
  68. }
  69. function handleLearnMorePress() {
  70. WebBrowser.openBrowserAsync('https://docs.expo.io/versions/latest/workflow/development-mode/');
  71. }
  72. function handleHelpPress() {
  73. WebBrowser.openBrowserAsync(
  74. 'https://docs.expo.io/versions/latest/get-started/create-a-new-app/#making-your-first-change'
  75. );
  76. }
  77. const styles = StyleSheet.create({
  78. container: {
  79. flex: 1,
  80. backgroundColor: '#fff',
  81. },
  82. developmentModeText: {
  83. marginBottom: 20,
  84. color: 'rgba(0,0,0,0.4)',
  85. fontSize: 14,
  86. lineHeight: 19,
  87. textAlign: 'center',
  88. },
  89. contentContainer: {
  90. paddingTop: 30,
  91. },
  92. welcomeContainer: {
  93. alignItems: 'center',
  94. marginTop: 10,
  95. marginBottom: 20,
  96. },
  97. welcomeImage: {
  98. width: 100,
  99. height: 80,
  100. resizeMode: 'contain',
  101. marginTop: 3,
  102. marginLeft: -10,
  103. },
  104. getStartedContainer: {
  105. alignItems: 'center',
  106. marginHorizontal: 50,
  107. },
  108. homeScreenFilename: {
  109. marginVertical: 7,
  110. },
  111. codeHighlightText: {
  112. color: 'rgba(96,100,109, 0.8)',
  113. },
  114. codeHighlightContainer: {
  115. backgroundColor: 'rgba(0,0,0,0.05)',
  116. borderRadius: 3,
  117. paddingHorizontal: 4,
  118. },
  119. getStartedText: {
  120. fontSize: 17,
  121. color: 'rgba(96,100,109, 1)',
  122. lineHeight: 24,
  123. textAlign: 'center',
  124. },
  125. tabBarInfoContainer: {
  126. position: 'absolute',
  127. bottom: 0,
  128. left: 0,
  129. right: 0,
  130. ...Platform.select({
  131. ios: {
  132. shadowColor: 'black',
  133. shadowOffset: { width: 0, height: -3 },
  134. shadowOpacity: 0.1,
  135. shadowRadius: 3,
  136. },
  137. android: {
  138. elevation: 20,
  139. },
  140. }),
  141. alignItems: 'center',
  142. backgroundColor: '#fbfbfb',
  143. paddingVertical: 20,
  144. },
  145. tabBarInfoText: {
  146. fontSize: 17,
  147. color: 'rgba(96,100,109, 1)',
  148. textAlign: 'center',
  149. },
  150. navigationFilename: {
  151. marginTop: 5,
  152. },
  153. helpContainer: {
  154. marginTop: 15,
  155. alignItems: 'center',
  156. },
  157. helpLink: {
  158. paddingVertical: 15,
  159. },
  160. helpLinkText: {
  161. fontSize: 14,
  162. color: '#2e78b7',
  163. },
  164. });