Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marker Icons #87

Merged
merged 8 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/images/Current_Location.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/marker_focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/marker_resting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions components/store/StoreMarker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { Image } from 'react-native';
import { MarkerContainer, MarkerStoreName } from '../../styled/store';

function StoreMarker({ storeName, focused }) {
return (
<MarkerContainer>
{focused && (
tommypoa marked this conversation as resolved.
Show resolved Hide resolved
<Image source={require('../../assets/images/Marker_Focused.png')} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm probably need higher resolution versions of these

)}
{!focused && (
<Image source={require('../../assets/images/Marker_Resting.png')} />
tommypoa marked this conversation as resolved.
Show resolved Hide resolved
)}
<MarkerStoreName>{storeName}</MarkerStoreName>
</MarkerContainer>
);
}

export default StoreMarker;
32 changes: 25 additions & 7 deletions screens/map/MapScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ import { NavHeaderContainer, Subhead } from '../../components/BaseComponents';
import CenterLocation from '../../components/CenterLocation';
import Hamburger from '../../components/Hamburger';
import StoreProducts from '../../components/product/StoreProducts';
import StoreMarker from '../../components/store/StoreMarker';
import Colors from '../../constants/Colors';
import Window from '../../constants/Layout';
import { getProductData, getStoreData } from '../../lib/mapUtils';
import { BottomSheetContainer, BottomSheetHeaderContainer, DragBar, SearchBar } from '../../styled/store';
import {
BottomSheetContainer,
BottomSheetHeaderContainer,
DragBar,
SearchBar,
} from '../../styled/store';

const minSnapPoint = 160;
const midSnapPoint = 325;
Expand Down Expand Up @@ -203,6 +209,16 @@ export default class MapScreen extends React.Component {
// Only called after initial store has been set
// Only expand the bottom sheet to display products if navigated from 'See Products' button on StoreList
changeCurrentStore(store, resetSheet = false) {
// Set store focus status
this.state.store.focused = false;
store.focused = true;

// Animate to new store region
const region = {
latitude: store.latitude,
longitude: store.longitude,
...deltas,
};
this.setState(
{
store,
Expand All @@ -212,6 +228,7 @@ export default class MapScreen extends React.Component {
this.bottomSheetRef.snapTo(0);
}
await this._populateStoreProducts(store);
await this._map.animateToRegion(region, 1000);
}
);
}
Expand Down Expand Up @@ -282,10 +299,12 @@ export default class MapScreen extends React.Component {
latitude: store.latitude,
longitude: store.longitude,
}}
title={store.storeName}
description={store.storeName}
onPress={() => this.changeCurrentStore(store)}
/>
onPress={() => this.changeCurrentStore(store)}>
<StoreMarker
storeName={store.storeName}
focused={store.focused}
/>
</Marker>
))}
{/* If current location found, show current location marker */}
{this.state.location && (
Expand All @@ -294,8 +313,7 @@ export default class MapScreen extends React.Component {
.toString()
.concat(coords.longitude.toString())}
coordinate={coords}
title="Your Location"
pinColor="#166e00"
image={require('../../assets/images/Current_Location.png')}
/>
)}
</MapView>
Expand Down
13 changes: 13 additions & 0 deletions styled/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ import styled from 'styled-components/native';
import { Body, ButtonContainer } from '../components/BaseComponents';
import Colors from '../constants/Colors';

export const MarkerContainer = styled.View`
width: 150px
display: flex
align-items: center
`;
export const MarkerStoreName = styled.Text`
tommypoa marked this conversation as resolved.
Show resolved Hide resolved
font-family: poppins-semibold;
font-size: 16px;
line-height: 24px;
text-align: center
color: ${Colors.black};
tommypoa marked this conversation as resolved.
Show resolved Hide resolved
`;

export const DragBar = styled.View`
background-color: ${Colors.secondaryText};
height: 4px;
Expand Down