Skip to content

Commit

Permalink
fix: Make location icon center aligned (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 authored Sep 30, 2019
1 parent e8bd3fd commit 99cd5d3
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 39 deletions.
2 changes: 1 addition & 1 deletion App/Screens/Home/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const styles = StyleSheet.create({
container: {
...theme.withPadding,
marginBottom: theme.spacing.normal,
marginTop: theme.spacing.tiny
marginTop: theme.spacing.mini
},
isStationTooFar: {
...theme.text,
Expand Down
34 changes: 17 additions & 17 deletions App/Screens/Home/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ import alert from '../../../../assets/images/alert.png';
import { ChangeLocation, CurrentLocation } from '../../../components';
import { i18n } from '../../../localization';
import { ApiContext, CurrentLocationContext } from '../../../stores';
import { distanceToStation, isStationTooFar, DistanceUnit } from '../../../util/station';
import {
distanceToStation,
isStationTooFar,
DistanceUnit
} from '../../../util/station';
import * as theme from '../../../util/theme';

interface HeaderProps {
Expand All @@ -40,8 +44,14 @@ export function Header (props: HeaderProps) {
const { onChangeLocationClick } = props;

const distanceUnit = i18n.t('distance_unit');
const haversineDistanceUnit = i18n.t('haversine_distance_unit') as DistanceUnit;
const distance = distanceToStation(currentLocation!, api!, haversineDistanceUnit);
const haversineDistanceUnit = i18n.t(
'haversine_distance_unit'
) as DistanceUnit;
const distance = distanceToStation(
currentLocation!,
api!,
haversineDistanceUnit
);
const isTooFar = isStationTooFar(currentLocation!, api!);

return (
Expand All @@ -65,9 +75,7 @@ export function Header (props: HeaderProps) {
</View>
</View>

<View style={styles.changeLocation}>
<ChangeLocation onPress={onChangeLocationClick} />
</View>
<ChangeLocation onPress={onChangeLocationClick} />
</View>
</View>
);
Expand All @@ -87,23 +95,15 @@ const styles = StyleSheet.create({
flexDirection: 'row'
},
currentLocation: {
marginRight: theme.spacing.tiny,
marginRight: theme.spacing.mini,
flex: 1
},

changeLocation: {
alignSelf: 'stretch',
alignItems: 'flex-end',
justifyContent: 'flex-start',
maxWidth: 60
},

distance: {
alignItems: 'center',
flexDirection: 'row',
marginTop: theme.spacing.tiny
marginTop: theme.spacing.mini
},
warning: {
marginRight: theme.spacing.tiny
marginRight: theme.spacing.mini
}
});
2 changes: 1 addition & 1 deletion App/Screens/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const styles = StyleSheet.create({
},
scrollView: { flex: 1 },
selectFrequency: {
marginTop: theme.spacing.tiny
marginTop: theme.spacing.mini
},
shit: {
...theme.shitText,
Expand Down
4 changes: 2 additions & 2 deletions App/Screens/Home/SelectFrequency/SelectFrequency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function SelectFrequency (props: SelectFrequencyProps) {
}

scroll.current!.scrollTo({
x: dailyWidth + theme.spacing.tiny
x: dailyWidth + theme.spacing.mini
});
handleChangeFrequency('weekly');
}}
Expand Down Expand Up @@ -100,7 +100,7 @@ export function SelectFrequency (props: SelectFrequencyProps) {

const styles = StyleSheet.create({
boxButton: {
marginRight: theme.spacing.tiny
marginRight: theme.spacing.mini
},
container: {
flexDirection: 'row',
Expand Down
2 changes: 1 addition & 1 deletion App/components/BoxButton/BoxButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const styles = StyleSheet.create({
borderColor: 'rgba(0, 0, 0, 0.1)',
borderRadius: scale(12),
borderWidth: 1,
marginBottom: theme.spacing.tiny,
marginBottom: theme.spacing.mini,
paddingHorizontal: theme.spacing.small,
paddingVertical: scale(4), // Padding for the shadow
shadowOpacity: 0.1
Expand Down
4 changes: 2 additions & 2 deletions App/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ const styles = StyleSheet.create({
alignItems: 'center',
flexDirection: 'row',
justifyContent: 'space-around',
paddingVertical: theme.spacing.tiny
paddingVertical: theme.spacing.mini
},
bigButtonText: {
...theme.title,
color: theme.primaryColor
},
icon: {
marginRight: theme.spacing.tiny
marginRight: theme.spacing.mini
},
primary: {
borderColor: theme.primaryColor,
Expand Down
31 changes: 17 additions & 14 deletions App/components/ChangeLocation/ChangeLocation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,48 @@
// along with Sh**t! I Smoke. If not, see <http://www.gnu.org/licenses/>.

import React from 'react';
import { Image, StyleSheet, Text, TouchableOpacity, TouchableOpacityProps } from 'react-native';
import {
Image,
StyleSheet,
Text,
TouchableOpacity,
TouchableOpacityProps
} from 'react-native';
import { scale } from 'react-native-size-matters';

import { i18n } from '../../localization';
import * as theme from '../../util/theme';

import changeLocation from '../../../assets/images/changeLocation.png';

interface ChangeLocationProps extends TouchableOpacityProps {

}
interface ChangeLocationProps extends TouchableOpacityProps {}

export function ChangeLocation (props: ChangeLocationProps) {
const { onPress } = props;
const { onPress, ...rest } = props;

return (
<TouchableOpacity onPress={onPress}>
<Image style={styles.icon} source={changeLocation} />
<TouchableOpacity onPress={onPress} style={styles.container} {...rest}>
<Image source={changeLocation} style={styles.icon} />
<Text style={styles.label}>{i18n.t('home_header_change_location')}</Text>
</TouchableOpacity>
);
}

const styles = StyleSheet.create({
container: {
backgroundColor: 'yellow',
maxWidth: 60
flexDirection: 'column',
justifyContent: 'center',
width: 60
},

icon: {
alignSelf: 'center',
marginBottom: scale(4)
marginBottom: theme.spacing.tiny
},

label: {
color: theme.primaryColor,
fontFamily: theme.gothamBlack,
fontSize: scale(7),
lineHeight: scale(8),
letterSpacing: 2,
lineHeight: scale(10),
textAlign: 'center',
textTransform: 'uppercase'
}
Expand Down
3 changes: 2 additions & 1 deletion App/util/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export const primaryColor = '#F8A65D';
export const textColor = '#44464A';
export const secondaryTextColor = '#8B909A';
export const spacing = {
tiny: scale(10),
tiny: scale(5),
mini: scale(10),
small: scale(15),
normal: scale(20),
big: scale(36)
Expand Down

0 comments on commit 99cd5d3

Please sign in to comment.