@@ -27,6 +27,7 @@ import {
2727 type Circle ,
2828 type Polyline ,
2929 type Polygon ,
30+ type Padding ,
3031} from '@googlemaps/react-native-navigation-sdk' ;
3132
3233export interface MapControlsProps {
@@ -41,11 +42,11 @@ const MapsControls: React.FC<MapControlsProps> = ({ mapViewController }) => {
4142 const [ enableLocationMarker , setEnableLocationMarker ] = useState ( true ) ;
4243 const [ latitude , onLatChanged ] = useState ( '' ) ;
4344 const [ longitude , onLngChanged ] = useState ( '' ) ;
44- const [ padding , setPadding ] = useState ( {
45- top : '' ,
46- bottom : '' ,
47- left : '' ,
48- right : '' ,
45+ const [ padding , setPadding ] = useState < Padding > ( {
46+ top : 0 ,
47+ bottom : 0 ,
48+ left : 0 ,
49+ right : 0 ,
4950 } ) ;
5051
5152 useEffect ( ( ) => {
@@ -202,14 +203,9 @@ const MapsControls: React.FC<MapControlsProps> = ({ mapViewController }) => {
202203 } ;
203204
204205 const onPaddingChanged = ( edge : keyof typeof padding , value : string ) => {
205- const updatedPadding = { ...padding , [ edge ] : value } ;
206+ const updatedPadding : Padding = { ...padding , [ edge ] : Number ( value ) } ;
206207 setPadding ( updatedPadding ) ;
207- mapViewController . setPadding (
208- Number ( updatedPadding . top ) ,
209- Number ( updatedPadding . left ) ,
210- Number ( updatedPadding . bottom ) ,
211- Number ( updatedPadding . right )
212- ) ;
208+ mapViewController . setPadding ( updatedPadding ) ;
213209 } ;
214210
215211 return (
@@ -297,38 +293,47 @@ const MapsControls: React.FC<MapControlsProps> = ({ mapViewController }) => {
297293 dropdownStyle = { styles . dropdownMenuStyle }
298294 />
299295 </ View >
300- < TextInput
301- style = { styles . input }
302- onChangeText = { value => onPaddingChanged ( 'top' , value ) }
303- value = { padding . top }
304- placeholder = "Top padding"
305- placeholderTextColor = "#000"
306- keyboardType = "numeric"
307- />
308- < TextInput
309- style = { styles . input }
310- onChangeText = { value => onPaddingChanged ( 'bottom' , value ) }
311- value = { padding . bottom }
312- placeholder = "Bottom padding"
313- placeholderTextColor = "#000"
314- keyboardType = "numeric"
315- />
316- < TextInput
317- style = { styles . input }
318- onChangeText = { value => onPaddingChanged ( 'left' , value ) }
319- value = { padding . left }
320- placeholder = "Left padding"
321- placeholderTextColor = "#000"
322- keyboardType = "numeric"
323- />
324- < TextInput
325- style = { styles . input }
326- onChangeText = { value => onPaddingChanged ( 'right' , value ) }
327- value = { padding . right }
328- placeholder = "Right padding"
329- placeholderTextColor = "#000"
330- keyboardType = "numeric"
331- />
296+ < View style = { styles . controlButtonGap } />
297+ < View style = { styles . rowContainer } >
298+ < Text > Top padding</ Text >
299+ < TextInput
300+ style = { styles . input }
301+ onChangeText = { value => onPaddingChanged ( 'top' , value ) }
302+ value = { padding . top ?. toFixed ( 0 ) }
303+ keyboardType = "numeric"
304+ inputMode = "numeric"
305+ />
306+ </ View >
307+ < View style = { styles . rowContainer } >
308+ < Text > Bottom padding</ Text >
309+ < TextInput
310+ style = { styles . input }
311+ onChangeText = { value => onPaddingChanged ( 'bottom' , value ) }
312+ value = { padding . bottom ?. toFixed ( 0 ) }
313+ keyboardType = "numeric"
314+ inputMode = "numeric"
315+ />
316+ </ View >
317+ < View style = { styles . rowContainer } >
318+ < Text > Left padding</ Text >
319+ < TextInput
320+ style = { styles . input }
321+ onChangeText = { value => onPaddingChanged ( 'left' , value ) }
322+ value = { padding . left ?. toFixed ( 0 ) }
323+ keyboardType = "numeric"
324+ inputMode = "numeric"
325+ />
326+ </ View >
327+ < View style = { styles . rowContainer } >
328+ < Text > Right padding</ Text >
329+ < TextInput
330+ style = { styles . input }
331+ onChangeText = { value => onPaddingChanged ( 'right' , value ) }
332+ value = { padding . right ?. toFixed ( 0 ) }
333+ keyboardType = "numeric"
334+ inputMode = "numeric"
335+ />
336+ </ View >
332337 </ View >
333338 ) ;
334339} ;
0 commit comments