-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated how markers & callouts are rendered to maintain types + added…
… default callout for title/description
- Loading branch information
1 parent
bd510d6
commit 429b018
Showing
4 changed files
with
121 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
import * as React from "react"; | ||
import { Callout as MapCalloutComponent } from "./react-native-maps"; | ||
import type { MapCalloutProps as MapCalloutComponentProps } from "react-native-maps"; | ||
import { Callout as MapCalloutComponent } from "./react-native-maps"; | ||
|
||
export interface MapCalloutProps | ||
extends Omit<MapCalloutComponentProps, "tooltip"> { | ||
showTooltip?: boolean; | ||
} | ||
|
||
// Has to be a function named 'Callout' to be matched as a Callout component and not a custom view for marker | ||
// See: https://github.com/teovillanueva/react-native-web-maps/blob/81278079c6f26a707d915d69de9a00080c305957/packages/react-native-web-maps/src/components/marker.web.tsx#L79 | ||
export function Callout({ | ||
showTooltip, | ||
...rest | ||
}: React.PropsWithChildren<MapCalloutProps>) { | ||
return <MapCalloutComponent tooltip={!showTooltip} {...rest} />; | ||
/** | ||
* Renders nothing, serves as placeholder for props | ||
* Rendering exposed as function to avoid having an intermediary component that changes the type | ||
* | ||
* This is done because the underlying package has logic dependant on the type of child | ||
* See: https://github.com/teovillanueva/react-native-web-maps/blob/5f3d0ec7c24f789c3df30c1d6d7223e638ff5868/packages/react-native-web-maps/src/components/marker.web.tsx#L79 | ||
*/ | ||
const MapCallout: React.FC<React.PropsWithChildren<MapCalloutProps>> = () => { | ||
return null; | ||
}; | ||
|
||
export function renderCallout(props: MapCalloutProps, key: React.Key) { | ||
return ( | ||
<MapCalloutComponent key={key} tooltip={!props.showTooltip} {...props} /> | ||
); | ||
} | ||
|
||
export default MapCallout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { default as MapView } from "./components/MapView"; | ||
export { default as MapMarker } from "./components/MapMarker"; | ||
export { Callout as MapCallout } from "./components/MapCallout"; | ||
export { default as MapCallout } from "./components/MapCallout"; |