YouTube2Text

Build a Full Stack React Native App with Payments | PostgreSQL, TypeScript, Stripe, Tailwind — Transcript

by JavaScript Mastery · 52,551 words · 7,258 segments · language en · Watch on YouTube

Full transcript

  1. 0:00do you want to create feature full Stack
  2. 0:02mobile applications that push the
  3. 0:04boundaries of what's possible leave a
  4. 0:06lasting impression and set you aart if
  5. 0:08so you're in the right place hi there
  6. 0:11and welcome to a highly anticipated
  7. 0:13course where you'll build a full stack
  8. 0:15Uber clone and no this won't be your
  9. 0:18average app showing a map on a screen
  10. 0:20I'm talking about a 15 screen
  11. 0:23state-of-the-art application that uses
  12. 0:25expo's latest features such as Expo
  13. 0:27router API routes Expo location
  14. 0:30Lightning Fast EDG ready postgress
  15. 0:32database Global State Management with
  16. 0:35zest stand and many others after taking
  17. 0:37this course you can build any mobile app
  18. 0:39you can imagine why because I didn't cut
  19. 0:42any Corners when making it I decided to
  20. 0:44include screens that appear on all of
  21. 0:46the most popular apps in the world
  22. 0:48you'll learn how to make splash screens
  23. 0:50and onboarding flows add authentication
  24. 0:52access device sensors integrate Maps
  25. 0:55build custom tabs navigation models
  26. 0:57bottom sheets success screens and even
  27. 1:00integrate payments using stripe there
  28. 1:02are also some Uber specific features
  29. 1:04you'll Implement such as live Google
  30. 1:06location with Google maps showing nearby
  31. 1:08rides search relocations using Google
  32. 1:10Places choose a destination driver and
  33. 1:13book a ride get directions and estimated
  34. 1:16time see all booked rides and your
  35. 1:19profile details alongside this video in
  36. 1:21the description below I've also prepared
  37. 1:23the ultimate react native guide that
  38. 1:25covers everything you need to know to
  39. 1:27become a fantastic developer the guide
  40. 1:29covers the complete react native Road
  41. 1:31mapap prerequisites and essential react
  42. 1:34native Concepts and project ideas you
  43. 1:36can build and deploy to get a job you
  44. 1:38can download the guide and use it as a
  45. 1:40reference whenever you're unsure what to
  46. 1:42do next of course the guide is
  47. 1:44completely free and once again the link
  48. 1:46is in the description alongside that in
  49. 1:48this video I'll teach you react native
  50. 1:50fundamentals Expo router for file-based
  51. 1:53navigation zustand for Global State
  52. 1:55Management native wind for styling Expo
  53. 1:58API routes stripe payments data fetching
  54. 2:01with custom hooks reusable Advanced
  55. 2:03components with best practices
  56. 2:05typescript for writing types safe code
  57. 2:07es length and preder for organizing the
  58. 2:09code authentication with email
  59. 2:12verification using Clerk and even
  60. 2:14postgress using neon a serverless fully
  61. 2:17managed postgress database that
  62. 2:18automatically scales resources and lets
  63. 2:21you write native SQL queries it is so
  64. 2:24good that even versell uses it behind
  65. 2:26the scenes for their versell postgress
  66. 2:28service now with even better teaching
  67. 2:30methods you'll get an open source
  68. 2:32codebase a custom figma design and a
  69. 2:34Discord server with a dedicated Uber
  70. 2:36channel to resolve bugs if you get stuck
  71. 2:39all those things are free so grab those
  72. 2:41from the links below while I continue
  73. 2:42telling you more about the project a
  74. 2:45basic to medium understanding of react
  75. 2:47native is needed so if you're not quite
  76. 2:49there yet check out the react native
  77. 2:51crash course and come right back and
  78. 2:53we're also working on the ultimate react
  79. 2:55native course to learn more about it
  80. 2:57check out the first page in the guide
  81. 2:59that I mentioned before in this course
  82. 3:01though I'll also teach you how to set up
  83. 3:03an IDE you didn't know you needed
  84. 3:05webstorm is a professional JavaScript
  85. 3:07and typescript IDE that will make you so
  86. 3:09efficient you'll wonder what you were
  87. 3:11doing all this time Jed brains reached
  88. 3:13out to sponsor this video and initially
  89. 3:15I was skeptical about switching from the
  90. 3:17code editor I've been so used to so I
  91. 3:20used it for over 3 months to test it for
  92. 3:21myself and oh boy is it powerful I can't
  93. 3:25wait to share everything it can do I'll
  94. 3:26do it later on while we're developing
  95. 3:28the application but just to say it
  96. 3:30quickly it has smart terminal with auto
  97. 3:32suggestions typescript type suggestions
  98. 3:34code completion automatic bug fixes
  99. 3:37oneclick refactoring speed search and an
  100. 3:40integrated git and GitHub system and
  101. 3:42here's the best part clicking the link
  102. 3:43in the description will give you a free
  103. 3:4590-day access plus if you're a student
  104. 3:48it'll remain free download it while I
  105. 3:50continue telling you more about the app
  106. 3:51will build today when you first launch
  107. 3:53the app a custom splash screen will
  108. 3:55appear for a few seconds you'll then go
  109. 3:58through a smooth onboarding process
  110. 3:59process highlighting the app's main
  111. 4:01features after that you'll see a sign up
  112. 4:04off screen where you can create a new
  113. 4:06account or log in if we go to create a
  114. 4:08new account it'll ask you for your email
  115. 4:11and password but this time I decided to
  116. 4:13teach you how to implement email
  117. 4:15verification too after you enter your
  118. 4:17details the app will request a code sent
  119. 4:19to your email hold on okay here it is if
  120. 4:23you try to enter anything else of course
  121. 4:25it won't work enter the right code and
  122. 4:27voila your account is successfully
  123. 4:29verified you can also choose to
  124. 4:31authenticate using Google which works
  125. 4:33smoothly and logs you in within seconds
  126. 4:35now we are redirected to the homepage
  127. 4:37you'll first notice a popup asking for
  128. 4:39location access once you grant
  129. 4:41permission your location will
  130. 4:43immediately appear on the map you'll
  131. 4:45also see the nearby drivers if you click
  132. 4:47on them their names will be displayed
  133. 4:49below is a list of all rides I've booked
  134. 4:51so far and at the top a Google
  135. 4:53autocomplete search bar will suggest
  136. 4:55locations as you type pretty cool right
  137. 4:57once we select a location we're taking
  138. 4:59to the ride finding screen where you can
  139. 5:01enter your destination and see the
  140. 5:03location on the map through this smooth
  141. 5:05bottom sheet which we can expand or
  142. 5:07collaps you can also change your
  143. 5:09location and choose where you want to
  144. 5:11start by selecting places in
  145. 5:12autocompletion next we move to choose a
  146. 5:15writer screen where you can pick your
  147. 5:17preferred writer at a fair price then
  148. 5:19you'll be directed to the confirmation
  149. 5:21screen where you can review the details
  150. 5:23one last time before giving any money
  151. 5:25thanks to stripe we can select from
  152. 5:27various payment methods I'll enter some
  153. 5:29dummy details hit pay and watch it go
  154. 5:32through successfully you'll see this
  155. 5:33cool model with a smooth animation popup
  156. 5:36specifying that the booking is
  157. 5:37successful we click back home to return
  158. 5:40to the home screen to see the new ride
  159. 5:41we just booked you can also see the
  160. 5:43complete list of rides in the history
  161. 5:44screen plus there's also a well-designed
  162. 5:47profile screen with all of your details
  163. 5:49it is fully responsive and provides
  164. 5:52consistent results across all types of
  165. 5:54devices it is such a large feature reach
  166. 5:57application isn't it and you'll learn
  167. 5:58how to build it to today so what are you
  168. 6:01waiting for let's Dive Right In before
  169. 6:04we begin developing our app I want to
  170. 6:06show you how you can set up a new IDE
  171. 6:09that I tried and loved so much that I
  172. 6:11decided to use it to replace my vs code
  173. 6:14I know making a switch is not easy but
  174. 6:17just try it and you won't be
  175. 6:19disappointed Jed brain's tools are
  176. 6:21trusted by Google Tesla Visa Shopify
  177. 6:25City Bank and even NASA so they'll suit
  178. 6:28us just fine the link in the description
  179. 6:30will give you a free 90-day webstorm
  180. 6:33license so you have nothing to lose open
  181. 6:35it fill in your information click redeem
  182. 6:38and follow the instructions in the email
  183. 6:40once you click the link you got in your
  184. 6:42email you'll be redirected to your
  185. 6:43account dashboard and just click
  186. 6:45download then select your operating
  187. 6:48system and click download keep in mind
  188. 6:50this is a full IDE and not just a code
  189. 6:53editor so it's going to take some time
  190. 6:55to download let's leave it B and I'll be
  191. 6:57right back and if you're not ready to
  192. 6:59choose webstorm yet that's totally okay
  193. 7:02you can still follow along with the
  194. 7:03entire video without any problems I just
  195. 7:06want to say that I've been trying it on
  196. 7:08our internal projects for the last
  197. 7:10couple of months and found it to be the
  198. 7:12perfect IDE for web and mobile
  199. 7:15applications I'm still discovering new
  200. 7:17features as I go but I'm already so
  201. 7:19impressed that I won't be going back to
  202. 7:21vs code anytime soon once you install it
  203. 7:23it's going to ask you whether you want
  204. 7:25to import your settings from vs code so
  205. 7:27you can do that or start completely from
  206. 7:29SC scratch in this case I will import
  207. 7:31the settings you can choose the theme
  208. 7:33the key maps plugins and even the recent
  209. 7:35projects this was super quick and now we
  210. 7:39can create a new project it can be just
  211. 7:41an empty project which we can create on
  212. 7:43our
  213. 7:44desktop under SL Uber dclone and click
  214. 7:50create once you're in there it'll look
  215. 7:53something like this but of course we can
  216. 7:54fully customize it and what's the one
  217. 7:57thing that developers first change when
  218. 7:59they download a new IDE it's got to be
  219. 8:02the theme so press control or command
  220. 8:05shift p and it'll open up this search
  221. 8:08context where you can search for theme
  222. 8:11press enter and then select one of the
  223. 8:13predefined themes but of course you can
  224. 8:15press get more themes and very easily
  225. 8:18install any theme you want in this case
  226. 8:21I'll proceed with one dark theme and
  227. 8:23press
  228. 8:24accept and immediately it got applied
  229. 8:28another thing I'll do just so you can
  230. 8:29follow along more easily is increase the
  231. 8:31font size so I'll use the command shift
  232. 8:34p to go to settings select font and I
  233. 8:39will increase it to about 18 and enable
  234. 8:43ligatures this should allow you to see
  235. 8:45much better what I'm working on I think
  236. 8:48this is more than enough to get us going
  237. 8:50as we develop the application we can
  238. 8:51continue customizing the IDE to make it
  239. 8:54more your own and I'll be pointing out
  240. 8:56to all the cool details that webstorm
  241. 8:58does for us so with that said let's get
  242. 9:00started with a project setup to develop
  243. 9:03our mobile application of course we'll
  244. 9:05be using react native a platform that
  245. 9:08allows us to learn a technology such as
  246. 9:10react once and then write code anywhere
  247. 9:14be that Android iOS or web so as we
  248. 9:17click get started we'll be redirected to
  249. 9:20the getting started guide and I want to
  250. 9:22point your attention to
  251. 9:23something they say right here that you
  252. 9:26can use react native without a framework
  253. 9:29however they've found that most
  254. 9:31developers benefit from using a react
  255. 9:33framework like Expo providing you with
  256. 9:35features such as file based routing
  257. 9:37highquality Universal libraries and the
  258. 9:40ability to write plugins that modify
  259. 9:42native code without having to manage
  260. 9:44native files so we'll use the
  261. 9:46recommended approach and we'll start a
  262. 9:48new react native project with Expo we
  263. 9:51can do that by quickly navigating over
  264. 9:53to their page and going to the docs to
  265. 9:56get started with it there's only one
  266. 9:58command we need to run MPX create xfo
  267. 10:00app at latest so if we copy it and go
  268. 10:04back to our code editor you can open up
  269. 10:06the terminal by holding the control and
  270. 10:08then the key left of the one key on your
  271. 10:10keyboard and yeah terminal is a whole
  272. 10:12other beast in webstorm as we write
  273. 10:15commands I'll point out some cool
  274. 10:16features that it has so right here we
  275. 10:19can run MPX create Expo app at latest
  276. 10:22and then add the dot slash at the end to
  277. 10:24create it in the current Uber clone
  278. 10:26repository let's press enter and and
  279. 10:29press y to install the following
  280. 10:31packages let's give it a moment until it
  281. 10:33does its thing and while the packages
  282. 10:35are getting installed let's set up the
  283. 10:37database which we'll use to make our
  284. 10:39entire Uber application possible we need
  285. 10:42to have a place to store user accounts
  286. 10:44the writers the drivers and the rides
  287. 10:47themselves so click the neon link down
  288. 10:49in the description to be able to follow
  289. 10:51along and see exactly what I'm seeing
  290. 10:54next click get started and sign up I'll
  291. 10:57continue with Google for this project
  292. 10:59we're not using any thirdparty libraries
  293. 11:02for our database management you'll be
  294. 11:04working with a native postgress database
  295. 11:06and will write real SQL queries here you
  296. 11:10can enter your project name started with
  297. 11:12JSM uncore and then you can enter your
  298. 11:14project name you can do ride or Uber or
  299. 11:17whatever you prefer and same thing for
  300. 11:19the database name I'll do JSM ride you
  301. 11:22can choose the region that is closest to
  302. 11:24you and click create project and there
  303. 11:27we go we are redirected to this
  304. 11:29beautiful dashboard which will put to
  305. 11:31full use soon enough there we go it took
  306. 11:34some time but it finally worked your
  307. 11:36project is ready and now we can either
  308. 11:39run Android iOS or web before we do that
  309. 11:42you can press these three dots here and
  310. 11:44enable the new terminal which is in
  311. 11:46better right now and soon you'll see
  312. 11:48some of the new functionalities that it
  313. 11:50brings to the table for now let's just
  314. 11:53type mpm start and press enter you will
  315. 11:56see some warnings right here but that's
  316. 11:58not a big deal because below that you
  317. 12:01will see a QR code that you can scan
  318. 12:03with your phone and this QR code is very
  319. 12:06important for the whole Expo react
  320. 12:09native environment if you don't want to
  321. 12:11use it there's some different
  322. 12:13alternative options that we can use such
  323. 12:15as pressing a to open up Android Studio
  324. 12:17or the letter i to open up the iOS
  325. 12:20simulator but for all of these things
  326. 12:22you have to have heavy software we all
  327. 12:26know those stories where you open up
  328. 12:27Android studio and your device starts
  329. 12:30heating up and explodes and for the iOS
  330. 12:33it doesn't explode but you have to have
  331. 12:35very expensive devices what Expo allows
  332. 12:38us to do is to use the Expo go
  333. 12:40application to run our application on
  334. 12:43our phone in real time and see exactly
  335. 12:46what we're developing and we can even
  336. 12:48play with it and touch the app in real
  337. 12:50time that is super cool so let's go back
  338. 12:53to this QR code and if you're an iOS
  339. 12:56you'll have to scan it with your camera
  340. 12:58and before to scan it you'll have to go
  341. 13:00to your app store or Google Play store
  342. 13:02and just download the Expo go
  343. 13:05Application it should look something
  344. 13:06like this on your phone so I think this
  345. 13:08is the perfect time that I brought my
  346. 13:10phone preview on the right side of the
  347. 13:12screen so at all times while watching
  348. 13:14this video you'll be able to see exactly
  349. 13:17what I'm seeing on my phone screen so
  350. 13:19once you download it simply click open
  351. 13:22and you'll also have to create your Expo
  352. 13:25account by logging in if you're an
  353. 13:27Android you can open up the Expo Go app
  354. 13:29and scan the code from there and if
  355. 13:31you're an iOS you can scan it directly
  356. 13:34from your native camera app and on both
  357. 13:36systems make sure that you're connected
  358. 13:38to the same Wi-Fi network where you're
  359. 13:41running the code so both the phone and
  360. 13:43the device have to be on the same
  361. 13:44network and on iOS you'll also have to
  362. 13:47go to your phone settings expoo app and
  363. 13:50turn on the local network and also turn
  364. 13:53the VPN status off to not connect it
  365. 13:57this is necessary for Expo to connect
  366. 13:59properly then open up your phone camera
  367. 14:02point it at your QR code and click open
  368. 14:05in expoo but it seems like there's an
  369. 14:08error here it says too many open files
  370. 14:11error node Watcher broke and then it
  371. 14:14exited so we of course cannot test our
  372. 14:16application if we're no longer running
  373. 14:18the Expo server since it points to the
  374. 14:20node Watcher instance I think our node
  375. 14:23version might have something to do with
  376. 14:25this so let's just go to the node.js
  377. 14:27website and click download node.js
  378. 14:30LTS this is the long-term support
  379. 14:33version once it gets downloaded simply
  380. 14:35follow the steps to install it to check
  381. 14:38whether our newly installed version of
  382. 14:39node applied we can type node DV and
  383. 14:43unfortunately it's still using a newer
  384. 14:46experimental node version for me and for
  385. 14:48you it might be something else but maybe
  386. 14:50not the one that we just installed for
  387. 14:52that reason we can use a package called
  388. 14:54NVM that is a version manager for
  389. 14:57node.js there's a handy the GitHub repo
  390. 15:00that allows us to install it and update
  391. 15:02it with one script command you can use
  392. 15:04Curl on Mac OS or W get on windows so
  393. 15:09let's copy the command for your own
  394. 15:10operating system and paste it in the
  395. 15:13terminal it'll quickly install NVM and
  396. 15:15you need to close and reopen your
  397. 15:17terminal so let's close this one and
  398. 15:19reopen it to verify the installation you
  399. 15:21can run
  400. 15:23command-v MVM which should output MVM if
  401. 15:27the installation was successful and now
  402. 15:29you can install a specific version of
  403. 15:30node I believe the active version at the
  404. 15:32time of the recording of this video is
  405. 15:35version 2016 so we can say NVM install
  406. 15:39206 0 and press enter there we go and
  407. 15:43now we can type node DV to check your
  408. 15:46current node version now let's rerun mpm
  409. 15:49start to see whether now node Watcher
  410. 15:53will properly watch over our Expo
  411. 15:55application I'll scan the code one more
  412. 15:57time with my device
  413. 16:00and open in Expo go it seems like the
  414. 16:02application is building you can see that
  415. 16:04right here iOS has been bundled and we
  416. 16:07can see the welcome screen success so
  417. 16:10now we know that we might want to use
  418. 16:12these stable versions of node when
  419. 16:13running your Expo applications great but
  420. 16:16with that said I mean just just look at
  421. 16:18this we have successfully set up a react
  422. 16:20native application and right now I have
  423. 16:23my phone in my hand and I can swipe
  424. 16:26around move through different screens
  425. 16:28and even open up some toggles that tell
  426. 16:30me a bit more about the Expos
  427. 16:32functionalities we already have a
  428. 16:35working Expo application but of course
  429. 16:37today you will turn what you see on the
  430. 16:39screen right now and what you're holding
  431. 16:41in your hand into what I believe is one
  432. 16:44of the most popular mobile apps of all
  433. 16:47time Uber so let's continue with doing
  434. 16:51just that and since this will be a
  435. 16:53pretty big application you know that
  436. 16:55every big app needs to have a proper
  437. 16:58setup
  438. 16:59we need to ensure that the app is
  439. 17:01scalable and the code is readable so for
  440. 17:04that reason let's go ahead and set up a
  441. 17:06couple of things that will make our
  442. 17:08development experience so much better
  443. 17:10first we'll install native wind native
  444. 17:13wind is a react native version of
  445. 17:15Tailwind CSS that allows us to very
  446. 17:18quickly write Styles within our mobile
  447. 17:21applications so let's just head over to
  448. 17:23the Expo quick start and install native
  449. 17:26Wind by running mpm install native wind
  450. 17:29and then installing Tailwind CSS as well
  451. 17:32we can copy this command go back to
  452. 17:34webstorm and run this command now we can
  453. 17:37see that our terminal is currently
  454. 17:38running the expoo application so we can
  455. 17:41just open up a new one right here and
  456. 17:44paste these commands we can quickly head
  457. 17:46over to our package.json I used a
  458. 17:49command P shortcut to quickly open up my
  459. 17:53file manager and we can scroll down to
  460. 17:55dependencies and search for Tailwind CSS
  461. 17:57as a Dev dependency as well as a native
  462. 18:00wind installed right here as a regular
  463. 18:03dependency next we need to set up
  464. 18:05Tailwind CSS by running MPX tailin CSS
  465. 18:08in nit so let's open up the terminal and
  466. 18:10paste this command here by the way I
  467. 18:12want to point your attention to how
  468. 18:14webstorm terminal dynamically separates
  469. 18:18each command from each other so you know
  470. 18:20exactly what you're working on here we
  471. 18:22have the one that we just ran and Below
  472. 18:24we can run a new one there we go this
  473. 18:27just created a new file and it's asking
  474. 18:29us whether we want to automatically add
  475. 18:31it to G sure we can add it and now we
  476. 18:35can check out our new tailwind config.js
  477. 18:38and we can copy this code from the
  478. 18:40Native width installation and paste it
  479. 18:42right here but of course we'll have to
  480. 18:44modify it to make sure the content is
  481. 18:47all right there we go step three is to
  482. 18:50add the native wind Babble plugin under
  483. 18:52Babel config JS so let's navigate over
  484. 18:55to Babel config JS one more time I am
  485. 18:58using the command or control P to open
  486. 19:01up the file explorer which is the
  487. 19:03quickest way to move over the files but
  488. 19:05of course you can just open up the
  489. 19:06project by pressing the command shift
  490. 19:09and e or clicking right here and then
  491. 19:12finding the babble config now I will add
  492. 19:15the plugins native wind
  493. 19:18Babble and that's it we can start
  494. 19:20writing code before we test it out we
  495. 19:22need to do one more thing and that is
  496. 19:24make typescript work with our native
  497. 19:27wind so the only thing we have to do do
  498. 19:29is create a new native wind- env. D.S
  499. 19:33file in the root of our directory so we
  500. 19:36can do that right here by creating a new
  501. 19:39file and pasting this
  502. 19:41name and then we can add this reference
  503. 19:44right within it and now typescript will
  504. 19:46know exactly what we're doing with the
  505. 19:48styles to test it out we can copy this
  506. 19:50view right here from the example code
  507. 19:53and go to our app tabs and then index.
  508. 19:56TSX as you can see here right now it
  509. 19:59says welcome and all of this other text
  510. 20:01we don't necessarily need that we just
  511. 20:04need one single view to start
  512. 20:06understanding how we can modify the code
  513. 20:08that has been provided to us so I'll
  514. 20:10just use one single view by the way a
  515. 20:13view in react native is similar to a div
  516. 20:17in web development so let's import this
  517. 20:19view from react native at the top by
  518. 20:21saying import
  519. 20:24view as well as a text and a status bar
  520. 20:28for from react native and we don't need
  521. 20:31any of the other Imports we can also
  522. 20:33remove all the other styles that we had
  523. 20:35in there now to test whether it works we
  524. 20:38have to position our text to appear in
  525. 20:40the middle of the screen and in react
  526. 20:43native we do that with something called
  527. 20:45a safe area View and there's an
  528. 20:47additional package that we can install
  529. 20:49that provides that component right out
  530. 20:51of the box so we can run mpm
  531. 20:55install
  532. 20:56react-native DS safe - area- context and
  533. 21:01press
  534. 21:02enter as soon as it installs and it'll
  535. 21:05do so quickly because it's a very small
  536. 21:07package we can now import something
  537. 21:09known as a safe area view coming from
  538. 21:13react safe area context and instead of
  539. 21:16using the regular view we can wrap her
  540. 21:19app with a safe area view now you can
  541. 21:22see that the text fits nicely at the top
  542. 21:24of the screen now even though the text
  543. 21:26is in view the styles are still not
  544. 21:28getting applied and we can see that
  545. 21:30because the text should be centered but
  546. 21:32it's still appearing at the top so we
  547. 21:34can go over our Tailwind that config.js
  548. 21:37and we can quickly modify the content we
  549. 21:40need to tell it where what will be
  550. 21:41writing styles so that it starts
  551. 21:44understanding them so instead of a
  552. 21:46capital A for app we can say
  553. 21:49slapp slash asterisk asterisk meaning
  554. 21:52everything in those folders within the
  555. 21:54app SL asterisk Dot and then we have
  556. 21:58those files extensions and here instead
  557. 22:00of a custom directory we have to modify
  558. 22:02this to
  559. 22:04say/
  560. 22:07components SL asterisk asterisk SL
  561. 22:10asterisk and now if we go back you'll
  562. 22:13see that the text is centered we can
  563. 22:15also give it a class name equal to
  564. 22:18something like text- r-500 to see that
  565. 22:22it changes color now it is highly likely
  566. 22:25that this will not be working for you
  567. 22:27immediately there's just just one a bit
  568. 22:29of an annoying thing that we sometimes
  569. 22:31have to do with Expo applications
  570. 22:33whenever we make any big changes such as
  571. 22:36install native wind or any other major
  572. 22:38packages and that is clear the cach okay
  573. 22:42remember this clear cash if something
  574. 22:45doesn't work so for you what you can do
  575. 22:49is stop the serve from running clear it
  576. 22:51and then run MPX
  577. 22:54Expo
  578. 22:56start- C this run it with a cleared
  579. 23:00cache so if you rerun the project you
  580. 23:02can see it right here it says bundler
  581. 23:05cache is empty rebuilding and then you
  582. 23:07can press R while in terminal to reload
  583. 23:10your application after you do this I'm
  584. 23:13pretty positive that it should work and
  585. 23:16there we go our text is in the middle
  586. 23:19and we can say something like uber clone
  587. 23:22we're getting ready to start building it
  588. 23:24now Uber is a big application and as
  589. 23:27I've told you already when you're
  590. 23:29starting to develop big applications
  591. 23:31there is a bit of a setup work that you
  592. 23:32have to do to make sure that the rest of
  593. 23:35the building process flows smoothly and
  594. 23:38one of the things that is very important
  595. 23:39to set up in big projects is a linter in
  596. 23:43our case we'll use expo's recommended es
  597. 23:46length and preder configuration so let's
  598. 23:48just follow the steps we can run MPX
  599. 23:51Expo lint I'll do it in our second
  600. 23:54terminal not to disturb our application
  601. 23:56it's going to ask us a couple of
  602. 23:57questions such as says do you want to
  603. 23:59install eslint in this project and I'm
  604. 24:01going to say why for yes let's give it
  605. 24:03some time and I'll be right back there
  606. 24:05we go eslint has been configured we also
  607. 24:08need to install prettier so let's scroll
  608. 24:11down and I think somewhere here we can
  609. 24:12see the installation command so let's
  610. 24:15copy it and paste it in the terminal
  611. 24:18that was simple and now we have to
  612. 24:20update our eslint RC file with the
  613. 24:23following code so let's head over to
  614. 24:26eslint rc. Js and paste this code right
  615. 24:30in now eslint and prier will be watching
  616. 24:33over our changes and make sure that we
  617. 24:35write quality code in webstorm there's
  618. 24:38one additional thing that we have to do
  619. 24:39to properly set up eslint so press
  620. 24:42command shift b or control shift B and
  621. 24:45type eslint open up its preferences and
  622. 24:49head over to manual es lint
  623. 24:51configuration click on this Arrow right
  624. 24:54here and then choose the es lint for our
  625. 24:56specific Uber project and select run es
  626. 24:59lint fix on Save click apply and also
  627. 25:03head to tools actions on Save and make
  628. 25:06sure that it is turned on we can repeat
  629. 25:09the same thing with prier by going to
  630. 25:11settings manual preder configuration and
  631. 25:13then choosing our own config right here
  632. 25:16and run on Save apply and okay that's it
  633. 25:20you can see how immediately pretty a
  634. 25:22changes our configuration to be easier
  635. 25:25on the eyes and it works so seamlessly
  636. 25:27with storm and if you're using some
  637. 25:29other code editor here's the settings
  638. 25:31that Json file which you can put in
  639. 25:33there to also make it work there the
  640. 25:35code available to copy is in the GitHub
  641. 25:37readme linked below and now that we have
  642. 25:39linting set up let's customize webstorm
  643. 25:42even further to make it truly our own
  644. 25:45I'm going to press command shift b or
  645. 25:47control shift B on Windows and I'll go
  646. 25:50ahead and change the theme you can
  647. 25:51scroll down and go to get more themes
  648. 25:54and many of you have been asking me what
  649. 25:56theme do I use and now I can finally
  650. 25:59tell you it's going to be a cat pin
  651. 26:02theme you can type it like this and you
  652. 26:05can just go to search in the marketplace
  653. 26:07it's spelled with a double p and Double
  654. 26:09C you can install it and once you do you
  655. 26:12can go to theme and change it to kuchin
  656. 26:16and then choose the flavor you prefer
  657. 26:18macchiato or
  658. 26:20mocha once you have that I'm going to
  659. 26:22also do another thing and that is change
  660. 26:24the font family so you can search for
  661. 26:27font
  662. 26:28go to preferences and then go to General
  663. 26:31editor settings font and here I chose F
  664. 26:35code this is the font that I've been
  665. 26:37using for a long time you can also
  666. 26:39choose that one and you can install it
  667. 26:41by simply downloading the font to your
  668. 26:43device another thing I want to focus on
  669. 26:45is to turn on something called Soft wrap
  670. 26:49so go to configure soft wraps make sure
  671. 26:52to add the asterisk.svg
  672. 26:58so that it wraps for those files and
  673. 27:00turn off the used the original line
  674. 27:02indent for wrap fragments that's going
  675. 27:05to allow us to WRA specific files it
  676. 27:08should look something like this so that
  677. 27:10once the text goes beyond the line you
  678. 27:13can still see it on the screen right
  679. 27:14here to make it easier for you to follow
  680. 27:16what I'm doing and another thing we can
  681. 27:18do is install a material theme for our
  682. 27:21icons and folders to make them look just
  683. 27:24a bit better so once again command shift
  684. 27:26p search for
  685. 27:29plugins go to Marketplace and search for
  686. 27:32icons you can choose the atom material
  687. 27:35icons or anything else that you prefer
  688. 27:38in this case I'll go with adom click
  689. 27:40install apply and okay and we do need to
  690. 27:44restart our IDE for the changes to be
  691. 27:46applied once you're restarted you can
  692. 27:48notice that now all of the folders have
  693. 27:50their corresponding icons which makes it
  694. 27:53look so much better also you can see
  695. 27:55that the colors change for some of the
  696. 27:57icons on the side for now what I want to
  697. 27:59do is clean up this environment a bit so
  698. 28:02we can just hide some of the things
  699. 28:04right here that we don't need to create
  700. 28:06a bit more space for us we can customize
  701. 28:08the toolbar remove the part from the
  702. 28:10center and also remove some of the parts
  703. 28:13from the right as we don't necessarily
  704. 28:14need to play with a toolbar play with a
  705. 28:17code with me we don't need anything on
  706. 28:19the right so I will remove that as well
  707. 28:21and this will clean it up just a bit you
  708. 28:23can do the same thing for the things at
  709. 28:24the bottom that you don't necessarily
  710. 28:26need and there we go I went went ahead
  711. 28:28and I hided some of the things from the
  712. 28:30screen now we have a cleaner working
  713. 28:33environment with that said we can now
  714. 28:35proceed with cleaning up our file and
  715. 28:37folder structure now that we can see it
  716. 28:39a bit clearer when we initially set up
  717. 28:41our react native export application it
  718. 28:43came with a lot of different things the
  719. 28:46file and folder structure already set up
  720. 28:48two different pages there's a lot of
  721. 28:50stuff that we don't necessarily need and
  722. 28:53that will just complicate your
  723. 28:55understanding of our react native
  724. 28:56application so I want to make sure to
  725. 28:58take a second to delete all of the
  726. 29:00things that we don't need to focus on
  727. 29:02creating everything from
  728. 29:05scratch right now our application is not
  729. 29:07running and maybe for the better that's
  730. 29:10because we are going to do a whole
  731. 29:12cleanup and then we're going to run it
  732. 29:13together later on so first things first
  733. 29:16let's delete the things that we don't
  734. 29:17need I'll begin with deleting the tabs
  735. 29:20route Group by simply clicking delete or
  736. 29:23pressing the backspace key and pressing
  737. 29:26delete next I'll delete the hooks folder
  738. 29:28as we don't need it I'll also delete the
  739. 29:30constants folder and the components
  740. 29:32folder as well as the assets folder so
  741. 29:35we're going to clean our entire
  742. 29:37application up we only have our HTML
  743. 29:40index DSX and you might be wondering
  744. 29:42what is this HTML file well Expo allows
  745. 29:45you to run your applications in the
  746. 29:47browser as well but that's not what we
  747. 29:49need to be concerned with at this point
  748. 29:50in time there's also a 404 page that can
  749. 29:54show up if we are on a not found screen
  750. 29:57but again not something that is super
  751. 29:59important right now what we do want to
  752. 30:01focus on instead is the layout. TSX file
  753. 30:06we want to update it a bit to suit our
  754. 30:08very minimalistic app right now that
  755. 30:10doesn't have any additional files inside
  756. 30:12of here you'll notice we have a theme
  757. 30:14provider for now I will go ahead and
  758. 30:16delete it and the only thing we'll have
  759. 30:18is the stack a stack of different
  760. 30:21screens the name of her first screen
  761. 30:24will be just index it's her home and
  762. 30:27under options will run Heather shown as
  763. 30:29false we also have a screen for the not
  764. 30:33found and this is the only thing we want
  765. 30:34to have for now just an empty screen
  766. 30:37next we can create that index screen
  767. 30:40right here in the root of our directory
  768. 30:42so let's go to app and let's create a
  769. 30:45new file called index. TSX within it we
  770. 30:49can create a new homepage by saying
  771. 30:51const home is equal to and we're going
  772. 30:54to create a new Arrow function component
  773. 30:57and let's not forget to to export
  774. 30:59default that home component at the
  775. 31:01bottom within it we can return something
  776. 31:04within it we can import a view which is
  777. 31:07going to come from react
  778. 31:10native and we can show a text also
  779. 31:14coming from react native and it can say
  780. 31:17something like home for now you can
  781. 31:19notice that webstorm sometimes adds
  782. 31:21these additional inlay hints that allow
  783. 31:24us to see where we're using specific
  784. 31:26instances of our code
  785. 31:28um they're going to be super useful
  786. 31:30later on when they tell you more
  787. 31:32information about different parameters
  788. 31:34within the functions but in this case I
  789. 31:36don't need them to show the usages I can
  790. 31:38hide code Vision usages in line hence
  791. 31:41not all and this is just going to
  792. 31:42provide us with a bit of a cleaner
  793. 31:44working environment now is the time that
  794. 31:47we reopen our terminal and rerun mpm
  795. 31:51start just to see if our application
  796. 31:53still works after making all of those
  797. 31:55changes we can press R to reload our
  798. 31:59application and you'll see that we have
  799. 32:01an issue in our not found. TSX which
  800. 32:04makes sense because we change so many
  801. 32:06things I pressed command P or control P
  802. 32:09to open up the file search and if I
  803. 32:12start typing you can very quickly just
  804. 32:14press enter and navigate to that
  805. 32:16different file here you can see that we
  806. 32:18used two different components which we
  807. 32:21no longer have so we can just remove
  808. 32:23their Imports and we can also just
  809. 32:26instead of a themed view just say view
  810. 32:28coming from react native and instead of
  811. 32:31theme text we can just say text coming
  812. 32:33from react native as
  813. 32:36well there we go if we save it we should
  814. 32:39have no more issues with the code but
  815. 32:43our app still doesn't seem to be there
  816. 32:45well that's because this view doesn't
  817. 32:47have any Styles and most likely the text
  818. 32:49is being pushed above our application so
  819. 32:52we can use a safe area
  820. 32:55view coming from react native or in this
  821. 32:58case we have a special package react
  822. 33:00native safe area context as well but
  823. 33:03it's still not showing so if I open up
  824. 33:06my terminal we can see that the iOS
  825. 33:07bundling failed and it's still
  826. 33:09complaining about the components themed
  827. 33:11text even though we deleted it from the
  828. 33:13not found screen so what we can do is
  829. 33:16press R once again to reload our
  830. 33:18application once
  831. 33:19more now it's complaining about hooks
  832. 33:22use color scheme from App layout so we
  833. 33:25can go within it we can remove
  834. 33:27everything that we're no longer using
  835. 33:28just to simplify it alongside the used
  836. 33:31color context and we can also remove
  837. 33:33this color scheme from here and if we
  838. 33:36scroll down we can see that the stack
  839. 33:38screen is okay and we're not using
  840. 33:40anything regarding what we just deleted
  841. 33:42so I think we're good now I'll just
  842. 33:44reload one more time and now it's
  843. 33:47complaining about a splash screen okay
  844. 33:50in the app that config.js because we
  845. 33:52removed our assets this is completely
  846. 33:54normal we removed a lot of code so we
  847. 33:56have to make sure that it all
  848. 33:58works so in this case I'll provide you
  849. 34:02with the full assets for this entire
  850. 34:04project in the description down below
  851. 34:06you can find an Uber repository with the
  852. 34:09entire codebase for this project but
  853. 34:12what's even more important is that right
  854. 34:14there you can find the entire readme for
  855. 34:17this project and one of the things in
  856. 34:19the readme are the Snippets and the
  857. 34:21Assets in this case you can download the
  858. 34:24assets for this project this includes
  859. 34:26the illustrations the the icons and all
  860. 34:29the little images that we'll be showing
  861. 34:30on the app to make the development of
  862. 34:32our app easier so let's click here and
  863. 34:36you can just press the download button
  864. 34:38once you download them simply unzip them
  865. 34:40and then drag and drop them to the
  866. 34:42folder where you have your app for us
  867. 34:44it's on desktop and it's within the Uber
  868. 34:46clone so now if we go here you can see
  869. 34:49the full assets of our application
  870. 34:51webstorm also ask me whether I want to
  871. 34:53add it to G so we can say sure and here
  872. 34:56we have all of the IM
  873. 34:58so that means that now we can go to the
  874. 35:00app. Json and we can modify some
  875. 35:04important information about our app for
  876. 35:06example we can choose the name as Uber
  877. 35:09with a capital u and a slug of uber here
  878. 35:13it's taking the icon directly from the
  879. 35:15assets images icon.png and it's taking a
  880. 35:18splash screen directly from our assets
  881. 35:21as well we can leave the rest as it is
  882. 35:24now if we try to reload our application
  883. 35:26once more you you can see that a new
  884. 35:28splash screen that says ride appears
  885. 35:31right here so if we reload it once more
  886. 35:33you can see how nice it looks like a
  887. 35:35splash screen on mobile devices is a
  888. 35:37screen that appears before your
  889. 35:39application loads it gives the user
  890. 35:41something to look at while it's loading
  891. 35:43now we have issues with the fonts
  892. 35:45because we won't be using the regular
  893. 35:47space mono font rather we'll be using a
  894. 35:50different one we'll be using plus
  895. 35:52Jakarta Sans so we can head over to our
  896. 35:56app and then head over over to layout.
  897. 35:58TSX to modify the fonts we're
  898. 36:01using these fonts just need to be copied
  899. 36:04and you can find them under the Snippets
  900. 36:06in this GitHub repo you can find root
  901. 36:08layout fonts copy this block of code go
  902. 36:12back here and then simply paste them
  903. 36:14I'll Zoom this out a bit so you can see
  904. 36:16it better make sure that it is formatted
  905. 36:19well I believe it already should be for
  906. 36:21you if you still see some issues in your
  907. 36:23terminal you might want to press contrl
  908. 36:26C to exit and then you can run mpm start
  909. 36:29once again and then it should build it
  910. 36:31properly after pressing the r key on
  911. 36:34your keyboard you can see the splash
  912. 36:35screen while it's loading and then after
  913. 36:37that you can just see the home and that
  914. 36:40home is exactly what we have crafted in
  915. 36:42our index. TSX so this is perfect now we
  916. 36:47have a structure that we're starting to
  917. 36:50understand we have an app where we have
  918. 36:52a not found page we have a layout and an
  919. 36:54index and we have also learned how to
  920. 36:57add a splash screen to our react
  921. 36:59application through app. Json it is as
  922. 37:03simple as pointing to an image that you
  923. 37:05want to show so let me show you it's
  924. 37:07assets images Splash if we go to assets
  925. 37:10images and then splash this image is
  926. 37:14right here perfect with that in mind we
  927. 37:17are ready to set up the styling for our
  928. 37:19application that we'll use throughout
  929. 37:21this project we can start by navigating
  930. 37:24over to Tailwind doc config.js
  931. 37:28in that same GitHub repo you can find
  932. 37:30the modified Tailwind config JS that
  933. 37:32extends all of these fonts and ensures
  934. 37:35we can very easily use them so just
  935. 37:37override the existing tailin config
  936. 37:40you'll notice that here we also import
  937. 37:43some of the different variants of colors
  938. 37:45such as primary secondary success danger
  939. 37:48and warning so that we can use them
  940. 37:50within our application nothing more
  941. 37:53nothing less so what do you say with all
  942. 37:55of that setup out of the way our you're
  943. 37:57ready to start creating the onboarding
  944. 37:59screens of our application finally some
  945. 38:02real code right we already have this
  946. 38:04splash screen and now we're starting
  947. 38:06with the first out of three onboarding
  948. 38:08screens and I would highly recommend
  949. 38:10that you replicate this figma design as
  950. 38:12well the link is going to be down in the
  951. 38:13description you can easily get it and
  952. 38:16that way at every point in time you will
  953. 38:18know exactly what we're building so get
  954. 38:21that figma design and let's start by
  955. 38:22creating our first onboarding screen
  956. 38:25within the app folder we'll create a new
  957. 38:28route Group by creating a new directory
  958. 38:32and I'll call it rout within parentheses
  959. 38:36like this within the root we'll create a
  960. 38:39new underscore layout yes each route
  961. 38:43group will have its own layout depending
  962. 38:45on what is it showing on the screen
  963. 38:48because our onboarding screens won't
  964. 38:49have the Bottom bar which means that we
  965. 38:51have to have a separate layout from the
  966. 38:53rest of the screens then within the root
  967. 38:56we can create another another directory
  968. 38:58which will be called tabs so these are
  969. 39:01the tabs that we can switch between and
  970. 39:03here we're going to have some of the
  971. 39:05primary pages of our application it'll
  972. 39:08also have its own uncore layout. DSX and
  973. 39:12it'll have a few other files such as the
  974. 39:15homepage the profile and more so what do
  975. 39:18you say that we create them right away
  976. 39:19by creating like a home. TSX file and
  977. 39:23within it we can just create a simple
  978. 39:26react a function component const home is
  979. 39:30equal to basically an aror function
  980. 39:33component that returns a view with a
  981. 39:35text we already have that right it is
  982. 39:37currently within the primary index. TSX
  983. 39:40so let's copy it and paste it into home
  984. 39:43we can now copy this and create a few
  985. 39:45other files as well within the tabs
  986. 39:48folder it'll be a new profile. TSX where
  987. 39:52we can paste everything we have here and
  988. 39:55rename home to profile we can do the
  989. 39:58same thing for chat.
  990. 40:01TSX and rename it to chat and we can do
  991. 40:05the same thing for history so this is
  992. 40:07going to be a history of a r that we
  993. 40:10have history. DSX we can paste it and
  994. 40:15call it history I think we can rename it
  995. 40:18to something like rides it would make a
  996. 40:20bit more sense so let's just do rides.
  997. 40:24TSX and there we go it automatically
  998. 40:28renamed it here as well perfect so now
  999. 40:31we can start seeing how our application
  1000. 40:33will look like and it's very important
  1001. 40:35to mention here that what you're seeing
  1002. 40:37right now is Expo router it is a file
  1003. 40:41based router for react native
  1004. 40:43applications allowing you to manage the
  1005. 40:45navigation between the screens in your
  1006. 40:47application so you can move seamlessly
  1007. 40:49between different parts of your apps UI
  1008. 40:52using the same components on multiple
  1009. 40:53platforms what I love about it is that
  1010. 40:56it's using the same file based routing
  1011. 40:58concept from web specifically nextjs so
  1012. 41:02if you've done some nextjs apps it's
  1013. 41:04going to feel like home so how exactly
  1014. 41:06does it work well Expo router uses links
  1015. 41:09to move between pages in the app it's
  1016. 41:12similar to an anchor tag or href
  1017. 41:14attribute or you have an app you have an
  1018. 41:16index page about page and you can have
  1019. 41:18subpages or even Dynamic pages and then
  1020. 41:21you can use links to move to different
  1021. 41:23pages or use buttons we can also use the
  1022. 41:26navigate functionality which behaves
  1023. 41:28similarly to modifying the URL in the
  1024. 41:30browser and the primary way of
  1025. 41:32navigating in Expo applications is the
  1026. 41:34stack Navigator it is like a navigation
  1027. 41:37bar in the browser you first need to
  1028. 41:39create a file-based routing structure
  1029. 41:42like with an app a layout and then some
  1030. 41:44additional routes and then in the layout
  1031. 41:47you can create something known as a
  1032. 41:49stack a stack of screens each screen can
  1033. 41:53decide to show or hide the header Styles
  1034. 41:56can have different colors and more and
  1035. 41:58then you can configure how do you get to
  1036. 42:00each one of these screens by giving them
  1037. 42:03a name so let's create a stack of our
  1038. 42:05own we use the stack to modify how a
  1039. 42:08specific route behaves so if we go right
  1040. 42:11here to our root layout you can see that
  1041. 42:13we have this index route which is our
  1042. 42:15homepage and there we have added an
  1043. 42:18option of header shown to false if we
  1044. 42:20remove that option you'll be able to see
  1045. 42:22the name of the route which typically
  1046. 42:24you don't want to show so that's the
  1047. 42:27reason why we have to add all of these
  1048. 42:28stack screens only so we can add options
  1049. 42:31header shown is set to false and we're
  1050. 42:34going to repeat this process for all the
  1051. 42:36other routes and Route groups so we're
  1052. 42:39going to do the same for the root so
  1053. 42:42that's the root route group Heather
  1054. 42:44shown false and we're going to do the
  1055. 42:46same for o this is a second group of
  1056. 42:49routes which will'll show so let's go
  1057. 42:51here and next to root which is going to
  1058. 42:54be the primary part of our application
  1059. 42:56where we're going to have all the routes
  1060. 42:57we're going to have something that
  1061. 42:58happens before we enter the main
  1062. 43:01application which is the onboarding and
  1063. 43:03the off so let's create a new directory
  1064. 43:06called off in parenthesis there we can
  1065. 43:09also create a newor layout. TSX and
  1066. 43:13within it we can duplicate the main
  1067. 43:15layout we have right now but we'll
  1068. 43:18remove some of the things regarding the
  1069. 43:19fonts we're loading the fonts once we
  1070. 43:22don't need to load them anymore so it's
  1071. 43:24going to be much much simpler it's going
  1072. 43:26to look something like this import stack
  1073. 43:29from Expo router then we can declare a
  1074. 43:32layout and a simpler way to do it is
  1075. 43:34const
  1076. 43:36layout is equal to an arrow
  1077. 43:39function and then we can just export
  1078. 43:41default it at the bottom by saying
  1079. 43:43export default
  1080. 43:45layout and here we have different stacks
  1081. 43:47of screens for that route group so no
  1082. 43:50longer do we have to have the index or
  1083. 43:52the root or the KN found rather we're
  1084. 43:55just going to have the welcome which is
  1085. 43:57going to be the primary screen and then
  1086. 43:59we're going to have sign up and finally
  1087. 44:02we're going to have the sign in and we
  1088. 44:04want to hide the headers in all
  1089. 44:06places so that means that we have to
  1090. 44:08create these additional off Pages such
  1091. 44:11as welcome sign in and sign up let's
  1092. 44:15create all three I'll create a new file
  1093. 44:18called
  1094. 44:19sign-in. TSX and within it we can paste
  1095. 44:23just the basic component which we
  1096. 44:24created in our index. TSX so that's just
  1097. 44:27going to be a basic view safe area view
  1098. 44:31with a text that's going to say sign in
  1099. 44:34we can duplicate that once more by
  1100. 44:36creating a second file in the oth group
  1101. 44:40which is going to be called sign Dash
  1102. 44:43up. DSX and we can rename that to sign
  1103. 44:47up we can also rename the actual
  1104. 44:50component name sign up single word and
  1105. 44:54we can do the same thing for the sign in
  1106. 44:56since I forgot to do it there sign in
  1107. 45:00and finally we need to create one last
  1108. 45:03off page which is going to be the first
  1109. 45:05one we'll start to work on and that is
  1110. 45:07the welcome onboarding so welcome. TSX
  1111. 45:10where we can paste it and say
  1112. 45:14onboarding great so now the question is
  1113. 45:17how can we navigate to this page right
  1114. 45:19here right now our app is saying home
  1115. 45:22because we have this index. TSX that is
  1116. 45:25rendering the home well in here will do
  1117. 45:27a simple redirect in case we're logged
  1118. 45:30in so the return will do only one thing
  1119. 45:33and that's going to be call to a
  1120. 45:36redirect
  1121. 45:37component coming from Expo router with
  1122. 45:40an hre of forward slash route group of O
  1123. 45:45SL welcome now as soon as somebody opens
  1124. 45:48up the application we'll be redirected
  1125. 45:50to oops the screen doesn't exist okay we
  1126. 45:53know that at least the 404 is working as
  1127. 45:57well let me do a Reload by pressing R
  1128. 45:59right here and you can see that now it
  1129. 46:01worked sometimes while developing react
  1130. 46:03native applications you'll have to
  1131. 46:06reload your application often and now we
  1132. 46:08are on the onboarding screen we also
  1133. 46:11have a warning right here at the bottom
  1134. 46:12but you can just collapse it to close it
  1135. 46:14right now we can close all of the
  1136. 46:16currently open files and just head over
  1137. 46:19to our welcome screen which is really an
  1138. 46:22onboarding and the pages for the
  1139. 46:24onboarding are going to look like this
  1140. 46:26it's going to be a three page or
  1141. 46:28three-step onboarding process where
  1142. 46:31we'll have some nice illustration a
  1143. 46:33title description tabs that move as we
  1144. 46:36move to the second screen and then the
  1145. 46:38button that says next so let's get
  1146. 46:41started with creating our first real
  1147. 46:43piece of user interface in a large react
  1148. 46:46native application there's one small
  1149. 46:48thing that I can see here and that is
  1150. 46:50that we have one week warning pointed
  1151. 46:52out by our webstorm in this case this is
  1152. 46:54not a real warning because if you think
  1153. 46:57about it it says unused default export
  1154. 47:00but we're actually using a file based
  1155. 47:02routing system so we never actually have
  1156. 47:04to import the onboarding it is just
  1157. 47:06being used by default once we go to that
  1158. 47:09page so to hide this error you can press
  1159. 47:12command or control shift B and type
  1160. 47:15inspections and then search for unused
  1161. 47:18Global symbol and tick it off click okay
  1162. 47:21and then close and reopen your webstorm
  1163. 47:24if you do that you can run mpm start one
  1164. 47:26more time
  1165. 47:27and the error will be gone great another
  1166. 47:30thing you can do to clean up your
  1167. 47:31workspace is go to toolbar and then
  1168. 47:34toggle it off um I don't think I need
  1169. 47:36all that info at the top and this just
  1170. 47:38makes it so much easier for you to
  1171. 47:40follow along and with that in mind we
  1172. 47:42can now dive right into the onboarding
  1173. 47:45I'll press R to bundle our app one more
  1174. 47:47time so press this warning and we can
  1175. 47:50get started everything is already
  1176. 47:52wrapped in a safe area view coming from
  1177. 47:54react native safe area context which is
  1178. 47:57why we can see the onboarding text right
  1179. 47:59within our screen next we can give our
  1180. 48:01safier view some class names such as a
  1181. 48:04class name is equal to flex h- full to
  1182. 48:08give it a full height items D Center
  1183. 48:11justifi Das between and BG - white so
  1184. 48:16now this will Center the text
  1185. 48:17horizontally next instead of this text
  1186. 48:20right within the safe area view we'll
  1187. 48:22create our first touchable opacity and
  1188. 48:26we'll UT Ed from react native in the
  1189. 48:29react native or mobile World a touchable
  1190. 48:32opacity is basically just a button you
  1191. 48:35know how on web you have a button here
  1192. 48:38on mobile you have a touchable opacity
  1193. 48:41within which we will render a text
  1194. 48:43coming from react native and this text
  1195. 48:46will say something like skip so in case
  1196. 48:48we want to skip this on boarding we can
  1197. 48:51do that what's going to happen if we
  1198. 48:53decide to skip it well instead of
  1199. 48:55onclick here we have an onpress activity
  1200. 48:59and on press we can call a callback
  1201. 49:02function and say something like router.
  1202. 49:05replace and we want to go over to for SL
  1203. 49:10off SL
  1204. 49:12sign-up just like this and this router
  1205. 49:16will be coming from Expo router so we
  1206. 49:18can say import router coming from Expo
  1207. 49:22router great now we can also give a
  1208. 49:26class name to this touchable opacity and
  1209. 49:28that's going to be a w full so full
  1210. 49:31width Flex justify Dash and items Dash
  1211. 49:36end in the padding of five so we show it
  1212. 49:40a little button at the top right we can
  1213. 49:42also style this text element by giving
  1214. 49:45it a class name which is equal to let's
  1215. 49:49do um text- Black text- MD for medium
  1216. 49:54and font D Jakarta bold so this is one
  1217. 49:57of the fonts that we imported it didn't
  1218. 50:00seem to apply the Bold style so I think
  1219. 50:02we should use the capital J there we go
  1220. 50:04Jakarta bold this now works great now
  1221. 50:08let's go below this touchable opacity
  1222. 50:10and let's create a component that allows
  1223. 50:12us to swipe left and right like we're in
  1224. 50:15Tinder but we're not swiping different
  1225. 50:17dates we're swiping the onboarding cards
  1226. 50:21almost as exciting right so for that
  1227. 50:23we'll install a new component in the new
  1228. 50:27terminal mpm install
  1229. 50:29react-native D
  1230. 50:31swiper and we can use it right below the
  1231. 50:34touchable opacity by saying swiper and
  1232. 50:37we can import it at the top by saying
  1233. 50:39import swiper coming from
  1234. 50:43react-native D swiper currently this
  1235. 50:46will break our application because
  1236. 50:47swiper expects to have some things
  1237. 50:49within it so let's add it first of all
  1238. 50:53we have to create a new reference to
  1239. 50:55this swiper so so that we can control it
  1240. 50:58we can do that by saying con swiper ref
  1241. 51:01is equal to use ref of a type swiper and
  1242. 51:06at the start it can be set to null next
  1243. 51:09we can just say ref is equal to swiper
  1244. 51:12ref on this swiper we can also give it a
  1245. 51:16couple of other properties such as a
  1246. 51:18loop in this case we don't want to Loop
  1247. 51:21over the swiper we just want it to come
  1248. 51:23to the end after the three so we'll set
  1249. 51:25the loop property to false it also
  1250. 51:28allows us to change how the dots look
  1251. 51:30like uh so the dot for the first swipe
  1252. 51:33second and the third so we can say dot
  1253. 51:35is equal to a view which remember is a
  1254. 51:39div in a mobile world and we can make it
  1255. 51:41self closing and give it a class name
  1256. 51:46equal to w-32 pixels within square
  1257. 51:49brackets h-4 pixels margin X of one and
  1258. 51:55BG of a very light variant of a white
  1259. 51:59color so that's going to be E2 E8 F0 and
  1260. 52:03we of course have to import the view
  1261. 52:06from react native and we also have to
  1262. 52:08import use ref inside of square brackets
  1263. 52:12from react now this is a very cool thing
  1264. 52:15about webstorm as soon as we imported
  1265. 52:17this use ref we no longer have to hover
  1266. 52:19over it to see what it does you can see
  1267. 52:22that it understood that this n that we
  1268. 52:24passed is a property that that specifies
  1269. 52:27the initial value similar thing here it
  1270. 52:30recognized that the first prop or the
  1271. 52:32first parameter to this function that
  1272. 52:33we're passing is corresponding to an hre
  1273. 52:37property so now as you're typing you can
  1274. 52:39immediately know what you need to pass
  1275. 52:41in it sure you could hover over it and
  1276. 52:43see what it is but it is so convenient
  1277. 52:45to just start typing something and then
  1278. 52:48immediately know that that's
  1279. 52:49corresponding to an hre in that specific
  1280. 52:52method great so now we created this
  1281. 52:54swiper and explained how a DOT should
  1282. 52:56look like we can also duplicate this Dot
  1283. 52:59and change it to an active dot so
  1284. 53:03depending on which screen we're
  1285. 53:04currently on and here we're going to
  1286. 53:06change the BG color to something like
  1287. 53:11028 6 FF and we're going to make it
  1288. 53:15rounded by saying rounded Das full as a
  1289. 53:18matter of fact we can do that for the
  1290. 53:20dot regular dot as well great and
  1291. 53:23somehow we have to keep track of the
  1292. 53:25indexes that we're switching from and to
  1293. 53:28so we can create a new use State call it
  1294. 53:32active index set active index at the
  1295. 53:35start set to zero and then we can handle
  1296. 53:38that with the on index changed property
  1297. 53:41which will accept a callback function
  1298. 53:43with the new index and we can simply set
  1299. 53:45active index to be equal to the index
  1300. 53:48that we have right here finally we can
  1301. 53:50show something within that swiper and
  1302. 53:52sure what you could do is create an
  1303. 53:54array of things right here that's going
  1304. 53:56to have different objects where each
  1305. 53:59object will have something like a title
  1306. 54:02it'll have an image and description and
  1307. 54:04if you did this quickly your jsx file or
  1308. 54:08in this case TSX would grew and then you
  1309. 54:10would have to map over them but
  1310. 54:12typically you don't want to combine the
  1311. 54:15presentation which is the jsx or the TSX
  1312. 54:17in this case with the data so the data
  1313. 54:20of what we will be showing so for that
  1314. 54:23reason it's always good to separate some
  1315. 54:25of these pieces
  1316. 54:26in specialized files in this case I'll
  1317. 54:29create a new directory or folder called
  1318. 54:33constants and within it I'll create a
  1319. 54:36new file called
  1320. 54:39index.ts here we can create a new
  1321. 54:41onboarding array which will contain
  1322. 54:44three different objects for three
  1323. 54:46different screens that we have each one
  1324. 54:48will have an ID it'll also have a title
  1325. 54:51something like the perfect ride is just
  1326. 54:55a tab
  1327. 54:57away and we can also have a
  1328. 55:00description something like the
  1329. 55:03Journey Begins With
  1330. 55:08ride and we need an image to show so for
  1331. 55:11now I'll leave image to null and now we
  1332. 55:13can do the same thing for all of the
  1333. 55:15other onboarding fields and of course
  1334. 55:17let's just export this as well by saying
  1335. 55:19export con onboarding now within here we
  1336. 55:22can use this onboarding coming from the
  1337. 55:24index. DSX file and map over it by
  1338. 55:27saying map where we get each individual
  1339. 55:30item and for each one of those items we
  1340. 55:32want to render a new view for now let's
  1341. 55:36simply show the item. tile and it's
  1342. 55:39pretty cool how it immediately knows how
  1343. 55:41these properties look like so we can
  1344. 55:44just say this and it's not showing on
  1345. 55:46the screen right now and that's because
  1346. 55:49we cannot just showed a text inside of a
  1347. 55:51view in react native in react native you
  1348. 55:54have to wrap it in a text prop prop y so
  1349. 55:56let's import text from react native and
  1350. 55:59also close it up with a text property if
  1351. 56:02we save this you can see the perfect
  1352. 56:04ride is just a tap away and soon enough
  1353. 56:07we'll be able to swipe that left and
  1354. 56:09right to move to the next screen and if
  1355. 56:11you accidentally go to sign up you can
  1356. 56:13just press R to reload and rebundle the
  1357. 56:16application great now alongside this we
  1358. 56:19want to show an image from figma and
  1359. 56:21sure you could go here and download it
  1360. 56:24but thankfully we already have it in the
  1361. 56:26app assets so the only thing you have to
  1362. 56:27do here in the constants is refer to
  1363. 56:31images. onboarding one but of course we
  1364. 56:34have to have the path to that image so
  1365. 56:37we'll have to do something like import
  1366. 56:40onboarding
  1367. 56:41one from add SL assets SL images SL
  1368. 56:48onboarding
  1369. 56:49one.png and now we'll have this
  1370. 56:51onboarding one image that we can show
  1371. 56:54but we'll have to do this for import
  1372. 56:56recoring every single image every single
  1373. 56:58icon and everything else so for that
  1374. 57:01reason just to simplify the procedure a
  1375. 57:03bit more I have added the entire
  1376. 57:05constants index.ts where I'm simply
  1377. 57:08importing all of those images and then
  1378. 57:11exporting them where we need them that
  1379. 57:13way it's going to be much simpler to
  1380. 57:15just continue with development when our
  1381. 57:17data is nicely structured and we can
  1382. 57:19easily import it so copy this file and
  1383. 57:22then override the entire index.ts of
  1384. 57:25constants
  1385. 57:27you'll notice that here we have the
  1386. 57:28entire on boarding we have some icons
  1387. 57:31and we have all of these assets it's
  1388. 57:33currently saying that it cannot find the
  1389. 57:35type declarations for these things so we
  1390. 57:37have to add the type declarations for
  1391. 57:39these images just so that it recognizes
  1392. 57:42it so copy this first file and create a
  1393. 57:46new types type D.S that's going to be in
  1394. 57:49the root of the
  1395. 57:50directory new folder called
  1396. 57:54types and then within it we can create a
  1397. 57:57new file called type.
  1398. 58:02D.S and we need another one which is
  1399. 58:04type image. D.S where we can paste this
  1400. 58:09so create a new file image. D.S and
  1401. 58:13paste the Declarations for the images
  1402. 58:16now if we go back it's no longer
  1403. 58:18complaining great and now if you just
  1404. 58:20reload one more time you can still see
  1405. 58:22the perfect ride is just a type away but
  1406. 58:25now you can move move between different
  1407. 58:27onboarding profiles that is perfect and
  1408. 58:31of course if you want to you can
  1409. 58:32completely change the titles for each
  1410. 58:34one for now just the images are changing
  1411. 58:37which is great so let's show that image
  1412. 58:40so we can actually see the difference
  1413. 58:42and swipe between these three different
  1414. 58:44screens to this view I'll provide a
  1415. 58:48class name equal to flex items D Center
  1416. 58:52justify Das Center and the padding of
  1417. 58:55five
  1418. 58:56since we're mapping over it I'll also
  1419. 58:58give it a key equal to item. ID and
  1420. 59:01right within the view above the text
  1421. 59:03we'll render an image coming from react
  1422. 59:07native it'll be a self-closing component
  1423. 59:10with a source equal to item. image so
  1424. 59:14it's coming from constants a class name
  1425. 59:17equal to
  1426. 59:18w-o and
  1427. 59:20h-300 pixels and we'll also give it a
  1428. 59:22resize mode equal to contain so now you
  1429. 59:27can see how we have this nice looking
  1430. 59:28image and we can swipe between these
  1431. 59:30three images this is super cool because
  1432. 59:33swiping is not something you can do on
  1433. 59:35desktop devices but in Mobile It Feels
  1434. 59:38So natural to move it with your finger
  1435. 59:41right below this image we can render a
  1436. 59:44view once again it's like a div in react
  1437. 59:48this view can have a class name equal to
  1438. 59:50flex Flex D row items D Center justify
  1439. 59:55Das Center w- full and a margin top of
  1440. 59:5910 so we're just centering everything
  1441. 1:00:02within it we can render a text element
  1442. 1:00:05that'll have a class name equal to text-
  1443. 1:00:08Black text- 3 Excel to make it very
  1444. 1:00:11large font Das bold margin X of 10 and
  1445. 1:00:16text- Center within it we can simply
  1446. 1:00:19render the item. title the perfect ride
  1447. 1:00:22is just a step away we can go below this
  1448. 1:00:24View and below the text and create
  1449. 1:00:27another text this text will render the
  1450. 1:00:30description so we can immediately say
  1451. 1:00:32item. description and we can give it a
  1452. 1:00:35class name equal to text- MD font
  1453. 1:00:40djakarta semi bold text- Center
  1454. 1:00:45text-
  1455. 1:00:46hash
  1456. 1:00:488585 85 margin X of 10 to divide it from
  1457. 1:00:52the left and right side and a margin top
  1458. 1:00:54of three to divide it from the
  1459. 1:00:56and there we go your perfect ride is
  1460. 1:00:58just one step away in this case we can
  1461. 1:01:01make this text- LG just so it's a bit
  1462. 1:01:04larger there we go and we can finally
  1463. 1:01:07create a custom button that should go
  1464. 1:01:09below here that says next sure we can
  1465. 1:01:12swipe but if the user is not used to the
  1466. 1:01:14swiper we can also have just a button so
  1467. 1:01:17let's create our first custom component
  1468. 1:01:19of the day we're going to create a new
  1469. 1:01:21components folder right here in the Uber
  1470. 1:01:24clone called component components and
  1471. 1:01:27I'll create a new file called custom
  1472. 1:01:31button. TSX here we can create a const
  1473. 1:01:35custom button which is going to be a
  1474. 1:01:38react Arrow function component and it'll
  1475. 1:01:41have an immediate return so we can just
  1476. 1:01:43wrap it in parenthesis and at the bottom
  1477. 1:01:46we can export default the custom button
  1478. 1:01:50so this custom button will of course
  1479. 1:01:52return the touchable opacity because the
  1480. 1:01:55touchable opacity is a button in react
  1481. 1:01:58native every touchable opacity needs to
  1482. 1:02:00have an on press functionality and in
  1483. 1:02:03this case since it's a custom button
  1484. 1:02:05what this button will be doing will be
  1485. 1:02:07coming through props so we can simply
  1486. 1:02:10pass the onpress from props and then
  1487. 1:02:13call it right here it'll also have many
  1488. 1:02:15other things in the props so let's
  1489. 1:02:16destructure them we'll have a dynamic
  1490. 1:02:19title we have a BG variant which by
  1491. 1:02:22default can be set to primary we'll also
  1492. 1:02:24have a text variant
  1493. 1:02:26of the button which by default can be
  1494. 1:02:28set to default we're going to have an
  1495. 1:02:31icon left with a capital I and then icon
  1496. 1:02:34right if we need to provide it to the
  1497. 1:02:36button we're also going to have some
  1498. 1:02:38custom class names and finally we can
  1499. 1:02:40spread all the other props in case we
  1500. 1:02:42need to share it with the button and you
  1501. 1:02:44can see how convenient this is right now
  1502. 1:02:47that prer and Es length automatically
  1503. 1:02:49reformed my application so we can better
  1504. 1:02:51see what's happening within this
  1505. 1:02:53touchable opacity I'll say if there is
  1506. 1:02:55is an icon left then we can render that
  1507. 1:02:59icon left component just like so I'll
  1508. 1:03:03repeat that at the bottom and say if
  1509. 1:03:05there is an icon right we'll render the
  1510. 1:03:08icon
  1511. 1:03:09right and make sure to say left right
  1512. 1:03:12here in the middle will show the actual
  1513. 1:03:15text of the button so this is a text
  1514. 1:03:17coming from react native and it'll
  1515. 1:03:20render the title that we're passing as a
  1516. 1:03:22prop to this button now let's import
  1517. 1:03:25this custom button
  1518. 1:03:26at the bottom of the swiper we can do
  1519. 1:03:28that by declaring a custom button it'll
  1520. 1:03:31be a self-closing component and we need
  1521. 1:03:33to pass some of these props such as a
  1522. 1:03:36title and the title will say something
  1523. 1:03:38like next we want to go to the next
  1524. 1:03:41screen immediately you can see the next
  1525. 1:03:43key appear right below the swiper we can
  1526. 1:03:46also give it some class names such as w
  1527. 1:03:5011 out of 12 and margin top of 10 and
  1528. 1:03:53now we can dive into the button and
  1529. 1:03:55style it further by giving this
  1530. 1:03:57touchable opacity a class name which
  1531. 1:03:59will be a dynamic template string of
  1532. 1:04:03w-o rounded Das full Flex Flex D row
  1533. 1:04:09justify Das center items Das Center
  1534. 1:04:14Shadow
  1535. 1:04:15DMD Shadow D neutral d400
  1536. 1:04:20over7 and we can then dynamically call
  1537. 1:04:23get BG VAR
  1538. 1:04:26style and to it we can pass the BG
  1539. 1:04:29variant just like
  1540. 1:04:31so and finally we can render the class
  1541. 1:04:34name dynamically right here as well but
  1542. 1:04:37what is this get BG variant style well
  1543. 1:04:40it's a utility function which we can
  1544. 1:04:42create right here above by saying const
  1545. 1:04:45get BG variant style is equal to it
  1546. 1:04:50obviously accepts a variant which is of
  1547. 1:04:53a type button props which we can import
  1548. 1:04:56from types of a BG variant so it can
  1549. 1:04:59either be primary or secondary and we'll
  1550. 1:05:03open up a switch
  1551. 1:05:05statement where we'll look into the
  1552. 1:05:07variant of that button and depending on
  1553. 1:05:10the variant if the case is for example
  1554. 1:05:13secondary will apply a specific color
  1555. 1:05:17such as return BG gray 500 and now we
  1556. 1:05:23can cover it for all other cases so I'll
  1557. 1:05:26duplicate this a couple more times and
  1558. 1:05:28say if Case is danger then the color
  1559. 1:05:31will obviously be red 500 if it's
  1560. 1:05:35success then it'll be green
  1561. 1:05:39500 and if it is
  1562. 1:05:43outline then we'll make it transparent
  1563. 1:05:46by saying BG
  1564. 1:05:48transparent border Das neutral D300 and
  1565. 1:05:53Border Das 0.5 5
  1566. 1:05:57pixels and we can close it finally if
  1567. 1:06:01the case is the default case so we can
  1568. 1:06:04say default then I'll return a BG of
  1569. 1:06:07hash
  1570. 1:06:090286 FF which is some kind of a basic
  1571. 1:06:13button color great so now we can see
  1572. 1:06:15that this button is taking a b variant
  1573. 1:06:17of primary in this case and I believe
  1574. 1:06:20that is the default color here in this
  1575. 1:06:23case it looks like it's complaining a
  1576. 1:06:25bit
  1577. 1:06:26it says that the BG variant needs to be
  1578. 1:06:28of one of these types and what are we
  1579. 1:06:30passing it's BG variant
  1580. 1:06:33primary and here we're not passing
  1581. 1:06:35anything as the BG variant so I do
  1582. 1:06:38believe that we should be good but it
  1583. 1:06:40thinks that it is just a string and we
  1584. 1:06:42know that it's always going to be of one
  1585. 1:06:44of these types so we can say here that a
  1586. 1:06:48BG variant will be of a type button
  1587. 1:06:51props coming from the types declaration
  1588. 1:06:54this way we're importing this
  1589. 1:06:55declaration where we say that the B
  1590. 1:06:57variant will always be of one of these
  1591. 1:06:59types great so now we can also style the
  1592. 1:07:03text by giving it a class name equal to
  1593. 1:07:08text- LG font Das bold and we'll also do
  1594. 1:07:12a very similar thing that we have done
  1595. 1:07:14with the backgrounds so I will make this
  1596. 1:07:16a template
  1597. 1:07:18string and instead of saying get BG
  1598. 1:07:21variant I'll say Dynamic get text
  1599. 1:07:26variant style and then to it I'll pass
  1600. 1:07:29the text variant so now we have to
  1601. 1:07:32declare this function right above and
  1602. 1:07:34I'll do it by duplicating the get BG
  1603. 1:07:37variant and I'll say get text variant
  1604. 1:07:43style and it's going to be of text
  1605. 1:07:47variant right here we have the primary
  1606. 1:07:50which will just make the text black so
  1607. 1:07:52we can say text- black
  1608. 1:07:55next we can move this outline a bit
  1609. 1:07:58above below the primary and we'll call
  1610. 1:08:01that a secondary and this one we'll
  1611. 1:08:04simply say
  1612. 1:08:06text-
  1613. 1:08:09gr-100 next we have danger which is
  1614. 1:08:11going to be a
  1615. 1:08:13text-
  1616. 1:08:16r-100 and finally success is going to be
  1617. 1:08:19a text of green 100 and the default will
  1618. 1:08:23be a text of white so now we have those
  1619. 1:08:26two helper functions that are going to
  1620. 1:08:28help us determine what kind of variant
  1621. 1:08:30Styles we want for our button and of
  1622. 1:08:33course all of this in order to make it
  1623. 1:08:35easier to add new buttons in the future
  1624. 1:08:39we did some heavy lifting to make this
  1625. 1:08:40button fully customizable but now the
  1626. 1:08:43next time that we use it it's going to
  1627. 1:08:44be super simple now let's make that
  1628. 1:08:47button do something first we have to
  1629. 1:08:50figure out if we're on the last slide or
  1630. 1:08:53not if we're not on the last slide we
  1631. 1:08:55simply want to move to the next screen
  1632. 1:08:57once we click it so right at the top
  1633. 1:09:00let's use the active index to figure out
  1634. 1:09:02on which screen we're on we can create a
  1635. 1:09:05new variable called is last slide and
  1636. 1:09:08say if active index is triple equal to
  1637. 1:09:12onboarding length minus one so if we're
  1638. 1:09:15on the last screen that must mean that
  1639. 1:09:17we're on the last slide depending on
  1640. 1:09:20that we can change some different things
  1641. 1:09:23such as we can change the title we we
  1642. 1:09:25can say if is last slide say get started
  1643. 1:09:30else say next similarly we can change
  1644. 1:09:33the onpress button action by creating a
  1645. 1:09:36new callback function and checking if is
  1646. 1:09:40last slide is true then call the router
  1647. 1:09:45replace and point
  1648. 1:09:47two forward SL off sign up just like
  1649. 1:09:53this else if it's not the last step then
  1650. 1:09:56use the swiper ref. current question
  1651. 1:10:01mark. scroll by one so this is how you
  1652. 1:10:05scroll to the next screen so you can
  1653. 1:10:07swipe but you can also click next and
  1654. 1:10:10now it will navigate to the next screen
  1655. 1:10:12and if you get to the last one it'll
  1656. 1:10:14actually move you over to the sign up so
  1657. 1:10:17now let's reload the screen to go
  1658. 1:10:19back finally let's see why this button
  1659. 1:10:23is so slim we need to make it have a bit
  1660. 1:10:25more height so let's navigate over to
  1661. 1:10:27the custom button and let's give it a
  1662. 1:10:30padding of three there we go that's
  1663. 1:10:32better and to this touchable opacity we
  1664. 1:10:35also want to spread all of the other
  1665. 1:10:37props so we can do do do dot props that
  1666. 1:10:41means that whatever we pass right here
  1667. 1:10:43as a class name or as anything else
  1668. 1:10:46we're immediately also transferring to
  1669. 1:10:48this touchable opacity in this case it
  1670. 1:10:50is a custom width and a margin top and
  1671. 1:10:53this is making it look so nice ni and it
  1672. 1:10:56makes it super
  1673. 1:10:58customizable with that in mind our
  1674. 1:11:00welcome screens are now complete we can
  1675. 1:11:03nicely scroll between them you know how
  1676. 1:11:05you can change the title in the
  1677. 1:11:06description if you want to you can
  1678. 1:11:08navigate over with the buttons you can
  1679. 1:11:10press the skip at the top right or you
  1680. 1:11:12can just come to the end of the
  1681. 1:11:14onboarding and press get started an
  1682. 1:11:16onboarding sequence is something that
  1683. 1:11:19every single mobile application has so
  1684. 1:11:22now you know how to do it too and moving
  1685. 1:11:24forward we'll focus on the sign up and
  1686. 1:11:28signin screens so let's do that next by
  1687. 1:11:31heading over to sign Dash up our signup
  1688. 1:11:35page will have a bit more height than
  1689. 1:11:38what some of the devices can fit on one
  1690. 1:11:40screen so instead of a safe area view
  1691. 1:11:43we'll render a scroll view coming from
  1692. 1:11:47react native so let's imported scroll
  1693. 1:11:50View and text coming from react native
  1694. 1:11:53to that scroll View we can give a class
  1695. 1:11:56name equal to flex D1 as well as a
  1696. 1:11:59background of white within it we can
  1697. 1:12:02render a regular view which we also need
  1698. 1:12:05to import from react native so let's do
  1699. 1:12:09just that and let's give it a class name
  1700. 1:12:13equal to flex D1 and BG White Once Again
  1701. 1:12:18within that view we'll render one more
  1702. 1:12:20view within which we'll render an image
  1703. 1:12:23so let's render that image image right
  1704. 1:12:25here and that image once again will come
  1705. 1:12:28from react native it'll have a source
  1706. 1:12:32equal to images which we can import from
  1707. 1:12:36constants do signup car with a class
  1708. 1:12:41name equal to Z of0 w- full for full
  1709. 1:12:45width and
  1710. 1:12:47h-250 pixels for the full height and
  1711. 1:12:50take a look at this nice image at the
  1712. 1:12:52top let's also style this view by giving
  1713. 1:12:56it a class name equal to
  1714. 1:12:58relative w-o and
  1715. 1:13:02h-250 pixels as well below the image we
  1716. 1:13:05can render a text and that text will say
  1717. 1:13:10create your
  1718. 1:13:13account and we can style it a bit by
  1719. 1:13:15giving it a class name of text- 2XL
  1720. 1:13:19text- black font D Jakarta semi bold and
  1721. 1:13:26absolute with a bottom five and left
  1722. 1:13:29five so now we're absolutely positioning
  1723. 1:13:32it just at the bottom of this image but
  1724. 1:13:35it's going a bit within it since we have
  1725. 1:13:37a white gradient appearing right here we
  1726. 1:13:41can go below this view that's below the
  1727. 1:13:43text and we can create another view
  1728. 1:13:46right here this view will have a class
  1729. 1:13:50name equal to padding of five and within
  1730. 1:13:54it we can render a custom component of
  1731. 1:13:57input field so similar to what we have
  1732. 1:14:01done before with a custom button we want
  1733. 1:14:03to create a new custom component called
  1734. 1:14:07input field. TSX we can declare this new
  1735. 1:14:12component input field which is going to
  1736. 1:14:14be just an immediate return function
  1737. 1:14:18where we'll return something very soon
  1738. 1:14:20and then we can do export default input
  1739. 1:14:23field now let's immediately import it
  1740. 1:14:26right here so import input field coming
  1741. 1:14:30from components input field and this
  1742. 1:14:32input field will be within a special
  1743. 1:14:35view a view called keyboard avoiding
  1744. 1:14:39view pretty interesting once you have
  1745. 1:14:41this view your keyboard will not be able
  1746. 1:14:43to go into it because if it did how
  1747. 1:14:45would you type into it okay so that's
  1748. 1:14:49why we have this keyboard avoiding View
  1749. 1:14:51and within it we can also have a
  1750. 1:14:53touchable
  1751. 1:14:56without feedback so this is similar to a
  1752. 1:14:59button but this time we don't really
  1753. 1:15:01want to make it seem like we're clicking
  1754. 1:15:03it and we can import this from react
  1755. 1:15:06native within it we can render a view
  1756. 1:15:09with a class name equal to margin y of 2
  1757. 1:15:14and W of full and within it we can
  1758. 1:15:17render a piece of text that'll have a
  1759. 1:15:20class name it'll be template string of
  1760. 1:15:23text- LG font Das Jakarta semi bold and
  1761. 1:15:28margin bottom of three and we can also
  1762. 1:15:30render the label style which will pass
  1763. 1:15:33through props as well as a label itself
  1764. 1:15:37so now we already know that in the props
  1765. 1:15:39we have to get some things like the
  1766. 1:15:41label we have to get the label style and
  1767. 1:15:45later on much more so now let's pass
  1768. 1:15:50those props while we're calling the
  1769. 1:15:52input field from the signup component we
  1770. 1:15:55can pass things such as a label equal to
  1771. 1:15:58name we can pass a placeholder equal to
  1772. 1:16:01enter name or enter your name we can
  1773. 1:16:06pass an icon equal to icons which we can
  1774. 1:16:10import from icons.
  1775. 1:16:12person a value will be equal to a form
  1776. 1:16:16value so right at the top of this file
  1777. 1:16:18we can declare a form for the signup by
  1778. 1:16:21saying use state is equal to form
  1779. 1:16:25set form at the start equal to an object
  1780. 1:16:28that has a name equal to an empty string
  1781. 1:16:31it has an email equal to an empty string
  1782. 1:16:34as well and it has a password equal to
  1783. 1:16:37an empty string and now we can use that
  1784. 1:16:40value right within this first input
  1785. 1:16:43field by saying form. name and below it
  1786. 1:16:47we can call the on change Handler so on
  1787. 1:16:50change text will be equal to where we
  1788. 1:16:53get the value and then we need to set up
  1789. 1:16:56the form by saying set form and first we
  1790. 1:17:00have to spread the existing values of
  1791. 1:17:02the form by saying do do do form and
  1792. 1:17:05then update this specific Field's value
  1793. 1:17:08so the value of this specific field is
  1794. 1:17:11name and we can set that over to be
  1795. 1:17:13equal to Value I think I can expand this
  1796. 1:17:15in a few lines just so you can quickly
  1797. 1:17:17see what's happening so we're setting
  1798. 1:17:19the form by first spreading all of the
  1799. 1:17:21other fields and then updating
  1800. 1:17:23specifically the name field with the
  1801. 1:17:26name value if I zoom out a bit we can
  1802. 1:17:28see it in one line and that now allows
  1803. 1:17:30us to go into the input field and accept
  1804. 1:17:33all of these props so alongside the
  1805. 1:17:36label and the label style we also have
  1806. 1:17:39things like the icon the secure text
  1807. 1:17:43entry so if this is true that means that
  1808. 1:17:45we're typing in a password and by
  1809. 1:17:47default it will be set to false we have
  1810. 1:17:49the container style the input style the
  1811. 1:17:54icon sty style the class name and
  1812. 1:17:57finally we can spread all of the other
  1813. 1:18:00props that we have so now we can
  1814. 1:18:02continue with creating this field
  1815. 1:18:04because right now we're just showing the
  1816. 1:18:06label and nothing more so let's go below
  1817. 1:18:10this text and let's create a new view
  1818. 1:18:12inside of which we can create the icon
  1819. 1:18:15and the input this view will have a
  1820. 1:18:18class name equal to it'll be a dynamic
  1821. 1:18:22property of flex Flex D
  1822. 1:18:26row justify Das start items D Center
  1823. 1:18:31relative BG Das neutral of 100 rounded
  1824. 1:18:35Das full border border neutral of 100
  1825. 1:18:41and on Focus border Das primary of 500
  1826. 1:18:45and dynamic property of container style
  1827. 1:18:51if we decide to pass any additional
  1828. 1:18:52properties and now we're slowly starting
  1829. 1:18:55to create this specific input within it
  1830. 1:18:58we can check if we have the icon so if
  1831. 1:19:01icon exists then we can render an image
  1832. 1:19:05which we of course have to import from
  1833. 1:19:07react native we can do that right at the
  1834. 1:19:10top by getting the image from react
  1835. 1:19:13native this image will have of course a
  1836. 1:19:16source equal to Icon and a class name of
  1837. 1:19:21it will be dynamic w6h
  1838. 1:19:25six margin left of four and dynamic
  1839. 1:19:29property of Icon style so now we can see
  1840. 1:19:32this icon and what is soon going to
  1841. 1:19:34become an input field below the icon we
  1842. 1:19:37can render a text input which is a react
  1843. 1:19:40native component so we have to import it
  1844. 1:19:42from react native it will also have a
  1845. 1:19:45class name which will be dynamic it'll
  1846. 1:19:48be rounded Das
  1847. 1:19:51full padding of four F of Jakarta semi
  1848. 1:19:56bold text of 15 pixels Flex
  1849. 1:20:00one and it'll have Dynamic Property of
  1850. 1:20:04input style as well as text Dash left
  1851. 1:20:07it'll also have a property of secure
  1852. 1:20:09text entry equal to secure text entry
  1853. 1:20:13and we can spread all of the other props
  1854. 1:20:15that we decide to share with this input
  1855. 1:20:17so now you can slowly start seeing this
  1856. 1:20:19input appear on the screen enter your
  1857. 1:20:21name we can style this input a bit
  1858. 1:20:23further by modifying the keyboard
  1859. 1:20:26avoiding View and we can change the
  1860. 1:20:28behavior of this view depending on the
  1861. 1:20:31platform we're on so we can use the
  1862. 1:20:33special platform feature coming from
  1863. 1:20:35react native by saying platform which we
  1864. 1:20:38can import from react
  1865. 1:20:40native. and if the OS is equal to iOS
  1866. 1:20:44then we can do padding else we can do
  1867. 1:20:47height I learned that this makes it work
  1868. 1:20:49better on those specific devices to
  1869. 1:20:52touchable without feedback we can
  1870. 1:20:54provide an on press and here we can run
  1871. 1:20:58the keyboard coming from react native.
  1872. 1:21:02dismiss which means that if we click
  1873. 1:21:04outside or if we click within this
  1874. 1:21:06touchable opacity or touchable without
  1875. 1:21:08feedback we will close the keyboard
  1876. 1:21:11check this out I click it I click
  1877. 1:21:14outside it closes great and now we have
  1878. 1:21:17a single input field we can also specify
  1879. 1:21:20the types of those props which are equal
  1880. 1:21:23to input field props coming from types
  1881. 1:21:26and now that we have created this
  1882. 1:21:28structure for input Fields it is super
  1883. 1:21:30simple to just duplicate them below one
  1884. 1:21:33two
  1885. 1:21:34more the one below will have a label of
  1886. 1:21:38email it'll say enter email or enter
  1887. 1:21:42your email the icon will be icons. email
  1888. 1:21:47it'll say form. email and under form we
  1889. 1:21:51will set the email right here and for
  1890. 1:21:54the third one we can say password so
  1891. 1:21:57password enter your password icons will
  1892. 1:22:00be icons. loock and here we'll pass the
  1893. 1:22:03special secure text entry equal to True
  1894. 1:22:08Value is form. password and finally we
  1895. 1:22:11can set the password here as well and
  1896. 1:22:15now we can see three fields and how
  1897. 1:22:17simple it was to create them below those
  1898. 1:22:20three we can do something even simpler
  1899. 1:22:23and that is call our custom button we
  1900. 1:22:27can provide it a title of sign up we can
  1901. 1:22:31give it an on press which we'll call a
  1902. 1:22:34special function called on signup
  1903. 1:22:38press and we can give it a class name
  1904. 1:22:41equal to margin top of six so before we
  1905. 1:22:46save this we just have to create this on
  1906. 1:22:48signup press functionality so let me
  1907. 1:22:51just add it right here above const
  1908. 1:22:55on signup press is equal to an
  1909. 1:22:58async arrow
  1910. 1:23:00function which we'll create later on but
  1911. 1:23:02for now you can see how simple it was to
  1912. 1:23:05duplicate these three inputs and create
  1913. 1:23:07a custom button right below right below
  1914. 1:23:11this custom button soon enough we'll
  1915. 1:23:13create our oo meaning a special button
  1916. 1:23:17that will allow us to log in with Google
  1917. 1:23:20and Below oo will show just a regular
  1918. 1:23:23link coming coming from react
  1919. 1:23:26native that will point to for SL sign-
  1920. 1:23:30in and it'll have a text property of
  1921. 1:23:33something like already have an account
  1922. 1:23:37question mark and then we can render
  1923. 1:23:39another text right below and say
  1924. 1:23:41something like log in but this one will
  1925. 1:23:45have a class name equal to text- primary
  1926. 1:23:49d500 okay let's style this link just a
  1927. 1:23:53bit more by giving giving it a class
  1928. 1:23:56name equal to text-
  1929. 1:23:59LG text- Center text- general of 200 and
  1930. 1:24:05a margin top of 10 we can also create an
  1931. 1:24:08empty space right here after the
  1932. 1:24:10question mark like this and this is now
  1933. 1:24:12looking so much better below this link
  1934. 1:24:15and below the view later on we'll create
  1935. 1:24:18a model for the verification so I can
  1936. 1:24:20say verification model right here so now
  1937. 1:24:24let's add this oo button to which we can
  1938. 1:24:26add the functionality very soon I'll
  1939. 1:24:28create a new custom component called
  1940. 1:24:32oo which typically stands for social
  1941. 1:24:35authentication here we can create a new
  1942. 1:24:37component const oo is equal to a
  1943. 1:24:41functional component and we can just
  1944. 1:24:43export default ooth within there we can
  1945. 1:24:46automatically return a view within that
  1946. 1:24:49view we'll have another smaller view
  1947. 1:24:52that will have a class name equal to
  1948. 1:24:55flex Flex Das row justify Das center
  1949. 1:25:01items Das Center margin top of four and
  1950. 1:25:06a gap X of three within it we can render
  1951. 1:25:10one self-closing view that'll have a
  1952. 1:25:13class name equal to flex of
  1953. 1:25:17one h of one pixel so height of only one
  1954. 1:25:20pixel and a BG General of 100 below that
  1955. 1:25:26one dot we'll also have a text which we
  1956. 1:25:29need to import from react
  1957. 1:25:32native and this text will have a class
  1958. 1:25:35name equal to text- LG and it'll say or
  1959. 1:25:40and then right below that we can
  1960. 1:25:42duplicate this View and show it here so
  1961. 1:25:45this is going to look something like
  1962. 1:25:48this even though we cannot see it yet it
  1963. 1:25:50will be there soon once we call the O
  1964. 1:25:53off component which we just created so
  1965. 1:25:57all off and we can import it
  1966. 1:25:59automatically right here I'm going to
  1967. 1:26:02skip the on boarding and it should
  1968. 1:26:04appear just above the already have an
  1969. 1:26:07account thing but we cannot see it yet
  1970. 1:26:09so to make it a bit more visible we can
  1971. 1:26:11go below this inner View and create a
  1972. 1:26:15custom button it'll look something like
  1973. 1:26:18this and it'll have quite a few props a
  1974. 1:26:21title equal to log in
  1975. 1:26:25with Google there we go now we can see
  1976. 1:26:28it we can also give it a class name
  1977. 1:26:31equal to margin top w- full and Shadow
  1978. 1:26:39dnone we can also give it an icon left
  1979. 1:26:42which is going to be equal to a callback
  1980. 1:26:45function that automatically returns an
  1981. 1:26:48image and this image will have a source
  1982. 1:26:52equal to icons .
  1983. 1:26:55Google a resize mode equal to contain
  1984. 1:27:00and a class name equal to w-5
  1985. 1:27:05h-5 and margin X off two and of course
  1986. 1:27:09we need to import these icons at the top
  1987. 1:27:12by saying
  1988. 1:27:13import icons coming from add for slash
  1989. 1:27:18constants slash nothing because the
  1990. 1:27:22icons are exported from there now if we
  1991. 1:27:25head over to our sign up you can see a
  1992. 1:27:28button that says login with Google let's
  1993. 1:27:32also give it an additional property of
  1994. 1:27:36BG variant is equal to outline because
  1995. 1:27:40typically Google buttons don't have a
  1996. 1:27:42color typically they're white and the
  1997. 1:27:45text variant will be set to
  1998. 1:27:48primary like this there we go that's a
  1999. 1:27:51Google button and finally we can say on
  2000. 1:27:53press
  2001. 1:27:54and that'll be equal to a function
  2002. 1:27:56called to handle Google sign in so this
  2003. 1:28:00is a function which we can declare right
  2004. 1:28:02here above it'll have to be within the
  2005. 1:28:04function so it cannot be an instant
  2006. 1:28:06return rather we have to say return
  2007. 1:28:10here close it properly indent it and now
  2008. 1:28:14we can declare the function const handle
  2009. 1:28:17Google signin which will be equal to an
  2010. 1:28:19async function to which we can add the
  2011. 1:28:21logic very soon so now we have the
  2012. 1:28:24Google sign-in button and the regular
  2013. 1:28:26sign up and we can click on the login to
  2014. 1:28:29navigate over to a log in screen so if
  2015. 1:28:32we click it right now it'll be empty and
  2016. 1:28:35how will our login screen look like well
  2017. 1:28:38if we check out our design you can see
  2018. 1:28:39that it is basically almost the same as
  2019. 1:28:42the signup it just doesn't have the name
  2020. 1:28:44field because we already have our name
  2021. 1:28:47so for that reason to create our sign in
  2022. 1:28:50I will duplicate the signup head over to
  2023. 1:28:53sign in
  2024. 1:28:54and just override everything we have
  2025. 1:28:56here while I rename it to sign in so
  2026. 1:29:00let's do that here and here and Skip and
  2027. 1:29:06head over to login and there we go we
  2028. 1:29:08can see the same signup screen here but
  2029. 1:29:11in this case we'll make some changes so
  2030. 1:29:13let's go down we'll keep the same sign
  2031. 1:29:15up image but instead create your account
  2032. 1:29:18we'll say something like welcome and we
  2033. 1:29:21can also do an emoji of wave right here
  2034. 1:29:24you can find it on Google and copy it in
  2035. 1:29:26this case as I told you we won't have
  2036. 1:29:28the input field off name rather we'll
  2037. 1:29:30just have input fields for email and
  2038. 1:29:34password the button will say sign in of
  2039. 1:29:38course and instead of on signup press
  2040. 1:29:41here we'll have on sign in press
  2041. 1:29:44functionality so that's going to be on
  2042. 1:29:46sign
  2043. 1:29:48in and we can use it here at the same
  2044. 1:29:52time the form will only have the email
  2045. 1:29:54Emil and password it won't have a name
  2046. 1:29:56so we can delete it from here the link
  2047. 1:29:59will also have a reverse logic right
  2048. 1:30:01here instead of saying already have an
  2049. 1:30:03account we'll say something like don't
  2050. 1:30:07have an account and then we can say sign
  2051. 1:30:11up there we go so now we have enabled
  2052. 1:30:14switching between the sign in and the
  2053. 1:30:16sign up after we modify the H right here
  2054. 1:30:21I click sign up it goes there sign in
  2055. 1:30:24goes here and now we can nicely move
  2056. 1:30:26between the different screens this is
  2057. 1:30:29great The Next Step will of course be to
  2058. 1:30:32implement the functionality of
  2059. 1:30:34registering our account we'll first
  2060. 1:30:36start by implementing the functionality
  2061. 1:30:38of registering through the email and the
  2062. 1:30:41password and then later on we'll make
  2063. 1:30:43the oo work as well for authentication
  2064. 1:30:47will of course be using clerk it is more
  2065. 1:30:49than just a signup box it allows you to
  2066. 1:30:52very quickly implement
  2067. 1:30:54and super functional and secure
  2068. 1:30:56authentication flows and if you checked
  2069. 1:30:58out a couple of my other videos you know
  2070. 1:31:00that it's completely free for up to
  2071. 1:31:0310,000 not just users but monthly active
  2072. 1:31:07users it is super hard to ever cross
  2073. 1:31:09this number but if you do then you can
  2074. 1:31:11start paying or make a switch but if you
  2075. 1:31:14never reach that number it is completely
  2076. 1:31:16free and here's the best part clerk
  2077. 1:31:19created a phenomenal Expo quick start
  2078. 1:31:22making it work so seamlessly ly with
  2079. 1:31:24Mobile Expo applications the first step
  2080. 1:31:27we have already done we have installed
  2081. 1:31:29all the necessary things and created an
  2082. 1:31:31expo app but we just have to install the
  2083. 1:31:35Expo Metro runtime as well so let's just
  2084. 1:31:38copy the second part of this first
  2085. 1:31:40terminal command we can open up a new
  2086. 1:31:42terminal and paste it right here MPX XO
  2087. 1:31:46stall and then couple of these
  2088. 1:31:48dependencies we can continue following
  2089. 1:31:50the other steps such as installing the
  2090. 1:31:52clerk and the clerk Expo package by
  2091. 1:31:56pasting the command after that we'll
  2092. 1:31:58have to set up our environment variables
  2093. 1:32:00and in this case it looks like I'm
  2094. 1:32:02already logged in if you're not logged
  2095. 1:32:04in click the link in the description
  2096. 1:32:07which will allow you to follow along and
  2097. 1:32:09see exactly what I'm seeing and now I
  2098. 1:32:11can see that this is not the right key
  2099. 1:32:12for me either because I have to create a
  2100. 1:32:14new project so let's head over to the
  2101. 1:32:17dashboard and as you can see I already
  2102. 1:32:19created many clerk applications but now
  2103. 1:32:22we'll create a new one I'll call it
  2104. 1:32:25JSM Uber you can give it some other name
  2105. 1:32:29I think you can do something like ride
  2106. 1:32:30as well but make sure to start with
  2107. 1:32:32JSM we'll choose email signin option as
  2108. 1:32:36well as Google and click create
  2109. 1:32:39application you can see that they have
  2110. 1:32:40the Expo setup right here so we can
  2111. 1:32:43continue following right from
  2112. 1:32:45here here we have our environment test
  2113. 1:32:48variable so let's copy it and add it to
  2114. 1:32:50our envs I'll create a new file in the
  2115. 1:32:53root of our directory ctory called
  2116. 1:32:56EnV and just paste this environment
  2117. 1:32:59variable here webstorm asks me if I want
  2118. 1:33:02to install the EnV file support plugin
  2119. 1:33:05which I will install now we can continue
  2120. 1:33:08to the next step and that is adding the
  2121. 1:33:10clerk provider to our root layout so
  2122. 1:33:13let's copy this entire file head over to
  2123. 1:33:17layout and paste it right here at the
  2124. 1:33:19top you'll notice that we have some
  2125. 1:33:22imports we're getting that environment
  2126. 1:33:24key and we have a check if we don't have
  2127. 1:33:27a key after that we need to wrap our
  2128. 1:33:29entire application with the clerk
  2129. 1:33:31provider and the clerk loaded wrappers
  2130. 1:33:34so let's copy them delete this and wrap
  2131. 1:33:38our stack with the clerk provider and
  2132. 1:33:41clerk loaded and close one by
  2133. 1:33:44one I indented everything nicely and it
  2134. 1:33:48looks great we can add this if no
  2135. 1:33:50publishable key right within the root
  2136. 1:33:53layout
  2137. 1:33:54below the fonts loaded now let's go to
  2138. 1:33:57the next step and that is to configure
  2139. 1:34:00the token cache with Expo for that we
  2140. 1:34:03need to install the new package Expo
  2141. 1:34:06secure store so let's simply open up a
  2142. 1:34:09new terminal and copy and paste the
  2143. 1:34:11command the next step is to copy this
  2144. 1:34:14token cache so let's copy it and instead
  2145. 1:34:17of cluttering the layout file with all
  2146. 1:34:19of the authentication logic we can put
  2147. 1:34:22all authentication logic in another file
  2148. 1:34:25that can be within Uber clone and we can
  2149. 1:34:27create a new
  2150. 1:34:29folder called lib as in library and
  2151. 1:34:32within the library we can create a new
  2152. 1:34:34file called
  2153. 1:34:36O.S inside of which we can post this
  2154. 1:34:40token cache interface and here we can
  2155. 1:34:42also copy the token cache part of this
  2156. 1:34:45next code block we're not going to put
  2157. 1:34:47it within the layout which is going to
  2158. 1:34:49take the token cache so let's paste it
  2159. 1:34:51here and let's make sure to get the
  2160. 1:34:54secure store from Expo secure store and
  2161. 1:34:58all the other Imports that we need so
  2162. 1:35:00I'll paste it at the top of this file
  2163. 1:35:03right here we just need that and I don't
  2164. 1:35:06even believe we'll need the token cache
  2165. 1:35:08interface we can add it later on if it's
  2166. 1:35:10needed and since we'll use token cache
  2167. 1:35:12somewhere else for now I'll just say
  2168. 1:35:14export const token cache now let's go
  2169. 1:35:17down and the next thing is to create a
  2170. 1:35:21Home Route group layout I believe we
  2171. 1:35:24call this root and we already have it
  2172. 1:35:26the next step is to conditionally render
  2173. 1:35:29the content depending whether we're
  2174. 1:35:30signed in or not we don't have to do
  2175. 1:35:33this yet we're going to do it on the
  2176. 1:35:34homepage remember we haven't yet signed
  2177. 1:35:37in so we cannot even see the homepage
  2178. 1:35:39but maybe it will be good to see this
  2179. 1:35:41once we're actually logged in to see at
  2180. 1:35:44least something to see a successful
  2181. 1:35:46authentication state so let's actually
  2182. 1:35:48copy everything that is on here that is
  2183. 1:35:51indeed the index TSX of the home page so
  2184. 1:35:54we can override what we currently have
  2185. 1:35:56in our app Root tabs and then home and
  2186. 1:36:01here we can paste what we just copied if
  2187. 1:36:04we do authenticate successfully we
  2188. 1:36:06should be redirected to this page and we
  2189. 1:36:08should be able to see our email address
  2190. 1:36:11next we need to protect our o routes in
  2191. 1:36:14the layout by creating a new route group
  2192. 1:36:16O which we already have done with the
  2193. 1:36:19underscore layout file and now we can do
  2194. 1:36:21a redirect there so let's copy this if
  2195. 1:36:25statement and the use o and we can head
  2196. 1:36:28over to index. DSX which is our homepage
  2197. 1:36:33and here we can paste if signed in use o
  2198. 1:36:37and that's coming from clerk Expo we can
  2199. 1:36:39also imported so if we're signed in then
  2200. 1:36:42redirect to home else redirect to O
  2201. 1:36:47welcome in our case the home will be
  2202. 1:36:50under a bit of a different route it's
  2203. 1:36:52not going to be just for slash it'll be
  2204. 1:36:57slash
  2205. 1:36:59root slash
  2206. 1:37:02tabs
  2207. 1:37:04slome okay I hope that makes sense that
  2208. 1:37:08is the home page that we just added
  2209. 1:37:10these clerk functionalities too great so
  2210. 1:37:13far we're just following the steps the
  2211. 1:37:15next thing that it says is to add the
  2212. 1:37:17sign up page we already have the signup
  2213. 1:37:20page thankfully uh but we can copy this
  2214. 1:37:23on signup press function and on press
  2215. 1:37:27verify function so let's copy them head
  2216. 1:37:31over to sign up where we left off and
  2217. 1:37:34override the on signup press with these
  2218. 1:37:37new functions which we have just copied
  2219. 1:37:39with them we most likely also have to
  2220. 1:37:41get some of the states or we'll have to
  2221. 1:37:43make some of the modifications I think
  2222. 1:37:45we can add all of that on our own the
  2223. 1:37:47only thing we need is the call to the
  2224. 1:37:49use signup hook right here at the top
  2225. 1:37:52coming from Clerk Expo so let's call
  2226. 1:37:55this hook at the top use sign up and
  2227. 1:37:59this is coming from clerk Expo so we can
  2228. 1:38:02say import use sign up coming from clerk
  2229. 1:38:08at clerk clerk Expo we already have the
  2230. 1:38:12form that is good but we also need the
  2231. 1:38:14verification because for clerk to work
  2232. 1:38:17with react native applications via email
  2233. 1:38:19we need to verify our user login or sign
  2234. 1:38:22up by email and this will be just a
  2235. 1:38:25state so we can use the use State
  2236. 1:38:27snippet
  2237. 1:38:29verification set verification at the
  2238. 1:38:32start equal to an object containing the
  2239. 1:38:34state equal to
  2240. 1:38:36default the error code if there is one
  2241. 1:38:40at the start equal to an empty string
  2242. 1:38:42and the code the user is trying to enter
  2243. 1:38:45to verify their credentials that's also
  2244. 1:38:48going to be an empty string at the start
  2245. 1:38:50next our email address and password are
  2246. 1:38:53coming from a form so we have to say
  2247. 1:38:56email address and password are equal to
  2248. 1:38:58form. email and form that password next
  2249. 1:39:03we can leave this as it is and instead
  2250. 1:39:05of set pending verification to true we
  2251. 1:39:07can say set verification where we can
  2252. 1:39:10say dot do dot verification to spread
  2253. 1:39:13all the existing information about the
  2254. 1:39:15verification but we can set the state to
  2255. 1:39:18pending if we get an error we'll simply
  2256. 1:39:20conso log that error and that's it for
  2257. 1:39:23the signup but we have to figure out
  2258. 1:39:25what happens on the verification the
  2259. 1:39:28verification is the second part of the
  2260. 1:39:30authentication it's when we get the
  2261. 1:39:31email with the code that's asking us to
  2262. 1:39:34verify whether it's us who's trying to
  2263. 1:39:36sign up with our email account so we can
  2264. 1:39:38say if not loaded then return nothing
  2265. 1:39:42meaning exit out of the function else we
  2266. 1:39:45can try to complete the signup the code
  2267. 1:39:48in this case will be equal to
  2268. 1:39:50verification. code because that's where
  2269. 1:39:52we put it within that specific State
  2270. 1:39:54field if complete signup do status is
  2271. 1:39:58equal to complete then we want to set
  2272. 1:40:01active the session of the complete
  2273. 1:40:03signup that created session ID and we
  2274. 1:40:06also want to modify the verification
  2275. 1:40:08state to say do do do verification where
  2276. 1:40:12we spread everything but then we also
  2277. 1:40:14want to set the state to be equal to
  2278. 1:40:16success else if it doesn't succeed we
  2279. 1:40:19want to set the verification to state is
  2280. 1:40:23equal to failed and then we can add the
  2281. 1:40:26error message equal to
  2282. 1:40:29verification failed and finally on the
  2283. 1:40:32big catch we can also set the
  2284. 1:40:35verification error right here but this
  2285. 1:40:37time the error can be equal to error.
  2286. 1:40:40errors
  2287. 1:40:41z. long message so this will tell us a
  2288. 1:40:44bit more information about why the error
  2289. 1:40:47happened finally there's something that
  2290. 1:40:49aite hasn't done here and that is create
  2291. 1:40:52a new user in our own database once a
  2292. 1:40:55clerk user gets created and that's what
  2293. 1:40:58we want to do right here so I'll say to
  2294. 1:41:00do create a
  2295. 1:41:03database
  2296. 1:41:05user so here later on we'll make a
  2297. 1:41:07database call to create a user in our
  2298. 1:41:09database Beyond just being a clerk user
  2299. 1:41:13but for the time being we've been
  2300. 1:41:14looking at this create your account
  2301. 1:41:16screen for far too long and I would just
  2302. 1:41:18want to see something change so let's
  2303. 1:41:21try to authenticate with Clerk first but
  2304. 1:41:24of course to be able to do that we have
  2305. 1:41:26to create a model that would allow us to
  2306. 1:41:29type in the code that we got via email
  2307. 1:41:33so let's create a new model right here
  2308. 1:41:36below everything that we have
  2309. 1:41:38verification model it is waiting for us
  2310. 1:41:41to create this model we'll install a new
  2311. 1:41:43package mpm install
  2312. 1:41:46react-native Das model it's a very handy
  2313. 1:41:50package that basically screams don't
  2314. 1:41:53reinvent the wheel somebody else needed
  2315. 1:41:56a model before they created it it is
  2316. 1:41:58used by tens of thousands of people if
  2317. 1:42:01not more and we're going to make use of
  2318. 1:42:03that model in here as well but of course
  2319. 1:42:06we'll style it to match our own
  2320. 1:42:07application so to start creating it we
  2321. 1:42:10can use it by importing it by saying
  2322. 1:42:13react native
  2323. 1:42:15model which Imports it from react-native
  2324. 1:42:18D model and it accepts an is visible
  2325. 1:42:22prop and it'll only be visible if the
  2326. 1:42:26verification. state is triple equal to
  2327. 1:42:30success next within it we can show a
  2328. 1:42:33view and that view will have a class
  2329. 1:42:36name equal to BG dwh padding X of s
  2330. 1:42:41padding y of 9 rounded -2 XL and m-
  2331. 1:42:47h-300 pixels inside of square
  2332. 1:42:50brackets within it we can also render an
  2333. 1:42:53image with a source equal to images.
  2334. 1:42:58check and a class name equal to
  2335. 1:43:02w-10 pixels for the width h- 110 pixels
  2336. 1:43:07for the height and margin X of Auto and
  2337. 1:43:11margin y of
  2338. 1:43:13five if we save it we cannot see
  2339. 1:43:16anything yet because we haven't yet
  2340. 1:43:18modified the verification status by
  2341. 1:43:20entering our details but thank
  2342. 1:43:23thankfully we can mock that verification
  2343. 1:43:25status by changing the default State
  2344. 1:43:28variable to success and let's reload our
  2345. 1:43:32application just to see the latest
  2346. 1:43:34changes I think sometimes it does get
  2347. 1:43:37stuck oh this time we have an error
  2348. 1:43:39saying module Expo local
  2349. 1:43:42authentication could not be found within
  2350. 1:43:44the project directory this error seems
  2351. 1:43:47pretty self-explanatory it's saying that
  2352. 1:43:49it's unable to resolve this package from
  2353. 1:43:52Clerk Expo so that might mean that we
  2354. 1:43:55just need to install it manually so
  2355. 1:43:58let's copy the name let's say mpm
  2356. 1:44:01install and then say Expo local
  2357. 1:44:04authentication make sure to spell it
  2358. 1:44:06properly I often misspell authentication
  2359. 1:44:09and press
  2360. 1:44:11enter once it gets installed we can try
  2361. 1:44:14to reload our application and see if
  2362. 1:44:16that fixes it indeed it got bundled we
  2363. 1:44:20are back on our onboarding which is
  2364. 1:44:23looking great and it looks like we're
  2365. 1:44:25still having this console warning from
  2366. 1:44:27the root but we're going to fix that
  2367. 1:44:29very soon for now I will dismiss it and
  2368. 1:44:32we can see our beautiful
  2369. 1:44:34model let's continue creating it below
  2370. 1:44:37the image I'll show a text element with
  2371. 1:44:41a class name equal to text- 3XL font D
  2372. 1:44:46Jakarta
  2373. 1:44:48bold and text Dash Center within it we
  2374. 1:44:52can say some something like verified
  2375. 1:44:55right below we can do another text that
  2376. 1:44:57will have a class name equal to
  2377. 1:45:01text-base text- gray- 400 font D Jakarta
  2378. 1:45:07text- Center and margin top of two and
  2379. 1:45:11we can say something like you have
  2380. 1:45:13successfully verified your account and
  2381. 1:45:16finally below the text we can have
  2382. 1:45:19another custom button with a title of
  2383. 1:45:23browse Home on press we can have a
  2384. 1:45:26callback function that calls the
  2385. 1:45:28router from Expo router and replaces our
  2386. 1:45:33URL to a string of SL root which is in
  2387. 1:45:39parentheses slash tabs in parentheses
  2388. 1:45:44slome and it's going to have a class
  2389. 1:45:46name of margin top of
  2390. 1:45:50five there we go verified browse home
  2391. 1:45:54now we won't click it just yet as it'll
  2392. 1:45:56most likely break our
  2393. 1:45:58application but what we can do is
  2394. 1:46:01actually test out the full
  2395. 1:46:03functionalities of our authentication we
  2396. 1:46:06have added a lot of code I'm not saying
  2397. 1:46:08everything will work right of the bad
  2398. 1:46:11but we can give it a shot I will bring
  2399. 1:46:14back the default state of the
  2400. 1:46:16verification to default so it'll get
  2401. 1:46:19hidden and now that I think about it
  2402. 1:46:21instead of changing it to default we're
  2403. 1:46:23going to change it to pending because
  2404. 1:46:25that's the state that has to happen
  2405. 1:46:27before success so that means that we can
  2406. 1:46:30go down where we have created our react
  2407. 1:46:34native model and now we'll have to
  2408. 1:46:36create yet another react native model
  2409. 1:46:39with a status of
  2410. 1:46:42pending so let's copy
  2411. 1:46:45it and I'll put it right here on
  2412. 1:46:48top react native model with a status of
  2413. 1:46:51pending another property we can add to
  2414. 1:46:54this react native model is on modal hide
  2415. 1:46:58and on modal hide in this case we can
  2416. 1:47:01create a callback
  2417. 1:47:03function and we can set
  2418. 1:47:06verification by spreading the
  2419. 1:47:08verification properties and then
  2420. 1:47:11changing the state to
  2421. 1:47:13success and now we can go inside of that
  2422. 1:47:16model and craft it by crafting a view
  2423. 1:47:20that view will have a class name equal
  2424. 1:47:22to BG - wi padding X of 7 padding y of 9
  2425. 1:47:28we already know the drill rounded -2
  2426. 1:47:30Excel and m-h of 300 pixels there we go
  2427. 1:47:36that's our model within it we can render
  2428. 1:47:39a piece of text that'll have a class
  2429. 1:47:42name of text- 2XL font
  2430. 1:47:46djakarta extra bold and margin bottom of
  2431. 1:47:51two that's going to say something like
  2432. 1:47:53verification below that text we can have
  2433. 1:47:56another piece of text with a class name
  2434. 1:48:00equal to font D
  2435. 1:48:03Jakarta and margin bottom of
  2436. 1:48:06five and it can say we've sent a
  2437. 1:48:10verification code to form. mail so this
  2438. 1:48:14is the email you entered during the form
  2439. 1:48:17below this text we can create an input
  2440. 1:48:20field again it is Super Con venient Now
  2441. 1:48:23to create it because we have already
  2442. 1:48:25created this input field component uh
  2443. 1:48:28that's going to have a label equal to
  2444. 1:48:30code icon equal to icons. loock
  2445. 1:48:36placeholder equal to 1 2 3 4
  2446. 1:48:405 value equal to
  2447. 1:48:43verification. code keyboard type this is
  2448. 1:48:48something pretty interesting numeric in
  2449. 1:48:51web applications you cannot change your
  2450. 1:48:53physical keyboard but here you can um
  2451. 1:48:56next we can also have the onchange
  2452. 1:49:00text which will request a callback
  2453. 1:49:03function with the code you're typing in
  2454. 1:49:06and we can set verification to be equal
  2455. 1:49:10to where we spread verification and then
  2456. 1:49:12update the code that's going to look
  2457. 1:49:15something like
  2458. 1:49:16this finally if there is a verification
  2459. 1:49:19error we can show it so if verification
  2460. 1:49:24error then we can render another piece
  2461. 1:49:27of
  2462. 1:49:28text that's going to render the
  2463. 1:49:30verification. error of course that text
  2464. 1:49:33will be red in color so we can give it a
  2465. 1:49:36class name equal to text-
  2466. 1:49:39r-500 and text- smm as well as margin
  2467. 1:49:43top of one and below that we need to
  2468. 1:49:46have a custom
  2469. 1:49:48button of course that we'll use to
  2470. 1:49:50submit it so we can say VAR ify email
  2471. 1:49:55onpress here we're actually calling the
  2472. 1:49:57onpress verify which is the function
  2473. 1:49:59that we coded above with a class name of
  2474. 1:50:03margin top of five and BG success of 500
  2475. 1:50:07there we go that's looking good so what
  2476. 1:50:11do you say that we give it a shot I'll
  2477. 1:50:14change the default state to
  2478. 1:50:18default to CR form and now I'll start
  2479. 1:50:22typing my
  2480. 1:50:24name it's Adrien the email is contact at
  2481. 1:50:30JS mastery.
  2482. 1:50:32proo and we can choose a password Here
  2483. 1:50:36we have very strict clerk rules I
  2484. 1:50:38believe so if I enter
  2485. 1:50:40123123 and click sign up we have an
  2486. 1:50:43error it seems like we cannot expand it
  2487. 1:50:45right now but of course we want to show
  2488. 1:50:47that error in some kind of a better
  2489. 1:50:50place and that's where react native
  2490. 1:50:53alerts come in so we can scroll down to
  2491. 1:50:56this catch where we just consel log the
  2492. 1:50:58error and instead of a conso log we can
  2493. 1:51:01actually alert it by using the alert
  2494. 1:51:05functionality from react native. alert
  2495. 1:51:09of a type error and we can enter a
  2496. 1:51:12message of
  2497. 1:51:13er. Errors z. long
  2498. 1:51:18message now if we save this and try to
  2499. 1:51:22sign up with a basic password one more
  2500. 1:51:24time we got a nice error saying
  2501. 1:51:27passwords must be eight characters or
  2502. 1:51:30more even though you cannot see it on
  2503. 1:51:32the screen I think my phone recording
  2504. 1:51:34software is hiding it I do indeed see
  2505. 1:51:37six password dots on my screen now I
  2506. 1:51:40will change it to 123123123 to pass over
  2507. 1:51:45the8 character minimum limit and I'll
  2508. 1:51:47click sign
  2509. 1:51:49up now it says password has been found
  2510. 1:51:52in an online data breach for account
  2511. 1:51:54safety please use a different password
  2512. 1:51:56very interesting so it looks like we'll
  2513. 1:51:59have to choose a real password I'll
  2514. 1:52:02enter something specific I'll pause the
  2515. 1:52:05video and enter a strong password and
  2516. 1:52:08press sign
  2517. 1:52:10up this time a verification model
  2518. 1:52:14appeared which is a good sign and would
  2519. 1:52:17you look at that JSM ride verification
  2520. 1:52:20code just arrived in Mya email so let's
  2521. 1:52:24copy the code or should I say type it in
  2522. 1:52:28623
  2523. 1:52:30263 and click verify
  2524. 1:52:34email and nothing where is our success
  2525. 1:52:38screen why didn't we get renav to the
  2526. 1:52:41home are we signed in or are we not or
  2527. 1:52:44should I say was the account created or
  2528. 1:52:47was it not the best way to find out is
  2529. 1:52:49to go to Clerk's dashboard under users
  2530. 1:52:53and here you can indeed see a new user
  2531. 1:52:56that got
  2532. 1:52:57created but for some reason the success
  2533. 1:53:00model didn't show that's totally okay
  2534. 1:53:03let's delete the user and let's give it
  2535. 1:53:05another shot in react native you can
  2536. 1:53:08never show two models at the same time
  2537. 1:53:11and if you scroll down you can see that
  2538. 1:53:13we're using the same state to go from
  2539. 1:53:15pending and then to success we have to
  2540. 1:53:19use two different states to make that
  2541. 1:53:21happen so let's scroll up and let's
  2542. 1:53:24create a new state use State
  2543. 1:53:30snippet called show success model set
  2544. 1:53:35show success model at the start set to
  2545. 1:53:37false now we can scroll down and on our
  2546. 1:53:41pending model instead of setting the
  2547. 1:53:43verification state to success we can do
  2548. 1:53:46something else we can say if
  2549. 1:53:50verification. state
  2550. 1:53:53is triple equal to success then we can
  2551. 1:53:56set show success model to True let's
  2552. 1:54:02just turn this into a function and
  2553. 1:54:04properly close it and now when we
  2554. 1:54:07activate this second model for success
  2555. 1:54:10we're not going to activate it by the
  2556. 1:54:11verification that state rather we'll
  2557. 1:54:14activate it by this new show success
  2558. 1:54:16modal state so let's give it another
  2559. 1:54:19shot let's create a new account I again
  2560. 1:54:22pause the video enter my details and
  2561. 1:54:25press sign up we get this new
  2562. 1:54:28verification model which is great send
  2563. 1:54:30to contact jm.pro indeed we get back a
  2564. 1:54:34new code which I can enter on my phone
  2565. 1:54:37this feels so good it feels like I'm
  2566. 1:54:40trying to install or sign up for a
  2567. 1:54:42completely new mobile application
  2568. 1:54:475982 verify email and verified there we
  2569. 1:54:51go I love how nicely it's slided from
  2570. 1:54:54the bottom to the center of the screen
  2571. 1:54:55and now we can click browse home and it
  2572. 1:54:59broke my application let's try to reopen
  2573. 1:55:02it once again by the way we have to fix
  2574. 1:55:04the borders here of the splash screen so
  2575. 1:55:07let's fix that right away I think the
  2576. 1:55:09fixes in the app. Json where we have the
  2577. 1:55:12splash screen right here we have to
  2578. 1:55:14change the background color to match the
  2579. 1:55:16blue color of the application so that's
  2580. 1:55:202f8 e
  2581. 1:55:23if we save it and reload our entire
  2582. 1:55:26splash screen you can see that now it
  2583. 1:55:28appears perfectly on the screen and the
  2584. 1:55:30blue covers the entire thing now we can
  2585. 1:55:33skip the onboarding and try to sign up
  2586. 1:55:36one more time but I think the issue was
  2587. 1:55:39with this router. replace thing right
  2588. 1:55:42here instead of router replace let's try
  2589. 1:55:45to use a router. push there are minor
  2590. 1:55:48differences between the two but this
  2591. 1:55:50might just do it so one more time you'll
  2592. 1:55:53have to reload your clerk dashboard and
  2593. 1:55:56delete this user in case you want to use
  2594. 1:55:58the same email address I'll pause the
  2595. 1:56:00video and type in my credentials I'll
  2596. 1:56:03click sign
  2597. 1:56:05up enter my code click verify and browse
  2598. 1:56:10Home there we go it almost worked we
  2599. 1:56:13just have to hide the actual model the
  2600. 1:56:16only thing we have to do to fix this is
  2601. 1:56:19expand this router. push and add
  2602. 1:56:21something to it and that something is
  2603. 1:56:24set show success model and reset it back
  2604. 1:56:27to false because then once we rigate it
  2605. 1:56:30will no longer be showing great so if I
  2606. 1:56:34click it as you can see it works great
  2607. 1:56:38so now we can see our homepage and we
  2608. 1:56:41can get rid of this ugly top bar we can
  2609. 1:56:45do that easily by finding the layout
  2610. 1:56:47that is close to our home which is this
  2611. 1:56:50layout right here and we need to copy
  2612. 1:56:53one of the previous layouts that we've
  2613. 1:56:55had maybe this one right here we had in
  2614. 1:56:58the O we can copy it and head over to
  2615. 1:57:02the layout next to the tabs not the one
  2616. 1:57:05inside it but rather next to the tabs
  2617. 1:57:09and paste it
  2618. 1:57:11here here we can just say name tabs in
  2619. 1:57:15parenthesis Heather shown is set to
  2620. 1:57:18false and for now we can remove these
  2621. 1:57:20other routes and just leave the tabs
  2622. 1:57:22route group I'll also open up the app
  2623. 1:57:25once again and actually now might be a
  2624. 1:57:28good idea to implement the
  2625. 1:57:30authentication session to check whether
  2626. 1:57:32our user has already authenticated so we
  2627. 1:57:34can automatically skip the onboarding
  2628. 1:57:37and skip the welcome screen and skip the
  2629. 1:57:39authentication screens and go straight
  2630. 1:57:42to the home I mean think about it that's
  2631. 1:57:44the typical app experience you're not
  2632. 1:57:46going to sign in for the app or go
  2633. 1:57:48through the onboarding every time you
  2634. 1:57:49open the app on your phone you're going
  2635. 1:57:51to go Direct ly to the homepage of that
  2636. 1:57:53app so let's do that next I think it's
  2637. 1:57:56going to be an easy fix and it's not
  2638. 1:57:58working right now because I accidentally
  2639. 1:58:00skipped one of the steps in the Expo
  2640. 1:58:02clerk setup and that is if you go to
  2641. 1:58:05this app layout remember when I told you
  2642. 1:58:08that we will take apart this o TS token
  2643. 1:58:11cache just to not clutter the layout
  2644. 1:58:14well I exported it but I forgot to use
  2645. 1:58:17it so we have to pass this clerk token
  2646. 1:58:21cache
  2647. 1:58:22equal to token cache coming from lib o
  2648. 1:58:26right here once you pass it it should
  2649. 1:58:29have access to the current user session
  2650. 1:58:31it is still not redirecting me back to
  2651. 1:58:33home though which is okay for now we can
  2652. 1:58:36retest it once again later once we
  2653. 1:58:38implement the login functionality
  2654. 1:58:40because right now we just have the
  2655. 1:58:42registration so even if we did want it
  2656. 1:58:44to login again with the same account we
  2657. 1:58:46cannot do that right now so let's head
  2658. 1:58:49over to the sign in component or the
  2659. 1:58:53page and head over to this function
  2660. 1:58:56called on signin press if you head over
  2661. 1:58:59to the clerk Expo setup if you scroll
  2662. 1:59:02down there's going to be the sign in
  2663. 1:59:04page here as well just below the signup
  2664. 1:59:08there we go signin page and it includes
  2665. 1:59:11the on signin press you can get to this
  2666. 1:59:14documentation Page by googleing for Expo
  2667. 1:59:18clerk quick start now I will override
  2668. 1:59:21this function and we'll of course have
  2669. 1:59:23to do some additional fixes such as
  2670. 1:59:25importing this use signin functionality
  2671. 1:59:28alongside the router so we can paste
  2672. 1:59:30that right here at the top and we need
  2673. 1:59:33to import the use sign
  2674. 1:59:36in coming from at clerk SL clerk Expo
  2675. 1:59:43and we also need to import the used
  2676. 1:59:44router so let's do just that use router
  2677. 1:59:49from Expo router in here they're using
  2678. 1:59:52the Ed call back so that means that we
  2679. 1:59:54need to import the use call back from
  2680. 1:59:57react and as email address that's just
  2681. 2:00:00going to be form. email and password
  2682. 2:00:03will be equal to form. password other
  2683. 2:00:06than that I think we just need to fix it
  2684. 2:00:09in one more place form. email and form.
  2685. 2:00:13password right here in the dependency
  2686. 2:00:16array and we have no more errors now we
  2687. 2:00:20can try to sign in
  2688. 2:00:22let's skip the onboarding we've seen it
  2689. 2:00:24quite a few times let's head over to
  2690. 2:00:26login and enter the email and password
  2691. 2:00:29you signed up with I have stored it in
  2692. 2:00:32my Apple passwords and here's a cool
  2693. 2:00:34thing I can now just press password for
  2694. 2:00:36Expo Dev scan my face and it
  2695. 2:00:39automatically entered my email and
  2696. 2:00:41password and I can click sign in and
  2697. 2:00:44there we go I got redirected straight to
  2698. 2:00:47the tabs home this is amazing now we can
  2699. 2:00:52fix some of these routing issues that we
  2700. 2:00:54have with the warnings at the bottom for
  2701. 2:00:57example it is say that no route name
  2702. 2:00:59tabs exists in nested children tabs chat
  2703. 2:01:02tabs home and tabs profile so let's
  2704. 2:01:05first check our layout next to the tabs
  2705. 2:01:10and here we have added a name of tabs
  2706. 2:01:12Heather shown false but it looks like
  2707. 2:01:15we're missing the navigation to point to
  2708. 2:01:17the other screens on our main
  2709. 2:01:19application such as chat home profile
  2710. 2:01:22and rides and we'll create the knv bar
  2711. 2:01:25or should I say the Bottom bar for your
  2712. 2:01:27thumb right within tabs and then the
  2713. 2:01:30layout and then we'll be able to
  2714. 2:01:32navigate to all of these other screens
  2715. 2:01:34so let's do that next to get started
  2716. 2:01:37with creating our tabs let's first
  2717. 2:01:40declare the layout by saying const
  2718. 2:01:43layout is equal to just a regular
  2719. 2:01:46function and it can be an instant return
  2720. 2:01:49where we'll render the tabs coming from
  2721. 2:01:52Expo router and then we can export
  2722. 2:01:55default the layout so what are tabs well
  2723. 2:01:59tabs is like a navigation bar in web
  2724. 2:02:01applications it allows us to quickly
  2725. 2:02:04switch over to other screens this tab
  2726. 2:02:07will have an initial route name which
  2727. 2:02:10will be equal to index in this case and
  2728. 2:02:13we can also provide a couple of
  2729. 2:02:15different screen options to it the
  2730. 2:02:18screen options will be an object to
  2731. 2:02:20which we can provide things like tab bar
  2732. 2:02:23active tint color equal to White there's
  2733. 2:02:27many many other things that we can
  2734. 2:02:29provide to it for now I will just leave
  2735. 2:02:31this here within the tabs we also can
  2736. 2:02:35create different tabs. screens our first
  2737. 2:02:39Tab screen will be a self-closing
  2738. 2:02:41component with a name equal to home and
  2739. 2:02:45options where we can render the title
  2740. 2:02:48equal to home as well
  2741. 2:02:52header shown will be set to false and we
  2742. 2:02:55can even modify the tab bar icon which
  2743. 2:02:58is going to be a callback function that
  2744. 2:03:01returns a tab icon and this tab icon
  2745. 2:03:05will be a custom component which we can
  2746. 2:03:07declare right here const tab
  2747. 2:03:11icon is just an immediate return
  2748. 2:03:14function that for now just returns a
  2749. 2:03:18view within the view we can have another
  2750. 2:03:21smaller View coming from react native
  2751. 2:03:23and within it we can render an image
  2752. 2:03:26with this icon so we can import the
  2753. 2:03:28image and render it right here I just
  2754. 2:03:31noticed that my iPhone simulator is no
  2755. 2:03:33longer running so let me hook it up and
  2756. 2:03:36now we can get into our application and
  2757. 2:03:39now if we fix this typo right here we
  2758. 2:03:43should be able to get into our
  2759. 2:03:44application I'll just reloaded for good
  2760. 2:03:46measure and you can see that we're in it
  2761. 2:03:49says contact adjs master at the top
  2762. 2:03:53that's because we have said Heather
  2763. 2:03:54shown to false otherwise it would be
  2764. 2:03:56here so let's remove it and let's
  2765. 2:03:59continue working on the tabs you can
  2766. 2:04:01also start seeing the tabs appear on the
  2767. 2:04:03bottom and as we switch between them
  2768. 2:04:05we're actually going to different routes
  2769. 2:04:08pretty cool we have those routes as
  2770. 2:04:10they're dynamically taken from these
  2771. 2:04:13files we have created because each file
  2772. 2:04:16corresponds to a screen great so why are
  2773. 2:04:20we even adding these tab screens here
  2774. 2:04:22well to further modify how this Bottom
  2775. 2:04:24bar will look like and primarily to
  2776. 2:04:27change the icon so here we can take the
  2777. 2:04:30focused state of this icon and if it's
  2778. 2:04:33focused we can pass it as focused is
  2779. 2:04:37equal to focus and we can pass a source
  2780. 2:04:39equal to icons coming from index home
  2781. 2:04:44and now you'll be able to see that this
  2782. 2:04:46one the home should have an icon at
  2783. 2:04:48least it will have it once we add it
  2784. 2:04:50within this image we can also duplicate
  2785. 2:04:52this Tab screen three more times 1 2 3
  2786. 2:04:57the first time it'll be for home the
  2787. 2:05:00second time it will be for rides uh
  2788. 2:05:02rather the history of rides so we can
  2789. 2:05:04say rides and the title will be rides
  2790. 2:05:08and the icon will be
  2791. 2:05:11list the next one will be chat chat with
  2792. 2:05:15a Capital C and it's going to be icons.
  2793. 2:05:19chat and then the last one will be
  2794. 2:05:22profile title will be
  2795. 2:05:25profile and the icons will be profile as
  2796. 2:05:30well if we save it it's good they're
  2797. 2:05:32back but now we can further style how
  2798. 2:05:35each one of these looks like or at least
  2799. 2:05:38it's tab icon so let's give this first
  2800. 2:05:41view a class name equal to
  2801. 2:05:45flex Flex Das row justify Das Center I
  2802. 2:05:51items D
  2803. 2:05:53Center rounded D full and if it's
  2804. 2:05:56focused then we can give it a BG general
  2805. 2:06:00of 300 else we can give it nothing but
  2806. 2:06:04of course for this to work we have to
  2807. 2:06:05make it a template string so let's do
  2808. 2:06:08just that there we go that's good and
  2809. 2:06:12this Focus state is coming from props so
  2810. 2:06:14we can say source is for the image and
  2811. 2:06:17focus is for the focus State and we can
  2812. 2:06:19declare the types source is of a Type
  2813. 2:06:22image source prop type and focused will
  2814. 2:06:27simply be a Boolean the interview can be
  2815. 2:06:31styled in a similar manner it can have a
  2816. 2:06:34class name which will be a dynamic
  2817. 2:06:35template string of rounded D full W of
  2818. 2:06:4012 h of 12 items D Center justify Das
  2819. 2:06:45Center and if it is focused then we can
  2820. 2:06:49give it a BG of General
  2821. 2:06:53400 and otherwise it's going to be just
  2822. 2:06:56an empty string now you can see that we
  2823. 2:06:58have this green selector icon and for
  2824. 2:07:01the image itself let's give it a source
  2825. 2:07:03equal to
  2826. 2:07:04Source a tint color equal to White a
  2827. 2:07:10resize mode equal to
  2828. 2:07:13contain and finally a class name equal
  2829. 2:07:17to W of 7 and H of 7 as well and and now
  2830. 2:07:21we can see a nice looking home icon but
  2831. 2:07:25it still doesn't look that good and
  2832. 2:07:26that's because we haven't modified the
  2833. 2:07:29actual tabs options so we have many many
  2834. 2:07:32more options to choose how our tab will
  2835. 2:07:36look like tab bar active tint color is
  2836. 2:07:39just one of the options we can also say
  2837. 2:07:41tab bar inactive tint color and we can
  2838. 2:07:45also set that to White next we have tab
  2839. 2:07:49bar show label we're going to set that
  2840. 2:07:51to false that's because we have a nice
  2841. 2:07:53looking icon next we have a tab bar
  2842. 2:07:57style which will be equal to an object
  2843. 2:08:01that's going to have a background color
  2844. 2:08:03equal to Hash 333 333 and if we save
  2845. 2:08:08this you can now see this nice looking
  2846. 2:08:10background and finally this is starting
  2847. 2:08:12to look more like a real mobile app we
  2848. 2:08:15can give it a border radius of about
  2849. 2:08:19let's do 50 let's give it a a padding
  2850. 2:08:22bottom of zero an overflow of hidden a
  2851. 2:08:27margin horizontal equal to about 20 a
  2852. 2:08:31margin bottom equal to 20 as well height
  2853. 2:08:35of 78 display equal to flex justify
  2854. 2:08:40content equal to space between align
  2855. 2:08:44items equal to Center let's fix this
  2856. 2:08:48space between let's give it a flex
  2857. 2:08:51direction of
  2858. 2:08:53row and finally a position of absolute
  2859. 2:08:57so this way it will always appear on top
  2860. 2:08:59of other content and take a look at this
  2861. 2:09:02we have a beautiful bottom navigation
  2862. 2:09:05bar with nice looking icons and activity
  2863. 2:09:08status that allows us to switch between
  2864. 2:09:11all of our four apps screens and now we
  2865. 2:09:14can go back to our homepage so that's
  2866. 2:09:16going to be home and we can put this
  2867. 2:09:18within a safe area
  2868. 2:09:22view which is coming from react native
  2869. 2:09:24safe area context now we can actually
  2870. 2:09:27see Hello contact adjs Mastery Pro and
  2871. 2:09:30now if we reload our application by
  2872. 2:09:33shaking it a bit and pressing reload you
  2873. 2:09:36can notice that we are automatically
  2874. 2:09:37brought to our home screen which means
  2875. 2:09:40that we no longer have to go through
  2876. 2:09:42that entire welcome onboarding and off
  2877. 2:09:45process that's great we have a clean
  2878. 2:09:48slate to continue working on our
  2879. 2:09:50homepage so let's clean it up a bit and
  2880. 2:09:53sure we could start adding more UI but
  2881. 2:09:56what's UI good for if we don't have it
  2882. 2:09:59stored as real data that we're showing
  2883. 2:10:01in our app we want to make our apps
  2884. 2:10:03truly functional and use databases to
  2885. 2:10:06store users data and then present it to
  2886. 2:10:08them in a nice looking UI for that
  2887. 2:10:11reason now is the perfect time to
  2888. 2:10:13implement a database and in this video
  2889. 2:10:15we won't be using any backend as a
  2890. 2:10:17service tools we'll be using a native
  2891. 2:10:21postgress database and will even write
  2892. 2:10:24real SQL queries we'll do that with neon
  2893. 2:10:27the database platform which I think is
  2894. 2:10:29the best one so far and even versell
  2895. 2:10:32builds their postr databases on top of
  2896. 2:10:35them so if you haven't already created
  2897. 2:10:36an account at the start of the video
  2898. 2:10:38click the link in the description to
  2899. 2:10:40follow along and see exactly what I'm
  2900. 2:10:42seeing and create an account right now
  2901. 2:10:45once you do that you'll be redirected to
  2902. 2:10:47your neon dashboard let me show it to
  2903. 2:10:50you how simple it is to set it up in
  2904. 2:10:53this case we'll be using the neon driver
  2905. 2:10:55so let's copy this block of code and add
  2906. 2:10:58it to our code just to keep our code
  2907. 2:11:00clean I'll put it in a new file and this
  2908. 2:11:02time it has to be added to a special
  2909. 2:11:05file in Expo we have the possibility to
  2910. 2:11:08create APA routes does it sound familiar
  2911. 2:11:11it's because it's coming from nextjs so
  2912. 2:11:14we can create in parentheses an API
  2913. 2:11:17folder and then within it we can create
  2914. 2:11:20a new route for for our users's API so
  2915. 2:11:23let's say new file user Plus api. Ts
  2916. 2:11:29it's not dashes it's not square brackets
  2917. 2:11:32Expo uses pluses in between so user plus
  2918. 2:11:36API and here we can paste what we just
  2919. 2:11:39copied you'll quickly notice that we
  2920. 2:11:40don't have this package installed so
  2921. 2:11:42just copy it open up the second terminal
  2922. 2:11:45and run mpm install and install the neon
  2923. 2:11:48database serverless once you do that we
  2924. 2:11:51can store this database URL within our
  2925. 2:11:53environment variables so let's copy it
  2926. 2:11:57head over to
  2927. 2:11:59ourv and add it as a database undor URL
  2928. 2:12:04is equal to to the key that you just
  2929. 2:12:06copied you don't have to keep the string
  2930. 2:12:08signs so make sure to remove them now we
  2931. 2:12:11can go back in here and just use the
  2932. 2:12:14process. EnV right here so neon process.
  2933. 2:12:19EnV do
  2934. 2:12:22database uncore
  2935. 2:12:24URL and we might need to wrap it in a
  2936. 2:12:27template string because this needs to be
  2937. 2:12:30a string great and this exposes the SQL
  2938. 2:12:34neon querying function allowing us to
  2939. 2:12:36query anything we want from our database
  2940. 2:12:39we won't be querying it just here rather
  2941. 2:12:41we'll be using expose API routes
  2942. 2:12:44functionality that we can call from I
  2943. 2:12:47wanted to say front end but it's really
  2944. 2:12:49from mobile screens so let me show you
  2945. 2:12:51how that works the only thing you have
  2946. 2:12:53to do is export a new async function
  2947. 2:12:57declare whether it's post or get or
  2948. 2:12:59something else you get a request as the
  2949. 2:13:02first and only parameter and you open it
  2950. 2:13:05up in here you have a try and catch
  2951. 2:13:07block and you can do all the server
  2952. 2:13:10logic right here but let me explain this
  2953. 2:13:12by referring to the documentation as
  2954. 2:13:14well what are API routes they are
  2955. 2:13:17functions that are executed when a route
  2956. 2:13:20is matched
  2957. 2:13:22they can be used to handle sensitive
  2958. 2:13:23data such as API keys or Implement
  2959. 2:13:26custom server logic they're created by
  2960. 2:13:29creating files in the app directory with
  2961. 2:13:31the Plus api. Ts extension for example
  2962. 2:13:34the following route Handler is executed
  2963. 2:13:37when for/ Hello is matched to create an
  2964. 2:13:40API route you just need to export a new
  2965. 2:13:43function either say get or post and then
  2966. 2:13:46return a response. Json that's it
  2967. 2:13:49similar to nextjs and when it comes to
  2968. 2:13:52how we can use the neon serverless
  2969. 2:13:54driver well it's pretty simple you can
  2970. 2:13:57use raw SQL queries or use tools like
  2971. 2:14:00drizzle or something else to fetch data
  2972. 2:14:03in this application we'll be using
  2973. 2:14:05native SQL queries but if you want me to
  2974. 2:14:08use some kind of an orm like Prisma or
  2975. 2:14:10drizzle just let me know and this is it
  2976. 2:14:13take a look you just declare a new SQL
  2977. 2:14:16instance by declaring neon from neon
  2978. 2:14:19database serverless and you Prov provide
  2979. 2:14:21your database URL and you can
  2980. 2:14:23immediately start querying it pretty
  2981. 2:14:26cool right if you're not familiar with
  2982. 2:14:28SQL syntax I'll give you a phenomenal
  2983. 2:14:31resource you can refer to very soon but
  2984. 2:14:34with that in mind let's create our first
  2985. 2:14:35post request that would create a user we
  2986. 2:14:37can move this SQL neon thing right
  2987. 2:14:40within our post request because we have
  2988. 2:14:42to declare it every time we make a new
  2989. 2:14:44request then we can destructure some
  2990. 2:14:46things that we're passing into the
  2991. 2:14:48request such as the name email and clerk
  2992. 2:14:51ID and that's going to be equal to await
  2993. 2:14:55request. Json we're not passing those
  2994. 2:14:58yet but we'll pass it soon once we try
  2995. 2:15:01to make a call to this API route next
  2996. 2:15:03we're going to check if we don't have
  2997. 2:15:05access to the name or email or clerk ID
  2998. 2:15:09we're just going to return a
  2999. 2:15:12response.
  3000. 2:15:14Json where the first parameter is an
  3001. 2:15:16error where we can say missing required
  3002. 2:15:20fields and the second parameter is the
  3003. 2:15:23inid where we can send the status of 400
  3004. 2:15:27and it looks like I'm missing an equal
  3005. 2:15:29sign right here there we go now it
  3006. 2:15:31nicely structures it for me but if we do
  3007. 2:15:34have all of these fields then we can
  3008. 2:15:36form a new response that we're getting
  3009. 2:15:38from the database by saying const
  3010. 2:15:41response is equal to await SQL and now
  3011. 2:15:46here we dive into the magic of SQL
  3012. 2:15:49syntax the most most powerful way to
  3013. 2:15:52talk to a postgress or mySQL database
  3014. 2:15:55you just open up template strings you
  3015. 2:15:58expand it into multiple lines and you
  3016. 2:16:00can tell your database to do whatever
  3017. 2:16:03you want it to do the syntax and a bit
  3018. 2:16:06on the longer side as opposed to using
  3019. 2:16:08an orm but you have the full flexibility
  3020. 2:16:12so if you wanted to create a user no
  3021. 2:16:14longer is it just users. create or
  3022. 2:16:17something like that with SQL you can say
  3023. 2:16:20insert
  3024. 2:16:21into
  3025. 2:16:23users and then you can choose what you
  3026. 2:16:25want to insert into it in this case
  3027. 2:16:28it'll be name email and clerk ID and
  3028. 2:16:34then you can Define which values are you
  3029. 2:16:36passing into these fields that you are
  3030. 2:16:40inserting so the values will be a
  3031. 2:16:43template string of name a template
  3032. 2:16:46string of email and a template string of
  3033. 2:16:49clerk ID that's going to look something
  3034. 2:16:52like this and even though this SQL query
  3035. 2:16:55is quite simple soon enough we'll dive
  3036. 2:16:58into more complex SQL queries so I want
  3037. 2:17:01to share with you a course that I
  3038. 2:17:03created which will most likely be a paid
  3039. 2:17:05course later on but for now I will give
  3040. 2:17:07it to you for free so you can practice
  3041. 2:17:09your SQL knowledge before continuing
  3042. 2:17:12with the rest of this project if you
  3043. 2:17:14need it the course is called database
  3044. 2:17:17Mastery and it starts with pure SQL it
  3045. 2:17:21is currently available on our platform
  3046. 2:17:24and as I said soon enough it will become
  3047. 2:17:26paid but for now I can give you free
  3048. 2:17:30access there we dive into database
  3049. 2:17:32introductions introduction to SQL how to
  3050. 2:17:36create tables and insert data and Main
  3051. 2:17:39SQL parameters you can access it by
  3052. 2:17:42clicking the databases link down in the
  3053. 2:17:44description we'll revisit the course
  3054. 2:17:46later on once we start writing more
  3055. 2:17:48complex SQL queries for now we can can
  3056. 2:17:51proceed with the rest of this API call
  3057. 2:17:53we can return a new response and we can
  3058. 2:17:57say json.
  3059. 2:17:59stringify to which we can pass an object
  3060. 2:18:01of data which can be equal to the
  3061. 2:18:04response and as the second parameter to
  3062. 2:18:06the response we can pass a status of
  3063. 2:18:092011 and I just noticed that all of this
  3064. 2:18:12should have been within a try so I have
  3065. 2:18:14to put this Tri block all the way above
  3066. 2:18:18there we go and then we finally have a
  3067. 2:18:21catch so if we have an error we want a
  3068. 2:18:23console. log. error and we can also
  3069. 2:18:27return a response. Json with the error
  3070. 2:18:31and a status code of
  3071. 2:18:35500 great and this is our Expo API route
  3072. 2:18:41inside of which we're calling serverless
  3073. 2:18:43neon database so how can we actually
  3074. 2:18:46trigger this API route well I've told
  3075. 2:18:49you a bit about that when reading the
  3076. 2:18:51documentation but let me show it to you
  3077. 2:18:54one thing I'll do first is go to the lib
  3078. 2:18:57and create a new file called fetch. TS
  3079. 2:19:02and inside of here I prepared for you a
  3080. 2:19:05helper function that will make it easier
  3081. 2:19:07for us to continually make fetch calls
  3082. 2:19:10without writing so much code so if you
  3083. 2:19:13go to the read me of this video go to
  3084. 2:19:15Snippets you'll be able to find a lib
  3085. 2:19:17fetch. TS file so copy it and P pasted
  3086. 2:19:21right here you'll notice it has two
  3087. 2:19:23functions one is a hook use fetch which
  3088. 2:19:27will allow us to Simply fetch the data
  3089. 2:19:29and it already has built-in loading and
  3090. 2:19:32error handling right here so when we
  3091. 2:19:34fetch the data we can make sure that
  3092. 2:19:36it's either there it's either loading or
  3093. 2:19:39it aired out and here's the part that
  3094. 2:19:41actually helps us make the request it is
  3095. 2:19:45just a regular function that accepts the
  3096. 2:19:47URL and the options and it just calls
  3097. 2:19:50the regular Fetch with that URL and with
  3098. 2:19:53those options if the response is not
  3099. 2:19:55okay we throw an error else we forward
  3100. 2:19:58the response from that API call so
  3101. 2:20:00instead of writing this entire code
  3102. 2:20:03every time now we can just call the
  3103. 2:20:05fetch API functionality so let's call it
  3104. 2:20:08within signup we can navigate over to
  3105. 2:20:11sign up and remember where we have a
  3106. 2:20:13to-do right here create a database user
  3107. 2:20:17this is exactly what we want to do right
  3108. 2:20:19now so we can say AIT
  3109. 2:20:21and we can call this fetch API to which
  3110. 2:20:24we can pass first of all the URL SL API
  3111. 2:20:29SL
  3112. 2:20:30user why is it that well because it is
  3113. 2:20:34API user plus API so it means it's an
  3114. 2:20:37API route and as the second parameter we
  3115. 2:20:40can provide all the options such as a
  3116. 2:20:43method of post and then a body which
  3117. 2:20:46will be Json stringify to which we can
  3118. 2:20:49pass an object of name is equal to
  3119. 2:20:53formname email is equal to form. mail
  3120. 2:20:57and clerk ID is equal to complete signup
  3121. 2:21:01doc created
  3122. 2:21:04user ID like this and now you know where
  3123. 2:21:08these are coming from name email and
  3124. 2:21:09clerk ID correspond to our API
  3125. 2:21:15route and they correspond to these
  3126. 2:21:18request Json data variables name name
  3127. 2:21:20email and clerk we make this call from
  3128. 2:21:24when we sign up the user we call our
  3129. 2:21:26Expo API routes we insert that data into
  3130. 2:21:30the neon DB database at the same time we
  3131. 2:21:33create and connect the clerk user and
  3132. 2:21:36set it to the session so if we have done
  3133. 2:21:39everything correctly we should be able
  3134. 2:21:41to go to the neon DV database and go to
  3135. 2:21:45the SQL editor inside of here we can run
  3136. 2:21:48some SQL commands and with this GitHub
  3137. 2:21:51repost Snippets I prepared for you one
  3138. 2:21:53command that we need to run it is under
  3139. 2:21:56create users table SQL so you can copy
  3140. 2:22:00it go back to the neon DB console paste
  3141. 2:22:03it right here and we can read it
  3142. 2:22:05together it says create table users it's
  3143. 2:22:08going to have an ID which is going to be
  3144. 2:22:10a Serial primary key with a name email
  3145. 2:22:14and clerk ID and we can run this it
  3146. 2:22:17looks like we got an error and if I run
  3147. 2:22:19it again it's it says statement executed
  3148. 2:22:22successfully it looks like there was an
  3149. 2:22:24issue with the c character in the clerk
  3150. 2:22:26ID so just delete it and type it again
  3151. 2:22:29and try to rerun it I think it should
  3152. 2:22:31work maybe GitHub MDX added some special
  3153. 2:22:34characters here either way the table has
  3154. 2:22:37been created and we can head over to
  3155. 2:22:39Branch tables which is a new feature on
  3156. 2:22:41neon
  3157. 2:22:42DB this is pretty cool because we can
  3158. 2:22:44immediately see the users table appear
  3159. 2:22:47which means that we are ready to test
  3160. 2:22:49everything out and alongside a new user
  3161. 2:22:51appearing on clerk now a new user should
  3162. 2:22:54appear on neon DB as well so going back
  3163. 2:22:57to Clerk's dashboard for one last time I
  3164. 2:23:00will delete this user because now as
  3165. 2:23:03soon as we create a new one hopefully it
  3166. 2:23:05will appear on both sides so let's
  3167. 2:23:08reload our application clerk session
  3168. 2:23:11died which is great because that means
  3169. 2:23:13that we have deleted our user and now
  3170. 2:23:15before we go ahead and create a new
  3171. 2:23:17account there's just one more thing we
  3172. 2:23:18have to do and that is within the app.
  3173. 2:23:21Json if we want to use expose server
  3174. 2:23:24functionalities we have to go under web
  3175. 2:23:27output and change this into server
  3176. 2:23:30that's going to enable us to do APA
  3177. 2:23:32routes and alongside that we also have
  3178. 2:23:35to add a settings object into plugins
  3179. 2:23:39right here for the Expo router and we
  3180. 2:23:41can do that by adding the origin and
  3181. 2:23:44here we can have any kind of a mock URL
  3182. 2:23:47for our server at least it can be a mock
  3183. 2:23:49URL for development purposes and in this
  3184. 2:23:52case we can do something like a string
  3185. 2:23:54of https col sl/ uber.com and since we
  3186. 2:24:00have expanded this Expo router with
  3187. 2:24:02additional options we have to wrap it in
  3188. 2:24:04an array so now we'll have an array
  3189. 2:24:07where the name of the plugin will be
  3190. 2:24:09Expo router and then we're showing the
  3191. 2:24:11options as the second parameter so
  3192. 2:24:13that's going to look something like this
  3193. 2:24:16I think we can even put it all in one
  3194. 2:24:18line so it makes more sense
  3195. 2:24:21there we go perfect and now that we have
  3196. 2:24:25added this URL we also have to add it to
  3197. 2:24:28our environment variables that's going
  3198. 2:24:30to look something like this go to
  3199. 2:24:33EnV call it Expo corpore server URL and
  3200. 2:24:39make it equal to to this URL that we
  3201. 2:24:42have right here I think we need to end
  3202. 2:24:45it with a forward slash so we can do
  3203. 2:24:47that here and here now we can close
  3204. 2:24:51these files open up the terminal stop it
  3205. 2:24:54from running and run MPX Expo start- C
  3206. 2:24:59to rerun our application with cach
  3207. 2:25:02cleared and you'll notice that now it'll
  3208. 2:25:05take a bit of a longer time to bundle
  3209. 2:25:07which is a good thing because it means
  3210. 2:25:08that our app now has more things within
  3211. 2:25:10it so let's wait until it bundles there
  3212. 2:25:14we go soon enough we'll remove this
  3213. 2:25:16clerk warning from the bottom and now we
  3214. 2:25:18can try to register one more more time
  3215. 2:25:21make sure to delete your existing clerk
  3216. 2:25:23account I'll enter my name and I'll also
  3217. 2:25:27enter my email and password and I'll
  3218. 2:25:30click sign up here we get our
  3219. 2:25:33verification code
  3220. 2:25:3686437 and we can verify our email there
  3221. 2:25:40we go verified browse home we got
  3222. 2:25:43redirected to home but that's nothing
  3223. 2:25:45new we also get a new clerk user but
  3224. 2:25:48that's also nothing new the most
  3225. 2:25:50important thing is that if you go to
  3226. 2:25:52your neon console and go to table check
  3227. 2:25:55out the users table and here our new
  3228. 2:25:58user will be created so soon enough
  3229. 2:26:01we'll be able to create additional
  3230. 2:26:03tables for writers and drivers and we
  3231. 2:26:06can make a connection between all of
  3232. 2:26:08that to store it in our database and
  3233. 2:26:10displayed within our app great work so
  3234. 2:26:13far moving forward we can finally start
  3235. 2:26:16creating some of the UI for our homepage
  3236. 2:26:18so let's navigate to our home and let's
  3237. 2:26:21Dive Right In to get started with
  3238. 2:26:24creating our homepage we can wrap
  3239. 2:26:26everything in a safe area View and give
  3240. 2:26:28it a class name equal to BG General 500
  3241. 2:26:33that's going to give it a nice looking
  3242. 2:26:34grayish background now for the first
  3243. 2:26:36time in this course we'll use something
  3244. 2:26:39known as a flat list coming from react
  3245. 2:26:42native a flat list in react native is a
  3246. 2:26:46performant interface for rendering basic
  3247. 2:26:49flat lists supporting things like
  3248. 2:26:51horizontal mode header support footer
  3249. 2:26:54separators pull to refresh scroll
  3250. 2:26:56loadings it's basically a UL an
  3251. 2:26:59unordered list but with some additional
  3252. 2:27:01functionalities for mobile devices where
  3253. 2:27:04you can pull to refresh you can scroll
  3254. 2:27:06horizontally and they all nicely appear
  3255. 2:27:09it is also completely customizable so
  3256. 2:27:11you can choose exactly how each one of
  3257. 2:27:13these elements looks like but the gist
  3258. 2:27:15is you get some data and then you decide
  3259. 2:27:18how each one of these list items looks
  3260. 2:27:20like and finally you render it within a
  3261. 2:27:23flat list I'll show all of that to you
  3262. 2:27:25right now so for the flat list to work
  3263. 2:27:28we of course have to have some data so
  3264. 2:27:30we can have a data object and for now I
  3265. 2:27:32can make that an array of different
  3266. 2:27:35rides so how will each one of our rides
  3267. 2:27:38look like well it's going to have an
  3268. 2:27:41origin address a destination address
  3269. 2:27:44different map information a screenshot
  3270. 2:27:46of the map driver first name last name
  3271. 2:27:48and more so we could go ahead and create
  3272. 2:27:51some kind of a mock list of rides right
  3273. 2:27:53here and that's exactly what I've done
  3274. 2:27:56under these code Snippets just to make
  3275. 2:27:58your life a bit easier so if you scroll
  3276. 2:28:00all the way to the bottom you can see
  3277. 2:28:02that we have mock rides and this is
  3278. 2:28:05simply an array with a couple of objects
  3279. 2:28:08that allow us to mock four different
  3280. 2:28:10rides just so we can create their UI
  3281. 2:28:12first and then implement the
  3282. 2:28:13functionality later so let's go ahead
  3283. 2:28:16and copy this code snippet and we can
  3284. 2:28:19put it right here above our page const
  3285. 2:28:22recent rides is equal to and then we can
  3286. 2:28:26paste this entire array right here what
  3287. 2:28:29we can do is just collapse it that way
  3288. 2:28:31we don't have to keep looking at this
  3289. 2:28:32huge array but we can now use it within
  3290. 2:28:35the data so let's just say data is equal
  3291. 2:28:38to recent rides I think I misspelled it
  3292. 2:28:42there we go recent rides and we can
  3293. 2:28:45slice only the first five characters so
  3294. 2:28:48from zero to five
  3295. 2:28:50question mark. slice just to make sure
  3296. 2:28:52that we actually do have them now that
  3297. 2:28:55we have the data we also have to have
  3298. 2:28:57something else to figure out how we will
  3299. 2:28:59render each ride or should I say how we
  3300. 2:29:02should render each item within the list
  3301. 2:29:05and for that we can use a prop called
  3302. 2:29:07render item that allows us to specify
  3303. 2:29:11how each one of these items will be
  3304. 2:29:14rendered so first make sure to create a
  3305. 2:29:16callback function that looks like this
  3306. 2:29:19you can D structure the item data like
  3307. 2:29:21this and then for each one we can return
  3308. 2:29:24a ride card which is a self closing
  3309. 2:29:28component to which we can pass the
  3310. 2:29:30entire ride which is equal to the item
  3311. 2:29:33of course this ride card is another
  3312. 2:29:35custom component that we have to create
  3313. 2:29:38so let's go to our components folder and
  3314. 2:29:42create a new component called ride card.
  3315. 2:29:47TSX here we can of course create a new
  3316. 2:29:50con ride card and we can export default
  3317. 2:29:54that ride
  3318. 2:29:55card and you already know that it's
  3319. 2:29:57going to accept only one prop so we can
  3320. 2:29:59destructure the prop of ride which is
  3321. 2:30:02going to be of a type ride is of a type
  3322. 2:30:06ride coming from the types and here for
  3323. 2:30:09now we can just return a view and within
  3324. 2:30:11the view for now we can render a text
  3325. 2:30:14and that text can render the ride.
  3326. 2:30:17driver. first uncore name just so we can
  3327. 2:30:21see who is the driver and don't forget
  3328. 2:30:23to import The View as well as the text
  3329. 2:30:27from react native there we go now we can
  3330. 2:30:30go back to home and we can import the
  3331. 2:30:33right card coming from components right
  3332. 2:30:36card and right at the top I'm not sure
  3333. 2:30:39if you can see it as it's very very
  3334. 2:30:40small we have four different names of
  3335. 2:30:43writers we can make that a bit larger by
  3336. 2:30:45giving it a class name equal to text- 3
  3337. 2:30:49XL
  3338. 2:30:51and there we go we can see David James
  3339. 2:30:53James and Michael that is great so now
  3340. 2:30:56our flat list has the data that it wants
  3341. 2:30:59to render and it also has a render item
  3342. 2:31:02function that tells it how each piece of
  3343. 2:31:05data should look like so now we can go
  3344. 2:31:07into the right card and start developing
  3345. 2:31:10it first things first we'll have to
  3346. 2:31:12mention ride. driver Ride die
  3347. 2:31:15geolocation Ride die destination many
  3348. 2:31:18many times as we have too many any
  3349. 2:31:20properties on this ride so what we could
  3350. 2:31:22do is just destructure those properties
  3351. 2:31:25at the top so we don't have to repeat
  3352. 2:31:26ourselves you do that by saying ride and
  3353. 2:31:29then you destructure it within a new
  3354. 2:31:31object we can destructure something like
  3355. 2:31:33a destination longitude we can
  3356. 2:31:36destructure the destination latitude as
  3357. 2:31:39well let's also destructure the origin
  3358. 2:31:42address we can destructure the
  3359. 2:31:44destination
  3360. 2:31:46address I think we'll need a created app
  3361. 2:31:50so when was the ride created at as well
  3362. 2:31:52as the ride time how much time does it
  3363. 2:31:55take we can then destructure the driver
  3364. 2:31:58and we can destructure the payment
  3365. 2:32:00uncore status I think this is going to
  3366. 2:32:02be enough for now so instead of saying
  3367. 2:32:04ride. driver now we can just say driver.
  3368. 2:32:07first name great so let's start turning
  3369. 2:32:10this ugly list of names into something
  3370. 2:32:13that looks like this each one of the
  3371. 2:32:14cards will have the pickup location
  3372. 2:32:17destination location a photo of that
  3373. 2:32:19entire path and many more pieces of
  3374. 2:32:22information quite exciting and a bit
  3375. 2:32:24easier than what we have done so far in
  3376. 2:32:26our application this is mainly just the
  3377. 2:32:28UI so let's give this view some class
  3378. 2:32:30names I'll give it a class name of flex
  3379. 2:32:33Flex D row items Das Center justify Das
  3380. 2:32:38Center BG of white to differentiate it
  3381. 2:32:41from that gray background rounded dlg to
  3382. 2:32:44give it that organic look Shadow
  3383. 2:32:48DSM Shadow Das neutral
  3384. 2:32:52D300 margin bottom of three so now this
  3385. 2:32:56will create this card like feel you can
  3386. 2:32:59see it on the right side or on your
  3387. 2:33:00phone and you can see how nice this list
  3388. 2:33:02behaves on your phone next we can move
  3389. 2:33:05this text a bit below and we can create
  3390. 2:33:07a second view right here this view will
  3391. 2:33:10have a class name equal to flex Flex D
  3392. 2:33:14row items Das Center justify Dash
  3393. 2:33:18between and a padding of three within it
  3394. 2:33:22we'll have one more view which we'll use
  3395. 2:33:24to enclose the image so we can give it a
  3396. 2:33:27class name of flex Flex D row items Das
  3397. 2:33:32Center and justify Dash
  3398. 2:33:35between within it we can render a react
  3399. 2:33:38native image so import it and give it a
  3400. 2:33:43source this time we'll refer to the
  3401. 2:33:45source by the URI which is going to be a
  3402. 2:33:49template string of
  3403. 2:33:54https maps. gapy and this go apify is
  3404. 2:33:59going to be such a cool API which will
  3405. 2:34:02use to transform the coordinates into an
  3406. 2:34:05image where it shows a map and the start
  3407. 2:34:08and two locations with the entire path
  3408. 2:34:10outlined within it so we'll have to head
  3409. 2:34:12over to gy.com as you can see it is
  3410. 2:34:15completely free for up to 3,000 credits
  3411. 2:34:18per day which is more than enough enough
  3412. 2:34:20and we can click get started the only
  3413. 2:34:22thing we have to do is basically create
  3414. 2:34:24an account which is free and no credit
  3415. 2:34:26card is required so simply continue with
  3416. 2:34:29Google create a project I'll name it JSM
  3417. 2:34:34ride choose the API I believe we're
  3418. 2:34:37using the static map API and it's going
  3419. 2:34:40to give you an API key which we can
  3420. 2:34:42store into our envs what you also get is
  3421. 2:34:45a complete API URL example so let's copy
  3422. 2:34:48that and let let's paste it right here
  3423. 2:34:50instead of this URI you can see it is
  3424. 2:34:53very very long right now but we can cut
  3425. 2:34:56it right here after lawn and lat as
  3426. 2:34:59we'll be providing our own longitude and
  3427. 2:35:02latitude and we don't need any of these
  3428. 2:35:04additional properties so we can remove
  3429. 2:35:07that and we also need to grab our API
  3430. 2:35:09key so copy it head over to our
  3431. 2:35:13envs and add a new one Expo public go
  3432. 2:35:18apy API I key is equal to this number
  3433. 2:35:22right here now if we go back we can
  3434. 2:35:24structure this better by saying maps.
  3435. 2:35:27gy.com V1 static map style is osm bright
  3436. 2:35:32so we don't need this smooth width is
  3437. 2:35:35600 height is 400 Center lawn lad and
  3438. 2:35:40now we can add a column and then we can
  3439. 2:35:43add a dynamic property of destination
  3440. 2:35:47longitude comma and then we can do
  3441. 2:35:50another property of destination latitude
  3442. 2:35:53we can add the end sign outside and say
  3443. 2:35:58Zoom is equal to 14 and finally we have
  3444. 2:36:01to provide the API key which is equal to
  3445. 2:36:05process. EnV
  3446. 2:36:07dot Expo
  3447. 2:36:09undoru uncore
  3448. 2:36:13gapore API uncore key make sure that
  3449. 2:36:16everything is spelled properly right
  3450. 2:36:18here and that this Expo public key is
  3451. 2:36:21the same one that you have right here in
  3452. 2:36:23your envs we can also provide this image
  3453. 2:36:26with a class name of a w of 80 pixels h
  3454. 2:36:33of 90
  3455. 2:36:36pixels rounded dlg still not there so
  3456. 2:36:40maybe I can reload my
  3457. 2:36:43application sometimes that helps once we
  3458. 2:36:45update our envs and there we go the maps
  3459. 2:36:48are appearing you can see we have David
  3460. 2:36:51James and Michael and even though
  3461. 2:36:53they're very very small right now it's
  3462. 2:36:55going to be so interesting to see once
  3463. 2:36:57we put it in a better looking UI of
  3464. 2:37:00course I'm talking about something like
  3465. 2:37:02this so now let's continue with the rest
  3466. 2:37:04of the UI we can go below this image and
  3467. 2:37:07still within the same view we can create
  3468. 2:37:10another
  3469. 2:37:11view with a class name equal to flex
  3470. 2:37:17flex-all margin X of five
  3471. 2:37:20Gap y of five and flex of one within it
  3472. 2:37:25we'll have another view to contain our
  3473. 2:37:27icon that'll have a class name equal to
  3474. 2:37:32flex Flex D row items Das Center and the
  3475. 2:37:36Gap X off
  3476. 2:37:39two and within it we can render an image
  3477. 2:37:43with a source equal to icons which we
  3478. 2:37:46need to import do two so which
  3479. 2:37:50destination are we going to with a class
  3480. 2:37:52name of w of 5 which is about 20 pixels
  3481. 2:37:56and an H of five there we go now we can
  3482. 2:37:59see this two icon and below it we can
  3483. 2:38:02render a text that'll spell out the
  3484. 2:38:05origin address so now we can give it a
  3485. 2:38:08class name equal to text- MD and font
  3486. 2:38:13Das Jakarta medium there we go and now
  3487. 2:38:17we can duplicate this view one more time
  3488. 2:38:20below for the from
  3489. 2:38:23destination or no should they say to
  3490. 2:38:25destination this was the origin address
  3491. 2:38:27so in the second one we can say icons.
  3492. 2:38:30point and I can change it to
  3493. 2:38:34destination address and to both of these
  3494. 2:38:36texts we need to add a special property
  3495. 2:38:39of number of lines is equal to one
  3496. 2:38:44because we don't want it to go over one
  3497. 2:38:46line there we go now we can see some
  3498. 2:38:48different locations at this point it's
  3499. 2:38:50safe to remove this driver first name as
  3500. 2:38:53it's messing with our view so if we do
  3501. 2:38:55that it's looking great now we can go
  3502. 2:38:58below this text and Below one two three
  3503. 2:39:02more views so only two are left at the
  3504. 2:39:05bottom there we can create a view that
  3505. 2:39:07will wrap the bottom part of our
  3506. 2:39:09card this view will have a class name
  3507. 2:39:13equal to flex
  3508. 2:39:15flex-all w- full margin top of five
  3509. 2:39:19BG general of 500 rounded
  3510. 2:39:24dlg padding of three items Das start and
  3511. 2:39:28justify Dash center for the time being
  3512. 2:39:32this messed up our UI but don't you
  3513. 2:39:34worry about that we can add another view
  3514. 2:39:36right here with a class name equal to
  3515. 2:39:40flex Flex D row items Das Center w- full
  3516. 2:39:46justify Dash
  3517. 2:39:47between notice times we're playing with
  3518. 2:39:50flex properties and margin bottom of
  3519. 2:39:53five within it we can render a piece of
  3520. 2:39:56text that'll just say date and
  3521. 2:40:00time and we can give it a class name of
  3522. 2:40:04text- MD font D Jakarta medium and text-
  3523. 2:40:11gray- 500 right below we can duplicate
  3524. 2:40:15this same
  3525. 2:40:17text and instead of in of saying date
  3526. 2:40:20and time we can render real date and
  3527. 2:40:22time by saying format date which we can
  3528. 2:40:25import and give it a created add
  3529. 2:40:29property then we can do a comma and once
  3530. 2:40:32again call the format date function and
  3531. 2:40:36this time pass it the ride time and this
  3532. 2:40:39format date is one of the utility
  3533. 2:40:41functions that we can create so let's
  3534. 2:40:44quickly head over to our lib and let's
  3535. 2:40:47create a new file called
  3536. 2:40:50U.S this stands for utility functions
  3537. 2:40:54one of these functions can be export
  3538. 2:40:56const format date that takes in a date
  3539. 2:41:01string which is a string and returns a
  3540. 2:41:05string so that's going to look something
  3541. 2:41:07like this this is the perfect type of
  3542. 2:41:10function that you would use chat GPT for
  3543. 2:41:13it is pretty simple not that complex and
  3544. 2:41:16it just gets the job done so if you go
  3545. 2:41:19to GitHub Snippets you'll see that I
  3546. 2:41:21provided you with this lib utils file
  3547. 2:41:24which you can copy and override this
  3548. 2:41:27utils you'll notice that here we have
  3549. 2:41:29this format date that basically takes a
  3550. 2:41:32date turns it into a new date gets the
  3551. 2:41:35month names and then returns it in a
  3552. 2:41:38nice human readable format we also have
  3553. 2:41:41a couple of other functions right here
  3554. 2:41:43all created by Chad GPT now we need to
  3555. 2:41:46import this format date function from
  3556. 2:41:49from
  3557. 2:41:50utils so let's do that at the top format
  3558. 2:41:54date at SL SL
  3559. 2:41:57utils and we cannot see that yet right
  3560. 2:42:00now because the layout is broken I think
  3561. 2:42:03everything is going in a row instead of
  3562. 2:42:04a column so let me scroll up and let's
  3563. 2:42:08look into some of these views right here
  3564. 2:42:11oh yeah this second view should have
  3565. 2:42:13been a
  3566. 2:42:16flex-all as in column item start justify
  3567. 2:42:20Center
  3568. 2:42:21here and a padding of three if you do
  3569. 2:42:25this check this out now everything folds
  3570. 2:42:28nicely and this date and time are also
  3571. 2:42:31appearing right here with the correct
  3572. 2:42:33information oh no it's taking the date
  3573. 2:42:35from the right time this right here
  3574. 2:42:37should have been a format time
  3575. 2:42:40function and we have to import it from
  3576. 2:42:42lib utils there we go 12th of August
  3577. 2:42:462024 8 hours this ride took eight hours
  3578. 2:42:50interesting now let's go one text and
  3579. 2:42:53one view down and create a new view
  3580. 2:42:56inside of which will show the driver
  3581. 2:42:58information so let's create its
  3582. 2:43:00container by giving it a class name of
  3583. 2:43:03flex
  3584. 2:43:05flex-r items Das Center w-o for full
  3585. 2:43:10width justify Das between to stay
  3586. 2:43:13consistent with the layout and margin
  3587. 2:43:15bottom of five to divide it from the
  3588. 2:43:17next section within here here we can
  3589. 2:43:19create a
  3590. 2:43:21text that text will say driver so let's
  3591. 2:43:24save it there we go now you can see the
  3592. 2:43:26driver and if you pay close attention
  3593. 2:43:29and if I zoom it out just a bit you'll
  3594. 2:43:31notice that this view right here is
  3595. 2:43:33exactly the same as this view so what we
  3596. 2:43:35can do is just duplicate this view
  3597. 2:43:39talking about the date and
  3598. 2:43:41time and put it right below next we can
  3599. 2:43:45change the date and time to driver and
  3600. 2:43:48we can change the information about the
  3601. 2:43:49date and time to driver. first name and
  3602. 2:43:55driver. last
  3603. 2:43:57name and take a look that looks great we
  3604. 2:44:01can duplicate it a few more times I'll
  3605. 2:44:03do it once more for now and this time
  3606. 2:44:06we'll talk about the car seats so how
  3607. 2:44:10many seats does this driver's car have
  3608. 2:44:13so we can get to that by rendering the
  3609. 2:44:16driver. carore seats
  3610. 2:44:19there we go that looks great some have
  3611. 2:44:21five some have four and finally we can
  3612. 2:44:24duplicate it once more to talk about the
  3613. 2:44:27payment so right here we can say
  3614. 2:44:31payment status and we can render a
  3615. 2:44:34payment status you can see that it all
  3616. 2:44:37says paid right now but we can change
  3617. 2:44:40the class names if it's paid to be green
  3618. 2:44:42and if it's not paid to be red so let's
  3619. 2:44:45turn this class name into a dynamic
  3620. 2:44:47template string and we can say if
  3621. 2:44:50payment status is triple equal to paid
  3622. 2:44:54then we can add an additional style of
  3623. 2:44:56text- green 500 else we can add a text
  3624. 2:45:00to Red
  3625. 2:45:02500 let's make sure to close this
  3626. 2:45:04properly we start with a question mark
  3627. 2:45:07end it here and close it right here
  3628. 2:45:12there we go this is
  3629. 2:45:14good now we can see that it all says
  3630. 2:45:17green we can also cap capitalize it so
  3631. 2:45:20here we can add capitalize so the paid
  3632. 2:45:23is capitalized with letter P you can see
  3633. 2:45:26how nice this form is like we can move
  3634. 2:45:29it up and down we can scroll it it is
  3635. 2:45:31absolutely amazing and with that we have
  3636. 2:45:34just developed our ride card it is
  3637. 2:45:37looking great so let's go back to home
  3638. 2:45:41and now that we have this ride card I
  3639. 2:45:43can show you the other properties of the
  3640. 2:45:46flat list that allow us to further
  3641. 2:45:48modify the look of that list such as a
  3642. 2:45:51class name where we can provide it a
  3643. 2:45:54padding X of five just to create some
  3644. 2:45:56more space there we go that's nice we
  3645. 2:45:59can also add a keyboard should persist
  3646. 2:46:03Taps and here we can say handled so now
  3647. 2:46:07if you tap on it the tabs should persist
  3648. 2:46:10this is preferred with flat lists we can
  3649. 2:46:13also add a Content container
  3650. 2:46:17style which can be a a padding bottom of
  3651. 2:46:21100 so now we'll have a bit more padding
  3652. 2:46:23at the bottom so we have space for our
  3653. 2:46:26bottom navigation now here's another
  3654. 2:46:28pretty cool thing this flat list
  3655. 2:46:31automatically allows you to Define how
  3656. 2:46:33an empty list component should look like
  3657. 2:46:36you just create a callback function and
  3658. 2:46:39return a new view that defines what's
  3659. 2:46:42going to happen if it is empty so let me
  3660. 2:46:46create a text first and say something
  3661. 2:46:49like empty of course we have to import
  3662. 2:46:52The View and the text at the top coming
  3663. 2:46:54from react
  3664. 2:46:58native and now if instead of these
  3665. 2:47:01recent rides I render an empty array you
  3666. 2:47:05can see empty at the top that means that
  3667. 2:47:07it gives us the possibility to style it
  3668. 2:47:09somehow differently so let's do just
  3669. 2:47:12that we can give this view a class name
  3670. 2:47:16equal to flex flex-all
  3671. 2:47:19items Das Center and justify Dash
  3672. 2:47:22Center next we need to check whether
  3673. 2:47:24we're currently loading or not it is
  3674. 2:47:27highly likely that sometimes we might be
  3675. 2:47:29loading so that's the reason why we
  3676. 2:47:31don't have any elements so for now I'll
  3677. 2:47:34just create a mock loading property and
  3678. 2:47:37set it to false later on this will come
  3679. 2:47:39from real Dynamic data So within this
  3680. 2:47:42view we can check if we're not
  3681. 2:47:46loading then we can render an empty
  3682. 2:47:49react fragment within which we'll have
  3683. 2:47:51an image that's another react native
  3684. 2:47:53component we have to
  3685. 2:47:55import and that image will have a source
  3686. 2:47:58equal to images make sure to import that
  3687. 2:48:02do no result if we save this it's going
  3688. 2:48:05to break because we have to have a
  3689. 2:48:07second part of the tary operator so if
  3690. 2:48:10we are loading for now we can just show
  3691. 2:48:12a
  3692. 2:48:14text that says
  3693. 2:48:17loading there we go now this is a huge
  3694. 2:48:20no results image so let's style it a bit
  3695. 2:48:23by giving it a class name of w40
  3696. 2:48:27h40 let's also give it an Al tag of no
  3697. 2:48:30recent rides
  3698. 2:48:33found and let's give it a resize mode of
  3699. 2:48:37contain there we go we can also give it
  3700. 2:48:41a piece of text right below it's going
  3701. 2:48:44to have a class name of text- smm and
  3702. 2:48:47it'll say no recent rides found there we
  3703. 2:48:52go as simple as that now if we are
  3704. 2:48:57loading we can show something else not
  3705. 2:49:00just a boring empty loader we can render
  3706. 2:49:03an activity indicator and that is coming
  3707. 2:49:06directly from react native it's going to
  3708. 2:49:09be a self-closing component called
  3709. 2:49:12activity
  3710. 2:49:14indicator and we can give it a size is
  3711. 2:49:17equal to small and a color of hash
  3712. 2:49:220000 there we go so now you can see a
  3713. 2:49:24very small activity indicator while it
  3714. 2:49:27is loading great let's collab this list
  3715. 2:49:31empty component and we can now bring
  3716. 2:49:33back the real data because we don't want
  3717. 2:49:35to be looking at an empty list and this
  3718. 2:49:37flat list is so versatile as you can see
  3719. 2:49:40we just defined how it would look empty
  3720. 2:49:42without using a turn operator on the
  3721. 2:49:44entire list they just provided a handy
  3722. 2:49:47prop another thing that the flat list
  3723. 2:49:49component provides is the list header
  3724. 2:49:51component allowing you to Define how a
  3725. 2:49:54header should look like let's make it
  3726. 2:49:56into a react fragment that's going to
  3727. 2:49:58render a view this view will have a
  3728. 2:50:01class name all Flex Flex Das row items
  3729. 2:50:06Das Center justify Dash between and
  3730. 2:50:10margin y of five within it we can render
  3731. 2:50:13a piece of text that says welcome and
  3732. 2:50:17then we can render the user question
  3733. 2:50:18mark. first name and we can even choose
  3734. 2:50:22to add a wave
  3735. 2:50:24Emoji you can go to Google and quickly
  3736. 2:50:27copy it welcome and now we have to get
  3737. 2:50:30the user's first name let's see where
  3738. 2:50:32this user is coming from going to the
  3739. 2:50:35top and collapsing the recent rides we
  3740. 2:50:37can see that the user is coming from the
  3741. 2:50:39hook of use user which is coming from
  3742. 2:50:42clerk Expo let's console. log. user to
  3743. 2:50:45see what data do we get in there there
  3744. 2:50:47we go take a look look at this there's a
  3745. 2:50:50lot of data but in this case the first
  3746. 2:50:52name and the full name are false I
  3747. 2:50:56believe that's because we haven't used
  3748. 2:50:57the Google authentication so far we have
  3749. 2:51:00just used the email o so maybe if we
  3750. 2:51:03don't have the first name we can render
  3751. 2:51:06something else maybe user question mark.
  3752. 2:51:10email addresses zero I believe that
  3753. 2:51:13should be the email address no it's
  3754. 2:51:15email address is zero. email address
  3755. 2:51:18there we go so now it says welcome
  3756. 2:51:21contact adjs mastery. proo it'll look
  3757. 2:51:23better once we authenticate using Google
  3758. 2:51:26let's style this text just a bit by
  3759. 2:51:28giving it a class name equal to text-
  3760. 2:51:312XL and font D jaarda extra bold okay so
  3761. 2:51:37maybe one Excel will be good now below
  3762. 2:51:39that text we can also render a touchable
  3763. 2:51:43opacity what is that that's a button so
  3764. 2:51:47what will this touchable opacity do well
  3765. 2:51:49it'll render an
  3766. 2:51:51image that has a source equal to
  3767. 2:51:55icons.
  3768. 2:51:57out and it'll have a class name of W4
  3769. 2:52:00and
  3770. 2:52:01H4 so that is this little button at the
  3771. 2:52:04top right that allows us to log out so
  3772. 2:52:07let's create a function right here
  3773. 2:52:11const handle sign out which is going to
  3774. 2:52:15be equal to an arrow function and now we
  3775. 2:52:18can add it as an onpress functionality
  3776. 2:52:21on this touchable opacity so on press we
  3777. 2:52:24can handle sign out and we can also give
  3778. 2:52:27it some additional class names such as
  3779. 2:52:30justify Das
  3780. 2:52:32center items Das Center W of 10 h of
  3781. 2:52:3810 rounded Das full and BG of
  3782. 2:52:42wide there we go so now it looks great
  3783. 2:52:46and I don't quite like that we have the
  3784. 2:52:47email address here so what do you say
  3785. 2:52:50that we split it and we split it by the
  3786. 2:52:55add sign because most people have their
  3787. 2:52:57name in the first place and then we take
  3788. 2:53:00the first part of that email right here
  3789. 2:53:02by doing this so now it's going to say
  3790. 2:53:04welcome contact because I signed up with
  3791. 2:53:06contact at JS Mastery Pro but for you
  3792. 2:53:09most likely this will be your name or
  3793. 2:53:11let me know in the comments down below
  3794. 2:53:13if it's something else we can also add
  3795. 2:53:15the capitalize right here so that now it
  3796. 2:53:18says welcome we can add a comma right
  3797. 2:53:22here contact much better or it's going
  3798. 2:53:25to be a first name once we do Google off
  3799. 2:53:28great and now I think we can make it a
  3800. 2:53:30bit bigger with 2XL moving down below
  3801. 2:53:33the touchable opacity and Below one more
  3802. 2:53:36view we can render one of the most
  3803. 2:53:38important parts of our application and
  3804. 2:53:40that's going to be a
  3805. 2:53:43Google text input that's going to be a
  3806. 2:53:46custom input which we'll create so let's
  3807. 2:53:49turn it into a component by going over
  3808. 2:53:51to the components folder and creating a
  3809. 2:53:54new Google text input. TSX you know the
  3810. 2:53:59drill it is const Google text
  3811. 2:54:04input which is equal
  3812. 2:54:06to an immediate returning function where
  3813. 2:54:09we export default Google text
  3814. 2:54:13input it's going to return a view and
  3815. 2:54:16within it we can have a text
  3816. 2:54:19that'll say search make sure to import
  3817. 2:54:22The View and the text from react
  3818. 2:54:25native so going back we can now render
  3819. 2:54:28this as a self-closing
  3820. 2:54:30component of course don't forget to
  3821. 2:54:33import it from Google text input and to
  3822. 2:54:36it we can pass some props such as icon
  3823. 2:54:39is equal to icons.
  3824. 2:54:42search we can pass it some container
  3825. 2:54:45style equal to BG White
  3826. 2:54:49Shadow MD and
  3827. 2:54:51Shadow
  3828. 2:54:54neutral
  3829. 2:54:56300 and we can provide a handle press so
  3830. 2:54:59what happens once we press it we want to
  3831. 2:55:01handle destination press and this is yet
  3832. 2:55:05another function which we can Define
  3833. 2:55:08right here at the top for which soon
  3834. 2:55:10enough we'll add the logic now we can
  3835. 2:55:12head into the Google text input to
  3836. 2:55:14accept all of these great props it's
  3837. 2:55:17going to be an icon
  3838. 2:55:19maybe later on we'll pass an initial
  3839. 2:55:21location as well it's going to be a
  3840. 2:55:24container style which we defined later
  3841. 2:55:27on we might want to change the input
  3842. 2:55:29background color so we can say text
  3843. 2:55:32input background color and finally the
  3844. 2:55:36handle
  3845. 2:55:38press and all of these will be of a type
  3846. 2:55:41Google Input props coming from types so
  3847. 2:55:45now we can style this view a bit by
  3848. 2:55:47giving it a class name of a template
  3849. 2:55:49string of flex Flex D row items Das
  3850. 2:55:54Center justify Das Center relative Z50
  3851. 2:56:00so it appears on top of other elements
  3852. 2:56:02rounded Das Excel and finally we can
  3853. 2:56:06spread all of the other container
  3854. 2:56:08Styles so now we can see the search
  3855. 2:56:10appear right here at the top and for now
  3856. 2:56:13we can give it just something like
  3857. 2:56:14margin bottom of five there we go so now
  3858. 2:56:18we can see a nice looking search or at
  3859. 2:56:20least what is soon going to become a
  3860. 2:56:22beautiful Google input from which you'll
  3861. 2:56:25be able to select all of the different
  3862. 2:56:27places in the world starting from the
  3863. 2:56:29places near you so it's going to be very
  3864. 2:56:31smart before we go ahead and create that
  3865. 2:56:34Google text input let's go a bit below
  3866. 2:56:37and create another react fragment inside
  3867. 2:56:39of which we can render a text that tells
  3868. 2:56:42us our current location so we can say
  3869. 2:56:45text your current location we can give
  3870. 2:56:48it a class name equal to text- excl font
  3871. 2:56:53djakarta bold and margin top of five as
  3872. 2:56:57well as a margin bottom of three below
  3873. 2:56:59it we can render a view that'll have a
  3874. 2:57:03class name equal to
  3875. 2:57:05flex Flex Das row items Das
  3876. 2:57:09Center BG of transparent and H of 300
  3877. 2:57:14pixels and within it we'll render maybe
  3878. 2:57:16the most important component of our
  3879. 2:57:18application and that is the map so let's
  3880. 2:57:21create a new file called map.
  3881. 2:57:24TSX you know the drill create a new map
  3882. 2:57:29which is equal to an arrow function
  3883. 2:57:31where we can export default that map and
  3884. 2:57:34for now we can just return a view so
  3885. 2:57:37let's say return a view coming from
  3886. 2:57:40react native and a text within it
  3887. 2:57:42that'll say map
  3888. 2:57:45beautiful so now we can render this map
  3889. 2:57:48right right here within it coming from
  3890. 2:57:49components map and you can see how it
  3891. 2:57:52says map right here so now we're getting
  3892. 2:57:54much much closer to this view right here
  3893. 2:57:56where it says welcome John we have a
  3894. 2:57:59sign out button a beautiful Google
  3895. 2:58:01autocomplete search your current
  3896. 2:58:03location and then the recent rides at
  3897. 2:58:05the bottom so while we're here let's go
  3898. 2:58:08below this react fragment and create one
  3899. 2:58:11final text which is going to be similar
  3900. 2:58:14to this your current location text so
  3901. 2:58:16let's copy it and it'll say
  3902. 2:58:19recent
  3903. 2:58:21rides there we go so we have recent
  3904. 2:58:23rides your current location and then
  3905. 2:58:26finally a greatl looking search input so
  3906. 2:58:29now we only have one question and that
  3907. 2:58:31is what do you want to do first since
  3908. 2:58:34you cannot talk to me right now and I
  3909. 2:58:36can only imagine what you're saying I'll
  3910. 2:58:38have to make a decision and I really
  3911. 2:58:40don't like this big hole in the center
  3912. 2:58:43of our application right now so let's do
  3913. 2:58:45the map first and then we can focus on
  3914. 2:58:47the Google autocomplete later on so I'll
  3915. 2:58:50close the home and the Google text input
  3916. 2:58:53leaving us with the map but of course
  3917. 2:58:55for that we'll have to add a lot of
  3918. 2:58:57functionalities integrating with
  3919. 2:58:59Google's apis to integrate Google's
  3920. 2:59:02Services you'll have to head over to
  3921. 2:59:04Google Cloud console that is console.
  3922. 2:59:07cloud.google.com
  3923. 2:59:09next you can create a new project so
  3924. 2:59:12just click new project at the top right
  3925. 2:59:14I'll call it JSM
  3926. 2:59:16dride and I'll put it under no
  3927. 2:59:19organizations choose where I want to put
  3928. 2:59:21it it looks like I have to choose an
  3929. 2:59:24organization and then click create I
  3930. 2:59:26think it takes about a minute for your
  3931. 2:59:28project to be created there we go it was
  3932. 2:59:31actually 5 Seconds let's select our
  3933. 2:59:33project and head over to apis and
  3934. 2:59:36services next click enable apis and
  3935. 2:59:40services and search for apis and
  3936. 2:59:42services we can search for places and
  3937. 2:59:46select the places API new new there we
  3938. 2:59:49go this is the one they even refresh the
  3939. 2:59:51icon and click enable it looks like the
  3940. 2:59:55place's API new requires a project with
  3941. 2:59:57a building account so let me try to
  3942. 3:00:00cancel this and go back and search for
  3943. 3:00:03just places API and choose this one it
  3944. 3:00:07seems like we can enable the places API
  3945. 3:00:09the original one not the new one without
  3946. 3:00:12entering the credit card details so just
  3947. 3:00:14go ahead and click enable here it might
  3948. 3:00:17ask you something else later on but then
  3949. 3:00:19just exit and it will be enabled let's
  3950. 3:00:22go back and let's enable the second API
  3951. 3:00:24we'll need which is the directions
  3952. 3:00:27API go to it and click enable great it
  3953. 3:00:32looks like it's enabling it right away
  3954. 3:00:34it did redirect me to this page where we
  3955. 3:00:36need to verify our card to get started
  3956. 3:00:39which is totally okay because they're
  3957. 3:00:40not going to charge us anything but for
  3958. 3:00:42now I'll try to exit out of that and
  3959. 3:00:44just go a page back hopefully we can do
  3960. 3:00:46it without entering any details but if
  3961. 3:00:48we need to we'll have to do that later
  3962. 3:00:50on now let's head over to our
  3963. 3:00:53dashboard and go to enabled apis and
  3964. 3:00:56services then click credentials and then
  3965. 3:01:00press create credentials and choose API
  3966. 3:01:03key there we go we just got our API key
  3967. 3:01:06so let's copy it head over to our EnV
  3968. 3:01:11and type Expo public Google API key and
  3969. 3:01:18paste the key that you just copied I
  3970. 3:01:20think this should be enough and it
  3971. 3:01:22should work if Google doesn't mess with
  3972. 3:01:24us further we'll see if it will work
  3973. 3:01:26soon enough now we can go back to the
  3974. 3:01:28map to start implementing it we'll have
  3975. 3:01:31to install two new packages so let's
  3976. 3:01:34type mpm install
  3977. 3:01:38react-native-maps as well as
  3978. 3:01:42react-native-maps DD directions and
  3979. 3:01:45press
  3980. 3:01:46enter as soon as they in sold we'll be
  3981. 3:01:49able to use a map view sounds convenient
  3982. 3:01:52right map view coming from react native
  3983. 3:01:56Maps next we can start passing it props
  3984. 3:01:59that'll make it work so let's give it a
  3985. 3:02:02provider prop which is equal to provider
  3986. 3:02:06uncore default which is coming from
  3987. 3:02:09react native Maps that's going to be
  3988. 3:02:11Google most likely next we can give it a
  3989. 3:02:14class name equal to w-o for full width
  3990. 3:02:18H full so it takes the full height of
  3991. 3:02:20the container and round it Dash to excel
  3992. 3:02:23to make the borders a bit
  3993. 3:02:26organic and would you look at that the
  3994. 3:02:29map is here currently for me it shows
  3995. 3:02:33the country of Croatia with its very
  3996. 3:02:35interesting shape as this is where I'm
  3997. 3:02:38based at for you it's going to show
  3998. 3:02:40something else and you can see how fluid
  3999. 3:02:43it is I can zoom in zoom out and move it
  4000. 3:02:46around and it just works so seamlessly
  4001. 3:02:50great so with that in mind let's
  4002. 3:02:52continue modifying this map to make it
  4003. 3:02:54soothe the needs of our application I'll
  4004. 3:02:57give it a tint color equal to black as
  4005. 3:03:01well as a map type equal to muted
  4006. 3:03:04standard this will make it just a bit
  4007. 3:03:07muted so it fits the theme of our
  4008. 3:03:09application better and it allows us to
  4009. 3:03:12better show the routes from and to
  4010. 3:03:14different locations in this case we're
  4011. 3:03:16not interested in seeing all the rivers
  4012. 3:03:18and lakes and mountains what we're
  4013. 3:03:21interested in are the roads let's also
  4014. 3:03:23turn off show points of interest by
  4015. 3:03:26saying show points of interest is equal
  4016. 3:03:29to
  4017. 3:03:30false now how can we change the initial
  4018. 3:03:33region that it points to well here we
  4019. 3:03:36can say const region is equal to an
  4020. 3:03:39object where we need to provide
  4021. 3:03:41different things such as the latitude
  4022. 3:03:43longitude and more very soon we'll
  4023. 3:03:46calculate this dynamically
  4024. 3:03:48so we'll be able to pass it as initial
  4025. 3:03:51region is equal to and then we can pass
  4026. 3:03:55the region right here but for now let's
  4027. 3:03:57leave it as it is we can also say shows
  4028. 3:04:01user location and set that to true as
  4029. 3:04:05well and finally we can make the user
  4030. 3:04:07interface style light as our application
  4031. 3:04:10is in light mode and I just noticed
  4032. 3:04:13something I mean look at the bottom left
  4033. 3:04:15corner of this map it says Apple Maps so
  4034. 3:04:20it's not Google the default in this case
  4035. 3:04:23actually is Apple because I'm on an
  4036. 3:04:25iPhone if you're using some kind of a
  4037. 3:04:27different operating system you might get
  4038. 3:04:29different map presented to you coming
  4039. 3:04:32from map view from react native maps how
  4040. 3:04:35convenient but we still needed to get
  4041. 3:04:37that Google API key which we'll test
  4042. 3:04:39later on for the places and directions
  4043. 3:04:43and you might have noticed how it found
  4044. 3:04:45your location but it didn't specifically
  4045. 3:04:49pinpoint to where you are on the map
  4046. 3:04:51that's because if you don't Grant your
  4047. 3:04:54device location permissions then it
  4048. 3:04:56cannot know where you are which might be
  4049. 3:04:59good or not depending on how much
  4050. 3:05:00privacy you want but all of the great
  4051. 3:05:03applications to work properly need to
  4052. 3:05:05have your correct location imagine if
  4053. 3:05:08Uber didn't have your exact location how
  4054. 3:05:10would drivers nowhere to find you so how
  4055. 3:05:13do we implement the functionality of
  4056. 3:05:16getting your exact Lo
  4057. 3:05:18well let me show you we'll install a
  4058. 3:05:21package called zustand so mpm install
  4059. 3:05:25zustand and no zustand doesn't have
  4060. 3:05:28anything to do with knowing your
  4061. 3:05:30location but it has Bare Necessities for
  4062. 3:05:34State Management in react and react
  4063. 3:05:36native so it is a state management
  4064. 3:05:38Library you can think of it like react
  4065. 3:05:40context it allows you to create a store
  4066. 3:05:43of some information and then you can use
  4067. 3:05:46an update that information across your
  4068. 3:05:49entire application so let's do just that
  4069. 3:05:53going back to our code we can create a
  4070. 3:05:55new folder in the root of our directory
  4071. 3:05:58and we can call it store within the
  4072. 3:06:00store we can create an index.ts
  4073. 3:06:04file there we can import the create
  4074. 3:06:08functionality from zand once we have the
  4075. 3:06:11create function it allows us to create a
  4076. 3:06:13store and we can do that by saying const
  4077. 3:06:17use location store is equal to
  4078. 3:06:21create that function takes in one
  4079. 3:06:24parameter which is the state Creator so
  4080. 3:06:26it is a callback function with an
  4081. 3:06:29immediate return of an object so it
  4082. 3:06:31looks like this you open up a callback
  4083. 3:06:34function and then you immediately write
  4084. 3:06:37parentheses and then braces this means
  4085. 3:06:39that you're immediately returning an
  4086. 3:06:41object here as the first parameter of
  4087. 3:06:43the Callback function we get a set
  4088. 3:06:46function that allows us to set the state
  4089. 3:06:49now we want to export this Ed location
  4090. 3:06:52store because once we create it zustand
  4091. 3:06:55allows us to call it from any file also
  4092. 3:06:58we can Define the type of that store in
  4093. 3:07:00this case it'll be a location store
  4094. 3:07:03coming from
  4095. 3:07:04types it'll have things like the user
  4096. 3:07:08address which at the start will be set
  4097. 3:07:10to null we can also give it a user
  4098. 3:07:13longitude set to null by default next
  4099. 3:07:16we're going to have a user
  4100. 3:07:18address which is also going to be set to
  4101. 3:07:20null destination longitude set to null
  4102. 3:07:24destination latitude set to null
  4103. 3:07:27destination address set to null by
  4104. 3:07:30default as well and then we have to have
  4105. 3:07:33a Setter function set user
  4106. 3:07:36location which will take in a latitude
  4107. 3:07:40longitude and the address and we have to
  4108. 3:07:43Define the types of these so that's
  4109. 3:07:45going to be latitude
  4110. 3:07:47is a number longitude is a number and
  4111. 3:07:52address is a string and this entire
  4112. 3:07:55thing returns a function or rather it's
  4113. 3:07:58a function block so let's type it out
  4114. 3:08:01properly looks like I have a typo
  4115. 3:08:03somewhere or maybe not maybe it's good
  4116. 3:08:06but the prettier is not formatting it
  4117. 3:08:08yet because we're missing some things
  4118. 3:08:09still we'll fix it as we go in this
  4119. 3:08:12function block where we're passing the
  4120. 3:08:14latitude longitude and the address we
  4121. 3:08:16can now use this Setter function given
  4122. 3:08:19to us by zest end to now actually set
  4123. 3:08:22those values so remember what I said
  4124. 3:08:24immediate return of an object that is
  4125. 3:08:26parentheses and then curly braces where
  4126. 3:08:30we set the user latitude to be equal to
  4127. 3:08:33Latitude we said the user
  4128. 3:08:36longitude to be equal to longitude and
  4129. 3:08:39we set the user address to be equal to
  4130. 3:08:42address I think I have a typo here
  4131. 3:08:44that's why it's not fixing it so if I
  4132. 3:08:46fix the typo
  4133. 3:08:48there we go this is better but it's
  4134. 3:08:50still complaining about something it's
  4135. 3:08:52saying that it's missing the user
  4136. 3:08:53latitude so let's make sure to fix that
  4137. 3:08:56user latitude yeah indeed it is missing
  4138. 3:08:59I have user address two times and it's
  4139. 3:09:02missing one more thing and that is the
  4140. 3:09:04set destination location so that's going
  4141. 3:09:07to be a second Setter function set
  4142. 3:09:10destination location which will be
  4143. 3:09:12almost exactly the same as set user
  4144. 3:09:15location so let's just duplicate it
  4145. 3:09:18it'll also accept the latitude longitude
  4146. 3:09:20and the
  4147. 3:09:22address and this time instead of saying
  4148. 3:09:24user latitude longitude and address
  4149. 3:09:26we'll say
  4150. 3:09:28destination latitude longitude and
  4151. 3:09:31address there we go now it nicely saves
  4152. 3:09:34it and we have to rename it to set
  4153. 3:09:37destination location now we can see our
  4154. 3:09:40tab script and pror or an esent nobody's
  4155. 3:09:42complaining anymore and that's why I
  4156. 3:09:45love typescript so much B Bas on this
  4157. 3:09:47location store where we said how
  4158. 3:09:49everything should look like it is now
  4159. 3:09:51saving your ass from making stupid
  4160. 3:09:53mistakes and typos as I have typed user
  4161. 3:09:56address two times maybe you didn't good
  4162. 3:09:59for you but now now that we have no red
  4163. 3:10:02squiggly lines hopefully this makes a
  4164. 3:10:04bit more sense we have some values and
  4165. 3:10:08we have some Setters for those values
  4166. 3:10:10where we set the user location and where
  4167. 3:10:13we set the destination location great so
  4168. 3:10:16this is called a dtin store and now we
  4169. 3:10:19have access to this use location store
  4170. 3:10:21hook which we can call where are we
  4171. 3:10:24going to call it for the first time well
  4172. 3:10:26it's going to be within our homepage the
  4173. 3:10:29first time we open up our application
  4174. 3:10:32and log our user in right here we can
  4175. 3:10:35say const and we can get the set user
  4176. 3:10:39location as well as set destination
  4177. 3:10:44location and that's going to be equal to
  4178. 3:10:46you use location store coming from store
  4179. 3:10:51alongside getting these Setters from the
  4180. 3:10:53store we also need one more thing and
  4181. 3:10:55that is a use State for the permissions
  4182. 3:10:59whether we have given permissions for
  4183. 3:11:01our location so we can say has
  4184. 3:11:04permissions and set has permissions at
  4185. 3:11:07the start set to false and now we can
  4186. 3:11:11create a new use effect
  4187. 3:11:14hook that's going to take in a callback
  4188. 3:11:16function
  4189. 3:11:18and also a dependency array also see how
  4190. 3:11:20webstorm adds this inlay hints about
  4191. 3:11:24what each one of these parameters is
  4192. 3:11:26first is the actual effect and then the
  4193. 3:11:28dependency array for now we'll keep the
  4194. 3:11:30dependency array empty and within it
  4195. 3:11:33we'll create a new async function called
  4196. 3:11:36request
  4197. 3:11:37location const
  4198. 3:11:40request location is equal to an async
  4199. 3:11:45function and we can call it immediately
  4200. 3:11:48so just right here request location
  4201. 3:11:51within it we can get the status of a
  4202. 3:11:53request for a location by destructuring
  4203. 3:11:56the status by saying await location
  4204. 3:12:00coming from react native do
  4205. 3:12:04request
  4206. 3:12:06foreground
  4207. 3:12:09permission async and this location is
  4208. 3:12:12coming at the top from react native and
  4209. 3:12:14you can see that right now it's having
  4210. 3:12:16trouble getting this method from the
  4211. 3:12:18location object and that's because the
  4212. 3:12:21location is coming from a new package
  4213. 3:12:23called Expo location so let's install it
  4214. 3:12:27mpm install Expo Das location once it
  4215. 3:12:31installs we can just import it at the
  4216. 3:12:33top by saying
  4217. 3:12:35import asterisk meaning everything as
  4218. 3:12:39location from Expo
  4219. 3:12:43location and it looks like I have a typo
  4220. 3:12:45right here it's per perms plural now
  4221. 3:12:49it's okay and it knows exactly what this
  4222. 3:12:51function is about asks the user to Grant
  4223. 3:12:54permissions for location while the app
  4224. 3:12:56is in the foreground next we can check
  4225. 3:12:58if the status is not equal to Granite
  4226. 3:13:02then we can set has permissions to false
  4227. 3:13:07and exit out of the function but if we
  4228. 3:13:09did get the permissions we can get
  4229. 3:13:11access to a location by saying lead
  4230. 3:13:13location is equal to a weight location
  4231. 3:13:17dot get current positions async next we
  4232. 3:13:23can extract the address from the
  4233. 3:13:24location by saying const address is
  4234. 3:13:27equal to await location. reverse geocode
  4235. 3:13:32async to which we pass the
  4236. 3:13:35latitude equal to
  4237. 3:13:37location. cords question mark. latitude
  4238. 3:13:41and we can add the exclamation mark at
  4239. 3:13:43the end because we know it'll be there
  4240. 3:13:45just for tab script to know and we can
  4241. 3:13:47repeat the same thing for the
  4242. 3:13:50longitude once we have that here's the
  4243. 3:13:53keyp part we can call the set user
  4244. 3:13:56location which is coming from our store
  4245. 3:13:59and now we can update the latitude to be
  4246. 3:14:01equal to
  4247. 3:14:03location. chords.
  4248. 3:14:06Latitude we can do the same thing for
  4249. 3:14:08the
  4250. 3:14:09longitude and we can also store the
  4251. 3:14:12address which is going to be a template
  4252. 3:14:13string of
  4253. 3:14:15address Z
  4254. 3:14:18.name comma address 0. region and you
  4255. 3:14:23can notice that here it's complaining
  4256. 3:14:24about the await all of this has to be
  4257. 3:14:27within the request location function
  4258. 3:14:29which is async so let's put it there and
  4259. 3:14:33close the function right here now this
  4260. 3:14:35will request location access and then
  4261. 3:14:38set it to the store which means that
  4262. 3:14:39we'll be able to use it from anywhere
  4263. 3:14:41else in our application okay so if we
  4264. 3:14:44have done everything correctly a new
  4265. 3:14:45popup asking your location permission
  4266. 3:14:48should have appeared for you you cannot
  4267. 3:14:50see it here on my computer screen but on
  4268. 3:14:52my phone I can see allow Expo go to use
  4269. 3:14:55your
  4270. 3:14:56location and I'll click allow while
  4271. 3:14:58using the app in case you gave access to
  4272. 3:15:01expoo to your location before then it'll
  4273. 3:15:05already have it but you can then switch
  4274. 3:15:07it by going to settings and then say ask
  4275. 3:15:09next time or when I share so this time
  4276. 3:15:12it's always going to ask you for the
  4277. 3:15:13location great so now that we're getting
  4278. 3:15:16this location
  4279. 3:15:17we're actually not only getting it but
  4280. 3:15:19we're also setting it to the store which
  4281. 3:15:22means that we can now go back to the map
  4282. 3:15:24and we have all the necessary
  4283. 3:15:26information to figure out where our user
  4284. 3:15:28is on the map so let's extract that
  4285. 3:15:32information by saying const and these
  4286. 3:15:35structure the user longitude user
  4287. 3:15:38latitude destination
  4288. 3:15:42latitude and
  4289. 3:15:44destination longitude and that's going
  4290. 3:15:47to be equal to use location store and
  4291. 3:15:51now that we have that we can figure out
  4292. 3:15:53our region and what is a region well
  4293. 3:15:56region is a circle around you with a
  4294. 3:16:00specified radius from within which we
  4295. 3:16:02can search for
  4296. 3:16:04drivers and we can get the region by
  4297. 3:16:07calling a special method called
  4298. 3:16:10calculate
  4299. 3:16:12region to which we then need to provide
  4300. 3:16:15all of this information such as the user
  4301. 3:16:17longitude latitude destination longitude
  4302. 3:16:20and latitude and that's it but what is
  4303. 3:16:23this calculate region well it's one of
  4304. 3:16:25the utility functions that you can get
  4305. 3:16:28in the Snippets down below if you search
  4306. 3:16:30for lib map. DS copy this and create a
  4307. 3:16:35new file in the lip called map. TS here
  4308. 3:16:41we'll put all the utility functions for
  4309. 3:16:43the map it seems like a lot but it's
  4310. 3:16:47really not we have three different
  4311. 3:16:49functions here we have the calculate
  4312. 3:16:51driver's time which we can nicely
  4313. 3:16:54collapse right here we also have
  4314. 3:16:57calculate region which is the one which
  4315. 3:16:59we want to work on right now and we also
  4316. 3:17:02have generate markers from data this is
  4317. 3:17:06a function that takes in the drivers and
  4318. 3:17:08marks their locations around our Circle
  4319. 3:17:11but later on once we have real drivers
  4320. 3:17:13you can just get their coordinates and
  4321. 3:17:15then use the same function to generate
  4322. 3:17:17markers with slight modifications don't
  4323. 3:17:20worry I'll explain every one of these
  4324. 3:17:22functions as we use them so first let's
  4325. 3:17:24import the use calculate region within
  4326. 3:17:27our map it's going to come from the map
  4327. 3:17:30utils and now we can see what do we have
  4328. 3:17:32to pass to it if there is no user
  4329. 3:17:35longitude and latitude it'll set some
  4330. 3:17:37fake values right here and if there's no
  4331. 3:17:40destination longitude and latitude it'll
  4332. 3:17:42just take a Delta meaning a difference
  4333. 3:17:45from our current user location and and
  4334. 3:17:47just in my specific case I'll take these
  4335. 3:17:49mock values I'll go to home and when
  4336. 3:17:53we're setting the user location I will
  4337. 3:17:56set them to these mock values just so I
  4338. 3:17:59don't have to allow for relocation every
  4339. 3:18:01time now if I go back to the map you can
  4340. 3:18:05see that we're getting the minimum
  4341. 3:18:06latitude and maximum
  4342. 3:18:08latitude based on the user latitude and
  4343. 3:18:11the destination latitude once we have
  4344. 3:18:13that we add some padding meaning we
  4345. 3:18:16spread the circle around our user and we
  4346. 3:18:20further calculate
  4347. 3:18:21it as I said before Chad GPT is perfect
  4348. 3:18:25for these types of functions but it's
  4349. 3:18:27going to make much more sense once we
  4350. 3:18:29actually put it to action so let me go
  4351. 3:18:32back right here and let's put this
  4352. 3:18:33region to use I'll say initial region is
  4353. 3:18:37equal to region and I'll turn on the
  4354. 3:18:39show user location in my case it is
  4355. 3:18:42using this specific location I provided
  4356. 3:18:45which is right here in San
  4357. 3:18:48Francisco so the next thing we can focus
  4358. 3:18:51on is showing some drivers nearby our
  4359. 3:18:54location and we can do that by going
  4360. 3:18:56back to our store and creating a second
  4361. 3:19:00store which will be called use driver
  4362. 3:19:03store here we can export const use
  4363. 3:19:07driver store you know the drill and then
  4364. 3:19:10we can say create with a type of driver
  4365. 3:19:14store and we get this Setter
  4366. 3:19:16functionality it right here make sure to
  4367. 3:19:19import the driver store from the types
  4368. 3:19:21and within here we can set the drivers
  4369. 3:19:24at the start equal to an empty array as
  4370. 3:19:27marker data coming from types it's going
  4371. 3:19:31to be an array of marker data and later
  4372. 3:19:34on we'll have a selected driver which at
  4373. 3:19:36the start can be set to null we have to
  4374. 3:19:39have a set select the driver which is
  4375. 3:19:42going to be equal to a callback function
  4376. 3:19:45that takes in a drive of a type number
  4377. 3:19:48and then calls the set functionality
  4378. 3:19:51with its own callback function where we
  4379. 3:19:53can set the select a
  4380. 3:19:55driver to be equal to driver ID right
  4381. 3:19:59below that we have the set drivers
  4382. 3:20:01functionality to set all the
  4383. 3:20:04drivers which takes in drivers as an
  4384. 3:20:07array of marker data and again calls the
  4385. 3:20:10set functionality where it sets drivers
  4386. 3:20:13to drivers and finally we can clear
  4387. 3:20:16select the driver which is just going to
  4388. 3:20:18call a set functionality and set a
  4389. 3:20:21selected driver to null and it looks
  4390. 3:20:23like I misspelled the driver ID and in
  4391. 3:20:26this case there's so many different
  4392. 3:20:27parentheses and braces and things to
  4393. 3:20:30mess up so what I'll do is I'll provide
  4394. 3:20:33this index.ts of store in the code
  4395. 3:20:36Snippets in the GitHub readme so if you
  4396. 3:20:38mess something up you can copy and paste
  4397. 3:20:40it from there now that we have that used
  4398. 3:20:43driver store we can make use of it in
  4399. 3:20:45the map by getting the selected driver
  4400. 3:20:49as well as the set
  4401. 3:20:51drivers by saying is equal to use driver
  4402. 3:20:55store and now the question is where are
  4403. 3:20:58we going to get the drivers from of
  4404. 3:21:00course they're going to come from our
  4405. 3:21:01neon DB post girl database but for the
  4406. 3:21:04time being let's mock some drivers like
  4407. 3:21:07we mocked our recent rides just so we
  4408. 3:21:09can see it on the screen in the GitHub
  4409. 3:21:11read me you can see a little toggle with
  4410. 3:21:14Moog drivers so copy it and paste it at
  4411. 3:21:18the top of the map file cons drivers is
  4412. 3:21:22equal to this array make sure to
  4413. 3:21:25collapse
  4414. 3:21:26it once you have the drivers we can
  4415. 3:21:29create a new use
  4416. 3:21:31effect it has a callback function and it
  4417. 3:21:35also has a dependency array that changes
  4418. 3:21:38whenever the drivers change in here we
  4419. 3:21:40want to check if the drivers exist and
  4420. 3:21:42whether they're an array so we can say
  4421. 3:21:44if array that do is array to which we
  4422. 3:21:48can pass the drivers and if we have the
  4423. 3:21:51drivers but if we don't have the user so
  4424. 3:21:53if no user latitude or no user
  4425. 3:21:58longitude in that case we want to exit
  4426. 3:22:00out of this but if we do have the user
  4427. 3:22:03location and if we have the drivers we
  4428. 3:22:06want to create markers on the map so we
  4429. 3:22:09can say const new
  4430. 3:22:11markers and that's equal to generate
  4431. 3:22:14markers from data so this is this is a
  4432. 3:22:16function that we created in the map
  4433. 3:22:19utils to which we can pass the data
  4434. 3:22:21equal to drivers and we can pass the
  4435. 3:22:24user latitude and the user longitude and
  4436. 3:22:28that'll generate the markers this is not
  4437. 3:22:30too big of a deal right now because we
  4438. 3:22:32have mock drivers later on once we have
  4439. 3:22:34the real ones from the database it'll be
  4440. 3:22:37okay so now that we have these new
  4441. 3:22:39markers we can set them to the state so
  4442. 3:22:41let's create a new used State and let's
  4443. 3:22:45call it
  4444. 3:22:47markers and set markers at the start
  4445. 3:22:50equal to an empty array and they'll be
  4446. 3:22:52of a type marker
  4447. 3:22:55data and specifically an array of marker
  4448. 3:22:59datas and after we create these new
  4449. 3:23:01markers we can simply set markers to be
  4450. 3:23:05equal to new
  4451. 3:23:08markers and just to go to the map utils
  4452. 3:23:11I can explain how the generate markers
  4453. 3:23:13from data Works basically it's it's
  4454. 3:23:16getting the information about our user
  4455. 3:23:18latitude and longitude so where are we
  4456. 3:23:21right now and it's adding a random
  4457. 3:23:24offset to mock the driver's locations so
  4458. 3:23:27that it seems like they're next to us
  4459. 3:23:29once you implement the real geolocation
  4460. 3:23:31for the drivers you won't have to do
  4461. 3:23:33this you'll be able to just show a
  4462. 3:23:35couple of the drivers that are most
  4463. 3:23:37nearby to the
  4464. 3:23:39user but now the question is where do we
  4465. 3:23:42show these markers and how do we show
  4466. 3:23:44them within the map let me show you
  4467. 3:23:48we can go to the map and specifically
  4468. 3:23:50inside of the map and here we can map
  4469. 3:23:53over the markers by saying markers. map
  4470. 3:23:58where we get each individual marker and
  4471. 3:24:01for each marker we can automatically
  4472. 3:24:03return a new marker this marker is
  4473. 3:24:06coming from react native Maps so let's
  4474. 3:24:10look into it react native Maps we have a
  4475. 3:24:13map view and then before the provider
  4476. 3:24:15default inside of the curly braces we
  4477. 3:24:18can import the marker but of course the
  4478. 3:24:21marker needs to have some
  4479. 3:24:23information so what we can do is give it
  4480. 3:24:26a key equal to marker. ID give it
  4481. 3:24:30coordinates which are going to be equal
  4482. 3:24:32to an object of
  4483. 3:24:34latitude equal to marker.
  4484. 3:24:38latitude longitude equal to marker.
  4485. 3:24:43longitude we can give that specific
  4486. 3:24:46marker a title equal to marker. tile and
  4487. 3:24:51we can also give it an image equal to if
  4488. 3:24:54selected driver is triple equal to
  4489. 3:24:58marker. ID then we can render the icons
  4490. 3:25:01coming from constants do selected marker
  4491. 3:25:06else we can just render a marker icon
  4492. 3:25:09depending on which marker is selected
  4493. 3:25:12and would you look at that we have four
  4494. 3:25:14cars appearing next to our current
  4495. 3:25:16location for me there is no pin about
  4496. 3:25:19the where I'm at right now but for you
  4497. 3:25:22there should be one so it's looking even
  4498. 3:25:24better now we have our current location
  4499. 3:25:27showing on the map we see the recent
  4500. 3:25:29rides and we see the drivers near by us
  4501. 3:25:32that can drive us somewhere but the
  4502. 3:25:35question is where are we going to go and
  4503. 3:25:37how can we tell that to our Uber
  4504. 3:25:39application to implement that we'll have
  4505. 3:25:41to focus on the second biggest part of
  4506. 3:25:44our homepage and that my friend is our
  4507. 3:25:48Google text input finally we'll be able
  4508. 3:25:51to type something in and get the path
  4509. 3:25:54drawn out from our current location to
  4510. 3:25:57our destination location so let's dive
  4511. 3:26:00right into the Google text input and
  4512. 3:26:02let's start implementing it first things
  4513. 3:26:05first we have to install a package for
  4514. 3:26:07the react native Google Places
  4515. 3:26:09autocomplete and its name is exactly
  4516. 3:26:12that mpm install
  4517. 3:26:15react-native -
  4518. 3:26:17google-places D Auto
  4519. 3:26:22Complete we have a view right here and
  4520. 3:26:25directly within the view where currently
  4521. 3:26:27it says search will render the
  4522. 3:26:29self-closing Google Places autocomplete
  4523. 3:26:34and we have to import it right at the
  4524. 3:26:35top from the react native Google Places
  4525. 3:26:38autocomplete that's a mou full and
  4526. 3:26:41immediately you can see a nice looking
  4527. 3:26:43input appear and if you click into it
  4528. 3:26:45you can start typing tying
  4529. 3:26:47something but it's still not showing any
  4530. 3:26:50information so let's continue styling it
  4531. 3:26:52further and passing other props to it
  4532. 3:26:55that it expects such as fetch details
  4533. 3:26:58which can be set to true we can also
  4534. 3:27:01pass it a placeholder equal to search or
  4535. 3:27:05maybe something like where you want to
  4536. 3:27:08go next we can give it a debounce this
  4537. 3:27:11means that it's only going to make a
  4538. 3:27:13request every 200 milliseconds if if it
  4539. 3:27:16was going to make a request every key
  4540. 3:27:18press that would be too many requests
  4541. 3:27:21and we can also give it some Styles so
  4542. 3:27:24let's create a large object of styles
  4543. 3:27:27we're writing CSS injs here and first we
  4544. 3:27:31can style different things such as the
  4545. 3:27:33text input
  4546. 3:27:34container so we can create that as
  4547. 3:27:36another object that's going to look like
  4548. 3:27:39this and we can say align items is equal
  4549. 3:27:42to Center we can also say justify
  4550. 3:27:45content is equal to Center as well we
  4551. 3:27:48can give it a border
  4552. 3:27:51radius equal to
  4553. 3:27:5320 a margin horizontal equal to 20 as
  4554. 3:27:57well you can see how it's moving it and
  4555. 3:28:00a position set to
  4556. 3:28:02relative and also a shadow
  4557. 3:28:06color equal to Hash D4 D4 D4 next we can
  4558. 3:28:12style the text input so let's go outside
  4559. 3:28:16inside of this and say text
  4560. 3:28:18input we can give it a background color
  4561. 3:28:22which is going to be equal to either the
  4562. 3:28:25text input background color or the color
  4563. 3:28:29white so this is the one we're passing
  4564. 3:28:31through props text input background
  4565. 3:28:34color let's properly close this it's
  4566. 3:28:37also going to have a font size of 16 a
  4567. 3:28:41font weight of 600 a margin top of 5 and
  4568. 3:28:47a width of 100% finally a border radius
  4569. 3:28:52of 200 to make it not have such rough
  4570. 3:28:56Corners finally once we can see some
  4571. 3:28:58elements on the screen we can style how
  4572. 3:29:01they look like by modifying the list
  4573. 3:29:04view Styles we can say that the
  4574. 3:29:07background color of the list view will
  4575. 3:29:09be equal to text input background color
  4576. 3:29:12if it exists or else it'll be set to
  4577. 3:29:16white we can also give it a position
  4578. 3:29:19equal to
  4579. 3:29:20relative we can give it a top position
  4580. 3:29:24equal to zero a width equal to
  4581. 3:29:27100% a border radius set to 10 a shadow
  4582. 3:29:33color equal to D4 D4 D4 and a zindex of
  4583. 3:29:3999 so it appears on top of other
  4584. 3:29:42elements great so now our input is
  4585. 3:29:45looking
  4586. 3:29:46great but as we type nothing is
  4587. 3:29:49happening yet so let's give it some
  4588. 3:29:51additional properties as well such as
  4589. 3:29:55the onpress functionality once we press
  4590. 3:29:57it what do we want to happen well first
  4591. 3:30:01once we press it we can get some
  4592. 3:30:03information from the press such as the
  4593. 3:30:05data and the details which is at the
  4594. 3:30:08start set to null and then we can call
  4595. 3:30:10the function and call a handle press
  4596. 3:30:13function and this function is coming
  4597. 3:30:15through props to it we need to pass the
  4598. 3:30:18latitude longitude and the address so
  4599. 3:30:20let's do just that Latitude will be
  4600. 3:30:23equal to details question mark.
  4601. 3:30:26geometry.
  4602. 3:30:28location. latitude or lat
  4603. 3:30:31L and we can add an exclamation mark
  4604. 3:30:34because we know it's there we can repeat
  4605. 3:30:36the same thing with the longitude but
  4606. 3:30:38it's going to be LNG at the end and
  4607. 3:30:41finally the address will be equal to
  4608. 3:30:44data do description next to the on press
  4609. 3:30:47we also have to Define our query so this
  4610. 3:30:50is the search query and the key here is
  4611. 3:30:53going to be equal to the Google Places
  4612. 3:30:55API so this is something we can Define
  4613. 3:30:57right here at the top by saying const
  4614. 3:31:01Google Places API key let's make sure to
  4615. 3:31:06spell it properly is equal to process.
  4616. 3:31:10env. Expo
  4617. 3:31:13corpu gooogle AP apore key and we can
  4618. 3:31:17now use this Google Places API key as
  4619. 3:31:20the key in the query and we can set the
  4620. 3:31:24language equal to any language in the
  4621. 3:31:27world I use en n for English we can also
  4622. 3:31:30choose to render a left button so that's
  4623. 3:31:33how customizable it is render left
  4624. 3:31:36button which will be equal to a callback
  4625. 3:31:39function where we return a view that has
  4626. 3:31:42a class name equal to justify i- center
  4627. 3:31:47items Das Center and a w of 6 and an H
  4628. 3:31:51of
  4629. 3:31:52six within it we can render an image
  4630. 3:31:56coming from react native with a source
  4631. 3:32:00and if an icon exists then we return an
  4632. 3:32:03icon else we tap into the icons from
  4633. 3:32:07constants do search so you can see a big
  4634. 3:32:09search icon on the right right now we
  4635. 3:32:11can style it by giving it a class name
  4636. 3:32:14equal to w ofc 6 and H of 6 with a
  4637. 3:32:18resize mode equal to
  4638. 3:32:21contain there we go that's much better
  4639. 3:32:24finally we can have one last property
  4640. 3:32:28called text input props which will
  4641. 3:32:32accept a placeholder text color which
  4642. 3:32:35will set to be equal to Gray and a
  4643. 3:32:38placeholder will be equal to either the
  4644. 3:32:41initial location so this is if we
  4645. 3:32:43already have a location from before or
  4646. 3:32:46double question mark this is to make
  4647. 3:32:48sure that if we don't have the initial
  4648. 3:32:50location we can show something else and
  4649. 3:32:52that else is where do you want to
  4650. 3:32:57go great so now if I clear it you can
  4651. 3:33:00see where do you want to go and if we
  4652. 3:33:02start typing something like let's see
  4653. 3:33:06Zagreb is the capital of
  4654. 3:33:08Croatia nothing shows up or whatever you
  4655. 3:33:11start typing most likely nothing is
  4656. 3:33:14showing up either
  4657. 3:33:16and the main point of this Google
  4658. 3:33:19autocomplete is for it to autocomplete
  4659. 3:33:21exciting locations and cities near our
  4660. 3:33:25location so why is it not working well
  4661. 3:33:27when Google gave us our API key I
  4662. 3:33:30thought that they're going to let it
  4663. 3:33:31work but it looks like if we go to
  4664. 3:33:34enable apis and services and then search
  4665. 3:33:37for directions API and then even though
  4666. 3:33:40it is enabled we have to go to manage
  4667. 3:33:43and then we have to go through this
  4668. 3:33:44verification process process where the
  4669. 3:33:46use our card to verify that we're not a
  4670. 3:33:49robot they won't charge us absolutely
  4671. 3:33:53anything until we manually decide to
  4672. 3:33:55upgrade to a paid account so this is
  4673. 3:33:57just a strict verification to make sure
  4674. 3:33:59that we're not a
  4675. 3:34:01robot so I'll click agree and continue
  4676. 3:34:04you'll have to enter some additional
  4677. 3:34:05information and then proceed further in
  4678. 3:34:08a matter of seconds my account was
  4679. 3:34:10verified and now you need to answer a
  4680. 3:34:12couple more
  4681. 3:34:14questions you you can say what you want
  4682. 3:34:16to
  4683. 3:34:18build say what you're
  4684. 3:34:20doing choose the
  4685. 3:34:24platform and select the framework once
  4686. 3:34:27you do that it'll give you a new API key
  4687. 3:34:29which you can copy take on enable all
  4688. 3:34:32Google Maps apis for this project and
  4689. 3:34:34create a budget alert to help you stay
  4690. 3:34:37on top of your spending so you don't get
  4691. 3:34:39charged more but that's almost
  4692. 3:34:41impossible to reach given that I believe
  4693. 3:34:43you would need to have millions and
  4694. 3:34:45millions of calls to reach that amount
  4695. 3:34:48so you can think of it as completely
  4696. 3:34:50free and then go to Google Maps platform
  4697. 3:34:53now I'm fully aware that some of you
  4698. 3:34:56might not have a credit card and that's
  4699. 3:34:59totally okay some subscribers have told
  4700. 3:35:01me in the comments of a previous video
  4701. 3:35:03that for India specifically there's also
  4702. 3:35:05Ola Maps which is completely free and
  4703. 3:35:08you can get it without a credit card so
  4704. 3:35:10that's another thing that you can try
  4705. 3:35:11out if Google is not an option or maybe
  4706. 3:35:14other people in the comments will be
  4707. 3:35:16able to tell you some alternative
  4708. 3:35:17Solutions if you really cannot use
  4709. 3:35:19Google but in this case I'll be
  4710. 3:35:21proceeding with Google so it created a
  4711. 3:35:24new project for me and I do believe that
  4712. 3:35:26the services are automatically enabled
  4713. 3:35:28for Google Maps so we can just use this
  4714. 3:35:31new API key that has been provided to us
  4715. 3:35:34and I can paste it right here once you
  4716. 3:35:37do that and whenever you make some
  4717. 3:35:38changes you'll have to reload your
  4718. 3:35:41application so stop it from running and
  4719. 3:35:44then run MPX Expos start- C to clear
  4720. 3:35:48your cache now if you open up the search
  4721. 3:35:51once again and start typing something
  4722. 3:35:53you'll see powered by Google and you'll
  4723. 3:35:56be able to see some great locations
  4724. 3:35:57appear on your screen you'll be able to
  4725. 3:36:00select from many of them and the next
  4726. 3:36:02step we'll have to do is to open up a
  4727. 3:36:04new screen that will allow us to verify
  4728. 3:36:07your current location your destination
  4729. 3:36:09location and then we'll be able to
  4730. 3:36:11create a trip which is a handshake
  4731. 3:36:14between you and and the driver so to
  4732. 3:36:17make that happen we have to make sure
  4733. 3:36:19that something happens once we press or
  4734. 3:36:21choose a specific location and that is
  4735. 3:36:25coming through props from the homepage
  4736. 3:36:28so if we go to home you can see that
  4737. 3:36:30we're passing handle destination press
  4738. 3:36:32which is currently completely empty once
  4739. 3:36:35we press it it's going to give us access
  4740. 3:36:37to a location that contains three
  4741. 3:36:40different things a Latitude which is a
  4742. 3:36:43number a longitude which is is also a
  4743. 3:36:46number and then an address which is a
  4744. 3:36:50string what do we do with those well we
  4745. 3:36:53can call the set destination location to
  4746. 3:36:56which we can pass this newly selected
  4747. 3:36:59location destination once we do that we
  4748. 3:37:02can use the router. push functionality
  4749. 3:37:05to go to the second screen forward slash
  4750. 3:37:09in parentheses root and then find Dash
  4751. 3:37:13Ride Now check this out even typescript
  4752. 3:37:17didn't save me when I was setting up the
  4753. 3:37:20name of the type within this
  4754. 3:37:22location it was okay with launch titude
  4755. 3:37:26but in this case webstorm spellchecking
  4756. 3:37:30found the mistake here it was supposed
  4757. 3:37:32to be
  4758. 3:37:33longitude so this was super useful next
  4759. 3:37:37we have to import the
  4760. 3:37:39router from Expo router so let's do just
  4761. 3:37:42that
  4762. 3:37:49and in this case Expo is also pretty
  4763. 3:37:52smart because it tells us right now that
  4764. 3:37:55there's no such screen find ride so
  4765. 3:37:58let's go ahead and create it we can go
  4766. 3:38:01to our file
  4767. 3:38:02explorer go to app rout and then right
  4768. 3:38:07here next to tabs we can create a new
  4769. 3:38:10file directly in the root we can call it
  4770. 3:38:13find- rde
  4771. 3:38:16TSX there we can say const find ride is
  4772. 3:38:20equal to a react error function where we
  4773. 3:38:24can run export default find ride you
  4774. 3:38:28know the drill we can there return a
  4775. 3:38:32view coming from react native and we can
  4776. 3:38:36return a text element for now saying
  4777. 3:38:39find right just so we know if we have
  4778. 3:38:42reached that screen
  4779. 3:38:44properly now if we go back to home from
  4780. 3:38:47where we were redirecting you can see
  4781. 3:38:49that it's no longer complaining and
  4782. 3:38:52thanks to zustand and our store before
  4783. 3:38:55we change the screen we're also setting
  4784. 3:38:57our destination location right here to
  4785. 3:38:59the store so that even on the next
  4786. 3:39:01screen we know where we want to go so
  4787. 3:39:04let's give it a shot I'll type
  4788. 3:39:07Sacramento right here in California USA
  4789. 3:39:10and it navigates me over to find ride
  4790. 3:39:14and just so I can prove prove to you
  4791. 3:39:16that we actually know where we want to
  4792. 3:39:17go we can make use of the used location
  4793. 3:39:20store so let's head over to find
  4794. 3:39:24ride use the use location store by
  4795. 3:39:28saying const something is equal to use
  4796. 3:39:31location
  4797. 3:39:32store and here we can destructure the
  4798. 3:39:35user address which is our current
  4799. 3:39:37address and the destination address and
  4800. 3:39:41we can also get the set destination
  4801. 3:39:42address and set user location
  4802. 3:39:46in case we decide to change it you know
  4803. 3:39:47how in Uber you can change your current
  4804. 3:39:49location in case you will be somewhere
  4805. 3:39:51else once the driver picks you up so now
  4806. 3:39:55here in the text I can give it a class
  4807. 3:39:57name equal to text-
  4808. 3:40:012XL and I can say you are here and I can
  4809. 3:40:06render the user address I can duplicate
  4810. 3:40:09it and say you are going to and here we
  4811. 3:40:13can say destination address
  4812. 3:40:15and now if I save this you can see you
  4813. 3:40:18are here San Francisco you're going to
  4814. 3:40:21Sacramento wonderful this is working
  4815. 3:40:25like a charm and we can even go back and
  4816. 3:40:28if we want to go somewhere else let's
  4817. 3:40:30say Pao
  4818. 3:40:32Alto we can also go right here so let's
  4819. 3:40:36do that next as you can notice the next
  4820. 3:40:39three screens have a very similar layout
  4821. 3:40:41they have a map at the top here here and
  4822. 3:40:45here they have some kind of a widget
  4823. 3:40:48that appears at the bottom which is this
  4824. 3:40:50form right here here and here and then
  4825. 3:40:54you can slide it above to cover the map
  4826. 3:40:57so for that reason I'll teach you how to
  4827. 3:40:59create something very cool and that is a
  4828. 3:41:01layout component so that we can reuse a
  4829. 3:41:04very similar layout but then change
  4830. 3:41:06what's shown within it so let's go to
  4831. 3:41:09components and create a new file called
  4832. 3:41:12ride layout. TSX
  4833. 3:41:15it'll be a component like any other
  4834. 3:41:18starting with con ride layout which is a
  4835. 3:41:22react functional
  4836. 3:41:24component we can export default. ride
  4837. 3:41:27layout and then we can return some kind
  4838. 3:41:30of a view right within
  4839. 3:41:32it the difference between a regular
  4840. 3:41:35component and a layout component is that
  4841. 3:41:38layouts typically accept children as
  4842. 3:41:41props so we can Define children right
  4843. 3:41:43here and it'll be of a type children is
  4844. 3:41:46a react node what does having children
  4845. 3:41:49allow us to do well first of all we can
  4846. 3:41:52have some kind of a text that allows us
  4847. 3:41:54to say top of the layout and we can
  4848. 3:41:58duplicate that to say bottom of the
  4849. 3:42:00layout but then in the middle we can
  4850. 3:42:03render whatever we show in the children
  4851. 3:42:06so if I do this we can now go back to
  4852. 3:42:09find ride and I'll wrap my entire
  4853. 3:42:12application with the ride layout of
  4854. 3:42:15course make sure to import it from
  4855. 3:42:17components and check what happens now we
  4856. 3:42:20have top of the layout bottom of the
  4857. 3:42:22layout and then in the middle we have
  4858. 3:42:25whatever we have right here for now we
  4859. 3:42:27can leave that just to be a text that
  4860. 3:42:30says something like find ride because
  4861. 3:42:33this is the screen that we're currently
  4862. 3:42:34on now later on we'll be able to reuse
  4863. 3:42:37this layout on other screens as well
  4864. 3:42:39screens such as these ones right here in
  4865. 3:42:43the root layout first we have the find
  4866. 3:42:47ride so we can also hide the header on
  4867. 3:42:50it later on we'll also have a
  4868. 3:42:54confirm ride and finally we'll have a
  4869. 3:42:58book ride and we want to hide headers
  4870. 3:43:00from all of them as you can see our
  4871. 3:43:03layout is now complaining about too many
  4872. 3:43:05screens defined so for now I will
  4873. 3:43:08comment out the bottom twoo and let's
  4874. 3:43:10continue working on our right layout
  4875. 3:43:13instead of having a top and bottom
  4876. 3:43:15bottom text we'll do something different
  4877. 3:43:17I'll wrap everything in a gesture handle
  4878. 3:43:21root view like this and that's going to
  4879. 3:43:24come from a new package so let's install
  4880. 3:43:27it by running mpm install
  4881. 3:43:31react-native-gesture-handler
  4882. 3:43:34once it installs we'll be able to just
  4883. 3:43:37import it from there this will allow us
  4884. 3:43:40to swipe our screen and then show
  4885. 3:43:42something underneath it before rendering
  4886. 3:43:44children let's render some other stuff
  4887. 3:43:46here like another view with a class name
  4888. 3:43:50equal to flex D1 and BG DWI within it we
  4889. 3:43:55can render yet another view with a class
  4890. 3:43:59name equal to flex
  4891. 3:44:03flex-all h- screen for full height and
  4892. 3:44:07BG
  4893. 3:44:09dl-500 I'll go back to my screen and now
  4894. 3:44:13we can see that the entire screen is
  4895. 3:44:14blue
  4896. 3:44:16we can show another view right below it
  4897. 3:44:18or right within it with a class name
  4898. 3:44:21equal to flex Flex Das row absolute Z of
  4899. 3:44:2710 top of
  4900. 3:44:2916 items Das Center justify Das start
  4901. 3:44:34and padding
  4902. 3:44:36xl5 nothing will show yet because we
  4903. 3:44:38have to put something within it and that
  4904. 3:44:41something will be a touchable opacity
  4905. 3:44:43which is basically a button on press of
  4906. 3:44:46this touchable opacity we'll call a
  4907. 3:44:48callback function that'll call the
  4908. 3:44:50router
  4909. 3:44:52doback so we can just go to a page back
  4910. 3:44:55and within it we can render a view
  4911. 3:44:58that'll render an image with a source
  4912. 3:45:01equal to icons coming from constants
  4913. 3:45:04doback
  4914. 3:45:05arrow with a resize mode of
  4915. 3:45:10contain and a class name equal to W6 h
  4916. 3:45:15six now you can see a little back arrow
  4917. 3:45:18right here on top left we can also style
  4918. 3:45:21it further by giving this view a class
  4919. 3:45:23name of W10 h10 BG white round the- full
  4920. 3:45:31and we can also give it items Das Center
  4921. 3:45:34and justify Das Center to put it in the
  4922. 3:45:37middle great so now we're starting to
  4923. 3:45:40create this backdrop right below the
  4924. 3:45:42touchable opacity we can also render a
  4925. 3:45:45piece of text that will say either a
  4926. 3:45:48title so it will render a title that we
  4927. 3:45:51pass through props so alongside children
  4928. 3:45:54we can also get the title and the title
  4929. 3:45:57will be of a type
  4930. 3:45:59string if we don't have a title then we
  4931. 3:46:02can render a piece of text that will say
  4932. 3:46:05something like go back let's style this
  4933. 3:46:08a bit by giving it a class name equal to
  4934. 3:46:11text- excl font djar PARTA semi bold and
  4935. 3:46:17margin left of five right below that
  4936. 3:46:19view will render a
  4937. 3:46:22map coming from components
  4938. 3:46:25map thankfully we have already crafted
  4939. 3:46:28this
  4940. 3:46:29component and that's going to go below
  4941. 3:46:31the view not below the
  4942. 3:46:34text there we go so now this makes much
  4943. 3:46:36more sense for the first time ever we
  4944. 3:46:39can see a map right here on our entire
  4945. 3:46:43screen how nice nice is that but here's
  4946. 3:46:46the key part going below this map and
  4947. 3:46:49below the view we'll create something
  4948. 3:46:52known as a bottom sheet and this bottom
  4949. 3:46:55sheet is coming from another custom
  4950. 3:46:58package it has more than 300,000 weekly
  4951. 3:47:01downloads and it provides this nice
  4952. 3:47:03bottom sheet that you can swipe up and
  4953. 3:47:05you can see the perfect use case is Maps
  4954. 3:47:09so let's copy this installation code
  4955. 3:47:12open up the terminal and run mpmi at
  4956. 3:47:15gorom SL bottom Das
  4957. 3:47:19sheet and now we can very easily import
  4958. 3:47:22it from there this bottom sheet also
  4959. 3:47:25requires a ref so we can say const
  4960. 3:47:28bottom sheet ref is equal to use ref
  4961. 3:47:33coming from
  4962. 3:47:34react of a type bottom sheet at the
  4963. 3:47:38start set to null now we can provide
  4964. 3:47:41this ref to this bottom sheet by saying
  4965. 3:47:43ref is equal to to bottom sheet ref we
  4966. 3:47:47can also give it snap points so these
  4967. 3:47:50are the two different points at which
  4968. 3:47:53the sheet will stop so we can put that
  4969. 3:47:56as an array and it can be equal to let's
  4970. 3:48:00do something like 40% and then the
  4971. 3:48:02second one can be about maybe
  4972. 3:48:0685% like
  4973. 3:48:08this and then we can also give an index
  4974. 3:48:11of zero to this bottom sheet
  4975. 3:48:15within the bottom sheet we can render
  4976. 3:48:17the
  4977. 3:48:19bottom sheet scroll
  4978. 3:48:23view that'll have a style equal to flex
  4979. 3:48:28of one and a padding of
  4980. 3:48:3120 and within it we can render the
  4981. 3:48:34children so this is where the magic
  4982. 3:48:37happens if I now go back right here to
  4983. 3:48:41search you can see that now there's a
  4984. 3:48:43find r text and if I scroll up and down
  4985. 3:48:48it gets stuck at 40 and 85%
  4986. 3:48:51respectively but again the key part is
  4987. 3:48:54that whatever is right in here what
  4988. 3:48:56we're wrapping with the ride layout
  4989. 3:48:58shows directly within this little view
  4990. 3:49:01that you can then move up and down but
  4991. 3:49:03the map remains right on top of it this
  4992. 3:49:07is such a beautiful user interface so
  4993. 3:49:10now the layout is mostly done and if we
  4994. 3:49:13go back to our final ride we can start
  4995. 3:49:16implementing whatever is supposed to be
  4996. 3:49:18within it let's first give it a title
  4997. 3:49:20equal to ride and let's create a view
  4998. 3:49:24right within
  4999. 3:49:26it this view will have a class name
  5000. 3:49:30equal to margin y of
  5001. 3:49:32three and within it we can render a text
  5002. 3:49:35element that will say from so where are
  5003. 3:49:38you coming from it'll have a class name
  5004. 3:49:42equal to text- LG font D Jakarta semi
  5005. 3:49:47bold and a margin bottom of
  5006. 3:49:49three right below it we can render a
  5007. 3:49:53reusable component which we have already
  5008. 3:49:54created called a Google text input of
  5009. 3:49:58course we have to pass a couple of props
  5010. 3:50:00to it so let's do just that we can pass
  5011. 3:50:02it the icon equal to
  5012. 3:50:05icons coming from constants do Target in
  5013. 3:50:09this case we already have an initial
  5014. 3:50:11location as well equal to user
  5015. 3:50:15address so now you can see we already
  5016. 3:50:18know where we're coming from because
  5017. 3:50:20it's taking it from a user address
  5018. 3:50:22location next we can provide some
  5019. 3:50:25container style equal to BG neutral
  5020. 3:50:30100 and we can also provide a text input
  5021. 3:50:35background color of hash F5 F5
  5022. 3:50:41F5 and then what happens on the handle
  5023. 3:50:43press well we can call a call function
  5024. 3:50:47where we get the
  5025. 3:50:48location and we simply set user location
  5026. 3:50:52to a new location that a user has
  5027. 3:50:56chosen in this case it's complaining a
  5028. 3:50:58bit about the initial location maybe
  5029. 3:51:01there's a type mismatch I'll just add an
  5030. 3:51:03exclamation mark at the end because we
  5031. 3:51:05know it'll be in the right format we can
  5032. 3:51:07end this view right here and check this
  5033. 3:51:10out I will simply duplicate this view
  5034. 3:51:13below and say not from but rather to
  5035. 3:51:18change the icons to map change the
  5036. 3:51:22address to destination address you can
  5037. 3:51:25disregard my low battery sign I'll go
  5038. 3:51:27ahead and go charge it soon and we can
  5039. 3:51:30also change the text input background
  5040. 3:51:32color to transparent here instead of set
  5041. 3:51:35user location we'll set the destination
  5042. 3:51:39location I'll close my battery warning
  5043. 3:51:42and would you look at this we have two
  5044. 3:51:44different inputs from and to and we can
  5045. 3:51:47change both of them by typing once again
  5046. 3:51:50so in San Francisco I can type and go
  5047. 3:51:53from let's say somewhere else here we go
  5048. 3:51:56but I do get a warning here saying that
  5049. 3:51:58virtualized lists should never be nested
  5050. 3:52:02and if we close this I'm guessing a
  5051. 3:52:05similar thing will happen right here yep
  5052. 3:52:07you can see virtualized lists should
  5053. 3:52:09never be nested we'll fix that very soon
  5054. 3:52:12but before we do that let's quickly add
  5055. 3:52:14a new custom button right here below
  5056. 3:52:17it's going to say find now remember
  5057. 3:52:20we're trying to find
  5058. 3:52:21drivers and what are we going to do on
  5059. 3:52:24press well on press we will use the
  5060. 3:52:28router coming from Expo router to push
  5061. 3:52:32over to forward slash root in
  5062. 3:52:35parenthesis forward slash confirm Das
  5063. 3:52:39ride and we can give this button a class
  5064. 3:52:42name equal to margin top of
  5065. 3:52:46five there we go this is looking much
  5066. 3:52:49better of course we have to actually
  5067. 3:52:51create this route so let's add a new
  5068. 3:52:55stack screen that's going to say confirm
  5069. 3:52:58ride and let's create a new file in the
  5070. 3:53:01app rout and it'll be
  5071. 3:53:04called
  5072. 3:53:06confirm ride. TSX where we can create a
  5073. 3:53:11new con confirm ride
  5074. 3:53:15and then we can export default that
  5075. 3:53:18confirm ride that'll for now return a
  5076. 3:53:22view and a
  5077. 3:53:25text saying confirm ride one thing that
  5078. 3:53:29could be the issue here is if we go to
  5079. 3:53:32the ride layout remember it's mentioning
  5080. 3:53:35something about scroll views so what if
  5081. 3:53:38we just use a bottom sheet view right
  5082. 3:53:40here and not a bottom scroll sheet view
  5083. 3:53:44we can import it remove the other one
  5084. 3:53:48and give that a shot we don't need a
  5085. 3:53:50scroll within a scroll I think that's
  5086. 3:53:52why it's complaining about so if one
  5087. 3:53:54more time we go
  5088. 3:53:56into
  5089. 3:53:58here and we need to bring it a bit up
  5090. 3:54:02and enter something like
  5091. 3:54:04Switzerland now it works perfect there's
  5092. 3:54:08one thing we could try though and that
  5093. 3:54:10is coming directly from the keyboard
  5094. 3:54:13behavior of the bottom sheet component
  5095. 3:54:17they say that we can Define the keyboard
  5096. 3:54:18appearance behavior and we can use the
  5097. 3:54:21extend or interactive to offset the
  5098. 3:54:24sheet by the size of the keyboard so by
  5099. 3:54:27default it is interactive so we can
  5100. 3:54:29switch it to maybe extend we can do that
  5101. 3:54:31by giving this bottom sheet a keyboard
  5102. 3:54:34Behavior equal to
  5103. 3:54:37extend but even if I try that it doesn't
  5104. 3:54:40seem to do the trick maybe on Android it
  5105. 3:54:43works so so we can leave it as it is
  5106. 3:54:45because by default it is indeed
  5107. 3:54:47interactive but we'll have to figure out
  5108. 3:54:49something else for iOS maybe we'll have
  5109. 3:54:52to pass custom snap points to this ride
  5110. 3:54:55layout by saying snap points is equal to
  5111. 3:54:58and it can be an array of something like
  5112. 3:55:0285% so now if I go to the ride layout
  5113. 3:55:06and accept those snap points which will
  5114. 3:55:08be an array of strings so we can say
  5115. 3:55:11snap points is optional and it is an
  5116. 3:55:13array of strings we can now either
  5117. 3:55:16render 4085 by default or if we have the
  5118. 3:55:19snap points we can then render it by
  5119. 3:55:21snap points so what this is going to do
  5120. 3:55:24is every time that you're here it's
  5121. 3:55:26always going to be opened at least
  5122. 3:55:2985% this way you can see the from and
  5123. 3:55:33two locations very nicely on the screen
  5124. 3:55:35here and on this screen you're not
  5125. 3:55:36supposed to be looking at the map anyway
  5126. 3:55:38you're supposed to be checking whether
  5127. 3:55:40the from and two are correct so with
  5128. 3:55:42that in mind we got that fix so let's
  5129. 3:55:45click find now which is going to
  5130. 3:55:46redirect us to confirm ride this is the
  5131. 3:55:51second page where we'll reuse the ride
  5132. 3:55:54layout so I'll show you how convenient
  5133. 3:55:56that is check this out instead of a view
  5134. 3:56:00I'll use the right layout coming from
  5135. 3:56:03components I'll give it a title which is
  5136. 3:56:06going to be choose a
  5137. 3:56:09driver and I'll give it snap points
  5138. 3:56:12which are going to be custom of about
  5139. 3:56:1565% for the first one and we can do
  5140. 3:56:1985% for the second one within it we can
  5141. 3:56:23render a flat list the data for the flat
  5142. 3:56:26list will be the drivers that we can
  5143. 3:56:28choose from and I do believe that we
  5144. 3:56:31already have some fake drivers I think
  5145. 3:56:33it was maybe in home let's see here we
  5146. 3:56:36have recent rides maybe it was in the
  5147. 3:56:39map yes right here at the top of the map
  5148. 3:56:41we have the mock drivers for now let's
  5149. 3:56:44simply copy them and add them at the top
  5150. 3:56:46of the confirm ride I promise soon
  5151. 3:56:49enough we'll make this Dynamic but for
  5152. 3:56:51now for the flat list data will be equal
  5153. 3:56:54to drivers next we can choose how we
  5154. 3:56:57want to render that item so we can say
  5155. 3:57:00render item we have a callback function
  5156. 3:57:03where we get access to that item and for
  5157. 3:57:06each one we return a driver card so this
  5158. 3:57:10is another component which we can create
  5159. 3:57:12in the components folder
  5160. 3:57:15let's create it by saying a driver card.
  5161. 3:57:19DSX you know the drill const driver card
  5162. 3:57:24is equal to a simple immediate return
  5163. 3:57:27component where we render a view with a
  5164. 3:57:31text that says something like driver and
  5165. 3:57:35we can immediately export default that
  5166. 3:57:38card going back we can import this card
  5167. 3:57:42and if we render it we'll have to go
  5168. 3:57:43back back let's go to Scranton
  5169. 3:57:46Pennsylvania and click find now and we
  5170. 3:57:48can see four different drivers to each
  5171. 3:57:51one of these drivers we can pass the
  5172. 3:57:53item which is basically the entire
  5173. 3:57:56information about a specific driver of
  5174. 3:57:58course in the driver card we'll have to
  5175. 3:58:00accept that prop so let's do that right
  5176. 3:58:03away it'll accept the item of a type
  5177. 3:58:07writer card props and basically what
  5178. 3:58:11we're developing here is this card where
  5179. 3:58:14where we show a profile photo of the
  5180. 3:58:15driver their name their rating how much
  5181. 3:58:18they cost how much it would take for
  5182. 3:58:21them to get to us and how many seats
  5183. 3:58:23their car has as well as their car photo
  5184. 3:58:26to speed up our workflow just a tiny bit
  5185. 3:58:28you can find it right here in the
  5186. 3:58:30Snippets copy it and paste it here
  5187. 3:58:33you'll notice that it is nothing more
  5188. 3:58:35than a touchable opacity basically a
  5189. 3:58:37button that you can click that has an
  5190. 3:58:40image and then with some repeated pieces
  5191. 3:58:42of text that that is it we can nicely
  5192. 3:58:45scroll through it we can click on them
  5193. 3:58:47this is looking great the only thing
  5194. 3:58:50we're missing back at confirm ride is
  5195. 3:58:53going to be this time not a header but a
  5196. 3:58:57list footer
  5197. 3:58:59component where we can define a callback
  5198. 3:59:02function and then Define a
  5199. 3:59:06view which we can
  5200. 3:59:08close that will have a class name equal
  5201. 3:59:12to margin X of five and margin top of
  5202. 3:59:1610 and within it we can render a custom
  5203. 3:59:19button with a title select ride and on
  5204. 3:59:23press we can run the Callback function
  5205. 3:59:27that calls the
  5206. 3:59:29router. push to slash in parentheses
  5207. 3:59:34root slash book- R so right now it is
  5208. 3:59:39red because we don't yet have that route
  5209. 3:59:42but soon enough it'll be there before we
  5210. 3:59:44go ahead and create it there's one more
  5211. 3:59:46thing we have to do and that is create a
  5212. 3:59:48completely new store so right now we
  5213. 3:59:52have the store for the location but
  5214. 3:59:55right below it there's a store for the
  5215. 3:59:57drivers where we're keeping track of all
  5216. 4:00:00of the active drivers and we're keeping
  5217. 4:00:02track of which driver has our user
  5218. 4:00:04selected so we can access that store
  5219. 4:00:08like we're used to so far by saying
  5220. 4:00:10const something is equal to use driver
  5221. 4:00:15store and from it we can extract the
  5222. 4:00:18drivers we can extract the selected
  5223. 4:00:21driver as well as set the selected
  5224. 4:00:24driver to the one that we click so to
  5225. 4:00:27the driver card we can pass the selected
  5226. 4:00:30equal to selected driver and we can add
  5227. 4:00:34the exclamation mark at the end because
  5228. 4:00:36we know it exists and then we can call
  5229. 4:00:38the set selected where we have a
  5230. 4:00:41callback function where we can call the
  5231. 4:00:43set selected driver and to it we can
  5232. 4:00:46pass the item. ID basically the ID of
  5233. 4:00:50the driver we're selecting and in this
  5234. 4:00:53case the drivers here override the
  5235. 4:00:56drivers above which is okay because we
  5236. 4:00:58don't need to Define them to times
  5237. 4:01:01rather I'll remove the drivers from here
  5238. 4:01:04and back on the map where we use the
  5239. 4:01:06drivers for the first time we can call
  5240. 4:01:08the set drivers go into the use effect
  5241. 4:01:12and right here at the top of it we can
  5242. 4:01:14say set drivers and pass our current
  5243. 4:01:17fake drivers that we have at the top
  5244. 4:01:19there's going to be a type mismatch but
  5245. 4:01:21don't worry too much about that this
  5246. 4:01:23will have to be removed anyway very soon
  5247. 4:01:25as soon as we add real drivers so now
  5248. 4:01:28let's create the last screen in our flow
  5249. 4:01:31which is going to be book ride we can do
  5250. 4:01:34that by going to root and creating a new
  5251. 4:01:37file called book ride. DSX it's going to
  5252. 4:01:41be a const book ride ride
  5253. 4:01:44component and we can run export default
  5254. 4:01:48book ride while we return a
  5255. 4:01:52view with a
  5256. 4:01:54text that's going to say book ride in
  5257. 4:01:58the layout we can also add book ride
  5258. 4:02:01back just so we can remove the
  5259. 4:02:04header now let's go through our entire
  5260. 4:02:07process one more time to test it out of
  5261. 4:02:10course the last screen being the book
  5262. 4:02:12ride oh and don't forget to add a return
  5263. 4:02:15statement right here before so that
  5264. 4:02:17everything works so if I do this and if
  5265. 4:02:21I go visit Michael from the office to
  5266. 4:02:24Scranton
  5267. 4:02:26Pennsylvania I'll click find now we can
  5268. 4:02:29see different drivers soon enough we'll
  5269. 4:02:31be able to select only one right now
  5270. 4:02:33we're selecting all of them and we can
  5271. 4:02:36click select ride and that's going to
  5272. 4:02:38lead us to the last screen in this ride
  5273. 4:02:41selection sequence where we can find
  5274. 4:02:43finally confirm that this is our driver
  5275. 4:02:46and we are ready to book a ride with
  5276. 4:02:48them and in terms of actual design this
  5277. 4:02:51is the page we'll develop next as you
  5278. 4:02:54can see it is very similar to previous
  5279. 4:02:57Pages we're still using the ride layout
  5280. 4:03:00and then we show something in the bottom
  5281. 4:03:02sheet we're so close to getting to the
  5282. 4:03:05payments part and we've already done a
  5283. 4:03:08lot of UI I really want to focus on the
  5284. 4:03:10functionality we've been using fake
  5285. 4:03:13drivers and fake rides right here on the
  5286. 4:03:15homepage so it's about time to turn all
  5287. 4:03:18of that into real data and real
  5288. 4:03:21databased
  5289. 4:03:22interactions so just so we can do that
  5290. 4:03:24very quickly I just provided you with
  5291. 4:03:26the UI for the root book ride which you
  5292. 4:03:30can copy here and just paste in this
  5293. 4:03:32book ride page just make sure to fix
  5294. 4:03:35this import where it's going to say ride
  5295. 4:03:39layout and there we go now we have the
  5296. 4:03:42ride information but it seems that it's
  5297. 4:03:45not properly picking up the driver
  5298. 4:03:47information I think I know why in the
  5299. 4:03:50map we're using fake
  5300. 4:03:52drivers and their IDs are
  5301. 4:03:56strings so when we're confirming the
  5302. 4:03:58selected driver we have to turn it into
  5303. 4:04:01a number so we can wrap it just like
  5304. 4:04:04this into a
  5305. 4:04:06number and back in the book ride we can
  5306. 4:04:09now consol log both the
  5307. 4:04:12drivers as well as has the selected
  5308. 4:04:14driver so we can do it just like so and
  5309. 4:04:18save
  5310. 4:04:19it we can see that selected driver is a
  5311. 4:04:22string of
  5312. 4:04:24one and we can see all drivers and there
  5313. 4:04:27should be one with the ID of one so now
  5314. 4:04:30it's just comparing the driver. ID which
  5315. 4:04:33is turned into a number format which is
  5316. 4:04:36equal to the selected driver ID so if I
  5317. 4:04:39go back choose one of these there we go
  5318. 4:04:43we can see the right information and
  5319. 4:04:45just the pickup time is not good so
  5320. 4:04:48right here for the pickup time we can
  5321. 4:04:50check if there is driver details time or
  5322. 4:04:54we can say something like 5 minutes this
  5323. 4:04:57is going to be fixed once we have the
  5324. 4:04:58real data but right now this is looking
  5325. 4:05:02great the only thing that is missing on
  5326. 4:05:04this screen is the confirm ride button
  5327. 4:05:07but that won't be just a simple button
  5328. 4:05:09it'll open up the entire stripe payment
  5329. 4:05:12window where will be be able to choose
  5330. 4:05:14from many different payment options and
  5331. 4:05:16issue a payment after which we'll be
  5332. 4:05:19redirected to the success model screen
  5333. 4:05:21so for the next step we can scroll all
  5334. 4:05:24the way down below this View and we can
  5335. 4:05:27render a new component which we can
  5336. 4:05:29create under the components folder and
  5337. 4:05:32we can call it payment.
  5338. 4:05:35TSX it'll be a react functional
  5339. 4:05:37component called
  5340. 4:05:39payment we don't have any props for now
  5341. 4:05:43but you know the drill it will return a
  5342. 4:05:46view that will have a
  5343. 4:05:49text that'll say payment and we can do
  5344. 4:05:53export
  5345. 4:05:55default payment right here at the bottom
  5346. 4:05:58now back in the book ride we can now
  5347. 4:06:01import the
  5348. 4:06:03payment and you can see it right here at
  5349. 4:06:06the bottom the payment itself will
  5350. 4:06:09simply be a react fragment that'll load
  5351. 4:06:12a custom button so here we can say
  5352. 4:06:15custom
  5353. 4:06:17button with a title equal to confirm
  5354. 4:06:21ride a class name equal to margin y of
  5355. 4:06:2510 to divide it a bit from the top and
  5356. 4:06:27bottom and on press we want to call a
  5357. 4:06:30function called open payment sheet this
  5358. 4:06:34is coming from stripe so we can declare
  5359. 4:06:37this function right here const open
  5360. 4:06:40payment sheet is equal to an AS Arrow
  5361. 4:06:44function which for now we can leave
  5362. 4:06:47blank so if we quickly go back to that
  5363. 4:06:51last screen that we had you can see that
  5364. 4:06:54now there is a confirm ride button which
  5365. 4:06:57means that we can focus on implementing
  5366. 4:06:59the payments big step ahead so let's
  5367. 4:07:02dive right into it great job when coming
  5368. 4:07:05this far for payments will of course use
  5369. 4:07:08stripe one of the largest
  5370. 4:07:10infrastructures for accepting any kind
  5371. 4:07:12of payments online online so head to
  5372. 4:07:15stripe.com and start now you can create
  5373. 4:07:18a new account or sign in once you sign
  5374. 4:07:21in you can turn on the test mode and
  5375. 4:07:24that'll make sure that all the
  5376. 4:07:25information that you can see here is
  5377. 4:07:27test data so no real transactions will
  5378. 4:07:30be processed here then you can go to
  5379. 4:07:33developers and API keys and here you
  5380. 4:07:36should have some of the standard keys or
  5381. 4:07:38if you don't have them already you can
  5382. 4:07:40just create them so I'll copy my
  5383. 4:07:42publishable key and I'll head to
  5384. 4:07:45myv and add a new Expo
  5385. 4:07:49undoru stripe uncore publishable
  5386. 4:07:53underscore key and make it equal to the
  5387. 4:07:55key that I just copied we'll also need
  5388. 4:07:57our secret key so let's copy it and add
  5389. 4:08:01a new stripe secretor key we don't have
  5390. 4:08:06to add Expo public before because we'll
  5391. 4:08:08use this only within the API routes so
  5392. 4:08:11it is truly secure now that we have our
  5393. 4:08:13keys let's open up the documentation
  5394. 4:08:15page thankfully Stripes docs are one of
  5395. 4:08:18the best documentations out there in the
  5396. 4:08:21development industry period so I'll link
  5397. 4:08:24this documentation page down in the
  5398. 4:08:25description where you can collect
  5399. 4:08:28payment details before creating a
  5400. 4:08:30payment intent and thankfully they have
  5401. 4:08:32guides for web iOS Android and react
  5402. 4:08:35native so we can just follow the steps
  5403. 4:08:38first we have to install and set up
  5404. 4:08:41stripe we can install stripe as well as
  5405. 4:08:44stripe react native so let's copy this
  5406. 4:08:46and paste it in our terminal and
  5407. 4:08:49alongside that I'll also copy this other
  5408. 4:08:51part using mpm the first one is serverid
  5409. 4:08:55stripe and the second one is stripe for
  5410. 4:08:57react native s DEC once we do that we
  5411. 4:09:00want to initialize stripe by using the
  5412. 4:09:03init method and this is within the
  5413. 4:09:05stripe provider and do you know where
  5414. 4:09:08we'll use this well we'll only wrap our
  5415. 4:09:11book ride page with this
  5416. 4:09:13so let's go ahead and copy this entire
  5417. 4:09:15file close all of the currently open
  5418. 4:09:18files and just open up the book ride I
  5419. 4:09:22can zoom this out just so we can see
  5420. 4:09:23what's happening a bit better and I'll
  5421. 4:09:26paste it right here at the top we'll
  5422. 4:09:29have to make some modifications for
  5423. 4:09:31example we won't be needing this entire
  5424. 4:09:34new functional
  5425. 4:09:36component next we'll have some use
  5426. 4:09:39effects functions as well as use States
  5427. 4:09:43that we can copy and move into our book
  5428. 4:09:46ride function and finally we have the
  5429. 4:09:48stripe provider itself which we can
  5430. 4:09:51copy and wrap our entire ride layout
  5431. 4:09:56with and finally we can close this
  5432. 4:09:59stripe
  5433. 4:10:01layout or rather should they say stripe
  5434. 4:10:04provider so I'm going to do it just like
  5435. 4:10:09this and
  5436. 4:10:11save as you can see now we have copied
  5437. 4:10:14over the logic for stripe with that we
  5438. 4:10:17have to import use state from react as
  5439. 4:10:21well as import use effect from react as
  5440. 4:10:25well next we need this fetch key
  5441. 4:10:27functionality and this is going to be a
  5442. 4:10:30call to our own server from which we can
  5443. 4:10:32fetch our secure stripe key to make sure
  5444. 4:10:35that we really want to process that
  5445. 4:10:37payment for now I will comment this part
  5446. 4:10:40out next we can scroll down and we need
  5447. 4:10:43to to enable different payment methods
  5448. 4:10:45that's in the payment method settings so
  5449. 4:10:48if you follow that link you'll see many
  5450. 4:10:50many different options that'll be
  5451. 4:10:51enabled depending on where you're at but
  5452. 4:10:54for now I'm okay with Apple and Google
  5453. 4:10:56pay as well as cards so I'll leave it as
  5454. 4:10:59it is and we can collapse the first two
  5455. 4:11:01steps entirely the third step is to set
  5456. 4:11:04up a return URL on the client side and
  5457. 4:11:08they say that we can put this within the
  5458. 4:11:10app. DSX we can skip this part because
  5459. 4:11:13if you're using Expo it says to set up
  5460. 4:11:15your scheme in ab. Json and that has
  5461. 4:11:17already been set up for us so thankfully
  5462. 4:11:19we can skip setting up the return URL
  5463. 4:11:23next we can collect the payment details
  5464. 4:11:25on the client side so we need to
  5465. 4:11:27initialize a payment sheet we can copy
  5466. 4:11:30this entire part of the code and this
  5467. 4:11:32will go on the checkout screen in our
  5468. 4:11:34case that'll be the payment screen so we
  5469. 4:11:37can go over to payment and we can paste
  5470. 4:11:41it right here at the top
  5471. 4:11:44you'll notice that we'll have to remove
  5472. 4:11:45the closing function block and remove
  5473. 4:11:49the export default checkout screen
  5474. 4:11:50because we already have our own payment
  5475. 4:11:52screen let's save it let's move the
  5476. 4:11:56import a bit
  5477. 4:11:58up and now this is starting to make a
  5478. 4:12:00bit more sense I will collapse
  5479. 4:12:02everything just so you can see what's
  5480. 4:12:04happening and we also need to move just
  5481. 4:12:06a few things from the book ride it's
  5482. 4:12:09going to be the publishable key fetch
  5483. 4:12:11publishable key and the use effect we
  5484. 4:12:13can move those things over to the
  5485. 4:12:14payment as well just to have everything
  5486. 4:12:17in one place I'll paste it right
  5487. 4:12:20here we can move the states to the top
  5488. 4:12:24right here and the only thing we have to
  5489. 4:12:26change is now that we have moved the
  5490. 4:12:28publishable key we have to actually
  5491. 4:12:30fetch it from environment variables in
  5492. 4:12:32the book ride so we can say process.
  5493. 4:12:35env. xoor public stripe
  5494. 4:12:41publishable key and I'm going to add an
  5495. 4:12:44exclamation mark because we know that
  5496. 4:12:46it'll be
  5497. 4:12:47there and we can move the Imports for
  5498. 4:12:50the used State and use effect over to
  5499. 4:12:52the payment oh we already have it great
  5500. 4:12:55so now let me Zoom this out a bit so you
  5501. 4:12:58can better see it and let's see what we
  5502. 4:13:00have so far in the payment we have this
  5503. 4:13:03publishable key which we won't really
  5504. 4:13:04need because it's going to be coming
  5505. 4:13:06from environment variables so we can
  5506. 4:13:08delete that we have the init payment
  5507. 4:13:10sheet and present payment sheet so we
  5508. 4:13:13first have to initialize it and then we
  5509. 4:13:16can present it we have a function called
  5510. 4:13:18initialize payment sheet which will call
  5511. 4:13:21when we want to initialize it and we
  5512. 4:13:23have a confirm Handler which they put
  5513. 4:13:25here for us and it'll be explained later
  5514. 4:13:28and in our case we don't need this
  5515. 4:13:29function to fetch the publishable key
  5516. 4:13:31we'll just use our own API calls to
  5517. 4:13:33fetch it so I can remove the use effect
  5518. 4:13:36as well just to make it a bit simpler
  5519. 4:13:38there we go now it's pretty simple we
  5520. 4:13:41have a function to initialize it a
  5521. 4:13:42function open it and our own onpress
  5522. 4:13:45function that should actually call these
  5523. 4:13:47functions and make the magic happen and
  5524. 4:13:50that's exactly what happens in The Next
  5525. 4:13:51Step where we decide to present the
  5526. 4:13:53payment sheet so we don't need to copy
  5527. 4:13:56this entire function block we can just
  5528. 4:13:58copy what's in it so the const error and
  5529. 4:14:02then ifs and elses and we can paste it
  5530. 4:14:05within the open payment sheet here we
  5531. 4:14:08also need to import the payment sheet
  5532. 4:14:10error and before we present the payment
  5533. 4:14:13sheet as I told you we first need to
  5534. 4:14:15initialize that payment sheet so right
  5535. 4:14:18here at the top I can say a
  5536. 4:14:22wait initialize payment sheet which we
  5537. 4:14:26call as a function once we initialize it
  5538. 4:14:29we can check if there are any errors and
  5539. 4:14:31if so we can just let people know that
  5540. 4:14:33there are errors by using the react
  5541. 4:14:36natives alert functionality so alert.
  5542. 4:14:39alert make sure to import it we can say
  5543. 4:14:42error code
  5544. 4:14:44code is error. code and we can also
  5545. 4:14:48render the error message there we go
  5546. 4:14:52else if there's no error we can set a
  5547. 4:14:54new state of success so let's define
  5548. 4:14:58that new state right here at the top by
  5549. 4:15:00saying use
  5550. 4:15:02State I'll call it success and set
  5551. 4:15:05success at the start set to
  5552. 4:15:08false and then in the else right here we
  5553. 4:15:11can set success
  5554. 4:15:13equal to true and we don't actually need
  5555. 4:15:16this secondary if and else we just need
  5556. 4:15:19the inner one so if there is an error we
  5557. 4:15:22show this and then else we can set the
  5558. 4:15:26success
  5559. 4:15:28great so this is a function for opening
  5560. 4:15:31a payment sheet let's see what else do
  5561. 4:15:33we have to do finally we have to confirm
  5562. 4:15:36the payment but we haven't even tested
  5563. 4:15:38whether everything works so far for us
  5564. 4:15:41so before we can confirm the payment
  5565. 4:15:43let's go back and try to actually open
  5566. 4:15:45up the payment sheet okay so we can go
  5567. 4:15:48to any kind of
  5568. 4:15:51location find choose a
  5569. 4:15:55driver and click
  5570. 4:15:57confirm this time we get an error saying
  5571. 4:16:00you did not provide an API key I think
  5572. 4:16:03that's because we haven't reloaded our
  5573. 4:16:04application since we added our key
  5574. 4:16:06because if you look at it here we indeed
  5575. 4:16:08are passing our publishable key we might
  5576. 4:16:11also need to fix our scheme scha so
  5577. 4:16:14let's make a change to that in our book
  5578. 4:16:16ride for the merchant identifier we can
  5579. 4:16:19do something like let's maybe do
  5580. 4:16:23merchant. uber.com doesn't really matter
  5581. 4:16:27and then the URL schema has to be the
  5582. 4:16:29same as you have in your app. Json I
  5583. 4:16:32think by default it is set to my app as
  5584. 4:16:35you can see right here so let's leave it
  5585. 4:16:38like that and let's reload our
  5586. 4:16:40application by stopping it from running
  5587. 4:16:43and then rerunning MPX Expo start with-
  5588. 4:16:46C to clear the
  5589. 4:16:47cache and press R to reload the
  5590. 4:16:50application I'll speed up the process of
  5591. 4:16:53going through all these screens and
  5592. 4:16:55would you look at that right here we
  5593. 4:16:57have a beautiful little strip payment
  5594. 4:16:59sheet where you can enter your credit
  5595. 4:17:01card information the fake one of course
  5596. 4:17:04you can even scan your card it is so
  5597. 4:17:06seamless and you can click pay or we
  5598. 4:17:09cannot right now that's because that's
  5599. 4:17:10our next step if we go here the next
  5600. 4:17:13step is to work on this confirm Handler
  5601. 4:17:15so we can actually initiate and process
  5602. 4:17:17a payment so now we have created this
  5603. 4:17:20sheet and we have to next figure out
  5604. 4:17:22what happens after we click the pay
  5605. 4:17:24button next let's copy this confirm
  5606. 4:17:27Handler
  5607. 4:17:29functionality and let's paste it right
  5608. 4:17:31here on top of initialized payment sheet
  5609. 4:17:35this confirm Handler will be used as a
  5610. 4:17:37method on this init payment sheet so
  5611. 4:17:41right after the mode we have the confirm
  5612. 4:17:43Handler which is equal to confirm
  5613. 4:17:46Handler which is this function we just
  5614. 4:17:48created here we had it below so we can
  5615. 4:17:50delete this empty part and now we have
  5616. 4:17:52the real confirm Handler right here the
  5617. 4:17:54next step for all of this to work is to
  5618. 4:17:57create a payment intent so I can
  5619. 4:18:00collapse this one where we collect the
  5620. 4:18:02payment details and finally we are ready
  5621. 4:18:04to create a payment intent meaning
  5622. 4:18:06create the possibility for the user to
  5623. 4:18:09pay and that has to happen on the server
  5624. 4:18:11side so now they created an app. poost
  5625. 4:18:15route in our case we'll be using expose
  5626. 4:18:18API routes so let's go ahead and copy
  5627. 4:18:20this and create this route that will
  5628. 4:18:23create a payment intent that'll be under
  5629. 4:18:26app API and we can create a new folder
  5630. 4:18:31called in parentheses stripe within it
  5631. 4:18:35we can create a new file called create
  5632. 4:18:38plus API dots and within here we can
  5633. 4:18:43paste what we just copied of course
  5634. 4:18:45we'll have to make little tweaks to make
  5635. 4:18:47it fit our Expo API route setup so we
  5636. 4:18:51won't be requiring anything we will
  5637. 4:18:54simply be
  5638. 4:18:55importing stripe capital letter from
  5639. 4:19:01stripe and then we can initialize a new
  5640. 4:19:04instance of stripe by saying con stripe
  5641. 4:19:07is equal to new stripe to which we
  5642. 4:19:10provide our secret key so that's going
  5643. 4:19:12to be be process.
  5644. 4:19:14env.
  5645. 4:19:16stripe
  5646. 4:19:18secretor key and you can add an
  5647. 4:19:20exclamation mark at the end because we
  5648. 4:19:22know it'll be there now we can remove
  5649. 4:19:24this stripe instance and the Imports for
  5650. 4:19:27Express and the setup for creating API
  5651. 4:19:29routes in Expo is just a bit different
  5652. 4:19:31so we're not immediately saying app.
  5653. 4:19:34post rather we're saying export async
  5654. 4:19:39function
  5655. 4:19:41post where we get get access to a
  5656. 4:19:43request of a type
  5657. 4:19:46request and we can extract the body by
  5658. 4:19:49saying const body is equal to await
  5659. 4:19:52request. Json and from here we extract
  5660. 4:19:55everything else we can extract things
  5661. 4:19:58like the name the email and the amount
  5662. 4:20:01from that body after we extract them
  5663. 4:20:03we'll have to check if a name doesn't
  5664. 4:20:05exist or if an email doesn't exist or if
  5665. 4:20:08the amount doesn't exist then we can
  5666. 4:20:11return a new re
  5667. 4:20:13response of
  5668. 4:20:15json.stringify where we can add an error
  5669. 4:20:20that's going to
  5670. 4:20:21say please enter a valid email address
  5671. 4:20:26and we can also pass a
  5672. 4:20:29status of 400 that has to go inside of
  5673. 4:20:33this block right here let's make sure we
  5674. 4:20:36are properly opening and closing
  5675. 4:20:39everything I don't think I properly
  5676. 4:20:41closed this function block right here
  5677. 4:20:42here if we fix that we should be
  5678. 4:20:46good there we go now this is immediately
  5679. 4:20:49structured in a better way by prier and
  5680. 4:20:51the isent and if we have all of this
  5681. 4:20:54information about a user we can start
  5682. 4:20:57creating our customer by saying let
  5683. 4:20:59customer and then we can have a check
  5684. 4:21:02whether the customer exists so we can
  5685. 4:21:04say const does customer
  5686. 4:21:08exist which is equal to a weight stripe
  5687. 4:21:12do customers. list and we're going to
  5688. 4:21:15search for a user with that specific
  5689. 4:21:18email next if a customer does exist in
  5690. 4:21:22that case we can say customer is equal
  5691. 4:21:24to does customer exist. data zero if a
  5692. 4:21:28customer exists we're going to get the
  5693. 4:21:30actual existing customer so we can say
  5694. 4:21:33existing customer from it we can extract
  5695. 4:21:36the data and then that length is greater
  5696. 4:21:38than one that's how we can check whether
  5697. 4:21:40the customer exists
  5698. 4:21:43else if a customer does not exist we
  5699. 4:21:45need to create a new stripe customer by
  5700. 4:21:47saying con new customer is equal to
  5701. 4:21:51await stripe. customers. create and we
  5702. 4:21:55pass a name and an email right within
  5703. 4:21:58the else if we have a new customer we
  5704. 4:22:01want to set the customer to be equal to
  5705. 4:22:03that new customer now how did I know to
  5706. 4:22:06do all of this stuff and not just create
  5707. 4:22:09the payment intent like the doc said
  5708. 4:22:11well even even though this General
  5709. 4:22:14collect payment before creating a
  5710. 4:22:16payment intent page was great it allows
  5711. 4:22:18us to do some basic stuff there is a
  5712. 4:22:21second documentation page this one right
  5713. 4:22:23here that talks specifically about
  5714. 4:22:26accepting payments in react native and
  5715. 4:22:29if you scroll down I think we have
  5716. 4:22:31implemented the couple of these first
  5717. 4:22:33points but one of these is that post
  5718. 4:22:37request about accepting a payment and
  5719. 4:22:40here they talk about creating custom
  5720. 4:22:42customers and then they also talk about
  5721. 4:22:44creating a payment intent for now we
  5722. 4:22:46have dealt with this part about creating
  5723. 4:22:48a customer and now we can copy the rest
  5724. 4:22:50of the stuff the link will also be down
  5725. 4:22:53in the description where we can create a
  5726. 4:22:55key for each customer and then create an
  5727. 4:22:57entire payment intent and return it to
  5728. 4:23:00the front end so let's copy this part
  5729. 4:23:02from line eight and let's paste it right
  5730. 4:23:05below our if for the
  5731. 4:23:07customer you'll notice that here we
  5732. 4:23:09create a key that we attach to a
  5733. 4:23:12specific customer and then we create a
  5734. 4:23:14payment intent using stripe. payment
  5735. 4:23:17intent. create and here we need to
  5736. 4:23:19specify the amount we're trying to
  5737. 4:23:21charge the user in this case notice that
  5738. 4:23:24I'm passing the amount as part of the
  5739. 4:23:25body so what we can do is instead of
  5740. 4:23:28using this default $10.99 price we can
  5741. 4:23:33instead run the parse
  5742. 4:23:36int of the amount and then multiply that
  5743. 4:23:40by 100 because all the the payments in
  5744. 4:23:43here are in cents so to get to the real
  5745. 4:23:46amount we have to multiply it by 100 we
  5746. 4:23:48can change the currency to USD for
  5747. 4:23:51American dollars we have a customer ID
  5748. 4:23:54and then they also enable something of
  5749. 4:23:57automatic payment methods which is very
  5750. 4:23:59cool and we can set that to true but in
  5751. 4:24:02this case just to make it work we'll
  5752. 4:24:04have to allow redirects and set to never
  5753. 4:24:06this is something that I found works
  5754. 4:24:08best with react native applications and
  5755. 4:24:11finally we have to return not res. Json
  5756. 4:24:15but rather a new response that looks
  5757. 4:24:18like this and then we have to first
  5758. 4:24:21stringify it so json. stringify and then
  5759. 4:24:25we have this entire object so let's fix
  5760. 4:24:28that there we go we're passing the
  5761. 4:24:30payment intent in this case we can send
  5762. 4:24:33out the entire payment intent and the
  5763. 4:24:36entire key so I will just leave it like
  5764. 4:24:38this payment intent the key and then the
  5765. 4:24:41customer ID
  5766. 4:24:43and I don't believe we have to send the
  5767. 4:24:45publishable key back because we already
  5768. 4:24:47have it on the front and side so I will
  5769. 4:24:49remove this part from here and this is
  5770. 4:24:52it this is our backend function to
  5771. 4:24:55create a payment intent it is lengthy
  5772. 4:24:59but it is mostly boilerplate code coming
  5773. 4:25:01from stripe that now allows us to come
  5774. 4:25:04back to the payment and implement it
  5775. 4:25:07specifically it'll happen in the confirm
  5776. 4:25:09Handler we're getting three things as
  5777. 4:25:11the param here the payment method the
  5778. 4:25:14should say payment method which we will
  5779. 4:25:16not need to use so I can just rename it
  5780. 4:25:18to an underscore that's kind of a good
  5781. 4:25:20practice if you're not using some of the
  5782. 4:25:22parameters and then we have to make a
  5783. 4:25:24request to our own server and stripe was
  5784. 4:25:27kind enough to already give us an
  5785. 4:25:29example of how we can do that in our
  5786. 4:25:32case we'll do it like this I'll say
  5787. 4:25:36const I'll destructure the payment
  5788. 4:25:39intent and the customer remember this is
  5789. 4:25:41just what we're sending from the back
  5790. 4:25:43end or you can call it Expo API route
  5791. 4:25:46and say await fetch API and we're going
  5792. 4:25:50to go to SL API in parentheses slst
  5793. 4:25:54stripe in parentheses SLC create the
  5794. 4:25:58route that we just created we can pass
  5795. 4:26:00additional options to it such as a
  5796. 4:26:03method of post headers equal to an
  5797. 4:26:07object where the content type is set to
  5798. 4:26:10application Json and most importantly we
  5799. 4:26:13need to pass over the body by running
  5800. 4:26:16json. stringify and passing in a name of
  5801. 4:26:19the person who is buying that's going to
  5802. 4:26:22be equal to a full name in this case
  5803. 4:26:25which we can get from the props into the
  5804. 4:26:28payment function so before we add this
  5805. 4:26:31part right here let's pass some props
  5806. 4:26:34into the payment function from the book
  5807. 4:26:36ride first things first right at the top
  5808. 4:26:39of the book ride we'll need to get some
  5809. 4:26:41information about the user and we can do
  5810. 4:26:43that easily with clerk by saying const D
  5811. 4:26:46structure the user is equal to use user
  5812. 4:26:51how
  5813. 4:26:53convenient now if we go down we can pass
  5814. 4:26:56all of the user related information to
  5815. 4:26:58the payment so we know who is making the
  5816. 4:27:00actual payment we can pass things like
  5817. 4:27:04full name is equal to user question
  5818. 4:27:07mark. full name and we can end each one
  5819. 4:27:10of these in exclamation mark because
  5820. 4:27:12clerk is not sure they're going to be
  5821. 4:27:14there depending on different use cases
  5822. 4:27:16but we know that it will indeed be there
  5823. 4:27:18so we can tell typescript that we can do
  5824. 4:27:21the same thing for the email by saying
  5825. 4:27:23user question mark. email addresses
  5826. 4:27:27z. email address exclamation mark and
  5827. 4:27:31then we need to pass the amount of the
  5828. 4:27:33drive so that's going to be driver
  5829. 4:27:36details question mark. price next we
  5830. 4:27:40need the driver ID as as well which is
  5831. 4:27:42going to be driver details question
  5832. 4:27:44mark. ID and finally ride time which is
  5833. 4:27:48going to be equal to driver details
  5834. 4:27:50question mark.
  5835. 4:27:53time and now we can go into the payment
  5836. 4:27:56and we can accept all of these
  5837. 4:27:58props let's do it right away by getting
  5838. 4:28:02the full name the email the amount the
  5839. 4:28:07driver ID and the ride time and all of
  5840. 4:28:11these will will be of a type payment
  5841. 4:28:14props coming from types now that we have
  5842. 4:28:17these we can send more information to
  5843. 4:28:19the server by saying that the name will
  5844. 4:28:22be equal to either the full name or
  5845. 4:28:27email.it and we can split it by the
  5846. 4:28:29email sign and take the first part we
  5847. 4:28:31can then pass over the email which will
  5848. 4:28:33be equal to email the amount which will
  5849. 4:28:36be equal to amount and the payment
  5850. 4:28:40method
  5851. 4:28:42ID which is going to be equal to payment
  5852. 4:28:45method.
  5853. 4:28:47ID again webstorm nicely found that I
  5854. 4:28:50have a typo it was supposed to be
  5855. 4:28:53payment now that we have this we
  5856. 4:28:55basically have everything we need to get
  5857. 4:28:58a payment intent or rather to create a
  5858. 4:29:00payment intent on the back end and pass
  5859. 4:29:03it over back to us on the front end so
  5860. 4:29:06right here below we can make a check and
  5861. 4:29:09see if payment intent
  5862. 4:29:12centore secret so are we getting any
  5863. 4:29:15secret from here if we are then we can
  5864. 4:29:18actually make a payment based on the
  5865. 4:29:20payment intent that we
  5866. 4:29:22created and to make that happen we'll
  5867. 4:29:25have to create a second API route for
  5868. 4:29:28payments so let's create a new file
  5869. 4:29:31within the stripe folder and let's call
  5870. 4:29:33it Pay Plus api. Ts and it'll start
  5871. 4:29:39similar to create we can copy the import
  5872. 4:29:42of stripe we can copy the part where we
  5873. 4:29:44initialize stripe where we export an
  5874. 4:29:46async function and where we extract some
  5875. 4:29:49data from the body heck this part as
  5876. 4:29:51well will be the same where we check
  5877. 4:29:52whether we have all the necessary info
  5878. 4:29:54so let's copy these initial lines and
  5879. 4:29:57paste them into the payment API and make
  5880. 4:30:00sure to properly close everything of
  5881. 4:30:03course we'll have to make some changes
  5882. 4:30:05instead of getting the name email and
  5883. 4:30:07amount in this case we're getting some
  5884. 4:30:09more payment related stuff such as theay
  5885. 4:30:12payment uncore method _ ID the payment _
  5886. 4:30:17intentor ID and the customer ID and now
  5887. 4:30:21we can make a check whether all of these
  5888. 4:30:23indeed exist and if they don't exist we
  5889. 4:30:26can say something like missing required
  5890. 4:30:29payment information great but if we have
  5891. 4:30:33all of that payment information below
  5892. 4:30:35this if we can finally create a new
  5893. 4:30:38payment method by saying con payment
  5894. 4:30:40method is equal to wait stripe. payment
  5895. 4:30:45methods do attach so which payment
  5896. 4:30:48method we want to attach well the one
  5897. 4:30:50that we have the ID for so payment
  5898. 4:30:53method ID and which customer is paying
  5899. 4:30:56for that well we can provide that in the
  5900. 4:30:58second parameter customer is equal to
  5901. 4:31:01customer uncore ID that's going to look
  5902. 4:31:04something like this and below it we can
  5903. 4:31:07get the result of the payment by saying
  5904. 4:31:09const result is equal to await stripe.
  5905. 4:31:14payment intents do confirm to which we
  5906. 4:31:17can pass the payment intent id and we
  5907. 4:31:20can pass the payment method as the
  5908. 4:31:22second option inside of curly braces
  5909. 4:31:25where we can say payment method is of a
  5910. 4:31:28type payment method. ID finally once we
  5911. 4:31:31have the result we can send it over to
  5912. 4:31:33the front end by returning a new
  5913. 4:31:36response within which we have a Json
  5914. 4:31:39stringify with a success that says true
  5915. 4:31:43a message that says something like
  5916. 4:31:45payment confirmed successfully and a
  5917. 4:31:49result of that payment equal to result
  5918. 4:31:52of course if something goes wrong then
  5919. 4:31:54we have to have a catch so I'll copy
  5920. 4:31:57this entire block of code and put it
  5921. 4:32:00within a try and catch block so this
  5922. 4:32:02part goes into try and in the catch
  5923. 4:32:05where we get the
  5924. 4:32:07error we can consal log the error and we
  5925. 4:32:12can also return a new response that has
  5926. 4:32:16a Json stringify within it that has the
  5927. 4:32:19property of error equal to error and a
  5928. 4:32:23status equal to 500 pointing to a server
  5929. 4:32:27error so now with these two API routes
  5930. 4:32:31first of all we have created a payment
  5931. 4:32:33intent allowing our user to get the
  5932. 4:32:36possibility to pay and then with the
  5933. 4:32:39second API route we are actually
  5934. 4:32:41allowing allwing the user to pay based
  5935. 4:32:43on the provided payment intent so going
  5936. 4:32:46back to the payment we can now receive
  5937. 4:32:48that response on the front ins Side by
  5938. 4:32:50saying const destructure the result and
  5939. 4:32:54say is equal to await fetch API in
  5940. 4:32:59parentheses
  5941. 4:33:00API slash in parentheses stripe SL pay
  5942. 4:33:06it'll have similar properties as before
  5943. 4:33:09such as a method of post headers equal
  5944. 4:33:13to content type of application Json and
  5945. 4:33:17a body which will be a json. stringify
  5946. 4:33:20to which we need to pass all of this
  5947. 4:33:22important information from the payment
  5948. 4:33:24intent such as the payment uncore method
  5949. 4:33:27uncore ID equal to payment method. ID a
  5950. 4:33:32payment uncore intentor ID equal to
  5951. 4:33:36payment intent. ID and what else do we
  5952. 4:33:39need I think it was is going to be let's
  5953. 4:33:43see customer ID so we can also pass the
  5954. 4:33:48customer ID is equal to customer because
  5955. 4:33:52that is actually the ID and now that
  5956. 4:33:55that is successful we can do the last
  5957. 4:33:57thing necessary which is to create a new
  5958. 4:34:00ride that means hooking up our driver to
  5959. 4:34:03our Rider and making sure that the rider
  5960. 4:34:05has actually paid and then we can create
  5961. 4:34:08a new ongoing ride we're not going to
  5962. 4:34:10test the payments yet yet before we can
  5963. 4:34:13create a new ride in the database so
  5964. 4:34:16let's do that next by checking
  5965. 4:34:19if result. centore
  5966. 4:34:23secret if it exists that means that
  5967. 4:34:25everything is ready to create a ride and
  5968. 4:34:28we have to be one scope above right here
  5969. 4:34:30to have access to this result here we
  5970. 4:34:33want to make a call to a new API route
  5971. 4:34:36of ride SLC create so let me close these
  5972. 4:34:41existing routes and let's create one
  5973. 4:34:44route but this time that will not be
  5974. 4:34:46just for stripe it'll be for creating
  5975. 4:34:49our own rides we can do that by creating
  5976. 4:34:52a new folder within our API folder
  5977. 4:34:56that's going to be called ride within
  5978. 4:34:58the ride we can create a new file called
  5979. 4:35:01create plus api. DS and within here we
  5980. 4:35:06have to connect to the neon database and
  5981. 4:35:09create a new record in the database most
  5982. 4:35:11this file will be just a single SQL
  5983. 4:35:13mutation so under Snippets in the GitHub
  5984. 4:35:16read me you can find the API ride create
  5985. 4:35:19plus API and you can copy it from here
  5986. 4:35:22and paste it right there you'll notice
  5987. 4:35:25that this is just a single try and catch
  5988. 4:35:28Block in the catch we're handling the
  5989. 4:35:30error and in the try we are getting all
  5990. 4:35:33the information from the body we are
  5991. 4:35:35destructuring it we're checking if it
  5992. 4:35:38all exists and then if it does we're
  5993. 4:35:40simply create creating a new SQL query
  5994. 4:35:43where we Define the fields and we Define
  5995. 4:35:46the values that we're passing into that
  5996. 4:35:49and finally returning this newly created
  5997. 4:35:51ride back to us again there is about 70
  5998. 4:35:53lines of code just because we had to
  5999. 4:35:55write pure SQL syntax nowadays there's
  6000. 4:35:58also tools like drizzle or Prisma so if
  6001. 4:36:01you'd like me to see use that more often
  6002. 4:36:03just let me know but sometimes it's good
  6003. 4:36:05to understand how Native SQL works
  6004. 4:36:08because these orm tools all use SQL
  6005. 4:36:11behind the scenes
  6006. 4:36:12and as I promised if you want to learn
  6007. 4:36:13more about SQL and also orms like Prisma
  6008. 4:36:17I would highly recommend checking out
  6009. 4:36:19this course that we created which is for
  6010. 4:36:21now completely free for you so here you
  6011. 4:36:23can learn a bit more about different SQL
  6012. 4:36:26mutations such as inserting data which
  6013. 4:36:28is exactly what we're doing in this one
  6014. 4:36:31it teaches you how you can insert
  6015. 4:36:32different properties take a look at this
  6016. 4:36:34it is exactly what we're doing insert
  6017. 4:36:37into users table name and email and then
  6018. 4:36:40you provide the values for that name and
  6019. 4:36:42email check this out insert into rides
  6020. 4:36:47origin address and then you provide the
  6021. 4:36:49value for the origin address pretty
  6022. 4:36:50straightforward but it is a bit lengthy
  6023. 4:36:53so I decided to provide it here for you
  6024. 4:36:55there's also going to be just one more
  6025. 4:36:57similar file to this one one more API
  6026. 4:36:59route where instead of creating
  6027. 4:37:02something we'll be fetching all of these
  6028. 4:37:04things from the rides so that's also
  6029. 4:37:06going to be lengthy so let's just
  6030. 4:37:08quickly create it it's going to be under
  6031. 4:37:10ride create create a new file it'll be a
  6032. 4:37:13dynamic route based on the ID so it's
  6033. 4:37:15going to be square brackets ID plus API
  6034. 4:37:19dots and you can find this file in the
  6035. 4:37:22GitHub readme down below so you can
  6036. 4:37:24paste it as well as you can see instead
  6037. 4:37:26of inserting in this case we're simply
  6038. 4:37:28selecting all of the properties that we
  6039. 4:37:30want to get from this request that we're
  6040. 4:37:33making great now we can go back to
  6041. 4:37:36payment and we can call this API request
  6042. 4:37:39that creates a new ride but before that
  6043. 4:37:42we'll have to get away from our mock
  6044. 4:37:44drivers and we'll have to create real
  6045. 4:37:46drivers in the database remember right
  6046. 4:37:49now I think in the map right we have
  6047. 4:37:52some fake drivers right here now what we
  6048. 4:37:54could do is manually create all of these
  6049. 4:37:57driver accounts but we can also go to
  6050. 4:37:59the SQL editor and we can run an SQL
  6051. 4:38:03mutation to create all of these drivers
  6052. 4:38:06so in this GitHub Snippets read me you
  6053. 4:38:08can see the create driver stable SQL
  6054. 4:38:11which you can copy and then paste right
  6055. 4:38:14here to create a table it says connected
  6056. 4:38:17there we go it's exceeded and then the
  6057. 4:38:19second thing we can do is seed the
  6058. 4:38:21database with the drivers seed is a word
  6059. 4:38:24that is used when you want to quickly
  6060. 4:38:26populate the database with some data so
  6061. 4:38:29we can copy this command and paste it
  6062. 4:38:32right here where we're going to insert
  6063. 4:38:34some drivers right here we can click run
  6064. 4:38:38and it has been successful we can verify
  6065. 4:38:41if we go into tables you should be able
  6066. 4:38:43to see a driver's table with four
  6067. 4:38:45different drivers great so now we can
  6068. 4:38:48remove these fake drivers and we can
  6069. 4:38:51actually fetch real drivers from the
  6070. 4:38:53database let's do just that we're using
  6071. 4:38:56those drivers right here in the use
  6072. 4:38:58effect and even I added a note right
  6073. 4:39:01here that we need to remove that rather
  6074. 4:39:04we have to fetch them for real and we
  6075. 4:39:06can do that by first creating an API
  6076. 4:39:08route that will give us back all of
  6077. 4:39:10those drivers so let's do it by creating
  6078. 4:39:13a new API route in the API folder called
  6079. 4:39:18driver Plus
  6080. 4:39:20api.
  6081. 4:39:21Ts and this one we can write ourselves
  6082. 4:39:24just so we can see how it is to write
  6083. 4:39:26some simple SQL queries we can say
  6084. 4:39:30export async function get where we can
  6085. 4:39:35open up a try and catch
  6086. 4:39:37block with the
  6087. 4:39:40error if if something goes wrong we can
  6088. 4:39:42just console. log. error and we can also
  6089. 4:39:47return a response. Json where we send
  6090. 4:39:51over the
  6091. 4:39:54error which is equal to the error
  6092. 4:39:57message in the try we can actually
  6093. 4:39:59access the neon DP database by saying
  6094. 4:40:01const SQL is equal to Neon coming from
  6095. 4:40:05neon database serverless to which we
  6096. 4:40:08need to provide our database URL or our
  6097. 4:40:11our connection string so let's say
  6098. 4:40:13process. env.
  6099. 4:40:16databaseurl it is that simple and now we
  6100. 4:40:20can say const response is equal to await
  6101. 4:40:24SQL we write a template string and we
  6102. 4:40:28select everything from drivers that's it
  6103. 4:40:33give me back all the drivers and with
  6104. 4:40:35that we can return response. Json where
  6105. 4:40:39we pass over the data which is equal to
  6106. 4:40:42response so now back in the map we can
  6107. 4:40:44fetch all of those drivers let's do that
  6108. 4:40:46right away at the top by saying const
  6109. 4:40:49data which we can rename to
  6110. 4:40:52drivers we also get the loading State
  6111. 4:40:54and the error States and that is equal
  6112. 4:40:57to use fetch we can specify the type
  6113. 4:41:01it'll send back an array of drivers like
  6114. 4:41:04this and here we need to specify the URL
  6115. 4:41:08which we're calling that's going to be
  6116. 4:41:10forward slash in parentheses API SL
  6117. 4:41:14driver I'm going to minimize this just a
  6118. 4:41:17bit I hope you can still see it and
  6119. 4:41:20we're basically fetching all the drivers
  6120. 4:41:21here so now we can make use of the
  6121. 4:41:24loading State and the error states by
  6122. 4:41:27adding something above the map so we can
  6123. 4:41:29say if we are loading or if there is no
  6124. 4:41:34user latitude or if there is no user
  6125. 4:41:38longitude in that case we can return a
  6126. 4:41:41view we can zoom it in and within it we
  6127. 4:41:44can return an activity indicator with a
  6128. 4:41:47size of small and a color equal to Hash
  6129. 4:41:510000
  6130. 4:41:530 it looks like that broke my screen
  6131. 4:41:56share right here no worries we'll fix it
  6132. 4:41:58soon we have to import The View right at
  6133. 4:42:01the top and Below we can check if
  6134. 4:42:03there's an error but let's make sure to
  6135. 4:42:05properly close this I noticed that I'm
  6136. 4:42:07missing the curly braces here if there
  6137. 4:42:10is an error we can basically have a very
  6138. 4:42:12similar view to this one I forgot to add
  6139. 4:42:15the class names so let's give it a class
  6140. 4:42:17names equal to flex justify Dash between
  6141. 4:42:22items - Center and w- full this will
  6142. 4:42:25basically make it appear in the middle
  6143. 4:42:28we can duplicate this entire view if
  6144. 4:42:30there's an error of course let's copy
  6145. 4:42:32the return as well and only instead of
  6146. 4:42:35the activity indicator we'll show a
  6147. 4:42:38text that'll say error and then we can
  6148. 4:42:41render the actual error
  6149. 4:42:43message and we have to import text from
  6150. 4:42:47react
  6151. 4:42:48native great so now we have the error
  6152. 4:42:50handling the loading handlers and we are
  6153. 4:42:54fetching the drivers so let's put those
  6154. 4:42:57drivers to use scrolling down we won't
  6155. 4:43:00be setting the drivers right here we'll
  6156. 4:43:02be setting them somewhere else in that
  6157. 4:43:04second place will be a new use effect
  6158. 4:43:07right below this one because now that we
  6159. 4:43:09have the real drivers we can also create
  6160. 4:43:12a path between the writer and the driver
  6161. 4:43:15so we can show it on the screen you know
  6162. 4:43:17that route the blue line from you and
  6163. 4:43:20the other person that's exactly what
  6164. 4:43:22we'll create basically navigation so
  6165. 4:43:25let's create a new use effect and we can
  6166. 4:43:28have an if statement here if markers do
  6167. 4:43:31length is greater than zero and if
  6168. 4:43:34destination latitude is not equal to
  6169. 4:43:37undefined so we cannot calculate
  6170. 4:43:39something if we don't have a destination
  6171. 4:43:41latitude and if destination longitude as
  6172. 4:43:45well is not equal to
  6173. 4:43:47undefined or we can just say if it
  6174. 4:43:49exists right so if markers that length
  6175. 4:43:53and if destination latitude and
  6176. 4:43:55destination longitude in that case we
  6177. 4:43:58can call a special utility function
  6178. 4:44:00called calculate driver times that's
  6179. 4:44:04going to look a bit like this and to it
  6180. 4:44:06we have to pass a couple of prompts we
  6181. 4:44:09need to pass all of the markers which
  6182. 4:44:11want to show on the screen which are
  6183. 4:44:12basically the cars the user's current
  6184. 4:44:15longitude the user's current latitude
  6185. 4:44:19and the destination latitude as well as
  6186. 4:44:21a destination
  6187. 4:44:24longitude that function is an Asing
  6188. 4:44:27function so we can call a that then on
  6189. 4:44:29it which will give us access to all of
  6190. 4:44:31the drivers and now once we get that we
  6191. 4:44:34can set
  6192. 4:44:36drivers to be drivers as marker data
  6193. 4:44:41array so this is to make sure that the
  6194. 4:44:42map understands that the drivers are
  6195. 4:44:44indeed appearing on the
  6196. 4:44:46screen and we can recall this function
  6197. 4:44:49whenever the markers change when the
  6198. 4:44:51destination latitude changes or when the
  6199. 4:44:54destination logitude changes as well so
  6200. 4:44:57now let's give it a shot I will close
  6201. 4:44:59this sheet and I'll say that I want to
  6202. 4:45:02go let's say somewhere near in San
  6203. 4:45:05Francisco and first of all don't forget
  6204. 4:45:07when you make a lot of changes reload
  6205. 4:45:09the entire application
  6206. 4:45:11so I'll stop it from running and I'll
  6207. 4:45:14rerun it one more time with the Das C
  6208. 4:45:16Tab and then press R to reload the
  6209. 4:45:19entire
  6210. 4:45:21application there we go oh this clerk
  6211. 4:45:24warning just reminded me that we need to
  6212. 4:45:25implement the O still so that's
  6213. 4:45:27something that we'll do very soon but
  6214. 4:45:29now you can see different drivers on the
  6215. 4:45:31screen as you were able to see before
  6216. 4:45:33but now if we go let's say we are in the
  6217. 4:45:36lower Pacific Heights right now if we
  6218. 4:45:38want to go to this nice park we can go
  6219. 4:45:41to Scott Street so let's do
  6220. 4:45:44Scott Street and that's in San
  6221. 4:45:48Francisco you can see that we have San
  6222. 4:45:51Francisco and then Scott Street and we
  6223. 4:45:53can click find now and this will open up
  6224. 4:45:56the different drivers we can select one
  6225. 4:45:58of those drivers and these now are real
  6226. 4:46:01drivers you can see that they changed
  6227. 4:46:03since the last time that we had the
  6228. 4:46:04drivers now they're coming from the
  6229. 4:46:06database we might need to do some work
  6230. 4:46:08to properly show the actual distance in
  6231. 4:46:11minutes so let me do that I think this
  6232. 4:46:14is in the driver card where we have the
  6233. 4:46:17minutes right here let's see if I can
  6234. 4:46:19find it this is the
  6235. 4:46:22price and right next to the price we
  6236. 4:46:25have the time we can use the parse
  6237. 4:46:27integer I believe to make this work and
  6238. 4:46:30now we can see four minutes 3 minutes
  6239. 4:46:32and more that's good and it looks like
  6240. 4:46:35the time needs to be a string so I can
  6241. 4:46:37easily convert this into a string by
  6242. 4:46:40maing it into a template string like
  6243. 4:46:44this great and it still works so now we
  6244. 4:46:48can choose a different driver and you
  6245. 4:46:50can see that on the screen the driver
  6246. 4:46:52that you choose becomes green so you can
  6247. 4:46:54see how they're changing colors right
  6248. 4:46:56here so now if I choose let's go with
  6249. 4:47:00David he seems to be one of the cheapest
  6250. 4:47:02ones and the closest to us oh no no way
  6251. 4:47:05looks like Michael drives a nice yellow
  6252. 4:47:07car $2 and 2 minutes away let's go with
  6253. 4:47:10that one and I'll click select now we
  6254. 4:47:14can see all the information about
  6255. 4:47:15Michael looks like we need to do the
  6256. 4:47:17same thing for the time so let me copy
  6257. 4:47:21this entire thing go to the right
  6258. 4:47:23information so that is I believe under
  6259. 4:47:26pickup
  6260. 4:47:27time in the book ride yes and we just
  6261. 4:47:30need to wrap this properly so it's
  6262. 4:47:32driver details. time let's add it
  6263. 4:47:35here driver
  6264. 4:47:39details. time
  6265. 4:47:42and we can remove this mock
  6266. 4:47:44number let's make sure to close it
  6267. 4:47:47properly and save it and now it says 4
  6268. 4:47:49minutes nice but if I Collapse it I'm
  6269. 4:47:52still not seeing the path from my
  6270. 4:47:54location to where I want to go so let's
  6271. 4:47:58head over to the map and let's look into
  6272. 4:48:00the function that has something to do
  6273. 4:48:02with the drivers this one is setting the
  6274. 4:48:05driver's car locations and I believe we
  6275. 4:48:09have to add some more dependencies to it
  6276. 4:48:11you can see even our webstorm is
  6277. 4:48:12complaining that it needs further
  6278. 4:48:15dependencies those are going to be the
  6279. 4:48:17user
  6280. 4:48:18latitude and the user longitude so
  6281. 4:48:21whenever those change we can also recall
  6282. 4:48:24this use effect but that's not the
  6283. 4:48:26problem the real solution lies right
  6284. 4:48:29here in the map jsx currently we have
  6285. 4:48:32just the map view and we have the
  6286. 4:48:34markers but we have to make a connection
  6287. 4:48:37from our current initial user location
  6288. 4:48:41to the destination location so right
  6289. 4:48:44within the map below these three
  6290. 4:48:47parentheses we can check whether we have
  6291. 4:48:50access to the destination latitude and
  6292. 4:48:52destination
  6293. 4:48:54longitude and if we have then we can
  6294. 4:48:57return a react fragment or should I say
  6295. 4:49:00react native fragment that'll show
  6296. 4:49:03another marker which is going to be the
  6297. 4:49:05marker for the destination let's give it
  6298. 4:49:08a key so we can differentiate it from
  6299. 4:49:10the others
  6300. 4:49:11such as destination let's give it some
  6301. 4:49:13coordinates to show it on the map we
  6302. 4:49:16need to pass it the latitude which is
  6303. 4:49:19going to be equal to you can guess it
  6304. 4:49:21destination
  6305. 4:49:22latitude and the longitude which is
  6306. 4:49:25going to be equal to guess it
  6307. 4:49:28destination longitude we can also pass
  6308. 4:49:31it a title which is going to be equal to
  6309. 4:49:34destination so let's do just that
  6310. 4:49:38destination and we can give it an image
  6311. 4:49:41which is going to be a typical
  6312. 4:49:43icons.
  6313. 4:49:45pin and now check this out I can
  6314. 4:49:48actually see that I wanted to go to
  6315. 4:49:50Scott Street and would you look at that
  6316. 4:49:53there's some trees there that seems like
  6317. 4:49:54a nice place to take a walk around and
  6318. 4:49:57we can see the pin on there on your
  6319. 4:49:59screen you should also be able to see a
  6320. 4:50:01pin near your exact location so you can
  6321. 4:50:04see pin from and to but now let's create
  6322. 4:50:07directions from you to the PIN we can do
  6323. 4:50:11that by installing a new package so
  6324. 4:50:13let's open up a new terminal and say mpm
  6325. 4:50:17install
  6326. 4:50:19react-native-maps D directions and
  6327. 4:50:22that's going to allow us to below the
  6328. 4:50:24marker put this new map view directions
  6329. 4:50:29we of course need to import it at the
  6330. 4:50:31top by saying
  6331. 4:50:34import map view
  6332. 4:50:36directions from react native Maps there
  6333. 4:50:40directions that is great and now we need
  6334. 4:50:43to give it additional information so it
  6335. 4:50:45knows what to show we of course have to
  6336. 4:50:48give it An Origin which is going to be
  6337. 4:50:50our user's latitude that's going to be
  6338. 4:50:53user
  6339. 4:50:54latitude and we have to give it
  6340. 4:50:56longitude which is going to be our
  6341. 4:50:57current user's
  6342. 4:51:00longitude next we have to give it the
  6343. 4:51:02destination which is going to be similar
  6344. 4:51:05to what we have here we can copy the
  6345. 4:51:07coordinates of the pin where we want to
  6346. 4:51:09go latitude is destination latitude and
  6347. 4:51:12the longitude is the destination
  6348. 4:51:14longitude to it we need to provide the
  6349. 4:51:16API key and that key is coming from envs
  6350. 4:51:19so we can say process. EnV Dot and let's
  6351. 4:51:23check the exact name in our
  6352. 4:51:25envs it's going to be Expo public Google
  6353. 4:51:29API key so we can copy it paste it here
  6354. 4:51:33let's make sure to properly close this
  6355. 4:51:35destination and finally below the API
  6356. 4:51:38key we can also choose our stroke color
  6357. 4:51:42so the color of the path that can be a
  6358. 4:51:45bluish color of something like hash 028
  6359. 4:51:496
  6360. 4:51:50FF and a stroke width of about two if we
  6361. 4:51:55save this we have to make sure that
  6362. 4:51:57we're properly enclosing it I think we
  6363. 4:51:59have two extra ending braces and we're
  6364. 4:52:02missing an equal sign right here and
  6365. 4:52:04would you look at that we now have a
  6366. 4:52:07complete path through the streets from
  6367. 4:52:10our current location on the map to the
  6368. 4:52:14destination location how cool is that if
  6369. 4:52:18you want to you can change the color and
  6370. 4:52:20you can make it a bit wider that's
  6371. 4:52:22totally okay too there we go this is
  6372. 4:52:24perfect and now we can even see maybe we
  6373. 4:52:27can go for this driver right here for
  6374. 4:52:28David instead of Michael so let's go
  6375. 4:52:30back let's choose David there we go that
  6376. 4:52:34Rider is now green and we can select the
  6377. 4:52:37ride and see where we want to go from
  6378. 4:52:40our our location to the destination
  6379. 4:52:42location great now where were we I think
  6380. 4:52:46we were on the payments where we want to
  6381. 4:52:48confirm the ride and just before we
  6382. 4:52:50actually pay it we wanted to create a
  6383. 4:52:53ride which we now actually can do
  6384. 4:52:55because we have real drivers in the
  6385. 4:52:57database we have created a real writer
  6386. 4:53:00when we created our account so the only
  6387. 4:53:02thing we have to do is to create a
  6388. 4:53:04server action that will connect it to
  6389. 4:53:07and book us a ride so let's head over to
  6390. 4:53:10to our API calls and check out our ride
  6391. 4:53:14create this is the one where we're
  6392. 4:53:16simply getting all the fields we
  6393. 4:53:18collected so far and then inserting it
  6394. 4:53:20into the database we can call it from
  6395. 4:53:22the front end now or should I say from
  6396. 4:53:24our device screen we can do that by
  6397. 4:53:27saying await fetch
  6398. 4:53:29API to which we can pass the URL of
  6399. 4:53:33Slash in parentheses
  6400. 4:53:36API SL rde SLC create
  6401. 4:53:41as additional options we can pass a
  6402. 4:53:44method equal to
  6403. 4:53:47post we can pass
  6404. 4:53:49headers equal to content type
  6405. 4:53:52application Json and we can pass the
  6406. 4:53:55body now keep in mind you know that in
  6407. 4:53:58the actual API request we are getting a
  6408. 4:54:00lot of things through the body so we
  6409. 4:54:02have to do the same thing here json.
  6410. 4:54:07stringify within an object and now we
  6411. 4:54:09have to pass all of the info we have
  6412. 4:54:12collected so far the user info the
  6413. 4:54:14destination info everything so let's say
  6414. 4:54:18origin address meaning where we're going
  6415. 4:54:21from is going to be equal to user
  6416. 4:54:24address and this user address we can get
  6417. 4:54:26from the location store so right at the
  6418. 4:54:29top we can get all of this great
  6419. 4:54:31information from the location store by
  6420. 4:54:33saying const something is equal to use
  6421. 4:54:37location
  6422. 4:54:38store and right here we we can get the
  6423. 4:54:41user address we can get the user
  6424. 4:54:44longitude user
  6425. 4:54:47latitude distination latitude
  6426. 4:54:50destination address and destination
  6427. 4:54:53longitude now in an Ideal World we
  6428. 4:54:56wouldn't need to destructure all of
  6429. 4:54:57these properties and then now again form
  6430. 4:54:59them properly ideally we would be using
  6431. 4:55:02the same exact names on both the front
  6432. 4:55:05end and the back end but sometimes it's
  6433. 4:55:07not like that sometimes stripe uses
  6434. 4:55:10underscores or Kebab case and you're
  6435. 4:55:12using camel case so it's always better
  6436. 4:55:14to destructure them and make sure that
  6437. 4:55:16you're passing the exact right names of
  6438. 4:55:19the variables on the back end right here
  6439. 4:55:21if we go to create ride or create ride
  6440. 4:55:24API this one right here you can notice
  6441. 4:55:27that we are inserting origin unor
  6442. 4:55:29address and not origin address with a
  6443. 4:55:32capital A right here so for that reason
  6444. 4:55:35we have to properly spell it here as
  6445. 4:55:36well origin address is equal to user
  6446. 4:55:40address address let's continue with
  6447. 4:55:41passing other properties as well such as
  6448. 4:55:44the destination address but make sure to
  6449. 4:55:47use the snake case right here is equal
  6450. 4:55:50to destination address in camel case we
  6451. 4:55:53can get the origin
  6452. 4:55:55latitude equal to user latitude and
  6453. 4:55:59origin longitude equal to user longitude
  6454. 4:56:03we can get the destination latitude
  6455. 4:56:05equal to destination
  6456. 4:56:08latitude make sure to put that in snake
  6457. 4:56:12case as well snake case is the
  6458. 4:56:14recommended case for postgress databases
  6459. 4:56:17that's why we're doing this and we can
  6460. 4:56:19do destination longitude equal to
  6461. 4:56:21destination longitude we can get the
  6462. 4:56:23rore time which is equal to right time.
  6463. 4:56:28to fixed Z we can do faircore
  6464. 4:56:33price to be equal to parse int we take
  6465. 4:56:36the amount and we multiply it by 100 to
  6466. 4:56:40get into sense as that's how strip
  6467. 4:56:42processes payments we can set the
  6468. 4:56:44payment status to be equal to paid
  6469. 4:56:47because this is after we actually
  6470. 4:56:49confirm that the payment went through by
  6471. 4:56:51stripe we need to know which driver
  6472. 4:56:53processed the payment and we need to
  6473. 4:56:55know the user ID that accepted that ride
  6474. 4:56:59and this user ID is coming from use o by
  6475. 4:57:02clerk so we can get it right here at the
  6476. 4:57:04top by destructuring the user ID coming
  6477. 4:57:08from use o from clerk great so now we
  6478. 4:57:13have everything we need that we're
  6479. 4:57:14passing to create a ride and finally we
  6480. 4:57:17can call the call back of the successful
  6481. 4:57:20intent creation so that's intent
  6482. 4:57:22creation call back to which we need to
  6483. 4:57:24pass our client secret which is equal to
  6484. 4:57:27result. client secret you can see that
  6485. 4:57:31stripe uses this snake case as well
  6486. 4:57:34finally this entire time we have been
  6487. 4:57:36within the confirm Handler which is only
  6488. 4:57:39one small part of the intent
  6489. 4:57:43configuration right here as you can see
  6490. 4:57:45now right below the intent configuration
  6491. 4:57:48we can enter the return URL which is
  6492. 4:57:52going to be my app
  6493. 4:57:55Colin book- rde so this is where we want
  6494. 4:57:59to go back to after we complete the
  6495. 4:58:01payment and if there's an error we can
  6496. 4:58:03just
  6497. 4:58:05console.log the error now let's see if
  6498. 4:58:07we have some warnings or errors
  6499. 4:58:09remaining we have one right here with
  6500. 4:58:11the client secret I think this is
  6501. 4:58:13something that we copied way back from
  6502. 4:58:15stripe but we don't need anymore as we
  6503. 4:58:18have implemented it right here above
  6504. 4:58:20where we're basically passing the client
  6505. 4:58:22secret into the intent creation callback
  6506. 4:58:25so we can remove this part right here do
  6507. 4:58:27we have any other warnings or errors we
  6508. 4:58:30can see that the confirm Handler is
  6509. 4:58:32complaining a bit about the types that
  6510. 4:58:34we're passing into it it's saying that
  6511. 4:58:37the payment method shouldn't have a type
  6512. 4:58:39any it seems that we don't have any
  6513. 4:58:42types for the payment method intent
  6514. 4:58:44creation call back and that's why it's
  6515. 4:58:45complaining right here those can be
  6516. 4:58:48easily fixed if you collapse the
  6517. 4:58:50function copy the entire function block
  6518. 4:58:53and paste it right here where it's being
  6519. 4:58:56used like
  6520. 4:58:58this and then you can remove this
  6521. 4:59:01original function because now we're just
  6522. 4:59:03using it automatically within stripe and
  6523. 4:59:06a pretty cool thing is now that it is
  6524. 4:59:08within the intent payment sheet it
  6525. 4:59:10actually knows everything about the
  6526. 4:59:12payment method intent creation call back
  6527. 4:59:15as it infers it from the types above
  6528. 4:59:18that's cool so with that in mind our
  6529. 4:59:20initialized payment sheet is finally
  6530. 4:59:23done with the confirm Handler the return
  6531. 4:59:25URL everything the whole deal and it
  6532. 4:59:29took a bit more time and that's because
  6533. 4:59:31at the same time we were setting up our
  6534. 4:59:33own code functionality such as getting
  6535. 4:59:35the Riders the drivers the ride creation
  6536. 4:59:38and so much more
  6537. 4:59:40but now all of that should be done and
  6538. 4:59:43before we go ahead and test it out just
  6539. 4:59:45bear with me there is one more thing we
  6540. 4:59:47have to do and that is create a success
  6541. 4:59:50model okay remember we just have this
  6542. 4:59:54one unused variable just a single one I
  6543. 4:59:57can delete these ones just so we don't
  6544. 4:59:59have warnings but there's just a single
  6545. 5:00:01unused variable called success we
  6546. 5:00:04wouldn't want to leave that success to
  6547. 5:00:06hang there on its own right so we can
  6548. 5:00:08use it within the mold mod if we're
  6549. 5:00:11successful let's reward our great
  6550. 5:00:14work by creating a react native
  6551. 5:00:18modal and say is visible only if success
  6552. 5:00:24how
  6553. 5:00:25convenient on backdrop press so once we
  6554. 5:00:29exit out of it on backdrop press so once
  6555. 5:00:33we click outside of it we simply want to
  6556. 5:00:36set the success to false so set success
  6557. 5:00:41to false which will hide the model and
  6558. 5:00:44then we can go on with our day and book
  6559. 5:00:46some additional rides or track our
  6560. 5:00:48existing ride so what are we going to
  6561. 5:00:50show within this react native model it
  6562. 5:00:53can be a
  6563. 5:00:54view with a class name equal to flex
  6564. 5:01:00flex-all items Das Center justify Dash
  6565. 5:01:04center background of white padding of
  6566. 5:01:07seven and rounded Das to to excel within
  6567. 5:01:11it we can render a check image so let's
  6568. 5:01:13get the image from react
  6569. 5:01:16native with a source equal to
  6570. 5:01:20images.
  6571. 5:01:22check and a class name of w of
  6572. 5:01:2728 h of 28 and a margin top of five now
  6573. 5:01:31how can we show this success model right
  6574. 5:01:34here well we can show it by turning the
  6575. 5:01:37success to True by default
  6576. 5:01:40just for the time being and closing this
  6577. 5:01:43payment sheet model and going all the
  6578. 5:01:45way back to somewhere
  6579. 5:01:48else so let's do just that and I think
  6580. 5:01:51this is our model but something seems to
  6581. 5:01:53be breaking at the moment oh maybe
  6582. 5:01:56because we forgot to import the view
  6583. 5:01:57from react native once we bring it back
  6584. 5:02:00we'll have to one more time test it out
  6585. 5:02:03oh there we go you can see this even on
  6586. 5:02:05the home screen we can see the last path
  6587. 5:02:07that we drawn out this would be a huge
  6588. 5:02:10path from California all the way to
  6589. 5:02:13Tennessee I recently saw a YouTube video
  6590. 5:02:16where a guy ordered the longest possible
  6591. 5:02:19Uber ride it was panning across multiple
  6592. 5:02:22European countries I think pretty cool
  6593. 5:02:25so let's go over and select a new
  6594. 5:02:28location maybe we want to go to New
  6595. 5:02:32York and I'll select a driver and a ride
  6596. 5:02:37and there we go now we can see this
  6597. 5:02:39small success ESS thing below the image
  6598. 5:02:42let's render a piece of text and make
  6599. 5:02:44sure to import it from react native it
  6600. 5:02:47can say something like booking placed
  6601. 5:02:50successfully or maybe something simpler
  6602. 5:02:52like ride booked we can give it a class
  6603. 5:02:55name of text- 2XL text- Center font D
  6604. 5:03:02Jakarta bold with a margin top of five
  6605. 5:03:05to divide it a bit from the Icon below
  6606. 5:03:07it we can render another piece of text
  6607. 5:03:11that will have a class
  6608. 5:03:13name equal to text-
  6609. 5:03:16MD text- General
  6610. 5:03:19D200 font Das Jakarta medium text-
  6611. 5:03:25Center and margin top of three and it
  6612. 5:03:28can say something like thank you for
  6613. 5:03:31your booking your reservation has been
  6614. 5:03:35placed please proceed with your trip
  6615. 5:03:40there we go that's looking nice and
  6616. 5:03:43below it we can render a custom button
  6617. 5:03:46this button will have a title of back
  6618. 5:03:49home and on press want to have a call
  6619. 5:03:52back
  6620. 5:03:53function that sets the success to false
  6621. 5:03:57once
  6622. 5:03:58again as well as uses the router. push
  6623. 5:04:02okay so I'm going to put this in
  6624. 5:04:04multiple lines so that after we set the
  6625. 5:04:06success we can also use the router
  6626. 5:04:10from Expo router. push and push to slash
  6627. 5:04:14root SL tabs
  6628. 5:04:18slome we haven't been there in quite
  6629. 5:04:21some time there we go and we want to
  6630. 5:04:23style it a bit by giving it a class name
  6631. 5:04:26equal to margin top of
  6632. 5:04:28five
  6633. 5:04:30beautiful what do you say that we
  6634. 5:04:32manually turn the success back over to
  6635. 5:04:35false and try to book an actual ride for
  6636. 5:04:38the first time in this entire
  6637. 5:04:42course let's do it I'll click confirm
  6638. 5:04:45ride from San Francisco to New York for
  6639. 5:04:49$11,200 and 42 hours in pickup time and
  6640. 5:04:54I'll click confirm ride there's one
  6641. 5:04:56mistake that I can notice here and that
  6642. 5:04:58is that the stripe button still says 10
  6643. 5:05:01bucks you definitely wouldn't want to
  6644. 5:05:02make this mistake in your relab because
  6645. 5:05:05people would soon enough make use of it
  6646. 5:05:08so we have to figure out where we're
  6647. 5:05:10passing the amount to stripe and it is
  6648. 5:05:13right here in the intent configuration
  6649. 5:05:15so that is the last part that is
  6650. 5:05:17remaining for us to do we can change the
  6651. 5:05:20merchant display name to something like
  6652. 5:05:24ride
  6653. 5:05:26Incorporated the amount will be set to
  6654. 5:05:29parse
  6655. 5:05:30int amount times 100 to get to cents and
  6656. 5:05:35the currency will be USD if I save this
  6657. 5:05:39and click close the sheet and reopen
  6658. 5:05:41it you can see that now the price is
  6659. 5:05:44correct so you can enter your card
  6660. 5:05:47number for stripe test mode it is
  6661. 5:05:51424242 and you can keep typing that
  6662. 5:05:53until the end you can do the same thing
  6663. 5:05:56for the months and
  6664. 5:05:58years and the CVC but make sure that
  6665. 5:06:01they're valid months and years and you
  6666. 5:06:04can now click pay don't worry no money
  6667. 5:06:06will be taken from your accounts you
  6668. 5:06:08haven't connected your own details with
  6669. 5:06:10this this is just test info so I'll
  6670. 5:06:13click
  6671. 5:06:14pay it says
  6672. 5:06:17processing and it seems to have went
  6673. 5:06:19through ride booked back
  6674. 5:06:22home this is amazing we can track her
  6675. 5:06:25location and even though these recent
  6676. 5:06:28rides are fake now our next step will be
  6677. 5:06:30to add a real recent ride right here so
  6678. 5:06:33we can check it out and see how that is
  6679. 5:06:35going great this means that the main
  6680. 5:06:38primary flow of our Uber application has
  6681. 5:06:42been completed a user can create their
  6682. 5:06:44account search for a location where they
  6683. 5:06:46want to go choose their driver book a
  6684. 5:06:49ride and make a payment beautiful work
  6685. 5:06:54and if you came to this part of the
  6686. 5:06:55video leave a comment down below and
  6687. 5:06:58tell me I'm here I completed the main
  6688. 5:07:01flow not many will get there so great
  6689. 5:07:04job now that we have that out of the way
  6690. 5:07:06as I said we can focus on replacing the
  6691. 5:07:09mock recent rides with the real ones by
  6692. 5:07:11fetching them from the database and then
  6693. 5:07:13after that we'll quickly fix the Google
  6694. 5:07:15o off and then we can focus on the rest
  6695. 5:07:18of these Pages once again great work I'm
  6696. 5:07:21super proud of you to remove our mock
  6697. 5:07:24rides and instead of them use the real
  6698. 5:07:26ones we can head over to our homepage we
  6699. 5:07:29can scroll a bit up and right here you
  6700. 5:07:32can see that we have fake recent rides
  6701. 5:07:35instead of those what do you say that we
  6702. 5:07:36fetch the real ones but to make that
  6703. 5:07:39happen we have to tap into this ride ID
  6704. 5:07:42functionality which is going to fetch
  6705. 5:07:44the specific rides for our own user
  6706. 5:07:47account and bring us back all the
  6707. 5:07:50details so let's go to the home and
  6708. 5:07:53let's say const data which we can rename
  6709. 5:07:56to recent rides we can also get the
  6710. 5:07:59loading from there and that's going to
  6711. 5:08:01be equal to use fetch to the URL SL API
  6712. 5:08:06inside of parenthesis forward SL rde
  6713. 5:08:09forward slash and then we have to do a
  6714. 5:08:11dynamic template string of user question
  6715. 5:08:15mark. ID first let's turn this string
  6716. 5:08:18into a template string there we go and
  6717. 5:08:20now let's actually get the user from the
  6718. 5:08:22use user and we can remove this fake
  6719. 5:08:24loading at the top now it says no recent
  6720. 5:08:28rides as you can see right here and I
  6721. 5:08:30think I know why we created the tables
  6722. 5:08:32for drivers and users but before
  6723. 5:08:34creating a ride we didn't create a table
  6724. 5:08:37for the rides so right here under
  6725. 5:08:39Snippets you have the create rides table
  6726. 5:08:42SQL query which we can execute in our
  6727. 5:08:45SQL editor and
  6728. 5:08:48run there we go it successfully created
  6729. 5:08:51the table and since the table wasn't
  6730. 5:08:53created before right now it doesn't
  6731. 5:08:55exist so let's go through the entire
  6732. 5:08:57application flow one more time and see
  6733. 5:08:59if the ride will get created okay I came
  6734. 5:09:02to the end screen in the flow I can
  6735. 5:09:04enter my credit card details and click
  6736. 5:09:07pay it's processing
  6737. 5:09:10it's successful and if I go back home we
  6738. 5:09:13can now see one recent rides from San
  6739. 5:09:15Francisco to Scranton and it even gives
  6740. 5:09:18us a little screenshot of the location
  6741. 5:09:20where we're going to great so now we can
  6742. 5:09:23remove this recent rise from here as
  6743. 5:09:25we're no longer using them and now all
  6744. 5:09:28of the data in our application is real
  6745. 5:09:31what we can do next is press the log out
  6746. 5:09:33button at the top right we haven't seen
  6747. 5:09:34our onboarding screens in quite some
  6748. 5:09:36time and I'm pressing it but it doesn't
  6749. 5:09:39seem to be working let's see what's up
  6750. 5:09:41with that button that is in a place
  6751. 5:09:44where it says welcome and then we have
  6752. 5:09:47the name so that's going to be right
  6753. 5:09:49here in a stack screen under home and
  6754. 5:09:52here we're handling the sign out
  6755. 5:09:54functionality where you can see that
  6756. 5:09:57it's completely empty so we have to
  6757. 5:09:59implement it the only thing that it'll
  6758. 5:10:01do is it'll call the sign out function
  6759. 5:10:05which is going to come from use o from
  6760. 5:10:07clerk so we can say const sign out is
  6761. 5:10:11equal to use o coming from Clerk and
  6762. 5:10:15then we can call it and we can use the
  6763. 5:10:18router. replace to go to for slash off
  6764. 5:10:22in parentheses slash sign in now let's
  6765. 5:10:26try to click the button one more time
  6766. 5:10:29and this time we are redirected to the
  6767. 5:10:31sign-in page now if I click login with
  6768. 5:10:34Google nothing will happen same thing if
  6769. 5:10:36we go to sign up it's not doing anything
  6770. 5:10:39that's because we have implemented only
  6771. 5:10:41the email authentication and now we have
  6772. 5:10:43to do oath clerk makes that super simple
  6773. 5:10:47with their documentation page on
  6774. 5:10:48building a custom flow for
  6775. 5:10:50authenticating with o o connections so
  6776. 5:10:53you can just search the docs for this
  6777. 5:10:55page it's under custom flows allo
  6778. 5:10:57connections and then you need to switch
  6779. 5:10:59it from nextjs to Expo we can skip this
  6780. 5:11:03Expo linking part skip the browser part
  6781. 5:11:05as well and the only thing we need is
  6782. 5:11:08this start oath flow with the O strategy
  6783. 5:11:12and then the onpress functionality this
  6784. 5:11:14part right here so let's copy that go
  6785. 5:11:17back to the code to our o component
  6786. 5:11:21where we have our custom button and we
  6787. 5:11:23can paste what we just copied I'll paste
  6788. 5:11:25it over this
  6789. 5:11:27function I'll rename the onpress to
  6790. 5:11:30handle
  6791. 5:11:32Google sign
  6792. 5:11:34in and I will override our on press on
  6793. 5:11:37the button click to handle Google Google
  6794. 5:11:39sign in and we can just slightly modify
  6795. 5:11:41this first of all let's import use oo
  6796. 5:11:45from clerk clerk Expo with a strategy of
  6797. 5:11:48Google
  6798. 5:11:49oo next import use call back from react
  6799. 5:11:54after that we can start this o flow and
  6800. 5:11:57we can slightly modify this part right
  6801. 5:11:59here so I'll close it just so we have a
  6802. 5:12:01clean slate and I'll say con result is
  6803. 5:12:05equal to a weight so we have to make
  6804. 5:12:08this function a sync
  6805. 5:12:10and Google oo like this to which we then
  6806. 5:12:15pass the start oo flow function but the
  6807. 5:12:19question is where is this Google ooth
  6808. 5:12:21coming from this Google ooth will be a
  6809. 5:12:24utility function which we can create
  6810. 5:12:26it'll be under lib o and then here we
  6811. 5:12:30have the token cache but now we'll
  6812. 5:12:32create an additional function export
  6813. 5:12:35const Google o o which is going to be an
  6814. 5:12:40async function that accepts the start oo
  6815. 5:12:44flow of a type any for now and we can
  6816. 5:12:48open up a new try and catch Block in the
  6817. 5:12:51catch we of course have the error and in
  6818. 5:12:53the try we'll copy this part about
  6819. 5:12:56linking so here we want to extract this
  6820. 5:12:58linking part and this if and else that
  6821. 5:13:00we removed previously and we can paste
  6822. 5:13:02it right here that's going to check
  6823. 5:13:04whether we have a created session ID and
  6824. 5:13:07whether we can sign up up and we can
  6825. 5:13:10also make a user
  6826. 5:13:12active for that we do need the linking
  6827. 5:13:15so remember what they say right here we
  6828. 5:13:17need to install Expo linking this will
  6829. 5:13:19allow us to link our application to the
  6830. 5:13:22Google signin model that pops up and
  6831. 5:13:24then it allows users to go back to your
  6832. 5:13:25own application so let's run mpm install
  6833. 5:13:29Expo linking and let's make sure to
  6834. 5:13:31import it at the top by saying import
  6835. 5:13:33everything as linking from Expo linking
  6836. 5:13:38and then we're creating creting a new
  6837. 5:13:39URL which we want to redirect to it is
  6838. 5:13:43SL root in
  6839. 5:13:45parentheses SL tabs slome next we're
  6840. 5:13:50checking if it's a signup or a sign in
  6841. 5:13:54rather has the user created an account
  6842. 5:13:56before if they have created an account
  6843. 5:13:59then we're doing sign in else we're
  6844. 5:14:01doing sign up so everything within this
  6845. 5:14:04if will be called both on the sign in
  6846. 5:14:07and the sign up so let me show you what
  6847. 5:14:10we can do we can say if set active
  6848. 5:14:13exists then we can await set active and
  6849. 5:14:17this is basically adding the user
  6850. 5:14:19session but now only if it's sign up so
  6851. 5:14:23if sign up. created user ID then we want
  6852. 5:14:29to also create a database user so we can
  6853. 5:14:31say await fetch
  6854. 5:14:34API with a URL of forward slash in
  6855. 5:14:38parentheses API SL
  6856. 5:14:41user the method will be set to post and
  6857. 5:14:45the body will be json. stringify where
  6858. 5:14:48we can pass a name which is a template
  6859. 5:14:50string of sign up. first name as well as
  6860. 5:14:56sign up. last name let's fix this typo
  6861. 5:15:00we can also pass the email equal to sign
  6862. 5:15:02up. email and we can pass the clerk ID
  6863. 5:15:05equal to signup do created user us ID
  6864. 5:15:10and this creates a user in the database
  6865. 5:15:12we want to go below this two sets of
  6866. 5:15:15double parentheses and Below one more to
  6867. 5:15:18return an object that's going to say
  6868. 5:15:20success is true we can also pass a code
  6869. 5:15:24of
  6870. 5:15:25success and pass a message of you have
  6871. 5:15:29successfully
  6872. 5:15:31authenticated outside of all of these
  6873. 5:15:34braces we can return success to false
  6874. 5:15:38because if we reach this point something
  6875. 5:15:40is not good would a message equal to an
  6876. 5:15:44error occurred finally in the catch
  6877. 5:15:47consol log the error and return success
  6878. 5:15:51false and a message that an error has
  6879. 5:15:54occurred so I can paste this and maybe
  6880. 5:15:57this time we can just do
  6881. 5:16:00error question mark. errors zero
  6882. 5:16:04question mark. long
  6883. 5:16:06message this will give us the full error
  6884. 5:16:09information and let's make the error of
  6885. 5:16:12a type any right
  6886. 5:16:14here great so now we are authenticating
  6887. 5:16:16users using Google oo and we're creating
  6888. 5:16:19an account when they sign up so let's
  6889. 5:16:21import this Google oo from lib o and
  6890. 5:16:24we're getting the result if the result.
  6891. 5:16:27code is triple equal to session unor
  6892. 5:16:30exists then we can alert coming from
  6893. 5:16:34react native. alert success but add a
  6894. 5:16:39message of session exists
  6895. 5:16:43redirecting to homepage and of course
  6896. 5:16:46we'll have to do a router. push slash in
  6897. 5:16:50parentheses root slash in parentheses
  6898. 5:16:53tabs slome outside of that if we can
  6899. 5:16:57check if result. success if that is the
  6900. 5:17:01case we can say success else we can say
  6901. 5:17:04error and that can be within the alert
  6902. 5:17:06so we don't actually need an if so
  6903. 5:17:08alert. alert and then we just show that
  6904. 5:17:11title and as the second parameter we
  6905. 5:17:13render the result. message if we catch
  6906. 5:17:18something then we can just do a console.
  6907. 5:17:20error
  6908. 5:17:22great I think this is it we already have
  6909. 5:17:25the UI now we implemented the logic and
  6910. 5:17:27we can give it a shot let's go through
  6911. 5:17:29the
  6912. 5:17:30onboarding and let's click login with
  6913. 5:17:33Google I noticed a typo there that was
  6914. 5:17:36supposed to be with right here
  6915. 5:17:39there we
  6916. 5:17:40go and let me click the
  6917. 5:17:44button Expo wants to use google.com to
  6918. 5:17:46sign in yes let's allow it I chose my
  6919. 5:17:51account and I'll click continue and it
  6920. 5:17:54didn't redirect I think I know why I
  6921. 5:17:57misspelled exists right here so session
  6922. 5:18:00exists okay I can fix this typon success
  6923. 5:18:04as well and if we go back to off in the
  6924. 5:18:08return right here so this is at the
  6925. 5:18:10bottom of our Google all OD function we
  6926. 5:18:13also need to pass the code and the code
  6927. 5:18:16will be success if you're successful or
  6928. 5:18:19here at the bottom in the catch the code
  6929. 5:18:21will be equal to error. code now this
  6930. 5:18:26code will sometimes correspond to
  6931. 5:18:30session uncore exists even though it's
  6932. 5:18:32not really an error I mean technically
  6933. 5:18:34it is because we're trying to sign up to
  6934. 5:18:37an account that exists but still in that
  6935. 5:18:39case we're going to say success
  6936. 5:18:41redirecting to homepage and one more
  6937. 5:18:44thing I noticed here in oth instead of
  6938. 5:18:46saying email address I just used email
  6939. 5:18:49right here which is wrong so this also
  6940. 5:18:51could have broken the application so if
  6941. 5:18:53we fix that we can give it one more shot
  6942. 5:18:56I'll click login with Google continue
  6943. 5:18:58next I'll say continue one more
  6944. 5:19:02time and we still didn't get redirected
  6945. 5:19:05but if I open up the terminal I can see
  6946. 5:19:07a conso log that I added before and if I
  6947. 5:19:10press R for reload you can see that we
  6948. 5:19:12are within our application and now it
  6949. 5:19:14says welcome Adrien which means that
  6950. 5:19:16we're successfully logged in with our
  6951. 5:19:18real account and we have one recent ride
  6952. 5:19:21beautiful I'm still not sure why this oo
  6953. 5:19:24is not redirecting this is definitely
  6954. 5:19:26something we need to come back to later
  6955. 5:19:28on but for now let's quickly implement
  6956. 5:19:30the all rides screen as it's going to be
  6957. 5:19:33super simple it's just going to be a
  6958. 5:19:35collection of recent rides and we're
  6959. 5:19:38showing that already on the home so it's
  6960. 5:19:40going to be super simple to show it here
  6961. 5:19:41as well we can head over to our rides
  6962. 5:19:44page which is right here Under tabs and
  6963. 5:19:47within it we can render a flat list
  6964. 5:19:51similar to the one that we have in the
  6965. 5:19:52home so let's quickly go to the home
  6966. 5:19:55let's find our flat list and let's copy
  6967. 5:19:59the entire thing just until the end of
  6968. 5:20:01the flat list and we can put it right
  6969. 5:20:04here within the safe area view make sure
  6970. 5:20:06to import flat list right here from from
  6971. 5:20:08react native and save it of course
  6972. 5:20:11there's going to be some fixes that we
  6973. 5:20:12have to do to make it work for example
  6974. 5:20:14we have to also fetch the recent rides
  6975. 5:20:17same as we're doing in the home so right
  6976. 5:20:19here at the top here we're fetching the
  6977. 5:20:21recent rides and here we're fetching the
  6978. 5:20:23user so we can copy those two things and
  6979. 5:20:26add them to the rides use user is coming
  6980. 5:20:29from clerk Expo and this is pretty cool
  6981. 5:20:32when I copy things from the other file
  6982. 5:20:34webstorm actually copies the Imports for
  6983. 5:20:36me which is amazing right now if we go
  6984. 5:20:39to all rides it kind of breaks and
  6985. 5:20:41that's because we don't need all this
  6986. 5:20:43data here so let's clean it up instead
  6987. 5:20:46of slicing the recent rides we can show
  6988. 5:20:48all the recent rides next under list
  6989. 5:20:51empty component we can more or less
  6990. 5:20:53leave it the same and under the header
  6991. 5:20:55it's going to be much simpler than what
  6992. 5:20:57we have here we don't have to have the
  6993. 5:20:58sign out button nor the Google text
  6994. 5:21:01input so we can basically remove
  6995. 5:21:03everything from here and just keep one
  6996. 5:21:06single piece of text that's going to say
  6997. 5:21:09all rides and we can give it a class
  6998. 5:21:11name equal to text- 2XL font D jaarda
  6999. 5:21:16bold and we can save it and right here
  7000. 5:21:19before the use fetch what we're
  7001. 5:21:20expecting to get back is an array of
  7002. 5:21:23rides which are coming from types so we
  7003. 5:21:26can Define the ride right here that way
  7004. 5:21:28flatlist knows what it is accepting and
  7005. 5:21:31believe it or not since we're reusing a
  7006. 5:21:33lot of the components we don't need
  7007. 5:21:35these Imports too and it was super simp
  7008. 5:21:38simple to just recreate this all rides
  7009. 5:21:41list right now it is just one but once
  7010. 5:21:44we book some more they'll all be shown
  7011. 5:21:46here we can also add a margin y of five
  7012. 5:21:50right here to divide it a bit from top
  7013. 5:21:52and bottom beautiful and I couldn't
  7014. 5:21:54proceed further without fixing this
  7015. 5:21:56redirect on the Google button so while I
  7016. 5:21:59took a bit of a break from recording I
  7017. 5:22:01went ahead and tested it out a bit
  7018. 5:22:03further and I think I've came to a
  7019. 5:22:06conclusion first of all we can go to the
  7020. 5:22:08Google text input and for some reason
  7021. 5:22:12Android devices have a problem when a
  7022. 5:22:14font weight is typed in as a number so I
  7023. 5:22:18went ahead and just wrapped it in a
  7024. 5:22:20string not a big deal but just something
  7025. 5:22:22that needed to be done for the Android
  7026. 5:22:24devices this won't fix the redirect on
  7027. 5:22:27its own but now we can head over to o o
  7028. 5:22:31right here and so far we've been only
  7029. 5:22:34redirecting if a session already exists
  7030. 5:22:37but here I can add an or and say if
  7031. 5:22:40result. code is triple equal to success
  7032. 5:22:44in that case we also want to redirect we
  7033. 5:22:48don't need to show the success message
  7034. 5:22:51and we can also remove this bottom alert
  7035. 5:22:53right here I thought we didn't need this
  7036. 5:22:55because Google in the O should do the
  7037. 5:22:58actual redirection here to the home but
  7038. 5:23:01for some reason it wasn't doing it so
  7039. 5:23:03maybe we need to do it manually like
  7040. 5:23:05this which is okay also don't forget
  7041. 5:23:08that in the O this right here has to be
  7042. 5:23:10email address not just email and while I
  7043. 5:23:14was further testing it I experienced
  7044. 5:23:16some additional issues such as this
  7045. 5:23:18error saying too many files open and
  7046. 5:23:21then my Expo server would crash
  7047. 5:23:24basically there is a solution and it is
  7048. 5:23:27to run Brew install Watchman on Mac OS
  7049. 5:23:31at least it fixes it for Mac very weird
  7050. 5:23:34issue but it worked for me another even
  7051. 5:23:36weirder issue is is that I got another
  7052. 5:23:39error saying use process and then work
  7053. 5:23:42with asnc plugins for some reason and a
  7054. 5:23:45solution to that is to downgrade
  7055. 5:23:48Tailwind to
  7056. 5:23:513.3.2 instead of carrot
  7057. 5:23:553.3.2 so if you're having some issues
  7058. 5:23:57you can go to package.json
  7059. 5:23:59and you can find tailin CSS remove this
  7060. 5:24:03carrot from here then you'll have to
  7061. 5:24:08clear the Expo folder clear the node
  7062. 5:24:11modules and delete it and also delete
  7063. 5:24:14the package lock Json rerun mpmi and
  7064. 5:24:18then start the Expo server again that
  7065. 5:24:20should fix it there's many of these very
  7066. 5:24:22small but weird issues but thankfully
  7067. 5:24:25I've managed to find solutions to them
  7068. 5:24:26what you can do next just to make sure
  7069. 5:24:28we're in the same page is delete all
  7070. 5:24:30clerk
  7071. 5:24:33users and you can delete all neon users
  7072. 5:24:36as well
  7073. 5:24:39if you have any rides delete those two
  7074. 5:24:41just so we have a clean slate once you
  7075. 5:24:43do that start the application again and
  7076. 5:24:46while we're here we can try to find a
  7077. 5:24:47way to suppress this clerk warning at
  7078. 5:24:50the bottom since we know that everything
  7079. 5:24:52works I can quickly go into the main
  7080. 5:24:54layout that's the app layout right here
  7081. 5:24:57and right at the top we can write
  7082. 5:24:59something like this import logbox from
  7083. 5:25:03react native and then we can say logbox
  7084. 5:25:07do ignore log logs patterns warning and
  7085. 5:25:10then that cleans it up so now we have a
  7086. 5:25:14nice clean onboarding and we can get
  7087. 5:25:16started I'll log in with Google I'll
  7088. 5:25:19click continue and we got redirected
  7089. 5:25:22that is great I know we changed a lot of
  7090. 5:25:25things so if this didn't work for you
  7091. 5:25:27don't worry it it happens it is possible
  7092. 5:25:30feel free to reach out on Discord or
  7093. 5:25:33check out the description where we can
  7094. 5:25:35mention some of the most common issues
  7095. 5:25:37that people have experienced
  7096. 5:25:38and solutions to them if you cannot find
  7097. 5:25:41a frequently Asked question then
  7098. 5:25:42definitely feel free to ask on Discord
  7099. 5:25:45the link is down in the description what
  7100. 5:25:46I would highly recommend is also
  7101. 5:25:48comparing your files to the final files
  7102. 5:25:51in the GitHub repository it's possible
  7103. 5:25:53that you have a typo here or there or
  7104. 5:25:55that the route is misspelled or
  7105. 5:25:57something even though we have linters
  7106. 5:25:59and typescript and all the other great
  7107. 5:26:02things mistakes happen which is okay but
  7108. 5:26:04for me it works right now so let's give
  7109. 5:26:07it another shot by going over the entire
  7110. 5:26:09applications
  7111. 5:26:11process we can select a ride let's give
  7112. 5:26:14James an opportunity now there we go
  7113. 5:26:16this looks good we can confirm the ride
  7114. 5:26:20and I can make a payment I'll enter my
  7115. 5:26:23test
  7116. 5:26:25details and click
  7117. 5:26:28pay it's
  7118. 5:26:32processing we got a success and we can
  7119. 5:26:35go back home where we can see our recent
  7120. 5:26:38ride right this is working beautifully
  7121. 5:26:41for me if I reload I can still see the
  7122. 5:26:43clerk warning here so I think we can
  7123. 5:26:45quickly go back to layout and change
  7124. 5:26:48this from warning to clerk this way
  7125. 5:26:50Clerk's warnings will be suppressed and
  7126. 5:26:53make sure to remove the three dots as
  7127. 5:26:54well so now if we
  7128. 5:26:59reload you can see it is gone and we can
  7129. 5:27:01continue exploring our application by
  7130. 5:27:03going to the ride screen and we can see
  7131. 5:27:06our recent ride there's only one right
  7132. 5:27:07here which is amazing so we have the
  7133. 5:27:10home and we have tested the entire
  7134. 5:27:13procedure of the flow of creating the
  7135. 5:27:15rides and now we can also super simply
  7136. 5:27:19just log in press
  7137. 5:27:21continue and we are in now as an
  7138. 5:27:25exercise I have left two different
  7139. 5:27:27screens for you one is the profile it
  7140. 5:27:30looks something like this you have a
  7141. 5:27:32profile photo your name email maybe even
  7142. 5:27:35an email status but it is not necessary
  7143. 5:27:38and then maybe even a phone number it is
  7144. 5:27:40optional you should be able to reuse the
  7145. 5:27:42input that we have created so far to
  7146. 5:27:44quickly spin up this screen and these
  7147. 5:27:46fields don't have to be editable so they
  7148. 5:27:49can be read only if you want to
  7149. 5:27:51implement it on your own feel free to
  7150. 5:27:53pause this video and give it a shot the
  7151. 5:27:55code for that will go inside of the
  7152. 5:27:57profile page and you can use the input
  7153. 5:27:59field component we have created so far
  7154. 5:28:02so pause this video if you want to
  7155. 5:28:03implement it on your own or if not if
  7156. 5:28:06you really want to be done with this
  7157. 5:28:07great applic
  7158. 5:28:08since the primary flow is now done I'll
  7159. 5:28:10provide you with a code it's going to be
  7160. 5:28:12in the GitHub read me where all of the
  7161. 5:28:14other code pieces have been and you can
  7162. 5:28:16simply paste it right here it'll look
  7163. 5:28:18something like this you get your very
  7164. 5:28:20simple image which we can pull from
  7165. 5:28:23clerk especially if you logged in using
  7166. 5:28:25Google we get your first name and last
  7167. 5:28:27name which we show in uneditable input
  7168. 5:28:30fields and then we can show the email
  7169. 5:28:33and the phone this is it very simple now
  7170. 5:28:37when it comes to messaging this is
  7171. 5:28:39something that I left completely
  7172. 5:28:41open-ended in this video I'll just
  7173. 5:28:43provide you with this illustration which
  7174. 5:28:45is just going to say no messages yet so
  7175. 5:28:47this project will not include messaging
  7176. 5:28:50but if you really want to bring this
  7177. 5:28:52project to another level you can go
  7178. 5:28:54ahead and Implement an entire messaging
  7179. 5:28:56system use some kind of a package or a
  7180. 5:28:59library or a service that will allow you
  7181. 5:29:01to do that in a simpler way if you do
  7182. 5:29:03decide to implement it well we are on
  7183. 5:29:06Instagram so you can simply tag us and
  7184. 5:29:09I'll gladly reshare your work you can
  7185. 5:29:11also tag me on Twitter where we're
  7186. 5:29:13sharing a lot of the great work that you
  7187. 5:29:15guys do for example I shared one 14
  7188. 5:29:18hours ago by mahad and we are on
  7189. 5:29:20LinkedIn too so if you create something
  7190. 5:29:22cool I'll gladly share your work if not
  7191. 5:29:25no worries I'll still provide you with a
  7192. 5:29:27way to finish this great project off so
  7193. 5:29:29you can share it with your friends and
  7194. 5:29:31potential employers you can do that by
  7195. 5:29:33going to the chat component and then
  7196. 5:29:35copy and paste the chat component from
  7197. 5:29:38the GitHub read me and paste it here as
  7198. 5:29:40you can notice it is a very simple safe
  7199. 5:29:43area view where we have an image and
  7200. 5:29:45some text so if we head over to that
  7201. 5:29:47screen this is how it looks like with
  7202. 5:29:50that in mind even though it seems like
  7203. 5:29:52we only have a couple of screens
  7204. 5:29:54actually there's so many more don't
  7205. 5:29:56forget about our great on boarding that
  7206. 5:29:58we saw at the start and that you can get
  7207. 5:30:00to if you reload your application this
  7208. 5:30:03looks great next we have a beautiful
  7209. 5:30:07Authentication login and sign up forms
  7210. 5:30:10where we can easily log into our account
  7211. 5:30:12we have a super responsive map where we
  7212. 5:30:15can see everything on the screen as well
  7213. 5:30:17as the recent rides and what do you say
  7214. 5:30:19that we give it one more shot let's go
  7215. 5:30:22to Pao Alto visit Steve Jobs we can
  7216. 5:30:27choose our writer there we
  7217. 5:30:29go this is looking great we can verify
  7218. 5:30:32our ride and click confirm and for one
  7219. 5:30:36last time we can pay just make sure that
  7220. 5:30:38our entire app is working seamlessly and
  7221. 5:30:42it's successful we can go back home to
  7222. 5:30:44see it in real time or go to all rides
  7223. 5:30:47where we can also see this new ride it
  7224. 5:30:49is a very comprehensive app with a lot
  7225. 5:30:51of moving pieces so I'm amazed that you
  7226. 5:30:54came to the end of this video if you're
  7227. 5:30:56still here definitely leave a comment
  7228. 5:30:58down below and tell me hey I finished it
  7229. 5:31:02I could have turned this into a paid
  7230. 5:31:03course but I decided to release it for
  7231. 5:31:06free here on YouTube Just so you can
  7232. 5:31:08learn about webstorm which is the new
  7233. 5:31:10IDE I'll be using in future videos too
  7234. 5:31:13clerk so you can Implement
  7235. 5:31:14authentication very easily and neon
  7236. 5:31:17which is my database of choice for all
  7237. 5:31:19future applications and now you know how
  7238. 5:31:21to use all of these great Dev tools to
  7239. 5:31:24implement apps such as the mighty Uber
  7240. 5:31:26clone and if you haven't already
  7241. 5:31:29definitely download the ultimate react
  7242. 5:31:31native guide just so you have a written
  7243. 5:31:33guide by your side when you continue
  7244. 5:31:36your react native Journey p P this video
  7245. 5:31:38and here on the first page I tell you a
  7246. 5:31:41bit more about something great that's
  7247. 5:31:43coming I have started to develop the
  7248. 5:31:45ultimate react native course if you
  7249. 5:31:47liked what we have done in this video
  7250. 5:31:49and you obviously have since you're at
  7251. 5:31:51the end of this video then you're going
  7252. 5:31:53to love what's coming in this Pro course
  7253. 5:31:55if you download the guide I'll keep you
  7254. 5:31:57updated with that in mind thank you so
  7255. 5:31:59much for watching and coming to the end
  7256. 5:32:01of this video great job on building the
  7257. 5:32:03Uber clone and I'll see you in the next
  7258. 5:32:06one have a wonderful day

About this transcript

This page contains the full transcript of Build a Full Stack React Native App with Payments | PostgreSQL, TypeScript, Stripe, Tailwind by JavaScript Mastery, generated from the public captions YouTube serves with the video. The transcript has 52,551 words across 7,258 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.