Skip to content

Commit

Permalink
Fix elevation problem for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
yutotakano committed Jun 30, 2019
1 parent 9dabdab commit 1d5659c
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/components/CTAButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { View, Text, StyleSheet } from 'react-native';

import { TouchableRipple } from 'react-native-paper';

import { fonts, colors } from '../styles';
import { fonts, colors, elevations } from '../styles';

export default class CTAButton extends React.PureComponent {
constructor(props) {
Expand Down Expand Up @@ -34,7 +34,7 @@ const buttonStyles = StyleSheet.create({
buttonOuter: {
overflow: 'hidden',
borderRadius: 30,
elevation: 10,
...elevations.ten,
backgroundColor: colors.primary
},
button: {
Expand Down
6 changes: 3 additions & 3 deletions src/components/CalendarDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import { View, Text, StyleSheet } from 'react-native';

import { fonts, colors } from '../styles';
import { fonts, colors, elevations } from '../styles';

export default class CalendarDate extends React.PureComponent {
constructor(props) {
Expand Down Expand Up @@ -72,7 +72,7 @@ const calendarStyles = StyleSheet.create({
width: 72,
borderRadius: 3,
backgroundColor: colors.white,
elevation: 2,
...elevations.two,
overflow: 'hidden'
},
month: {
Expand Down Expand Up @@ -113,7 +113,7 @@ const miniCalendarStyles = StyleSheet.create({
width: 40,
borderRadius: 2,
backgroundColor: colors.white,
elevation: 1,
...elevations.one,
overflow: 'hidden'
},
month: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/RoundIconCarousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Carousel from 'react-native-snap-carousel';
import { Icon } from 'react-native-elements';
import { TouchableRipple } from 'react-native-paper';

import { colors, fonts } from '../styles';
import { colors, fonts, elevations } from '../styles';

export default class RoundIconCarousel extends React.PureComponent {
constructor(props) {
Expand Down Expand Up @@ -93,7 +93,7 @@ const classesCarouselStyles = StyleSheet.create({
height: 72,
width: 72,
borderRadius: 36,
elevation: 2,
...elevations.two,
overflow: 'hidden'
},
container: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/TaskListCard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';

import { fonts, styles } from '../styles';
import { fonts, styles, elevations } from '../styles';

export default TaskListCard = props => (
<View
Expand Down Expand Up @@ -39,7 +39,7 @@ const cardStyles = StyleSheet.create({
backgroundColor: '#fff',
borderRadius: 4,
flex: 1,
elevation: 1,
...elevations.one,
paddingLeft: 32
},
title: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/UpcomingCarousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Carousel from 'react-native-snap-carousel';
import { TouchableRipple } from 'react-native-paper';

import CalendarDate from '../components/CalendarDate';
import { colors, fonts } from '../styles';
import { colors, fonts, elevations } from '../styles';

export default class UpcomingCarousel extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -253,7 +253,7 @@ const upcomingCarouselStyles = StyleSheet.create({
backgroundColor: colors.white,
height: 100,
borderRadius: 4,
elevation: 13 // Really increase this so the shadows appear blurry like iOS,
...elevations.thirteen // Really increase this so the shadows appear blurry like iOS,
},
container: {
flexDirection: 'row'
Expand Down
4 changes: 2 additions & 2 deletions src/screens/ManagebacAlertScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { BASE_URL } from '../../env';
import HTMLView from 'react-native-htmlview';

import { Storage } from '../helpers';
import { colors } from '../styles';
import { colors, elevations } from '../styles';

export default class ManagebacAlertScreen extends React.Component {
isMounted = false;
Expand Down Expand Up @@ -140,7 +140,7 @@ const alertStyles = StyleSheet.create({
backgroundColor: colors.lightBlue2,
borderBottomWidth: StyleSheet.hairlineWidth,
borderColor: colors.gray2,
elevation: 2
...elevations.two
},
bold: {
fontWeight: 'bold'
Expand Down
10 changes: 5 additions & 5 deletions src/screens/ManagebacMessageThreadScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { BASE_URL } from '../../env';
import HeaderIcon from '../components/HeaderIcon';
import EndOfList from '../components/EndOfList';
import { Storage } from '../helpers';
import { colors } from '../styles';
import { colors, elevations } from '../styles';

class ManagebacMessageThreadScreen extends React.Component {
isMounted = false;
Expand Down Expand Up @@ -479,18 +479,18 @@ const messageThreadStyles = StyleSheet.create({
backgroundColor: colors.lightBackground
},
topLevel: {
elevation: 3,
...elevations.three,
backgroundColor: colors.white,
marginBottom: 16
},
level2: {
elevation: 2,
...elevations.two,
backgroundColor: colors.white,
marginLeft: 16,
marginBottom: 16
},
level3: {
elevation: 1,
...elevations.one,
backgroundColor: colors.white,
marginLeft: 32,
marginBottom: 16
Expand Down Expand Up @@ -525,7 +525,7 @@ const messageThreadStyles = StyleSheet.create({
},
replyButtonContainer: {
backgroundColor: colors.white,
elevation: 4,
...elevations.four,
borderRadius: 30,
overflow: 'hidden',
flexDirection: 'row',
Expand Down
4 changes: 2 additions & 2 deletions src/screens/ManagebacViewCASReflectionsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import HeaderIcon from '../components/HeaderIcon';
import PreloadImage from '../components/PreloadImage';
import ExperienceUneditableWarning from '../components/ExperienceUneditableWarning';
import { Storage } from '../helpers';
import { fonts, colors } from '../styles';
import { fonts, colors, elevations } from '../styles';

export default class ManagebacViewCASReflectionsScreen extends React.Component {
isMounted = false;
Expand Down Expand Up @@ -475,7 +475,7 @@ const reflectionListStyles = StyleSheet.create({
fontSize: 12
},
itemContentWrapper: {
elevation: 2,
...elevations.two,
marginHorizontal: 16,
backgroundColor: colors.white,
borderRadius: 2,
Expand Down
4 changes: 2 additions & 2 deletions src/screens/SettingsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { connect } from 'react-redux';
import { version } from '../../package.json';

import { Storage } from '../helpers';
import { colors, fonts } from '../styles';
import { colors, fonts, elevations } from '../styles';

class SettingsScreen extends React.Component {
settingsSections = [
Expand Down Expand Up @@ -239,7 +239,7 @@ const settingsStyles = StyleSheet.create({
alignItems: 'center',
paddingVertical: 32,
marginBottom: 8,
elevation: 2
...elevations.two
},
profileIcon: {
width: 64,
Expand Down
73 changes: 71 additions & 2 deletions src/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { StyleSheet } from 'react-native';
/**
* The colors are generated with the following method:
* dark: [1/2] original (50%) #000000 (50%)
* dark2: [1/6] original (16.6%) #000000 (83.4%)
* dark2: [1/6] original (16.6%) #000000 (83.4%)
* light: [1/6] original (50%) #ffffff (50%)
* light2: [1/6] original (16.6%) #ffffff (83.4%)
*/
Expand Down Expand Up @@ -61,6 +61,75 @@ const fonts = StyleSheet.create({
}
});

const elevations = StyleSheet.create({
one: {
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 1
},
shadowOpacity: 0.18,
shadowRadius: 1.0,

elevation: 1
},
two: {
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 1
},
shadowOpacity: 0.2,
shadowRadius: 1.41,

elevation: 2
},
three: {
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 1
},
shadowOpacity: 0.22,
shadowRadius: 2.22,

elevation: 3
},
four: {
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 2
},
shadowOpacity: 0.23,
shadowRadius: 2.62,

elevation: 4
},
ten: {
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 5
},
shadowOpacity: 0.34,
shadowRadius: 6.27,

elevation: 10
},
thirteen: {
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 6
},
shadowOpacity: 0.39,
shadowRadius: 8.3,

elevation: 13
}
});

/*modularized styles*/
const styles = StyleSheet.create({
//apply to any
Expand Down Expand Up @@ -170,4 +239,4 @@ const labelColors = name => {
return color;
};

export { styles, colors, preset, labelColors, fonts };
export { styles, colors, preset, labelColors, fonts, elevations };

0 comments on commit 1d5659c

Please sign in to comment.