11import React , { useState , useEffect } from "react" ;
2- import { StyleSheet , Text , View , ScrollView } from "react-native" ;
3- import Radar , { Map , Autocomplete } from "react-native-radar" ;
2+ import { StyleSheet , Text , View , ScrollView , Platform } from "react-native" ;
3+ import Radar , { Map , Autocomplete , RadarClientLocationUpdate , RadarLocationUpdate , RadarEventUpdate } from "react-native-radar" ;
44import MapLibreGL from "@maplibre/maplibre-react-native" ;
55import ExampleButton from "./components/exampleButton" ;
66
77// The current version of MapLibre does not support the new react native architecture
88// MapLibreGL.setAccessToken(null);
99
10- const stringify = ( obj ) => JSON . stringify ( obj , null , 2 ) ;
10+ const stringify = ( obj : any ) => JSON . stringify ( obj , null , 2 ) ;
1111
12- Radar . on ( "events" , ( result ) => {
12+ Radar . on ( "events" , ( result : RadarEventUpdate ) => {
1313 console . log ( "events:" , stringify ( result ) ) ;
1414} ) ;
1515
16- Radar . on ( "location" , ( result ) => {
16+ Radar . on ( "location" , ( result : RadarLocationUpdate ) => {
1717 console . log ( "location:" , stringify ( result ) ) ;
1818} ) ;
1919
20- Radar . on ( "clientLocation" , ( result ) => {
20+ Radar . on ( "clientLocation" , ( result : RadarClientLocationUpdate ) => {
2121 console . log ( "clientLocation:" , stringify ( result ) ) ;
2222} ) ;
2323
2424Radar . on ( "error" , ( err ) => {
2525 console . log ( "error:" , stringify ( err ) ) ;
2626} ) ;
2727
28- Radar . on ( "log" , ( result ) => {
28+ Radar . on ( "log" , ( result : string ) => {
2929 console . log ( "log:" , stringify ( result ) ) ;
3030} ) ;
3131
3232export default function App ( ) {
3333 // add in your test code here!
3434 const [ displayText , setDisplayText ] = useState ( "" ) ;
3535
36- const handlePopulateText = ( displayText ) => {
36+ const handlePopulateText = ( displayText : string ) => {
3737 setDisplayText ( displayText ) ;
3838 } ;
39-
40- const stringify = ( obj ) => JSON . stringify ( obj , null , 2 ) ;
4139 Radar . initialize ( "prj_test_pk_0000000000000000000000000000000000000000" , true ) ;
42-
40+
4341 useEffect ( ( ) => {
44- Radar . setLogLevel ( "info " ) ;
42+ Radar . setLogLevel ( "debug " ) ;
4543
4644 Radar . setUserId ( "foo" ) ;
4745
@@ -57,24 +55,28 @@ export default function App() {
5755 return (
5856 < View style = { styles . container } >
5957 { /* The current version of MapLibre does not support the new react native architecture */ }
60- { /* <View style={{ width: "100%", height: "40%" }}>
61- <Map />
62- </View> */ }
63- < View style = { { width : "100%" , height : "10%" } } >
64- < Autocomplete
65- options = { {
66- near : {
67- latitude : 40.7342 ,
68- longitude : - 73.9911 ,
69- } ,
70- } }
71- />
72- </ View >
73- < View style = { { width : "100%" , height : "50%" } } >
74- < ScrollView >
58+ { Platform . OS !== "web" &&
59+ < >
60+ < View style = { { width : "100%" , height : "40%" } } >
61+ < Map />
62+ </ View >
63+ < View style = { { width : "100%" , height : "10%" } } >
64+ < Autocomplete
65+ options = { {
66+ near : {
67+ latitude : 40.7342 ,
68+ longitude : - 73.9911 ,
69+ } ,
70+ } }
71+ />
72+ </ View >
73+ </ >
74+ }
75+ < View style = { { width : "100%" , height : Platform . OS !== "web" ? "50%" : "100%" } } >
76+ < ScrollView style = { { height : "25%" } } >
7577 < Text style = { styles . displayText } > { displayText } </ Text >
7678 </ ScrollView >
77- < ScrollView >
79+ < ScrollView style = { { height : "75%" } } >
7880 < ExampleButton
7981 title = "getUser"
8082 onPress = { ( ) => {
@@ -186,7 +188,7 @@ export default function App() {
186188 . then ( ( result ) => {
187189 handlePopulateText (
188190 "trackOnce manual with location accuracy::" +
189- stringify ( result )
191+ stringify ( result )
190192 ) ;
191193 } )
192194 . catch ( ( err ) => {
@@ -197,7 +199,7 @@ export default function App() {
197199 } }
198200 />
199201 < ExampleButton
200- title = "trackOnce manual with beacons: "
202+ title = "trackOnce manual with beacons"
201203 onPress = { ( ) => {
202204 Radar . trackOnce ( {
203205 desiredAccuracy : "medium" ,
@@ -561,6 +563,15 @@ export default function App() {
561563 } ) ;
562564 } }
563565 />
566+
567+ < ExampleButton
568+ title = "version"
569+ onPress = { ( ) => {
570+ Radar . nativeSdkVersion ( ) . then ( ( nativeVersion ) => {
571+ handlePopulateText ( `sdk: ${ Radar . rnSdkVersion ( ) } , native: ${ nativeVersion } ` ) ;
572+ } )
573+ } }
574+ />
564575 </ ScrollView >
565576 </ View >
566577 </ View >
@@ -574,4 +585,7 @@ const styles = StyleSheet.create({
574585 alignItems : "center" ,
575586 justifyContent : "center" ,
576587 } ,
588+ displayText : {
589+ flex : 1
590+ }
577591} ) ;
0 commit comments