Turn symptom icons into icon font

This commit is contained in:
Julia Friesel
2018-11-27 16:07:38 +01:00
parent 16220305d7
commit 4f4d930c8e
22 changed files with 216 additions and 497 deletions
+19 -62
View File
@@ -2,7 +2,7 @@ import React, { Component } from 'react'
import { View, FlatList, ActivityIndicator } from 'react-native'
import range from 'date-range'
import { LocalDate } from 'js-joda'
import { Surface, Group as G } from 'react-native/Libraries/ART/ReactNativeART'
import { Surface } from 'react-native/Libraries/ART/ReactNativeART'
import { makeYAxisLabels, makeHorizontalGrid } from './y-axis'
import nfpLines from './nfp-lines'
import DayColumn from './day-column'
@@ -12,16 +12,20 @@ import { scaleObservable } from '../../local-storage'
import config from '../../config'
import AppText from '../app-text'
import { shared as labels } from '../labels'
import BleedingIcon from '../../assets/bleeding'
import CervixIcon from '../../assets/cervix'
import DesireIcon from '../../assets/desire'
import MucusIcon from '../../assets/mucus'
import NoteIcon from '../../assets/note'
import PainIcon from '../../assets/pain'
import SexIcon from '../../assets/sex'
import DripIcon from '../../assets/drip-icons'
import CycleDayIcon from '../../assets/home-circle'
import nothingChanged from '../../db/db-unchanged'
const symptomIcons = {
bleeding: <DripIcon size={16} name='drip-icon-bleeding' color={styles.iconShades.bleeding[3]}/>,
mucus: <DripIcon size={16} name='drip-icon-mucus' color={styles.iconShades.mucus[4]}/>,
cervix: <DripIcon size={16} name='drip-icon-cervix' color={styles.iconShades.cervix[3]}/>,
desire: <DripIcon size={16} name='drip-icon-desire' color={styles.iconShades.desire[2]}/>,
sex: <DripIcon size={16} name='drip-icon-sex' color={styles.iconShades.sex[2]}/>,
pain: <DripIcon size={16} name='drip-icon-pain' color={styles.iconShades.pain[0]}/>,
note: <DripIcon size={16} name='drip-icon-note' color={styles.iconShades.note[0]}/>
}
export default class CycleChart extends Component {
constructor(props) {
super(props)
@@ -151,16 +155,7 @@ export default class CycleChart extends Component {
height={this.symptomRowHeight /
this.symptomRowSymptoms.length}
>
<Surface
width={styles.yAxis.width * 0.8}
height={this.symptomRowHeight /
this.symptomRowSymptoms.length * 0.8}
viewBox={symptomIcons[symptomName].viewBox}
>
<G fill={symptomIcons[symptomName].color}>
{symptomIcons[symptomName].icon}
</G>
</Surface>
{symptomIcons[symptomName]}
</View>
})}
</View>
@@ -169,13 +164,13 @@ export default class CycleChart extends Component {
</View>
<View style={[styles.yAxis, { alignItems: 'center', justifyContent: 'center' }]}>
<Surface
width={styles.yAxis.width * 0.7}
height={styles.yAxis.width * 0.7}
viewBox='325 330 190 190'
width={styles.yAxis.width * 0.8}
height={styles.yAxis.width * 0.8}
>
<G fill="none" stroke="#1E0B7A" strokeWidth="10">
<CycleDayIcon/>
</G>
<CycleDayIcon
strokeWidth={10}
scale={0.12}
/>
</Surface>
<AppText style={[
styles.column.label.date,
@@ -232,41 +227,3 @@ function getTodayAndPreviousDays(n) {
return range(earlierDate, today).reverse()
}
const symptomIcons = {
'bleeding': {
'viewBox': '10 10 320 400',
'color': styles.iconShades.bleeding[3],
'icon': <BleedingIcon strokeWidth={'5'}/>
},
'mucus': {
'viewBox': '10 10 320 400',
'color': styles.iconShades.mucus[4],
'icon': <MucusIcon/>
},
'cervix': {
'viewBox': '10 10 320 440',
'color': styles.iconShades.cervix[3],
'icon': <CervixIcon/>
},
'desire': {
'viewBox': '10 10 320 380',
'color': styles.iconShades.desire[2],
'icon': <DesireIcon/>
},
'sex': {
'viewBox': '10 10 320 400',
'color': styles.iconShades.sex[2],
'icon': <SexIcon/>
},
'pain': {
'viewBox': '10 10 300 400',
'color': styles.iconShades.pain[0],
'icon': <PainIcon/>
},
'note': {
'viewBox': '10 10 270 400',
'color': styles.iconShades.note[0],
'icon': <NoteIcon/>
},
}
+3 -3
View File
@@ -69,7 +69,7 @@ export default class DayColumn extends Component {
if(this.fhmAndLtl.drawLtlAt) {
const ltlLine = (<Shape
stroke={styles.nfpLine.stroke}
stroke-width={styles.nfpLine.strokeWidth}
strokeWidth={styles.nfpLine.strokeWidth}
d={new Path()
.moveTo(0, this.fhmAndLtl.drawLtlAt)
.lineTo(config.columnWidth, this.fhmAndLtl.drawLtlAt)
@@ -84,7 +84,7 @@ export default class DayColumn extends Component {
const fhmLine = (<Shape
fill="red"
stroke={styles.nfpLine.stroke}
stroke-width={styles.nfpLine.strokeWidth}
strokeWidth={styles.nfpLine.strokeWidth}
d={new Path()
.moveTo(x, x)
.lineTo(x, this.props.columnHeight)
@@ -130,7 +130,7 @@ export default class DayColumn extends Component {
<G>
<Shape
stroke={styles.column.stroke.color}
stroke-width={styles.column.stroke.width}
strokeWidth={styles.column.stroke.width}
d={new Path().lineTo(0, this.props.chartHeight)}
/>
{ columnElements }
-12
View File
@@ -1,12 +0,0 @@
<svg version="1.1"
baseProfile="full"
width="300" height="200"
xmlns="http://www.w3.org/2000/svg">
<path d="
M15 3
Q16.5 6.8 25 18
A12.8 12.8 0 1 1 5 18
Q13.5 6.8 15 3z
" />
</svg>

Before

Width:  |  Height:  |  Size: 217 B

+10 -31
View File
@@ -6,21 +6,13 @@ import {
Dimensions
} from 'react-native'
import { LocalDate } from 'js-joda'
import Svg, { G } from 'react-native-svg'
import Header from '../header'
import { getCycleDay } from '../../db'
import cycleModule from '../../lib/cycle'
import styles from '../../styles'
import * as labels from './labels'
import AppText from '../app-text'
import BleedingIcon from '../../assets/bleeding'
import CervixIcon from '../../assets/cervix'
import DesireIcon from '../../assets/desire'
import MucusIcon from '../../assets/mucus'
import NoteIcon from '../../assets/note'
import PainIcon from '../../assets/pain'
import SexIcon from '../../assets/sex'
import TemperatureIcon from '../../assets/temperature'
import DripIcon from '../../assets/drip-icons'
const bleedingLabels = labels.bleeding
const feelingLabels = labels.mucus.feeling.categories
@@ -183,63 +175,63 @@ export default class CycleDayOverView extends Component {
onPress={() => this.navigate('BleedingEditView')}
data={this.getLabel('bleeding')}
disabled={dateInFuture}
iconName='drip-icon-bleeding'
>
<BleedingIcon viewBox='10 10 320 400' />
</SymptomBox>
<SymptomBox
title='Temperature'
onPress={() => this.navigate('TemperatureEditView')}
data={this.getLabel('temperature')}
disabled={dateInFuture}
iconName='drip-icon-temperature'
>
<TemperatureIcon viewBox='10 10 320 400' />
</SymptomBox>
<SymptomBox
title='Mucus'
onPress={() => this.navigate('MucusEditView')}
data={this.getLabel('mucus')}
disabled={dateInFuture}
iconName='drip-icon-mucus'
>
<MucusIcon viewBox='10 10 320 400' />
</SymptomBox>
<SymptomBox
title='Cervix'
onPress={() => this.navigate('CervixEditView')}
data={this.getLabel('cervix')}
disabled={dateInFuture}
iconName='drip-icon-cervix'
>
<CervixIcon viewBox='10 10 320 440' />
</SymptomBox>
<SymptomBox
title='Desire'
onPress={() => this.navigate('DesireEditView')}
data={this.getLabel('desire')}
disabled={dateInFuture}
iconName='drip-icon-desire'
>
<DesireIcon viewBox='10 10 320 380' />
</SymptomBox>
<SymptomBox
title='Sex'
onPress={() => this.navigate('SexEditView')}
data={this.getLabel('sex')}
disabled={dateInFuture}
iconName='drip-icon-sex'
>
<SexIcon viewBox='10 10 320 400' />
</SymptomBox>
<SymptomBox
title='Pain'
onPress={() => this.navigate('PainEditView')}
data={this.getLabel('pain')}
disabled={dateInFuture}
iconName='drip-icon-pain'
>
<PainIcon viewBox='10 10 300 400' />
</SymptomBox>
<SymptomBox
title='Note'
onPress={() => this.navigate('NoteEditView')}
data={this.getLabel('note')}
iconName='drip-icon-note'
>
<NoteIcon viewBox='10 10 270 400' />
</SymptomBox>
{/* this is just to make the last row adhere to the grid
(and) because there are no pseudo properties in RN */}
@@ -267,20 +259,7 @@ class SymptomBox extends Component {
disabled={this.props.disabled}
>
<View style={[styles.symptomBox, boxActive, disabledStyle]}>
{this.props.children ?
React.Children.map(this.props.children, child => {
return (
<Svg width={100} height={50} viewBox={child.props.viewBox}>
<G fill={d ? 'white' : 'black'}>
{child}
</G>
</Svg>
)
})
: null
}
<DripIcon name={this.props.iconName} size={50} color={d ? 'white' : 'black'}/>
<AppText style={[textActive, disabledStyle]}>
{this.props.title}
</AppText>
+8 -8
View File
@@ -2,7 +2,7 @@ import React, { Component } from 'react'
import { ScrollView, View, TouchableOpacity, TouchableHighlight, Dimensions } from 'react-native'
import { LocalDate, ChronoUnit } from 'js-joda'
import Icon from 'react-native-vector-icons/Entypo'
import Svg, { G } from 'react-native-svg'
import { Surface } from 'react-native/Libraries/ART/ReactNativeART'
import { secondaryColor, cycleDayColor, periodColor } from '../styles'
import { home as labels, bleedingPrediction as predictLabels, shared } from './labels'
import CycleDayIcon from '../assets/home-circle'
@@ -73,15 +73,15 @@ export default class Home extends Component {
style={styles.homeIconElement}
>
<View position='absolute'>
<Svg
<Surface
width={80}
height={80}
viewBox='340 345 170 170'
>
<G fill="none" stroke="#1E0B7A" strokeWidth="2">
<CycleDayIcon/>
</G>
</Svg>
<CycleDayIcon
strokeWidth={2}
scale={0.46}
/>
</Surface>
</View>
<View style={[styles.homeIconTextWrapper, styles.wrapperCycle]}>
<AppTextLight style={styles.iconText}>
@@ -107,7 +107,7 @@ export default class Home extends Component {
style={styles.homeIconElement}
>
<View position='absolute'>
<Drop/>
<Drop scale={0.55}/>
</View>
<View style={[styles.homeIconTextWrapper, styles.wrapperDrop]}>
<AppTextLight style={styles.iconText}>