@@ -1248,12 +1248,11 @@ <h3 id="setup-1">Setup 1</h3>
1248
1248
< p > ✏️ Terminate the existing dev server and start it again:</ p >
1249
1249
< pre > < code class ="language-bash "> npm run start
1250
1250
</ code > </ pre >
1251
- < p > ✏️ Create < strong > src/components/Tabs/Tabs.tsx</ strong > and update it to be:</ p >
1252
- < pre > < code class ="language-tsx "> import { Pressable, StyleSheet } from "react-native"
1253
-
1254
- import Box from "../../design/Box"
1255
- import { Theme, useTheme } from "../../design/theme"
1256
- import Typography from "../../design/Typography"
1251
+ < p > ✏️ Create < strong > src/shared/components/Tabs/Tabs.tsx</ strong > and update it to be:</ p >
1252
+ < pre > < code class ="language-tsx "> import Box from "@shared/design/Box"
1253
+ import { Theme, useTheme } from "@shared/design/theme"
1254
+ import Typography from "@shared/design/Typography"
1255
+ import { Pressable, StyleSheet } from "react-native"
1257
1256
1258
1257
export interface TabsProps {
1259
1258
options: Array<{
@@ -1325,19 +1324,18 @@ <h3 id="setup-1">Setup 1</h3>
1325
1324
1326
1325
</ code > </ pre >
1327
1326
< div line-highlight ='16, only '> </ div >
1328
- < p > ✏️ Create < strong > src/components/Tabs/index.ts</ strong > and update it to be:</ p >
1327
+ < p > ✏️ Create < strong > src/shared/ components/Tabs/index.ts</ strong > and update it to be:</ p >
1329
1328
< pre > < code class ="language-ts "> export { default } from "./Tabs"
1330
1329
export * from "./Tabs"
1331
1330
1332
1331
</ code > </ pre >
1333
1332
< p > ✏️ Create < strong > src/screens/RestaurantList/components/List/List.tsx</ strong > and update it to be:</ p >
1334
1333
< pre > < code class ="language-tsx "> import { useNavigation } from "@react-navigation/native"
1334
+ import Button from "@shared/design/Button"
1335
+ import Screen from "@shared/design/Screen"
1336
+ import { Restaurant } from "@shared/services/pmo/restaurant"
1335
1337
import { FlatList } from "react-native"
1336
1338
1337
- import Button from "../../../../design/Button"
1338
- import Screen from "../../../../design/Screen"
1339
- import { Restaurant } from "../../../../services/pmo/restaurant"
1340
-
1341
1339
export interface ListProps {
1342
1340
restaurants: Restaurant[]
1343
1341
}
@@ -1376,9 +1374,8 @@ <h3 id="setup-1">Setup 1</h3>
1376
1374
1377
1375
</ code > </ pre >
1378
1376
< p > ✏️ Create < strong > src/screens/RestaurantList/components/Map/Map.tsx</ strong > and update it to be:</ p >
1379
- < pre > < code class ="language-tsx "> import MapView, { PROVIDER_GOOGLE } from "react-native-maps"
1380
-
1381
- import { Restaurant } from "../../../../services/pmo/restaurant"
1377
+ < pre > < code class ="language-tsx "> import { Restaurant } from "@shared/services/pmo/restaurant"
1378
+ import MapView, { PROVIDER_GOOGLE } from "react-native-maps"
1382
1379
1383
1380
export interface MapProps {
1384
1381
restaurants: Restaurant[]
@@ -1399,15 +1396,15 @@ <h3 id="setup-1">Setup 1</h3>
1399
1396
</ code > </ pre >
1400
1397
< p > ✏️ Update < strong > src/screens/RestaurantList/RestaurantList.tsx</ strong > to be:</ p >
1401
1398
< pre > < code class ="language-tsx "> import { StackScreenProps } from "@react-navigation/stack"
1399
+ import Loading from "@shared/components/Loading"
1400
+ import Tabs from "@shared/components/Tabs"
1401
+ import Box from "@shared/design/Box"
1402
+ import Screen from "@shared/design/Screen"
1403
+ import Typography from "@shared/design/Typography"
1404
+ import { useRestaurants } from "@shared/services/pmo/restaurant"
1402
1405
import { useState } from "react"
1403
1406
1404
1407
import { RestaurantsStackParamList } from "../../App"
1405
- import Loading from "../../components/Loading"
1406
- import Tabs from "../../components/Tabs"
1407
- import Box from "../../design/Box"
1408
- import Screen from "../../design/Screen"
1409
- import Typography from "../../design/Typography"
1410
- import { useRestaurants } from "../../services/pmo/restaurant"
1411
1408
1412
1409
import List from "./components/List"
1413
1410
import Map from "./components/Map"
@@ -1462,7 +1459,7 @@ <h3 id="setup-1">Setup 1</h3>
1462
1459
export default RestaurantList
1463
1460
1464
1461
</ code > </ pre >
1465
- < div line-highlight ="2,6 ,12-13,26,44-51,54-58,only "> </ div >
1462
+ < div line-highlight ="3,8 ,12-13,26,44-51,54-58,only "> </ div >
1466
1463
< h3 id ="verify-1 "> Verify 1</ h3 >
1467
1464
< p > Navigate to the < code > Maps</ code > tab of the < code > RestaurantsList</ code > in your emulator and verify that the Map is rendering.</ p >
1468
1465
< p > < img alt ="Screenshot of how the application should look for the second solution. " src ="../static/img/react-native/18-maps/01-solution.png " style ="border: 4px solid black; border-radius: 25px; " height ="640 "/> </ p >
@@ -1478,9 +1475,8 @@ <h3 id="solution-1">Solution 1</h3>
1478
1475
< p > < details >
1479
1476
< summary > Click to see the solution</ summary > </ p >
1480
1477
< p > ✏️ Update < strong > src/screens/RestaurantList/components/Map/Map.tsx</ strong > to be:</ p >
1481
- < pre > < code class ="language-tsx "> import MapView, { PROVIDER_GOOGLE } from "react-native-maps"
1482
-
1483
- import { Restaurant } from "../../../../services/pmo/restaurant"
1478
+ < pre > < code class ="language-tsx "> import { Restaurant } from "@shared/services/pmo/restaurant"
1479
+ import MapView, { PROVIDER_GOOGLE } from "react-native-maps"
1484
1480
1485
1481
export interface MapProps {
1486
1482
restaurants: Restaurant[]
@@ -1504,7 +1500,7 @@ <h3 id="solution-1">Solution 1</h3>
1504
1500
export default Map
1505
1501
1506
1502
</ code > </ pre >
1507
- < div line-highlight ="10-21 , "> </ div >
1503
+ < div line-highlight ="9-20 , "> </ div >
1508
1504
< p > </ details > </ p >
1509
1505
< h2 id ="objective-2-add-restaurant-markers-with-tooltips-to-the-map "> Objective 2: Add restaurant markers with tooltips to the map</ h2 >
1510
1506
< p > Now that we have a map, let’s add markers for each one of the restaurants.
@@ -1547,10 +1543,9 @@ <h3 id="adding-markers-to-a-map">Adding markers to a map</h3>
1547
1543
< h3 id ="setup-2 "> Setup 2</ h3 >
1548
1544
< p > ✏️ Update < strong > src/screens/RestaurantList/components/Map/Map.tsx</ strong > to be:</ p >
1549
1545
< pre > < code class ="language-tsx "> import { useNavigation } from "@react-navigation/native"
1546
+ import { Restaurant } from "@shared/services/pmo/restaurant"
1550
1547
import MapView, { Marker, PROVIDER_GOOGLE } from "react-native-maps"
1551
1548
1552
- import { Restaurant } from "../../../../services/pmo/restaurant"
1553
-
1554
1549
export interface MapProps {
1555
1550
restaurants: Restaurant[]
1556
1551
}
@@ -1575,7 +1570,7 @@ <h3 id="setup-2">Setup 2</h3>
1575
1570
export default Map
1576
1571
1577
1572
</ code > </ pre >
1578
- < div line-highlight ="1-2,21-23 ,only "> </ div >
1573
+ < div line-highlight ="1,3,20-22 ,only "> </ div >
1579
1574
< h3 id ="verify-2 "> Verify 2</ h3 >
1580
1575
< p > Navigate to the < code > Maps</ code > tab of the < code > RestaurantsList</ code > in your emulator and verify that the Map is rendering.</ p >
1581
1576
< p > < img alt ="Screenshot of the restaurant view with the title “Green Bay, Wisconsin.” The map is still centered on Green Bay and now has several locations marked with red pins. One of the markers is labeled Cheese Curd City, 230 W Kinzie Street. The bottom tab bar has icons for Place My Order and Settings. " src ="../static/img/react-native/18-maps/02-solution.png " style ="border: 4px solid black; border-radius: 25px; " height ="640 "/> </ p >
@@ -1593,10 +1588,9 @@ <h3 id="solution-2">Solution 2</h3>
1593
1588
< summary > Click to see the solution</ summary > </ p >
1594
1589
< p > ✏️ Update < strong > src/screens/RestaurantList/components/Map/Map.tsx</ strong > to be:</ p >
1595
1590
< pre > < code class ="language-tsx "> import { useNavigation } from "@react-navigation/native"
1591
+ import { Restaurant } from "@shared/services/pmo/restaurant"
1596
1592
import MapView, { Marker, PROVIDER_GOOGLE } from "react-native-maps"
1597
1593
1598
- import { Restaurant } from "../../../../services/pmo/restaurant"
1599
-
1600
1594
export interface MapProps {
1601
1595
restaurants: Restaurant[]
1602
1596
}
@@ -1635,7 +1629,7 @@ <h3 id="solution-2">Solution 2</h3>
1635
1629
export default Map
1636
1630
1637
1631
</ code > </ pre >
1638
- < div line-highlight ="11,24-36 , "> </ div >
1632
+ < div line-highlight ="10,23-35 , "> </ div >
1639
1633
< p > </ details > </ p >
1640
1634
< h2 id ="next-steps "> Next steps</ h2 >
1641
1635
< p > We’ve accomplished a lot for our React Native App, in order to polish it just a bit more let’s get into some < a href ="./performance-optimization "> Performance and Optimization</ a > practices.</ p >
0 commit comments