Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| efd8ed0e08 |
@@ -63,11 +63,11 @@ const SymptomBox = ({
|
|||||||
/>
|
/>
|
||||||
<View style={styles.textContainer}>
|
<View style={styles.textContainer}>
|
||||||
<AppText style={symptomNameStyle}>{t(symptom)}</AppText>
|
<AppText style={symptomNameStyle}>{t(symptom)}</AppText>
|
||||||
{symptomDataToDisplay ? (
|
{symptomDataToDisplay && (
|
||||||
<AppText style={textStyle} numberOfLines={4}>
|
<AppText style={textStyle} numberOfLines={4}>
|
||||||
{symptomDataToDisplay}
|
{symptomDataToDisplay}
|
||||||
</AppText>
|
</AppText>
|
||||||
) : null}
|
)}
|
||||||
</View>
|
</View>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import SelectBoxGroup from './select-box-group'
|
|||||||
import SelectTabGroup from './select-tab-group'
|
import SelectTabGroup from './select-tab-group'
|
||||||
import Temperature from './temperature'
|
import Temperature from './temperature'
|
||||||
|
|
||||||
import { blank, save, shouldShow, symptomPage } from '../helpers/cycle-day'
|
import { blank, save, shouldShow, symtomPage } from '../helpers/cycle-day'
|
||||||
import { showToast } from '../helpers/general'
|
import { showToast } from '../helpers/general'
|
||||||
|
|
||||||
import { fertilityTrackingObservable } from '../../local-storage'
|
import { fertilityTrackingObservable } from '../../local-storage'
|
||||||
@@ -21,10 +21,9 @@ import info from '../../i18n/en/symptom-info'
|
|||||||
import { Colors, Containers, Sizes, Spacing } from '../../styles'
|
import { Colors, Containers, Sizes, Spacing } from '../../styles'
|
||||||
|
|
||||||
const SymptomEditView = ({ date, onClose, symptom, symptomData }) => {
|
const SymptomEditView = ({ date, onClose, symptom, symptomData }) => {
|
||||||
const symptomConfig = symptomPage[symptom]
|
const symptomConfig = symtomPage[symptom]
|
||||||
const [data, setData] = useState(symptomData ? symptomData : blank[symptom])
|
const [data, setData] = useState(symptomData ? symptomData : blank[symptom])
|
||||||
const [shouldShowInfo, setShouldShowInfo] = useState(false)
|
const [shouldShowInfo, setShouldShowInfo] = useState(false)
|
||||||
const isBleeding = symptom === 'bleeding'
|
|
||||||
const getParsedData = () => JSON.parse(JSON.stringify(data))
|
const getParsedData = () => JSON.parse(JSON.stringify(data))
|
||||||
const onPressLearnMore = () => setShouldShowInfo(!shouldShowInfo)
|
const onPressLearnMore = () => setShouldShowInfo(!shouldShowInfo)
|
||||||
const isFertilityTrackingEnabled = fertilityTrackingObservable.value
|
const isFertilityTrackingEnabled = fertilityTrackingObservable.value
|
||||||
@@ -117,15 +116,6 @@ const SymptomEditView = ({ date, onClose, symptom, symptomData }) => {
|
|||||||
style: styles.input,
|
style: styles.input,
|
||||||
textAlignVertical: 'top',
|
textAlignVertical: 'top',
|
||||||
}
|
}
|
||||||
const excludeToggle = shouldShow(symptomConfig.excludeText) && (
|
|
||||||
<Segment style={styles.segmentBorder}>
|
|
||||||
<AppSwitch
|
|
||||||
onToggle={onExcludeToggle}
|
|
||||||
text={symptomPage[symptom].excludeText}
|
|
||||||
value={data.exclude}
|
|
||||||
/>
|
|
||||||
</Segment>
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppModal onClose={onSave}>
|
<AppModal onClose={onSave}>
|
||||||
@@ -140,16 +130,10 @@ const SymptomEditView = ({ date, onClose, symptom, symptomData }) => {
|
|||||||
save={(value, field) => onSaveTemperature(value, field)}
|
save={(value, field) => onSaveTemperature(value, field)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* There should not be a line between the bleeding tab group and the exclude toggle */}
|
|
||||||
{shouldShow(symptomConfig.selectTabGroups) &&
|
{shouldShow(symptomConfig.selectTabGroups) &&
|
||||||
symptomPage[symptom].selectTabGroups.map((group) => {
|
symtomPage[symptom].selectTabGroups.map((group) => {
|
||||||
return (
|
return (
|
||||||
<Segment
|
<Segment key={group.key} style={styles.segmentBorder}>
|
||||||
key={group.key}
|
|
||||||
style={styles.segmentBorder}
|
|
||||||
last={isBleeding}
|
|
||||||
>
|
|
||||||
<AppText style={styles.title}>{group.title}</AppText>
|
<AppText style={styles.title}>{group.title}</AppText>
|
||||||
<SelectTabGroup
|
<SelectTabGroup
|
||||||
activeButton={data[group.key]}
|
activeButton={data[group.key]}
|
||||||
@@ -159,12 +143,8 @@ const SymptomEditView = ({ date, onClose, symptom, symptomData }) => {
|
|||||||
</Segment>
|
</Segment>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|
||||||
{/*for bleeding, we want to move the "exclude" toggle up between the tab and box groups, all other symptoms should still have it at the bottom*/}
|
|
||||||
{isBleeding && excludeToggle}
|
|
||||||
|
|
||||||
{shouldShow(symptomConfig.selectBoxGroups) &&
|
{shouldShow(symptomConfig.selectBoxGroups) &&
|
||||||
symptomPage[symptom].selectBoxGroups.map((group) => {
|
symtomPage[symptom].selectBoxGroups.map((group) => {
|
||||||
const isOtherSelected =
|
const isOtherSelected =
|
||||||
data['other'] !== null &&
|
data['other'] !== null &&
|
||||||
data['other'] !== false &&
|
data['other'] !== false &&
|
||||||
@@ -203,7 +183,7 @@ const SymptomEditView = ({ date, onClose, symptom, symptomData }) => {
|
|||||||
)}
|
)}
|
||||||
{shouldShow(symptomConfig.note) && (
|
{shouldShow(symptomConfig.note) && (
|
||||||
<Segment style={styles.segmentBorder}>
|
<Segment style={styles.segmentBorder}>
|
||||||
<AppText>{symptomPage[symptom].note}</AppText>
|
<AppText>{symtomPage[symptom].note}</AppText>
|
||||||
<AppTextInput
|
<AppTextInput
|
||||||
{...inputProps}
|
{...inputProps}
|
||||||
onChangeText={onEditNote}
|
onChangeText={onEditNote}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ const noteDescription = labels.noteExplainer
|
|||||||
const painLabels = labels.pain.categories
|
const painLabels = labels.pain.categories
|
||||||
const sexLabels = labels.sex.categories
|
const sexLabels = labels.sex.categories
|
||||||
const temperatureLabels = labels.temperature
|
const temperatureLabels = labels.temperature
|
||||||
const productLabels = labels.products.categories
|
|
||||||
|
|
||||||
const minutes = ChronoUnit.MINUTES
|
const minutes = ChronoUnit.MINUTES
|
||||||
|
|
||||||
@@ -61,15 +60,6 @@ export const blank = {
|
|||||||
bleeding: {
|
bleeding: {
|
||||||
exclude: false,
|
exclude: false,
|
||||||
value: null,
|
value: null,
|
||||||
pad: null,
|
|
||||||
tampon: null,
|
|
||||||
underwear: null,
|
|
||||||
cup: null,
|
|
||||||
softTampon: null,
|
|
||||||
disk: null,
|
|
||||||
none: null,
|
|
||||||
other: null,
|
|
||||||
note: null,
|
|
||||||
},
|
},
|
||||||
cervix: {
|
cervix: {
|
||||||
exclude: false,
|
exclude: false,
|
||||||
@@ -135,10 +125,11 @@ export const blank = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const symptomPage = {
|
export const symtomPage = {
|
||||||
bleeding: {
|
bleeding: {
|
||||||
excludeText: labels.bleeding.exclude.explainer,
|
excludeText: labels.bleeding.exclude.explainer,
|
||||||
note: null,
|
note: null,
|
||||||
|
selectBoxGroups: null,
|
||||||
selectTabGroups: [
|
selectTabGroups: [
|
||||||
{
|
{
|
||||||
key: 'value',
|
key: 'value',
|
||||||
@@ -146,13 +137,6 @@ export const symptomPage = {
|
|||||||
title: labels.bleeding.heaviness.explainer,
|
title: labels.bleeding.heaviness.explainer,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
selectBoxGroups: [
|
|
||||||
{
|
|
||||||
key: 'products',
|
|
||||||
options: productLabels,
|
|
||||||
title: labels.products.explainer,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
cervix: {
|
cervix: {
|
||||||
excludeText: cervixLabels.excludeExplainer,
|
excludeText: cervixLabels.excludeExplainer,
|
||||||
@@ -262,7 +246,12 @@ export const symptomPage = {
|
|||||||
|
|
||||||
export const save = {
|
export const save = {
|
||||||
bleeding: (data, date, shouldDeleteData) => {
|
bleeding: (data, date, shouldDeleteData) => {
|
||||||
saveBoxSymptom(data, date, shouldDeleteData, 'bleeding')
|
const { exclude, value } = data
|
||||||
|
const isDataEntered = isNumber(value)
|
||||||
|
const valuesToSave =
|
||||||
|
shouldDeleteData || !isDataEntered ? null : { value, exclude }
|
||||||
|
|
||||||
|
saveSymptom('bleeding', date, valuesToSave)
|
||||||
},
|
},
|
||||||
cervix: (data, date, shouldDeleteData) => {
|
cervix: (data, date, shouldDeleteData) => {
|
||||||
const { opening, firmness, position, exclude } = data
|
const { opening, firmness, position, exclude } = data
|
||||||
@@ -340,36 +329,10 @@ const saveBoxSymptom = (data, date, shouldDeleteData, symptom) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const label = {
|
const label = {
|
||||||
bleeding: (bleeding) => {
|
bleeding: ({ value, exclude }) => {
|
||||||
bleeding = mapRealmObjToJsObj(bleeding)
|
if (isNumber(value)) {
|
||||||
const bleedingLabel = []
|
const bleedingLabel = bleedingLabels[value]
|
||||||
if (bleeding && Object.values({ ...bleeding }).some((val) => val)) {
|
return exclude ? `(${bleedingLabel})` : bleedingLabel
|
||||||
Object.keys(bleeding).forEach((key) => {
|
|
||||||
if (bleeding[key] != null && key === 'value') {
|
|
||||||
bleedingLabel.push(
|
|
||||||
bleeding.exclude
|
|
||||||
? `(${bleedingLabels[bleeding[key]]})`
|
|
||||||
: bleedingLabels[bleeding[key]]
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
bleeding[key] &&
|
|
||||||
key !== 'other' &&
|
|
||||||
key !== 'note' &&
|
|
||||||
key !== 'value' &&
|
|
||||||
key !== 'exclude'
|
|
||||||
) {
|
|
||||||
bleedingLabel.push(bleedingLabels[key] || productLabels[key])
|
|
||||||
}
|
|
||||||
if (key === 'other' && bleeding.other) {
|
|
||||||
let label = productLabels[key]
|
|
||||||
if (bleeding.note) {
|
|
||||||
label = `${label} (${bleeding.note})`
|
|
||||||
}
|
|
||||||
bleedingLabel.push(label)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return bleedingLabel.join(', ')
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
temperature: ({ value, time, exclude }) => {
|
temperature: ({ value, time, exclude }) => {
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ export function getBleedingDaysSortedByDate() {
|
|||||||
return db
|
return db
|
||||||
.objects('CycleDay')
|
.objects('CycleDay')
|
||||||
.filtered('bleeding != null')
|
.filtered('bleeding != null')
|
||||||
.filtered('bleeding.value != null')
|
|
||||||
.sorted('date', true)
|
.sorted('date', true)
|
||||||
}
|
}
|
||||||
export function getTemperatureDaysSortedByDate() {
|
export function getTemperatureDaysSortedByDate() {
|
||||||
@@ -89,8 +88,9 @@ export function getCycleStartsSortedByDate() {
|
|||||||
export function saveSymptom(symptom, date, val) {
|
export function saveSymptom(symptom, date, val) {
|
||||||
let cycleDay = getCycleDay(date)
|
let cycleDay = getCycleDay(date)
|
||||||
if (!cycleDay) cycleDay = createCycleDay(date)
|
if (!cycleDay) cycleDay = createCycleDay(date)
|
||||||
|
|
||||||
db.write(() => {
|
db.write(() => {
|
||||||
if (symptom === 'bleeding' && val != null && val.value != null) {
|
if (symptom === 'bleeding') {
|
||||||
const mensesDaysAfter = getMensesDaysRightAfter(cycleDay)
|
const mensesDaysAfter = getMensesDaysRightAfter(cycleDay)
|
||||||
maybeSetNewCycleStart({
|
maybeSetNewCycleStart({
|
||||||
val,
|
val,
|
||||||
|
|||||||
@@ -1,195 +0,0 @@
|
|||||||
const TemperatureSchema = {
|
|
||||||
name: 'Temperature',
|
|
||||||
properties: {
|
|
||||||
value: 'double',
|
|
||||||
exclude: 'bool',
|
|
||||||
time: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
note: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const BleedingSchema = {
|
|
||||||
name: 'Bleeding',
|
|
||||||
properties: {
|
|
||||||
value: { type: 'int', optional: true },
|
|
||||||
exclude: 'bool',
|
|
||||||
pad: { type: 'bool', optional: true },
|
|
||||||
tampon: { type: 'bool', optional: true },
|
|
||||||
underwear: { type: 'bool', optional: true },
|
|
||||||
cup: { type: 'bool', optional: true },
|
|
||||||
softTampon: { type: 'bool', optional: true },
|
|
||||||
disk: { type: 'bool', optional: true },
|
|
||||||
none: { type: 'bool', optional: true },
|
|
||||||
other: { type: 'bool', optional: true },
|
|
||||||
note: { type: 'string', optional: true },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const MucusSchema = {
|
|
||||||
name: 'Mucus',
|
|
||||||
properties: {
|
|
||||||
feeling: { type: 'int', optional: true },
|
|
||||||
texture: { type: 'int', optional: true },
|
|
||||||
value: { type: 'int', optional: true },
|
|
||||||
exclude: 'bool',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const CervixSchema = {
|
|
||||||
name: 'Cervix',
|
|
||||||
properties: {
|
|
||||||
opening: { type: 'int', optional: true },
|
|
||||||
firmness: { type: 'int', optional: true },
|
|
||||||
position: { type: 'int', optional: true },
|
|
||||||
exclude: 'bool',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const NoteSchema = {
|
|
||||||
name: 'Note',
|
|
||||||
properties: {
|
|
||||||
value: 'string',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const DesireSchema = {
|
|
||||||
name: 'Desire',
|
|
||||||
properties: {
|
|
||||||
value: 'int',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const SexSchema = {
|
|
||||||
name: 'Sex',
|
|
||||||
properties: {
|
|
||||||
solo: { type: 'bool', optional: true },
|
|
||||||
partner: { type: 'bool', optional: true },
|
|
||||||
condom: { type: 'bool', optional: true },
|
|
||||||
pill: { type: 'bool', optional: true },
|
|
||||||
iud: { type: 'bool', optional: true },
|
|
||||||
patch: { type: 'bool', optional: true },
|
|
||||||
ring: { type: 'bool', optional: true },
|
|
||||||
implant: { type: 'bool', optional: true },
|
|
||||||
diaphragm: { type: 'bool', optional: true },
|
|
||||||
none: { type: 'bool', optional: true },
|
|
||||||
other: { type: 'bool', optional: true },
|
|
||||||
note: { type: 'string', optional: true },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const PainSchema = {
|
|
||||||
name: 'Pain',
|
|
||||||
properties: {
|
|
||||||
cramps: { type: 'bool', optional: true },
|
|
||||||
ovulationPain: { type: 'bool', optional: true },
|
|
||||||
headache: { type: 'bool', optional: true },
|
|
||||||
backache: { type: 'bool', optional: true },
|
|
||||||
nausea: { type: 'bool', optional: true },
|
|
||||||
tenderBreasts: { type: 'bool', optional: true },
|
|
||||||
migraine: { type: 'bool', optional: true },
|
|
||||||
other: { type: 'bool', optional: true },
|
|
||||||
note: { type: 'string', optional: true },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const MoodSchema = {
|
|
||||||
name: 'Mood',
|
|
||||||
properties: {
|
|
||||||
happy: { type: 'bool', optional: true },
|
|
||||||
sad: { type: 'bool', optional: true },
|
|
||||||
stressed: { type: 'bool', optional: true },
|
|
||||||
balanced: { type: 'bool', optional: true },
|
|
||||||
fine: { type: 'bool', optional: true },
|
|
||||||
anxious: { type: 'bool', optional: true },
|
|
||||||
energetic: { type: 'bool', optional: true },
|
|
||||||
fatigue: { type: 'bool', optional: true },
|
|
||||||
angry: { type: 'bool', optional: true },
|
|
||||||
other: { type: 'bool', optional: true },
|
|
||||||
note: { type: 'string', optional: true },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const CycleDaySchema = {
|
|
||||||
name: 'CycleDay',
|
|
||||||
primaryKey: 'date',
|
|
||||||
properties: {
|
|
||||||
date: 'string',
|
|
||||||
temperature: {
|
|
||||||
type: 'Temperature',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
isCycleStart: 'bool',
|
|
||||||
bleeding: {
|
|
||||||
type: 'Bleeding',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
mucus: {
|
|
||||||
type: 'Mucus',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
cervix: {
|
|
||||||
type: 'Cervix',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
note: {
|
|
||||||
type: 'Note',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
desire: {
|
|
||||||
type: 'Desire',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
sex: {
|
|
||||||
type: 'Sex',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
pain: {
|
|
||||||
type: 'Pain',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
mood: {
|
|
||||||
type: 'Mood',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
schema: [
|
|
||||||
CycleDaySchema,
|
|
||||||
TemperatureSchema,
|
|
||||||
BleedingSchema,
|
|
||||||
MucusSchema,
|
|
||||||
CervixSchema,
|
|
||||||
NoteSchema,
|
|
||||||
DesireSchema,
|
|
||||||
SexSchema,
|
|
||||||
PainSchema,
|
|
||||||
MoodSchema,
|
|
||||||
],
|
|
||||||
schemaVersion: 5,
|
|
||||||
migration: (oldRealm, newRealm) => {
|
|
||||||
if (oldRealm.schemaVersion < 5) {
|
|
||||||
const newObjects = newRealm.objects('Bleeding')
|
|
||||||
|
|
||||||
// loop through all objects and assign a default value for new properties
|
|
||||||
for (let i = 0; i < newObjects.length; i++) {
|
|
||||||
newObjects[i].pad = false
|
|
||||||
newObjects[i].tampon = false
|
|
||||||
newObjects[i].underwear = false
|
|
||||||
newObjects[i].cup = false
|
|
||||||
newObjects[i].softTampon = false
|
|
||||||
newObjects[i].disk = false
|
|
||||||
newObjects[i].none = false
|
|
||||||
newObjects[i].other = false
|
|
||||||
newObjects[i].note = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -3,6 +3,5 @@ import schema1 from './1.js'
|
|||||||
import schema2 from './2.js'
|
import schema2 from './2.js'
|
||||||
import schema3 from './3.js'
|
import schema3 from './3.js'
|
||||||
import schema4 from './4.js'
|
import schema4 from './4.js'
|
||||||
import schema5 from './5.js'
|
|
||||||
|
|
||||||
export default [schema0, schema1, schema2, schema3, schema4, schema5]
|
export default [schema0, schema1, schema2, schema3, schema4]
|
||||||
@@ -13,21 +13,6 @@ export const bleeding = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const products = {
|
|
||||||
categories: {
|
|
||||||
pad: 'pad',
|
|
||||||
tampon: 'tampon',
|
|
||||||
underwear: 'underwear',
|
|
||||||
cup: 'cup',
|
|
||||||
softTampon: 'soft tampon',
|
|
||||||
disk: 'disk',
|
|
||||||
none: 'none',
|
|
||||||
other: 'other',
|
|
||||||
},
|
|
||||||
header: 'period products',
|
|
||||||
explainer: 'Did you use period products?',
|
|
||||||
}
|
|
||||||
|
|
||||||
export const cervix = {
|
export const cervix = {
|
||||||
subcategories: {
|
subcategories: {
|
||||||
opening: 'opening',
|
opening: 'opening',
|
||||||
|
|||||||
|
After Width: | Height: | Size: 176 KiB |
|
Before Width: | Height: | Size: 190 KiB |
|
Before Width: | Height: | Size: 136 KiB |
|
Before Width: | Height: | Size: 104 KiB |
|
After Width: | Height: | Size: 138 KiB |
|
Before Width: | Height: | Size: 120 KiB After Width: | Height: | Size: 120 KiB |
|
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 190 KiB |
|
Before Width: | Height: | Size: 152 KiB After Width: | Height: | Size: 152 KiB |
|
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 129 KiB |
|
After Width: | Height: | Size: 131 KiB |
|
After Width: | Height: | Size: 172 KiB |
@@ -1 +1 @@
|
|||||||
drip. menstrual cycle and fertility tracking
|
drip. period & fertility tracker
|
||||||