From 971600d64d805603f3fcc6aa4e234b5585012944 Mon Sep 17 00:00:00 2001 From: mohamed Date: Thu, 23 Mar 2023 11:10:52 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=8E=20screen=20Point=5FViewer=20fini?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- R-Dash/core/Lap.ts | 13 +++++++++++++ R-Dash/screens/Lap.tsx | 16 +++------------- R-Dash/screens/NewTrack.tsx | 22 +++------------------- R-Dash/screens/Point_Viewer.tsx | 27 ++++++++++++++++++--------- 4 files changed, 37 insertions(+), 41 deletions(-) diff --git a/R-Dash/core/Lap.ts b/R-Dash/core/Lap.ts index 3bdb122..fc45595 100644 --- a/R-Dash/core/Lap.ts +++ b/R-Dash/core/Lap.ts @@ -51,6 +51,17 @@ export class Lap { }); return sum/this.points.length; } + + getMaxSpeed(){ + var max = 0.0; + this.points.forEach(pt => { + if(max < pt.getVCar()){ + max = pt.getVCar(); + } + }); + return max; + } + getLocationLat(){ var sum = 0.0; this.points.forEach(pt => { @@ -58,6 +69,7 @@ export class Lap { }); return sum/this.points.length; } + getLocationLong(){ var sum = 0.0; this.points.forEach(pt => { @@ -65,4 +77,5 @@ export class Lap { }); return sum/this.points.length; } + } \ No newline at end of file diff --git a/R-Dash/screens/Lap.tsx b/R-Dash/screens/Lap.tsx index ed3d52f..6e8a8a2 100644 --- a/R-Dash/screens/Lap.tsx +++ b/R-Dash/screens/Lap.tsx @@ -6,12 +6,12 @@ import React from 'react'; import { Lap as LapModel} from '../core/Lap'; import TopBar from '../components/TopBar'; -export default function Lap(props: { navigation: any, route }) { +export default function Lap(props: { navigation: any, route : any}) { const { session } = props.route.params; const { navigation } = props; // const laps: LapModel[] = session.getLaps(); - const laps: LapModel[] = session.getLaps().sort((lap1, lap2) => lap1.getNumber() - lap2.getNumber()); + const laps: LapModel[] = session.getLaps().sort((lap1 : LapModel, lap2 : LapModel) => lap1.getNumber() - lap2.getNumber()); const [currentLapIndex, setCurrentLapIndex] = React.useState(0); @@ -112,17 +112,7 @@ export default function Lap(props: { navigation: any, route }) { Max Speed: - {} km/h - - - - X: - {} X - - - - X: - {} X + {currentLap.getMaxSpeed()} km/h diff --git a/R-Dash/screens/NewTrack.tsx b/R-Dash/screens/NewTrack.tsx index 2b6df27..61dcf5c 100644 --- a/R-Dash/screens/NewTrack.tsx +++ b/R-Dash/screens/NewTrack.tsx @@ -3,6 +3,7 @@ import React, { useState } from 'react'; import { Button, Pressable, StyleSheet, Text, View, Image, TouchableOpacity, TextInput } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; import * as DocumentPicker from 'expo-document-picker'; +import TopBar from '../components/TopBar'; export default function NewTrack(props: { navigation: any }) { const { navigation } = props; @@ -23,25 +24,8 @@ export default function NewTrack(props: { navigation: any }) { return ( - - - - - - Name - - - - - - - - - - - - - + {/* Header */} + {/* Page */} diff --git a/R-Dash/screens/Point_Viewer.tsx b/R-Dash/screens/Point_Viewer.tsx index 8817758..f2a04b8 100644 --- a/R-Dash/screens/Point_Viewer.tsx +++ b/R-Dash/screens/Point_Viewer.tsx @@ -1,13 +1,13 @@ import { BackgroundImage } from '@rneui/base'; import { StyleSheet, Text, View, TouchableOpacity, ScrollView } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; -import MapView, { Polyline } from 'react-native-maps'; +import MapView, { Marker, Polyline } from 'react-native-maps'; import React from 'react'; import { Lap as LapModel} from '../core/Lap'; import TopBar from '../components/TopBar'; import { Point } from '../core/Point'; -export default function Lap(props: { navigation: any, route }) { +export default function Lap(props: { navigation: any, route : any}) { const { currentLap } = props.route.params; const { navigation } = props; @@ -30,6 +30,18 @@ export default function Lap(props: { navigation: any, route }) { } }; + const markers: { id: number; name: string; coordinate: { latitude: number; longitude: number } }[] = points.map((pt, index) => { + return { + id: index, + name: pt.getDistance() + 'm', + coordinate: { latitude: pt.getGeo().getGpsLat(), longitude: pt.getGeo().getGpsLong() }, + }; + }); + + const handleMarker = (index : number) => { + setCurrentPointIndex(index); + } + // currentLap.getPoints().forEach(pt => { // points.push({ latitude: pt.getGeo().getGpsLat(), longitude: pt.getGeo().getGpsLong() }); @@ -73,13 +85,10 @@ export default function Lap(props: { navigation: any, route }) { longitudeDelta: 0.015, }} > - {/* console.log('pressed')} - /> */} + {markers.map(({ id, name, coordinate }) => ( + handleMarker(id)} /> + ))} +