Skip to content

Commit

Permalink
Fix list of examples on Android
Browse files Browse the repository at this point in the history
In #548, we added Google Maps support for iOS. We changed the example
app to list examples based on whether they support Google Maps on iOS.
The logic was such that on Android it only showed the examples that are
iOS + Google Map compatible, however on Android this condition is
irrelevant, this commit changes it to show all examples on Android,
regardless.
  • Loading branch information
Spike Brehm committed Sep 22, 2016
1 parent f78c0ee commit dc33d7b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import LiteMapView from './examples/LiteMapView';
import CustomTiles from './examples/CustomTiles';
import StaticMap from './examples/StaticMap';

const IOS = Platform.OS === 'ios';
const ANDROID = Platform.OS === 'android';

function makeExampleMapper(useGoogleMaps) {
if (useGoogleMaps) {
return example => [
Expand All @@ -45,8 +48,7 @@ class App extends React.Component {

this.state = {
Component: null,
showGoogleMapsSwitch: Platform.OS === 'ios',
useGoogleMaps: Platform.OS === 'android',
useGoogleMaps: ANDROID,
};
}

Expand Down Expand Up @@ -89,7 +91,6 @@ class App extends React.Component {
renderExamples(examples) {
const {
Component,
showGoogleMapsSwitch,
useGoogleMaps,
} = this.state;

Expand All @@ -103,7 +104,7 @@ class App extends React.Component {
contentContainerStyle={styles.scrollview}
showsVerticalScrollIndicator={false}
>
{showGoogleMapsSwitch && this.renderGoogleSwitch()}
{IOS && this.renderGoogleSwitch()}
{examples.map(example => this.renderExample(example))}
</ScrollView>
}
Expand All @@ -113,7 +114,7 @@ class App extends React.Component {

render() {
return this.renderExamples([
// [<component>, <component description>, <Google compatible>, <Google add'l description>]
// [<component>, <component description>, <Google compatible>, <Google add'l description>]
[StaticMap, 'StaticMap', true],
[DisplayLatLng, 'Tracking Position', true, '(incomplete)'],
[ViewsAsMarkers, 'Arbitrary Views as Markers', true],
Expand All @@ -134,8 +135,9 @@ class App extends React.Component {
[LiteMapView, 'Android Lite MapView'],
[CustomTiles, 'Custom Tiles'],
]
.filter(example => example[2] || !this.state.useGoogleMaps)
.map(makeExampleMapper(this.state.useGoogleMaps))
// Filter out examples that are not yet supported for Google Maps on iOS.
.filter(example => ANDROID || (IOS && (example[2] || !this.state.useGoogleMaps)))
.map(makeExampleMapper(IOS && this.state.useGoogleMaps))
);
}
}
Expand Down

0 comments on commit dc33d7b

Please sign in to comment.