-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[google] PR feedback, fix CAAnimation bug
- Loading branch information
Showing
12 changed files
with
127 additions
and
114 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
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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* eslint-disable */ | ||
|
||
import { PropTypes } from 'react'; | ||
import { | ||
requireNativeComponent, | ||
NativeModules, | ||
Platform, | ||
} from 'react-native'; | ||
|
||
export const SUPPORTED = 'SUPPORTED'; | ||
export const USES_DEFAULT_IMPLEMENTATION = 'USES_DEFAULT_IMPLEMENTATION'; | ||
export const NOT_SUPPORTED = 'NOT_SUPPORTED'; | ||
|
||
export function getAirMapName(provider) { | ||
if (provider === 'google') return 'AIRGoogleMap'; | ||
return 'AIRMap'; | ||
} | ||
|
||
function getAirComponentName(provider, component) { | ||
return `${getAirMapName(provider)}${component}`; | ||
} | ||
|
||
export const contextTypes = { | ||
provider: PropTypes.string, | ||
}; | ||
|
||
export const createNotSupportedComponent = message => () => console.error(message) || null; | ||
|
||
export const googleMapIsInstalled = !!NativeModules.UIManager[getAirMapName('google')]; | ||
|
||
export default function decorateMapComponent(Component, { componentType, providers }) { | ||
const components = { | ||
default: requireNativeComponent(getAirComponentName(null, componentType), Component), | ||
}; | ||
|
||
Object.entries(providers).forEach(([provider, providerInfo]) => { | ||
const platformSupport = providerInfo[Platform.OS]; | ||
const componentName = getAirComponentName(provider, componentType); | ||
if (platformSupport === NOT_SUPPORTED) { | ||
components[provider] = createNotSupportedComponent(`react-native-maps: ${componentName} is not supported on ${Platform.OS}`); | ||
} else if (platformSupport === USES_DEFAULT_IMPLEMENTATION) { | ||
components[provider] = components.default; | ||
} else { // (platformSupport === SUPPORTED) | ||
if (Platform.OS === 'android' || (Platform.OS === 'ios' && googleMapIsInstalled)) { | ||
components[provider] = requireNativeComponent(componentName, Component); | ||
} | ||
} | ||
}); | ||
|
||
Component.contextTypes = contextTypes; | ||
Component.prototype.airComponent = function() { | ||
return components[this.context.provider || 'default']; | ||
}; | ||
|
||
Component.prototype.uiManagerCommand = function(name) { | ||
return NativeModules.UIManager[getAirComponentName(this.context.provider, componentType)] | ||
.Commands[name]; | ||
}; | ||
|
||
Component.prototype.mapManagerCommand = function(name) { | ||
return NativeModules[`${getAirComponentName(this.context.provider, componentType)}Manager`][name]; | ||
}; | ||
|
||
return Component; | ||
} |
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
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