src_components_Auth_Registration_RegisterMain.tsx.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title> src/components/Auth/Registration/RegisterMain.tsx</title>
  7. <script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
  8. <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
  9. <script src="./build/entry.js"></script>
  10. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  11. <!--[if lt IE 9]>
  12. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  13. <![endif]-->
  14. <link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
  15. <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
  16. <link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
  17. <link type="text/css" rel="stylesheet" href="styles/app.min.css">
  18. <link type="text/css" rel="stylesheet" href="styles/iframe.css">
  19. <link type="text/css" rel="stylesheet" href="">
  20. <script async defer src="https://buttons.github.io/buttons.js"></script>
  21. </head>
  22. <body class="layout small-header">
  23. <div id="stickyNavbarOverlay"></div>
  24. <div class="top-nav">
  25. <div class="inner">
  26. <a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
  27. <span aria-hidden="true"></span>
  28. <span aria-hidden="true"></span>
  29. <span aria-hidden="true"></span>
  30. </a>
  31. <div class="logo">
  32. </div>
  33. <div class="menu">
  34. <div class="navigation">
  35. <a
  36. href="index.html"
  37. class="link"
  38. >
  39. API Documentation
  40. </a>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <div id="main">
  46. <div
  47. class="sidebar "
  48. id="sidebarNav"
  49. >
  50. <nav>
  51. <h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Interfaces</h3><ul><li><a href="AddLandmarkProps.html">AddLandmarkProps</a></li><li><a href="CommentProps.html">CommentProps</a></li><li><a href="IdToken.html">IdToken</a></li><li><a href="IntroProps.html">IntroProps</a></li><li><a href="Landmark.html">Landmark</a></li><li><a href="LandmarkDetailsProps.html">LandmarkDetailsProps</a></li><li><a href="LandmarkPinProps.html">LandmarkPinProps</a></li><li><a href="LMComment.html">LMComment</a></li><li><a href="ProfileProps.html">ProfileProps</a></li><li><a href="RegisterProps.html">RegisterProps</a></li><li><a href="UserProfile.html">UserProfile</a></li></ul><h3>Components</h3><ul><li><a href="App.html">App</a></li><li><a href="Atlas.html">Atlas</a></li><li><a href="Comment.html">Comment</a></li><li><a href="PrimaryButton.html">PrimaryButton</a></li><li><a href="Profile.html">Profile</a></li><li><a href="SecondaryButton.html">SecondaryButton</a></li></ul><h3>Global</h3><ul><li><a href="global.html#IconStrings">IconStrings</a></li></ul></div><div class="category"><h2>Hooks</h2><h3>Namespaces</h3><ul><li><a href="useAuth.html">useAuth</a></li><li><a href="useLandmarks.html">useLandmarks</a></li><li><a href="useProfile.html">useProfile</a></li></ul></div><div class="category"><h2>Map</h2><h3>Interfaces</h3><ul><li><a href="UserLocation.html">UserLocation</a></li></ul><h3>Components</h3><ul><li><a href="AddLandmark.html">AddLandmark</a></li><li><a href="LandmarkDetails.html">LandmarkDetails</a></li><li><a href="LandmarkPin.html">LandmarkPin</a></li><li><a href="Map.html">Map</a></li></ul></div><div class="category"><h2>Navigation</h2><h3>Components</h3><ul><li><a href="AuthorizedNavigator.html">AuthorizedNavigator</a></li><li><a href="UnauthorizedNavigator.html">UnauthorizedNavigator</a></li></ul><h3><a href="global.html">Global</a></h3></div><div class="category"><h2>Stores</h2><h3>Classes</h3><ul><li><a href="AuthStore.html">AuthStore</a></li></ul></div><div class="category"><h2>Unauthorized</h2><h3>Components</h3><ul><li><a href="Intro.html">Intro</a></li><li><a href="UnauthorizedLayout.html">UnauthorizedLayout</a></li></ul><h3>Components / Registration</h3><ul><li><a href="RegisterMain.html">RegisterMain</a></li></ul></div>
  52. </nav>
  53. </div>
  54. <div class="core" id="main-content-wrapper">
  55. <div class="content">
  56. <header class="page-title">
  57. <p>Source</p>
  58. <h1>src/components/Auth/Registration/RegisterMain.tsx</h1>
  59. </header>
  60. <section>
  61. <article>
  62. <pre class="prettyprint source linenums"><code>import React, { useEffect, useState } from 'react';
  63. import { Alert, Dimensions, StyleSheet, View } from 'react-native';
  64. import 'react-native-get-random-values';
  65. import { Text } from 'react-native-paper';
  66. import { useRegistrationFormState } from '../../../contexts/RegisterContext';
  67. import { AuthStackNavigationProp } from '../../../navigation/UnauthorizedNavigator';
  68. import UnauthorizedLayout from '../AuthLayout';
  69. import RegisterCredentials from './RegisterCredential';
  70. import RegisterImage from './RegisterImage';
  71. import RegisterMeasurements from './RegisterMeasurements';
  72. import RegisterPassword from './RegisterPassword';
  73. import RegisterResult from './RegistrationResult';
  74. /**
  75. * {@link RegisterMain} component props.
  76. */
  77. export interface RegisterProps {
  78. /**The navigation object used to interact with the {@link Auth} navigator.*/
  79. navigation: AuthStackNavigationProp
  80. }
  81. export interface RegisterStepProps {
  82. changeStep: (stepNumber: number, stepSubtitleText: string) => void;
  83. setFormValues: (formValues: RegisterFormValues) => void
  84. formValues: RegisterFormValues
  85. }
  86. export interface RegisterFormValues {
  87. username?: string;
  88. email?: string;
  89. password?: string;
  90. confirmPassword?: string;
  91. sagitta?: false
  92. height?: string;
  93. weight?: string;
  94. }
  95. /**
  96. * The main registration component. Acts as a backdrop for all intermediate registration steps.
  97. * @category Unauthorized
  98. * @subcategory Registration
  99. * @component
  100. */
  101. export const RegisterMain : React.FC&lt;RegisterProps> = ({navigation}) => {
  102. /**Holds an integer value that maps to a step in the registration process.
  103. * The mapping is as follows:
  104. * - 1 -> Username and Email
  105. * - 2 -> Password
  106. * - 3 -> Sagitta and Measurements
  107. * - 4 -> Profile picture and submission
  108. * - 5 -> Result
  109. */
  110. const stepState = 1;
  111. const [step, setStep] = useState(stepState);
  112. /**
  113. * Holds the current subtitle text.
  114. */
  115. const subTitleState = "Let's start with some basic account information.";
  116. const [subtitle, setSubtitle] = useState&lt;string>(subTitleState);
  117. const [formValues, setFormValues] = useState&lt;RegisterFormValues>({});
  118. useEffect(() => {
  119. /**
  120. * Handler that intercepts a request to leave the registration screen and asks the user to confirm that they want to leave.
  121. * If they confirm they want to leave, all registration state will reset and the user will be directed back to {@link Intro}.
  122. * @memberOf RegisterMain
  123. */
  124. const preventExitFromRegistration = navigation.addListener('beforeRemove', (e) => {
  125. if (step != 5) {
  126. e.preventDefault();
  127. Alert.alert(
  128. 'Going so soon?',
  129. 'Are you sure you want to cancel registration?',
  130. [
  131. { text: "Don't leave", style: 'cancel', onPress: () => {} },
  132. {
  133. text: 'Discard',
  134. style: 'destructive',
  135. onPress: () => {
  136. setFormValues({});
  137. navigation.dispatch(e.data.action)
  138. },
  139. },
  140. ]
  141. );
  142. }})
  143. return preventExitFromRegistration;
  144. }, [navigation, step]);
  145. /**
  146. * Changes the registration step to the given value.
  147. */
  148. const changeStep = (step: any, subtitle: any) => {
  149. setStep(step);
  150. setSubtitle(subtitle);
  151. }
  152. /**
  153. * Returns to the intro screen.
  154. */
  155. const finish = () => {
  156. navigation.pop();
  157. }
  158. return (
  159. &lt;UnauthorizedLayout>
  160. &lt;View style={styles.brandContainer}>
  161. {step != 5 ?
  162. &lt;Text style={styles.title} >Welcome!&lt;/Text> : null}
  163. &lt;Text style={styles.subtitle}>{subtitle}&lt;/Text>
  164. &lt;/View>
  165. &lt;View>
  166. {step == 1 ? &lt;RegisterCredentials setFormValues={setFormValues} formValues={formValues} changeStep={changeStep}/> :
  167. step == 2 ? &lt;RegisterPassword setFormValues={setFormValues} formValues={formValues} changeStep={changeStep}/> :
  168. step == 3 ? &lt;RegisterMeasurements setFormValues={setFormValues} formValues={formValues} changeStep={changeStep}/> :
  169. step == 4 ? &lt;RegisterImage setFormValues={setFormValues} formValues={formValues} changeStep={changeStep} /> :
  170. step == 5 ? &lt;RegisterResult finish={finish}/> : null}
  171. &lt;/View>
  172. &lt;/UnauthorizedLayout>
  173. )
  174. }
  175. const styles = StyleSheet.create({
  176. container: {
  177. position: 'absolute',
  178. width: Dimensions.get('window').width,
  179. height: Dimensions.get('window').height,
  180. flex: 1,
  181. justifyContent: 'flex-start',
  182. resizeMode: 'cover',
  183. },
  184. brandContainer: {
  185. marginTop: 60,
  186. marginHorizontal: 25,
  187. flexDirection: 'column',
  188. justifyContent: 'space-evenly'
  189. },
  190. title: {
  191. color: 'white',
  192. fontSize: 20
  193. },
  194. subtitle: {
  195. color: 'white',
  196. fontSize: 15,
  197. marginTop: 20
  198. },
  199. });
  200. </code></pre>
  201. </article>
  202. </section>
  203. </div>
  204. <footer class="footer">
  205. <div class="content has-text-centered">
  206. <p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.7</a></p>
  207. <p class="sidebar-created-by">
  208. <a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
  209. <a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
  210. </p>
  211. </div>
  212. </footer>
  213. </div>
  214. <div id="side-nav" class="side-nav">
  215. </div>
  216. </div>
  217. <script src="scripts/app.min.js"></script>
  218. <script>PR.prettyPrint();</script>
  219. <script src="scripts/linenumber.js"> </script>
  220. </body>
  221. </html>