Skip to content

Commit c176d5b

Browse files
committed
chore: address review comments
1 parent 46c622d commit c176d5b

20 files changed

Lines changed: 276 additions & 67 deletions

File tree

MIGRATING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Version 0.14.0 introduces React Native's **New Architecture** (Fabric & TurboMod
1616

1717
| Category | Change |
1818
| --------------- | --------------------------------------------------------------------------------------------------- |
19-
| Architecture | New Architecture required (React Native 0.77+) |
19+
| Architecture | New Architecture required (React Native 0.79+) |
2020
| Native SDKs | Android Navigation SDK 7.3.0, iOS Navigation SDK 10.7.0 |
2121
| Navigation Init | Terms and Conditions dialog and session initialization are now separate methods |
2222
| Navigation Init | `init()` now returns `NavigationSessionStatus` instead of throwing errors |
@@ -39,7 +39,7 @@ Version 0.14.0 introduces React Native's **New Architecture** (Fabric & TurboMod
3939

4040
### Prerequisites
4141

42-
- **React Native 0.77 or higher** is required
42+
- **React Native 0.79 or higher** is required
4343
- **New Architecture must be enabled** in your project
4444

4545
### Step 1: Enable New Architecture

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ This repository contains a React Native plugin that provides a [Google Navigatio
3333

3434
The current version of this package has been tested and verified to work with the following React Native versions:
3535

36-
**0.81.1, 0.80.2, 0.79.6, 0.78.3, 0.77.3**
36+
**0.83.1, 0.82.1, 0.81.5, 0.80.3, 0.79.6**
3737

3838
> [!IMPORTANT]
39-
> This package requires React Native 0.77+ with the new architecture (Fabric & TurboModules) enabled. Make sure the new architecture is enabled in your project configuration as shown in the [Installation](#installation) section.
39+
> This package requires React Native 0.79+ with the new architecture (Fabric & TurboModules) enabled. Make sure the new architecture is enabled in your project configuration as shown in the [Installation](#installation) section.
40+
41+
> [!NOTE]
42+
> React Native 0.78.x and below are not supported due to Kotlin version incompatibility. If you need to use older React Native versions, please use version 0.13.x of this package with the old architecture.
4043
4144
> [!NOTE]
4245
> For users upgrading from versions prior to 0.14.0, please refer to the [Migration Guide](./MIGRATING.md) for instructions on migrating to the new architecture and updated API.

android/src/main/java/com/google/android/react/navsdk/IMapViewControllerProperties.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public interface IMapViewControllerProperties {
2828

2929
void setIndoorEnabled(boolean enabled);
3030

31+
void setIndoorLevelPickerEnabled(boolean enabled);
32+
3133
void setTrafficEnabled(boolean enabled);
3234

3335
void setCompassEnabled(boolean enabled);

android/src/main/java/com/google/android/react/navsdk/MapViewController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,12 @@ public void setIndoorEnabled(boolean enabled) {
843843
}
844844
}
845845

846+
public void setIndoorLevelPickerEnabled(boolean enabled) {
847+
if (mGoogleMap != null) {
848+
mGoogleMap.getUiSettings().setIndoorLevelPickerEnabled(enabled);
849+
}
850+
}
851+
846852
public void setTrafficEnabled(boolean enabled) {
847853
if (mGoogleMap != null) {
848854
mGoogleMap.setTrafficEnabled(enabled);

android/src/main/java/com/google/android/react/navsdk/NavViewManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@ public void setIndoorEnabled(FrameLayout view, boolean enabled) {
464464
getMapControllerProperties(view.getId()).setIndoorEnabled(enabled);
465465
}
466466

467+
@ReactProp(name = "indoorLevelPickerEnabled", defaultBoolean = true)
468+
public void setIndoorLevelPickerEnabled(FrameLayout view, boolean enabled) {
469+
getMapControllerProperties(view.getId()).setIndoorLevelPickerEnabled(enabled);
470+
}
471+
467472
@ReactProp(name = "trafficEnabled", defaultBoolean = false)
468473
public void setTrafficEnabled(FrameLayout view, boolean enabled) {
469474
getMapControllerProperties(view.getId()).setTrafficEnabled(enabled);

android/src/main/java/com/google/android/react/navsdk/ViewPropertiesSink.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class ViewPropertiesSink
3535
@Nullable private String mapStyle;
3636
@Nullable private Boolean mapToolbarEnabled;
3737
@Nullable private Boolean indoorEnabled;
38+
@Nullable private Boolean indoorLevelPickerEnabled;
3839
@Nullable private Boolean trafficEnabled;
3940
@Nullable private Boolean compassEnabled;
4041
@Nullable private Boolean buildingsEnabled;
@@ -99,6 +100,11 @@ public void setIndoorEnabled(boolean enabled) {
99100
this.indoorEnabled = enabled;
100101
}
101102

103+
@Override
104+
public void setIndoorLevelPickerEnabled(boolean enabled) {
105+
this.indoorLevelPickerEnabled = enabled;
106+
}
107+
102108
@Override
103109
public void setTrafficEnabled(boolean enabled) {
104110
this.trafficEnabled = enabled;
@@ -246,6 +252,9 @@ public void applyToController(MapViewController controller) {
246252
if (indoorEnabled != null) {
247253
controller.setIndoorEnabled(indoorEnabled);
248254
}
255+
if (indoorLevelPickerEnabled != null) {
256+
controller.setIndoorLevelPickerEnabled(indoorLevelPickerEnabled);
257+
}
249258
if (trafficEnabled != null) {
250259
controller.setTrafficEnabled(trafficEnabled);
251260
}
@@ -364,6 +373,7 @@ public void clear() {
364373
mapStyle = null;
365374
mapToolbarEnabled = null;
366375
indoorEnabled = null;
376+
indoorLevelPickerEnabled = null;
367377
trafficEnabled = null;
368378
compassEnabled = null;
369379
buildingsEnabled = null;

example/e2e/shared.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { device, element, waitFor, by, expect, log } from 'detox';
1919
const NO_ERRORS_DETECTED_LABEL = 'No errors detected';
2020

2121
// Helper function to add delays for iOS animations (iOS default transition is ~300ms)
22-
const maybeDelay = ms =>
22+
const iOSDelay = ms =>
2323
device.getPlatform() === 'ios'
2424
? new Promise(resolve => setTimeout(resolve, ms))
2525
: Promise.resolve();
@@ -88,16 +88,16 @@ export const initializeIntegrationTestsPage = async () => {
8888
await waitFor(element(by.id('integration_tests_button')))
8989
.toBeVisible()
9090
.withTimeout(30000);
91-
await maybeDelay(350);
91+
await iOSDelay(350);
9292
await element(by.id('integration_tests_button')).tap();
93-
await maybeDelay(350);
93+
await iOSDelay(350);
9494
};
9595

9696
export const selectTestByName = async name => {
9797
await waitFor(element(by.id('tests_menu_button')))
9898
.toBeVisible()
9999
.withTimeout(10000);
100-
await maybeDelay(350);
100+
await iOSDelay(350);
101101
await element(by.id('tests_menu_button')).tap();
102102
// Wait for the overlay scroll view to be visible
103103
await waitFor(element(by.id('overlay_scroll_view')))
@@ -141,6 +141,6 @@ export const selectTestByName = async name => {
141141
await waitFor(targetElement).toBeVisible().withTimeout(5000);
142142
}
143143

144-
await maybeDelay(600);
144+
await iOSDelay(600);
145145
await targetElement.tap();
146146
};

example/src/controls/mapsControls.tsx

Lines changed: 147 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,29 @@ export interface MapControlsProps {
4646
enabled: boolean,
4747
buttonEnabled: boolean
4848
) => void;
49+
// UI Settings
50+
readonly compassEnabled?: boolean;
51+
readonly onCompassEnabledChange?: (enabled: boolean) => void;
52+
readonly mapToolbarEnabled?: boolean;
53+
readonly onMapToolbarEnabledChange?: (enabled: boolean) => void;
54+
readonly indoorEnabled?: boolean;
55+
readonly onIndoorEnabledChange?: (enabled: boolean) => void;
56+
readonly indoorLevelPickerEnabled?: boolean;
57+
readonly onIndoorLevelPickerEnabledChange?: (enabled: boolean) => void;
58+
readonly rotateGesturesEnabled?: boolean;
59+
readonly onRotateGesturesEnabledChange?: (enabled: boolean) => void;
60+
readonly scrollGesturesEnabled?: boolean;
61+
readonly onScrollGesturesEnabledChange?: (enabled: boolean) => void;
62+
readonly scrollGesturesDuringRotateOrZoomEnabled?: boolean;
63+
readonly onScrollGesturesDuringRotateOrZoomEnabledChange?: (
64+
enabled: boolean
65+
) => void;
66+
readonly tiltGesturesEnabled?: boolean;
67+
readonly onTiltGesturesEnabledChange?: (enabled: boolean) => void;
68+
readonly zoomControlsEnabled?: boolean;
69+
readonly onZoomControlsEnabledChange?: (enabled: boolean) => void;
70+
readonly zoomGesturesEnabled?: boolean;
71+
readonly onZoomGesturesEnabledChange?: (enabled: boolean) => void;
4972
}
5073

5174
export const defaultZoom: number = 15;
@@ -59,6 +82,27 @@ const MapsControls: React.FC<MapControlsProps> = ({
5982
myLocationEnabled = false,
6083
myLocationButtonEnabled: _myLocationButtonEnabled = true,
6184
onMyLocationChange,
85+
// UI Settings
86+
compassEnabled = true,
87+
onCompassEnabledChange,
88+
mapToolbarEnabled = true,
89+
onMapToolbarEnabledChange,
90+
indoorEnabled = true,
91+
onIndoorEnabledChange,
92+
indoorLevelPickerEnabled = true,
93+
onIndoorLevelPickerEnabledChange,
94+
rotateGesturesEnabled = true,
95+
onRotateGesturesEnabledChange,
96+
scrollGesturesEnabled = true,
97+
onScrollGesturesEnabledChange,
98+
scrollGesturesDuringRotateOrZoomEnabled = true,
99+
onScrollGesturesDuringRotateOrZoomEnabledChange,
100+
tiltGesturesEnabled = true,
101+
onTiltGesturesEnabledChange,
102+
zoomControlsEnabled = true,
103+
onZoomControlsEnabledChange,
104+
zoomGesturesEnabled = true,
105+
onZoomGesturesEnabledChange,
62106
}) => {
63107
const mapTypeOptions = ['None', 'Normal', 'Satellite', 'Terrain', 'Hybrid'];
64108
const colorSchemeOptions = ['Follow System', 'Light', 'Dark'];
@@ -141,7 +185,21 @@ const MapsControls: React.FC<MapControlsProps> = ({
141185

142186
const getUiSettings = async () => {
143187
const result = await mapViewController.getUiSettings();
144-
showSnackbar(`UI Settings: compass=${result.isCompassEnabled}`);
188+
showSnackbar(
189+
`UI Settings:\n` +
190+
`- Compass: ${result.isCompassEnabled}\n` +
191+
`- Map Toolbar: ${result.isMapToolbarEnabled}\n` +
192+
`- Indoor Picker: ${result.isIndoorLevelPickerEnabled}\n` +
193+
`- Rotate: ${result.isRotateGesturesEnabled}\n` +
194+
`- Scroll: ${result.isScrollGesturesEnabled}\n` +
195+
`- Scroll (rotate/zoom): ${result.isScrollGesturesEnabledDuringRotateOrZoom}\n` +
196+
`- Tilt: ${result.isTiltGesturesEnabled}\n` +
197+
`- Zoom Controls: ${result.isZoomControlsEnabled}\n` +
198+
`- Zoom Gestures: ${result.isZoomGesturesEnabled}`,
199+
5000,
200+
true,
201+
12
202+
);
145203
};
146204

147205
const getIsMyLocationEnabled = async () => {
@@ -246,9 +304,9 @@ const MapsControls: React.FC<MapControlsProps> = ({
246304
};
247305

248306
/**
249-
* Add a ground overlay using position-based positioning.
307+
* Add a ground overlay using location-based positioning.
250308
* This uses a location with width/height in meters.
251-
* Note: On iOS, zoomLevel is required for position-based overlays.
309+
* Note: On iOS, zoomLevel is required for location-based overlays.
252310
*/
253311
const addGroundOverlayWithPosition = async () => {
254312
const cameraPosition = await mapViewController.getCameraPosition();
@@ -472,13 +530,99 @@ const MapsControls: React.FC<MapControlsProps> = ({
472530
}}
473531
/>
474532
</View>
533+
<View style={ControlStyles.rowContainer}>
534+
<Text style={ControlStyles.rowLabel}>Compass</Text>
535+
<ExampleAppButton
536+
title={compassEnabled ? 'Disable' : 'Enable'}
537+
onPress={() => onCompassEnabledChange?.(!compassEnabled)}
538+
/>
539+
</View>
540+
<View style={ControlStyles.rowContainer}>
541+
<Text style={ControlStyles.rowLabel}>Map Toolbar</Text>
542+
<ExampleAppButton
543+
title={mapToolbarEnabled ? 'Disable' : 'Enable'}
544+
onPress={() => onMapToolbarEnabledChange?.(!mapToolbarEnabled)}
545+
/>
546+
</View>
547+
<View style={ControlStyles.rowContainer}>
548+
<Text style={ControlStyles.rowLabel}>Indoor Maps</Text>
549+
<ExampleAppButton
550+
title={indoorEnabled ? 'Disable' : 'Enable'}
551+
onPress={() => onIndoorEnabledChange?.(!indoorEnabled)}
552+
/>
553+
</View>
554+
<View style={ControlStyles.rowContainer}>
555+
<Text style={ControlStyles.rowLabel}>Indoor Picker</Text>
556+
<ExampleAppButton
557+
title={indoorLevelPickerEnabled ? 'Disable' : 'Enable'}
558+
onPress={() =>
559+
onIndoorLevelPickerEnabledChange?.(!indoorLevelPickerEnabled)
560+
}
561+
/>
562+
</View>
475563
<ExampleAppButton title="Get UI Settings" onPress={getUiSettings} />
476564
<ExampleAppButton title="Get My location" onPress={getMyLocation} />
477565
<ExampleAppButton
478566
title="Get My location enabled"
479567
onPress={getIsMyLocationEnabled}
480568
/>
481569
</Accordion>
570+
571+
{/* Gestures */}
572+
<Accordion title="Gesture Settings">
573+
<View style={ControlStyles.rowContainer}>
574+
<Text style={ControlStyles.rowLabel}>Rotate gestures</Text>
575+
<ExampleAppButton
576+
title={rotateGesturesEnabled ? 'Disable' : 'Enable'}
577+
onPress={() =>
578+
onRotateGesturesEnabledChange?.(!rotateGesturesEnabled)
579+
}
580+
/>
581+
</View>
582+
<View style={ControlStyles.rowContainer}>
583+
<Text style={ControlStyles.rowLabel}>Scroll gestures</Text>
584+
<ExampleAppButton
585+
title={scrollGesturesEnabled ? 'Disable' : 'Enable'}
586+
onPress={() =>
587+
onScrollGesturesEnabledChange?.(!scrollGesturesEnabled)
588+
}
589+
/>
590+
</View>
591+
<View style={ControlStyles.rowContainer}>
592+
<Text style={ControlStyles.rowLabel}>Scroll during rotate/zoom</Text>
593+
<ExampleAppButton
594+
title={
595+
scrollGesturesDuringRotateOrZoomEnabled ? 'Disable' : 'Enable'
596+
}
597+
onPress={() =>
598+
onScrollGesturesDuringRotateOrZoomEnabledChange?.(
599+
!scrollGesturesDuringRotateOrZoomEnabled
600+
)
601+
}
602+
/>
603+
</View>
604+
<View style={ControlStyles.rowContainer}>
605+
<Text style={ControlStyles.rowLabel}>Tilt gestures</Text>
606+
<ExampleAppButton
607+
title={tiltGesturesEnabled ? 'Disable' : 'Enable'}
608+
onPress={() => onTiltGesturesEnabledChange?.(!tiltGesturesEnabled)}
609+
/>
610+
</View>
611+
<View style={ControlStyles.rowContainer}>
612+
<Text style={ControlStyles.rowLabel}>Zoom controls</Text>
613+
<ExampleAppButton
614+
title={zoomControlsEnabled ? 'Disable' : 'Enable'}
615+
onPress={() => onZoomControlsEnabledChange?.(!zoomControlsEnabled)}
616+
/>
617+
</View>
618+
<View style={ControlStyles.rowContainer}>
619+
<Text style={ControlStyles.rowLabel}>Zoom gestures</Text>
620+
<ExampleAppButton
621+
title={zoomGesturesEnabled ? 'Disable' : 'Enable'}
622+
onPress={() => onZoomGesturesEnabledChange?.(!zoomGesturesEnabled)}
623+
/>
624+
</View>
625+
</Accordion>
482626
</View>
483627
);
484628
};

example/src/helpers/snackbar.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ import Snackbar from 'react-native-snackbar';
2525
export const showSnackbar = (
2626
text: string,
2727
duration = Snackbar.LENGTH_SHORT,
28-
dismissPrevious = false
28+
dismissPrevious = false,
29+
numberOfLines: number = 2
2930
) => {
3031
if (dismissPrevious) {
3132
Snackbar.dismiss();
3233
}
33-
Snackbar.show({ text, duration });
34+
Snackbar.show({ text, duration, numberOfLines });
3435
};
3536

3637
export { Snackbar };

0 commit comments

Comments
 (0)