Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.10 KB | None | 0 0
  1. import React, { Component } from 'react'
  2. import { Text, View, StyleSheet, TouchableOpacity, Image } from 'react-native';
  3. import { createAppContainer } from 'react-navigation';
  4. import { createStackNavigator } from 'react-navigation-stack';
  5. import Loading from "./Loading";
  6.  
  7. // Stylesheetit
  8.  
  9. const styles = StyleSheet.create({
  10. home: {
  11. flex: 1,
  12. backgroundColor: '#7eb67b',
  13. justifyContent: 'center',
  14. alignItems: 'center',
  15. },
  16. welcome: {
  17. flex: 1,
  18. backgroundColor: '#fff',
  19. justifyContent: 'center',
  20. alignItems: 'center',
  21. },
  22. notes: {
  23. flex: 1,
  24. backgroundColor: '#ffaa00',
  25. justifyContent: 'center',
  26. alignItems: 'center',
  27. },
  28. bookmarks: {
  29. flex: 1,
  30. backgroundColor: '#967bb6',
  31. justifyContent: 'center',
  32. alignItems: 'center',
  33. },
  34. title: {
  35. color: '#fff',
  36. fontSize: 30,
  37. marginBottom: 20,
  38. },
  39. welcomeTitle: {
  40. color: '#5f5f5f',
  41. fontSize: 30,
  42. marginBottom: 20,
  43. bottom: 80,
  44. fontWeight: 'bold',
  45. },
  46. notesTitle: {
  47. color: '#fff',
  48. fontSize: 30,
  49. marginBottom: 20,
  50. bottom: 300,
  51. },
  52. toDoTitle: {
  53. color: '#fff',
  54. fontSize: 30,
  55. marginBottom: 20,
  56. bottom: 300,
  57. },
  58. main: {
  59. alignItems: 'center',
  60. },
  61. btn: {
  62. backgroundColor: '#fff',
  63. borderRadius: 10,
  64. padding: 10,
  65. paddingLeft: 20,
  66. paddingRight: 20,
  67. top: -5,
  68. },
  69. btn2:{
  70. backgroundColor: '#fff',
  71. borderRadius: 10,
  72. padding: 10,
  73. paddingLeft: 20,
  74. paddingRight: 20,
  75. top: 20,
  76. },
  77. welcomeBtn1Text: {
  78. color: '#fff',
  79. fontSize: 30,
  80. textAlign: 'center',
  81. },
  82. welcomeBtn2Text: {
  83. color: '#fff',
  84. fontSize: 30,
  85. textAlign: 'center',
  86. },
  87. welcomeBtn1:{
  88. backgroundColor: '#ffaa00',
  89. borderRadius: 10,
  90. padding: 80,
  91. paddingLeft: 110,
  92. paddingRight: 110,
  93. top: 60,
  94. },
  95. welcomeBtn2:{
  96. backgroundColor: '#967bb6',
  97. borderRadius: 10,
  98. padding: 80,
  99. paddingLeft: 110,
  100. paddingRight: 110,
  101. top: 80,
  102. }
  103. });
  104.  
  105. // Sivut
  106.  
  107. class HomeScreen extends Component {
  108. state = {
  109. loaded: false,
  110. }
  111. constructor(){
  112. super();
  113. Loading.load(v => this.setState({loaded: true}));
  114. }
  115. static navigationOptions = ({ navigation }) => {
  116. return {
  117. header: () => null
  118. }
  119. }
  120. render(){
  121. return (
  122. <View style={styles.home}>
  123. {this.state.loaded ?
  124. <View style={styles.main}>
  125. <Text style={styles.title}>App</Text>
  126. <TouchableOpacity
  127. onPress={() => this.props.navigation.navigate("Welcome")}
  128. style={styles.btn}
  129. >
  130. <Text style={styles.btnText}>Login</Text>
  131. </TouchableOpacity>
  132. <TouchableOpacity
  133. onPress={() => this.props.navigation.navigate("Welcome")}
  134. style={styles.btn2}
  135. >
  136. <Text style={styles.btnText}>Sign Up</Text>
  137. </TouchableOpacity>
  138. </View>
  139. : <Image
  140. source={require('./images/loading_gif.gif')}
  141. style={{width: 100, height: 100 }}
  142. />}
  143. </View>
  144. );
  145. }
  146. }
  147.  
  148. class WelcomeScreen extends Component {
  149. static navigationOptions = ({ navigation }) => {
  150. return {
  151. header: () => null
  152. }
  153. };
  154. render() {
  155. return (
  156. <View style={styles.welcome}>
  157. <Text style={styles.welcomeTitle}>Notepadd</Text>
  158. <View>
  159. <TouchableOpacity
  160. onPress={() => this.props.navigation.navigate("Notes")}
  161. style={styles.welcomeBtn1}
  162. >
  163. <Text style={styles.welcomeBtn1Text}>Notes</Text>
  164. </TouchableOpacity>
  165. <TouchableOpacity
  166. onPress={() => this.props.navigation.navigate("ToDo")}
  167. style={styles.welcomeBtn2}
  168. >
  169. <Text style={styles.welcomeBtn2Text}>Bookmarks</Text>
  170. </TouchableOpacity>
  171. </View>
  172. </View>
  173. );
  174. }
  175. }
  176.  
  177. class NotesScreen extends Component {
  178. static navigationOptions = ({ navigation }) => {
  179. return {
  180. header: () => null
  181. }
  182. };
  183. render() {
  184. return (
  185. <View style={styles.notes}>
  186. <Text style={styles.notesTitle}>Notes</Text>
  187. </View>
  188. );
  189. }
  190. }
  191.  
  192. class ToDoScreen extends Component {
  193. static navigationOptions = ({ navigation }) => {
  194. return {
  195. header: () => null
  196. }
  197. };
  198. render() {
  199. return (
  200. <View style={styles.bookmarks}>
  201. <Text style={styles.toDoTitle}>To Do</Text>
  202. </View>
  203. );
  204. }
  205. }
  206.  
  207.  
  208. // Variablet
  209.  
  210. const RootStack = createStackNavigator(
  211. {
  212. Home: HomeScreen,
  213. Welcome: WelcomeScreen,
  214. Notes: NotesScreen,
  215. ToDo: ToDoScreen,
  216. },
  217. {initialRouteName: "Home",
  218. },
  219. );
  220.  
  221. const AppContainer = createAppContainer(RootStack);
  222.  
  223. export default AppContainer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement