Compare commits

..

23 Commits

Author SHA1 Message Date
Sofiya Tepikin 2c4536fdee Bump i18next from 22.0.2 to 22.4.13
Bumps [i18next](https://github.com/i18next/i18next) from 22.0.2 to 22.4.13.
- [Release notes](https://github.com/i18next/i18next/releases)
- [Changelog](https://github.com/i18next/i18next/blob/master/CHANGELOG.md)
- [Commits](https://github.com/i18next/i18next/compare/v22.0.2...v22.4.13)
2023-03-21 09:05:28 +00:00
Sofiya Tepikin f11eb3d1a1 Merge branch 'fix/outdated-snapshot' into 'main'
Fix outdated snapshot

See merge request bloodyhealth/drip!593
2023-01-19 09:31:57 +00:00
Sofiya Tepikin 5f83464649 Fix outdated snapshot 2023-01-19 10:23:48 +01:00
Sofiya Tepikin 6e2e03f39e Merge branch 'chore/update-babel-dependencies' into 'main'
Chore/update babel dependencies

See merge request bloodyhealth/drip!579
2022-11-13 20:00:23 +00:00
Sofiya Tepikin cc62e24229 Chore/update babel dependencies 2022-11-13 20:00:23 +00:00
Sofiya Tepikin cd24522b4d Merge branch '618/Refactor-import-section-to-use-translation-lib' into 'main'
618 Refactor import section to use translation lib

See merge request bloodyhealth/drip!555
2022-11-06 14:47:05 +00:00
Lisa 446638d6de 618 Refactor import section to use translation lib 2022-11-06 14:47:05 +00:00
Lisa ae23ef2c58 Merge branch '624/Use-translation-library-in-tutorial' into 'main'
624 Use translation library in tutorial

See merge request bloodyhealth/drip!573
2022-11-06 14:43:15 +00:00
Lisa 38b9e8b31f Merge branch 'dependabot-npm_and_yarn-react-i18next-12.0.0' into 'main'
Bump react-i18next from 11.18.3 to 12.0.0

See merge request bloodyhealth/drip!571
2022-10-23 10:11:06 +00:00
Lisa Hillebrand 84d657cabb 614 Uppercase tutorial component 2022-10-23 11:56:32 +02:00
Lisa Hillebrand 4573b93921 624 Use translation library for chart tutorial 2022-10-23 11:54:11 +02:00
Sofiya Tepikin ab88a4c163 Bump react-i18next from 11.18.3 to 12.0.0
Bumps [react-i18next](https://github.com/i18next/react-i18next) from 11.18.3 to 12.0.0.
- [Release notes](https://github.com/i18next/react-i18next/releases)
- [Changelog](https://github.com/i18next/react-i18next/blob/master/CHANGELOG.md)
- [Commits](https://github.com/i18next/react-i18next/compare/v11.18.3...v12.0.0)
2022-10-23 09:06:40 +00:00
Lisa baaf89c04e Merge branch 'dependabot-npm_and_yarn-i18next-22.0.2' into 'main'
Bump i18next from 21.9.0 to 22.0.2

See merge request bloodyhealth/drip!570
2022-10-23 08:13:38 +00:00
Sofiya Tepikin d476f6c143 Bump i18next from 21.9.0 to 22.0.2
Bumps [i18next](https://github.com/i18next/i18next) from 21.9.0 to 22.0.2.
- [Release notes](https://github.com/i18next/i18next/releases)
- [Changelog](https://github.com/i18next/i18next/blob/master/CHANGELOG.md)
- [Commits](https://github.com/i18next/i18next/compare/v21.9.0...v22.0.2)
2022-10-21 09:07:30 +00:00
Sofiya Tepikin b56e0818f3 Merge branch '619/Create-test-utils-for-react-testing-library' into 'main'
619 Create test utils for react testing library

See merge request bloodyhealth/drip!556
2022-10-19 13:17:19 +00:00
Lisa 1b5ffaf5d6 619 Create test utils for react testing library 2022-10-19 13:17:19 +00:00
Sofiya Tepikin f68cc2b49e Merge branch 'fix/exclude-babel-core-from-dependabot' into 'main'
Exclude @babel/core library from dependabot updates

See merge request bloodyhealth/drip!560
2022-10-05 11:31:38 +00:00
Sofiya Tepikin 27d430a465 Exclude @babel/core library from dependabot updates 2022-10-05 13:28:49 +02:00
Sofiya Tepikin 28f52e2cea Merge branch '617/Remove-weblate-reference-from-readme' into 'main'
617 Remove reference to weblate from readme

See merge request bloodyhealth/drip!554
2022-10-05 10:10:46 +00:00
Lisa 3f87f298fb Merge branch '615-Use-translation-library-for-pages' into 'main'
615 Use translation library for pages

Closes #615

See merge request bloodyhealth/drip!530
2022-10-01 08:13:24 +00:00
Lisa Hillebrand 585f32863d 617 Remove reference to weblate from readme 2022-09-30 11:58:11 +02:00
Lisa Hillebrand 51e1c95e71 615 Remove unused page labels 2022-09-30 11:39:16 +02:00
Lisa Hillebrand 36c33c69b7 615 Use translation library for bottom menu 2022-09-30 11:39:00 +02:00
28 changed files with 1129 additions and 967 deletions
+1
View File
@@ -14,3 +14,4 @@ updates:
- dependency-name: 'react' - dependency-name: 'react'
- dependency-name: 'react-native' - dependency-name: 'react-native'
- dependency-name: 'react-native-push-notifications' - dependency-name: 'react-native-push-notifications'
- dependency-name: '@babel/core'
-4
View File
@@ -201,7 +201,3 @@ More information about how the app calculates fertility status and bleeding pred
react-native link react-native link
5. You should be able to use the icon now within drip, e.g. in Cycle Day Overview and on the chart. 5. You should be able to use the icon now within drip, e.g. in Cycle Day Overview and on the chart.
## Translation
We are using [Weblate](https://weblate.org/) as translation software.
@@ -6,16 +6,17 @@ import AppText from '../common/app-text'
import CloseIcon from '../common/close-icon' import CloseIcon from '../common/close-icon'
import { Containers, Spacing } from '../../styles' import { Containers, Spacing } from '../../styles'
import { chart } from '../../i18n/en/labels' import { useTranslation } from 'react-i18next'
const image = require('../../assets/swipe.png') const image = require('../../assets/swipe.png')
const Tutorial = ({ onClose }) => { const Tutorial = ({ onClose }) => {
const { t } = useTranslation()
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Image resizeMode="contain" source={image} style={styles.image} /> <Image resizeMode="contain" source={image} style={styles.image} />
<View style={styles.textContainer}> <View style={styles.textContainer}>
<AppText>{chart.tutorial}</AppText> <AppText>{t('chart.tutorial')}</AppText>
</View> </View>
<CloseIcon onClose={onClose} /> <CloseIcon onClose={onClose} />
</View> </View>
+1 -1
View File
@@ -9,7 +9,7 @@ import HorizontalGrid from './horizontal-grid'
import MainGrid from './main-grid' import MainGrid from './main-grid'
import NoData from './no-data' import NoData from './no-data'
import NoTemperature from './no-temperature' import NoTemperature from './no-temperature'
import Tutorial from './tutorial' import Tutorial from './Tutorial'
import YAxis from './y-axis' import YAxis from './y-axis'
import { getCycleDaysSortedByDate } from '../../db' import { getCycleDaysSortedByDate } from '../../db'
+2 -5
View File
@@ -8,15 +8,13 @@ import { Sizes } from '../../styles'
import { CHART_TICK_WIDTH } from '../../config' import { CHART_TICK_WIDTH } from '../../config'
const Tick = ({ yPosition, height, isBold, shouldShowLabel, label }) => { const Tick = ({ yPosition, height, isBold, shouldShowLabel, label }) => {
const top = yPosition - height / 2 - 4 const top = yPosition - height / 2
const containerStyle = [styles.container, { flexBasis: height, height, top }] const containerStyle = [styles.container, { flexBasis: height, height, top }]
const textStyle = isBold ? styles.textBold : styles.textNormal const textStyle = isBold ? styles.textBold : styles.textNormal
if (!shouldShowLabel) return null
return ( return (
<View style={containerStyle}> <View style={containerStyle}>
<AppText style={textStyle}>{label}</AppText> <AppText style={textStyle}>{shouldShowLabel && label}</AppText>
</View> </View>
) )
} }
@@ -38,7 +36,6 @@ const styles = StyleSheet.create({
position: 'absolute', position: 'absolute',
right: 0, right: 0,
width: CHART_TICK_WIDTH, width: CHART_TICK_WIDTH,
minHeight: Sizes.base + 2,
}, },
textBold: { textBold: {
fontSize: Sizes.base, fontSize: Sizes.base,
+6 -11
View File
@@ -3,7 +3,6 @@ import { LocalDate } from '@js-joda/core'
import { scaleObservable, unitObservable } from '../../local-storage' import { scaleObservable, unitObservable } from '../../local-storage'
import { getCycleStatusForDay } from '../../lib/sympto-adapter' import { getCycleStatusForDay } from '../../lib/sympto-adapter'
import { getCycleDay, getAmountOfCycleDays } from '../../db' import { getCycleDay, getAmountOfCycleDays } from '../../db'
import { Sizes } from '../../styles'
//YAxis helpers //YAxis helpers
@@ -51,18 +50,14 @@ export function getTickList(columnHeight) {
const label = tick.toFixed(1) const label = tick.toFixed(1)
let shouldShowLabel let shouldShowLabel
// when units === 0.1 and tick height is big enough, we show temp values with step 0.2 // when temp range <= 2, units === 0.1 we show temp values with step 0.2
// when units === 0.5 and tick height is not big enough, we show temp values with step 1 // when temp range > 2, units === 0.5 we show temp values with step 0.5
// otherwise we show temp values with step 0.5
switch (true) { if (unit === 0.1) {
case unit === 0.1 && tickHeight > Sizes.base + 2: // show label with step 0.2
shouldShowLabel = !((label * 10) % 2) shouldShowLabel = !((label * 10) % 2)
break } else {
case unit === 0.5 && tickHeight <= Sizes.base + 2: // show label with step 0.5
shouldShowLabel = !((label * 10) % 10)
break
default:
shouldShowLabel = !((label * 10) % 5) shouldShowLabel = !((label * 10) % 5)
} }
+6 -3
View File
@@ -6,20 +6,23 @@ import MenuItem from './menu-item'
import { Containers } from '../../styles' import { Containers } from '../../styles'
import { pages } from '../pages' import { pages } from '../pages'
import { useTranslation } from 'react-i18next'
const Menu = ({ currentPage, navigate }) => { const Menu = ({ currentPage, navigate }) => {
const menuItems = pages.filter((page) => page.isInMenu) const menuItems = pages.filter((page) => page.isInMenu)
const { t } = useTranslation(null, { keyPrefix: 'bottomMenu' })
return ( return (
<View style={styles.container}> <View style={styles.container}>
{menuItems.map(({ icon, label, component }) => { {menuItems.map(({ icon, labelKey, component }) => {
return ( return (
<MenuItem <MenuItem
isActive={component === currentPage} isActive={component === currentPage}
onPress={() => navigate(component)} onPress={() => navigate(component)}
icon={icon} icon={icon}
key={label} key={labelKey}
label={label} label={t(labelKey)}
/> />
) )
})} })}
+3 -15
View File
@@ -1,75 +1,63 @@
import settingsViews from './settings' import settingsViews from './settings'
import settingsLabels from '../i18n/en/settings'
const labels = settingsLabels.menuItems
export const pages = [ export const pages = [
{ {
component: 'Home', component: 'Home',
icon: 'home', icon: 'home',
label: 'Home',
}, },
{ {
component: 'Calendar', component: 'Calendar',
icon: 'calendar', icon: 'calendar',
isInMenu: true, isInMenu: true,
label: 'Calendar', labelKey: 'calendar',
parent: 'Home', parent: 'Home',
}, },
{ {
component: 'Chart', component: 'Chart',
icon: 'chart', icon: 'chart',
isInMenu: true, isInMenu: true,
label: 'Chart', labelKey: 'chart',
parent: 'Home', parent: 'Home',
}, },
{ {
component: 'Stats', component: 'Stats',
icon: 'statistics', icon: 'statistics',
isInMenu: true, isInMenu: true,
label: 'Stats', labelKey: 'stats',
parent: 'Home', parent: 'Home',
}, },
{ {
children: Object.keys(settingsViews), children: Object.keys(settingsViews),
component: 'SettingsMenu', component: 'SettingsMenu',
icon: 'settings', icon: 'settings',
label: 'Settings',
parent: 'Home', parent: 'Home',
}, },
{ {
component: 'Reminders', component: 'Reminders',
label: labels.reminders.name,
parent: 'SettingsMenu', parent: 'SettingsMenu',
}, },
{ {
component: 'NfpSettings', component: 'NfpSettings',
label: labels.nfpSettings.name,
parent: 'SettingsMenu', parent: 'SettingsMenu',
}, },
{ {
component: 'DataManagement', component: 'DataManagement',
label: labels.dataManagement.name,
parent: 'SettingsMenu', parent: 'SettingsMenu',
}, },
{ {
component: 'Password', component: 'Password',
label: labels.password.name,
parent: 'SettingsMenu', parent: 'SettingsMenu',
}, },
{ {
component: 'About', component: 'About',
label: 'About',
parent: 'SettingsMenu', parent: 'SettingsMenu',
}, },
{ {
component: 'License', component: 'License',
label: 'License',
parent: 'SettingsMenu', parent: 'SettingsMenu',
}, },
{ {
component: 'PrivacyPolicy', component: 'PrivacyPolicy',
label: 'PrivacyPolicy',
parent: 'SettingsMenu', parent: 'SettingsMenu',
}, },
{ {
@@ -6,40 +6,23 @@ import AppText from '../../common/app-text'
import Button from '../../common/button' import Button from '../../common/button'
import Segment from '../../common/segment' import Segment from '../../common/segment'
import { openImportDialog, getFileContent, importData } from './import-dialog'
import openShareDialogAndExport from './export-dialog' import openShareDialogAndExport from './export-dialog'
import DeleteData from './delete-data' import DeleteData from './delete-data'
import labels from '../../../i18n/en/settings' import labels from '../../../i18n/en/settings'
import { ACTION_DELETE, ACTION_EXPORT, ACTION_IMPORT } from '../../../config' import ImportData from './ImportData'
const DataManagement = () => { const DataManagement = () => {
const [isLoading, setIsLoading] = useState(false) const [isLoading, setIsLoading] = useState(false)
const [currentAction, setCurrentAction] = useState(null) const [isDeletingData, setIsDeletingData] = useState(false)
const startImportFlow = async (shouldDeleteExistingData) => {
setIsLoading(true)
const fileContent = await getFileContent()
if (fileContent) {
await importData(shouldDeleteExistingData, fileContent)
}
setIsLoading(false)
}
const startExport = () => { const startExport = () => {
setCurrentAction(ACTION_EXPORT) setIsDeletingData(false)
openShareDialogAndExport() openShareDialogAndExport()
} }
const startImport = () => {
setCurrentAction(ACTION_IMPORT)
openImportDialog(startImportFlow)
}
if (isLoading) return <AppLoadingView /> if (isLoading) return <AppLoadingView />
const isDeletingData = currentAction === ACTION_DELETE
return ( return (
<AppPage> <AppPage>
<Segment title={labels.export.button}> <Segment title={labels.export.button}>
@@ -48,17 +31,15 @@ const DataManagement = () => {
{labels.export.button} {labels.export.button}
</Button> </Button>
</Segment> </Segment>
<Segment title={labels.import.button}> <ImportData
<AppText>{labels.import.segmentExplainer}</AppText> resetIsDeletingData={() => setIsDeletingData(false)}
<Button isCTA onPress={startImport}> setIsLoading={setIsLoading}
{labels.import.button} />
</Button>
</Segment>
<Segment title={labels.deleteSegment.title} last> <Segment title={labels.deleteSegment.title} last>
<AppText>{labels.deleteSegment.explainer}</AppText> <AppText>{labels.deleteSegment.explainer}</AppText>
<DeleteData <DeleteData
isDeletingData={isDeletingData} isDeletingData={isDeletingData}
onStartDeletion={() => setCurrentAction(ACTION_DELETE)} onStartDeletion={() => setIsDeletingData(true)}
/> />
</Segment> </Segment>
</AppPage> </AppPage>
@@ -0,0 +1,97 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Alert } from 'react-native'
import DocumentPicker from 'react-native-document-picker'
import rnfs from 'react-native-fs'
import importCsv from '../../../lib/import-export/import-from-csv'
import alertError from '../common/alert-error'
import Segment from '../../common/segment'
import AppText from '../../common/app-text'
import Button from '../../common/button'
import { useTranslation } from 'react-i18next'
export default function ImportData({ resetIsDeletingData, setIsLoading }) {
const { t } = useTranslation(null, {
keyPrefix: 'hamburgerMenu.settings.data.import',
})
async function startImport(shouldDeleteExistingData) {
setIsLoading(true)
await importData(shouldDeleteExistingData)
setIsLoading(false)
}
async function getFileInfo() {
try {
const fileInfo = await DocumentPicker.pickSingle({
type: [DocumentPicker.types.csv, 'text/comma-separated-values'],
})
return fileInfo
} catch (error) {
if (DocumentPicker.isCancel(error)) return // User cancelled the picker, exit any dialogs or menus and move on
showImportErrorAlert(error)
}
}
async function getFileContent() {
const fileInfo = await getFileInfo()
if (!fileInfo) return null
try {
const fileContent = await rnfs.readFile(fileInfo.uri, 'utf8')
return fileContent
} catch (err) {
return showImportErrorAlert(t('error.couldNotOpenFile'))
}
}
async function importData(shouldDeleteExistingData) {
const fileContent = await getFileContent()
if (!fileContent) return
try {
await importCsv(fileContent, shouldDeleteExistingData)
Alert.alert(t('success.title'), t('success.message'))
} catch (err) {
showImportErrorAlert(err.message)
}
}
function openImportDialog() {
resetIsDeletingData()
Alert.alert(t('dialog.title'), t('dialog.message'), [
{
text: t('dialog.cancel'),
style: 'cancel',
onPress: () => {},
},
{
text: t('dialog.replace'),
onPress: () => startImport(false),
},
{
text: t('dialog.delete'),
onPress: () => startImport(true),
},
])
}
function showImportErrorAlert(message) {
const errorMessage = t('error.noDataImported', { message })
alertError(errorMessage)
}
return (
<Segment title={t('button')}>
<AppText>{t('segmentExplainer')}</AppText>
<Button isCTA onPress={openImportDialog}>
{t('button')}
</Button>
</Segment>
)
}
ImportData.propTypes = {
resetIsDeletingData: PropTypes.func.isRequired,
setIsLoading: PropTypes.func.isRequired,
}
@@ -1,64 +0,0 @@
import { Alert } from 'react-native'
import DocumentPicker from 'react-native-document-picker'
import rnfs from 'react-native-fs'
import importCsv from '../../../lib/import-export/import-from-csv'
import { shared as sharedLabels } from '../../../i18n/en/labels'
import labels from '../../../i18n/en/settings'
import alertError from '../common/alert-error'
export function openImportDialog(onImportData) {
Alert.alert(labels.import.title, labels.import.message, [
{
text: sharedLabels.cancel,
style: 'cancel',
onPress: () => {},
},
{
text: labels.import.replaceOption,
onPress: () => onImportData(false),
},
{
text: labels.import.deleteOption,
onPress: () => onImportData(true),
},
])
}
export async function getFileContent() {
let fileInfo
try {
fileInfo = await DocumentPicker.pickSingle({
type: [DocumentPicker.types.csv, 'text/comma-separated-values'],
})
} catch (error) {
if (DocumentPicker.isCancel(error)) {
// User cancelled the picker, exit any dialogs or menus and move on
return
} else {
importError(error)
}
}
let fileContent
try {
fileContent = await rnfs.readFile(fileInfo.uri, 'utf8')
} catch (err) {
return importError(labels.import.errors.couldNotOpenFile)
}
return fileContent
}
export async function importData(shouldDeleteExistingData, fileContent) {
try {
await importCsv(fileContent, shouldDeleteExistingData)
Alert.alert(sharedLabels.successTitle, labels.import.success.message)
} catch (err) {
importError(err.message)
}
}
function importError(msg) {
const postFixed = `${msg}\n\n${labels.import.errors.postFix}`
alertError(postFixed)
}
+1 -1
View File
@@ -1,6 +1,6 @@
import Reminders from './reminders/reminders' import Reminders from './reminders/reminders'
import NfpSettings from './nfp-settings' import NfpSettings from './nfp-settings'
import DataManagement from './data-management' import DataManagement from './data-management/DataManagement'
import Password from './password' import Password from './password'
import About from './About' import About from './About'
import License from './License' import License from './License'
+1 -5
View File
@@ -1,10 +1,6 @@
import { PixelRatio, StatusBar } from 'react-native' import { PixelRatio, StatusBar } from 'react-native'
import { scale, verticalScale } from 'react-native-size-matters' import { scale, verticalScale } from 'react-native-size-matters'
export const ACTION_DELETE = 'delete'
export const ACTION_EXPORT = 'export'
export const ACTION_IMPORT = 'import'
export const SYMPTOMS = [ export const SYMPTOMS = [
'bleeding', 'bleeding',
'temperature', 'temperature',
@@ -40,7 +36,7 @@ export const HIT_SLOP = {
top: verticalScale(20), top: verticalScale(20),
bottom: verticalScale(20), bottom: verticalScale(20),
left: scale(20), left: scale(20),
right: scale(20) right: scale(20),
} }
export const STATUSBAR_HEIGHT = StatusBar.currentHeight export const STATUSBAR_HEIGHT = StatusBar.currentHeight
+31
View File
@@ -1,4 +1,12 @@
{ {
"bottomMenu": {
"calendar": "Calendar",
"chart": "Chart",
"stats": "Stats"
},
"chart": {
"tutorial": "You can swipe the chart to view more dates."
},
"cycleDay": { "cycleDay": {
"symptomBox": { "symptomBox": {
"bleeding": "Bleeding", "bleeding": "Bleeding",
@@ -80,6 +88,29 @@
} }
}, },
"settings": { "settings": {
"data": {
"import": {
"button": "Import data",
"dialog": {
"cancel": "Cancel",
"delete": "Import and delete existing",
"message": "There are two options for the import:\n\n1. Keep existing cycle days and replace only the ones in the import file.\n\n2. Delete all existing cycle days and import cycle days from file",
"replace": "Import and replace",
"title": "Keep existing data?"
},
"error": {
"couldNotOpenFile": "Could not open file",
"futureEdit": "Future dates may only contain a note, no other symptoms",
"incorrectColumns": "Expected CSV column titles to be {{incorrectColumns}}",
"noDataImported": "{{message}}\n\nNo data was imported or changed"
},
"segmentExplainer": "Import data in CSV format",
"success": {
"message": "Data successfully imported",
"title": "Success"
}
}
},
"menuItem": { "menuItem": {
"dataManagement": { "dataManagement": {
"name": "Data", "name": "Data",
-4
View File
@@ -3,10 +3,6 @@ export const home = {
phase: (n) => `${['1st', '2nd', '3rd'][n - 1]} cycle phase`, phase: (n) => `${['1st', '2nd', '3rd'][n - 1]} cycle phase`,
} }
export const chart = {
tutorial: 'You can swipe the chart to view more dates.',
}
export const shared = { export const shared = {
cancel: 'Cancel', cancel: 'Cancel',
save: 'Save', save: 'Save',
-36
View File
@@ -1,24 +1,6 @@
import links from './links' import links from './links'
export default { export default {
menuItems: {
reminders: {
name: 'Reminders',
text: 'turn on/off reminders',
},
nfpSettings: {
name: 'NFP settings',
text: 'define how you want to use NFP',
},
dataManagement: {
name: 'Data',
text: 'import, export or delete your data',
},
password: {
name: 'Password',
text: '',
},
},
export: { export: {
errors: { errors: {
noData: 'There is no data to export', noData: 'There is no data to export',
@@ -31,24 +13,6 @@ export default {
segmentExplainer: segmentExplainer:
'Export data in CSV format for backup or so you can use it elsewhere', 'Export data in CSV format for backup or so you can use it elsewhere',
}, },
import: {
button: 'Import data',
title: 'Keep existing data?',
message: `There are two options for the import:
1. Keep existing cycle days and replace only the ones in the import file.
2. Delete all existing cycle days and import cycle days from file.`,
replaceOption: 'Import and replace',
deleteOption: 'Import and delete existing',
errors: {
couldNotOpenFile: 'Could not open file',
postFix: 'No data was imported or changed',
futureEdit: 'Future dates may only contain a note, no other symptoms',
},
success: {
message: 'Data successfully imported',
},
segmentExplainer: 'Import data in CSV format',
},
deleteSegment: { deleteSegment: {
title: 'Delete app data', title: 'Delete app data',
explainer: 'Delete app data from this phone', explainer: 'Delete app data from this phone',
-1
View File
@@ -17,7 +17,6 @@ i18n
compatibilityJSON: 'v3', // TODO: migrate json to v4 and afterwards remove it compatibilityJSON: 'v3', // TODO: migrate json to v4 and afterwards remove it
resources, resources,
fallbackLng: 'en', fallbackLng: 'en',
debug: true,
interpolation: { interpolation: {
escapeValue: false, // not needed for react as it escapes by default escapeValue: false, // not needed for react as it escapes by default
+4
View File
@@ -5,4 +5,8 @@ module.exports = {
transformIgnorePatterns: [ transformIgnorePatterns: [
'node_modules/(?!((jest-)?react-native(-.*)?|@react-native(-community)?)/)', 'node_modules/(?!((jest-)?react-native(-.*)?|@react-native(-community)?)/)',
], ],
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',
],
} }
+13 -5
View File
@@ -8,7 +8,7 @@ import {
import getColumnNamesForCsv from './get-csv-column-names' import getColumnNamesForCsv from './get-csv-column-names'
import replaceWithNullIfAllPropertiesAreNull from './replace-with-null' import replaceWithNullIfAllPropertiesAreNull from './replace-with-null'
import { LocalDate } from '@js-joda/core' import { LocalDate } from '@js-joda/core'
import labels from '../../i18n/en/settings' import i18next from 'i18next'
export default async function importCsv(csv, deleteFirst) { export default async function importCsv(csv, deleteFirst) {
const parseFuncs = { const parseFuncs = {
@@ -46,7 +46,10 @@ export default async function importCsv(csv, deleteFirst) {
const cycleDays = await csvParser(config) const cycleDays = await csvParser(config)
.fromString(csv) .fromString(csv)
.on('header', validateHeaders) .on('header', (headers) => validateHeaders(headers))
.on('error', (error) => {
throw error
})
//remove symptoms where all fields are null //remove symptoms where all fields are null
putNullForEmptySymptoms(cycleDays) putNullForEmptySymptoms(cycleDays)
@@ -67,8 +70,11 @@ function validateHeaders(headers) {
return expectedHeaders.indexOf(header) > -1 return expectedHeaders.indexOf(header) > -1
}) })
) { ) {
const msg = `Expected CSV column titles to be ${expectedHeaders.join()}` throw new Error(
throw new Error(msg) i18next.t('hamburgerMenu.settings.data.import.error.incorrectColumns', {
incorrectColumns: expectedHeaders.join(),
})
)
} }
} }
@@ -92,7 +98,9 @@ function throwIfFutureData(cycleDays) {
day.date > today && day.date > today &&
Object.keys(day).some((symptom) => symptom != 'date' && symptom != 'note') Object.keys(day).some((symptom) => symptom != 'date' && symptom != 'note')
) { ) {
throw new Error(labels.import.errors.futureEdit) throw new Error(
i18next.t('hamburgerMenu.settings.data.import.error.futureEdit')
)
} }
} }
} }
+3 -4
View File
@@ -1,17 +1,16 @@
export default function (feeling, texture) { export default function getSensiplanMucus(feeling, texture) {
if (typeof feeling != 'number' || typeof texture != 'number') return null if (typeof feeling != 'number' || typeof texture != 'number') return null
const feelingMapping = { const feelingMapping = {
0: 0, 0: 0,
1: 1, 1: 1,
2: 2, 2: 2,
3: 4 3: 4,
} }
const textureMapping = { const textureMapping = {
0: 0, 0: 0,
1: 3, 1: 3,
2: 4 2: 4,
} }
const nfpFeelingValue = feelingMapping[feeling] const nfpFeelingValue = feelingMapping[feeling]
const nfpTextureValue = textureMapping[texture] const nfpTextureValue = textureMapping[texture]
+2 -8
View File
@@ -12,15 +12,9 @@ export const unitObservable = Observable()
unitObservable.set(TEMP_SCALE_UNITS) unitObservable.set(TEMP_SCALE_UNITS)
scaleObservable((scale) => { scaleObservable((scale) => {
const scaleRange = scale.max - scale.min const scaleRange = scale.max - scale.min
if (scaleRange <= 1.5) {
switch (true) {
case scaleRange <= 1:
unitObservable.set(0.1) unitObservable.set(0.1)
break } else {
case scaleRange > 1 && scaleRange <= 2:
unitObservable.set(0.2)
break
default:
unitObservable.set(0.5) unitObservable.set(0.5)
} }
}) })
+8 -7
View File
@@ -36,14 +36,14 @@
"@react-native-community/datetimepicker": "^6.3.1", "@react-native-community/datetimepicker": "^6.3.1",
"@react-native-community/push-notification-ios": "^1.8.0", "@react-native-community/push-notification-ios": "^1.8.0",
"csvtojson": "^2.0.8", "csvtojson": "^2.0.8",
"i18next": "^21.9.0", "i18next": "^22.4.13",
"jshashes": "^1.0.8", "jshashes": "^1.0.8",
"moment": "^2.29.4", "moment": "^2.29.4",
"object-path": "^0.11.4", "object-path": "^0.11.4",
"obv": "0.0.1", "obv": "0.0.1",
"prop-types": "^15.8.1", "prop-types": "^15.8.1",
"react": "17.0.2", "react": "17.0.2",
"react-i18next": "^11.18.3", "react-i18next": "^12.0.0",
"react-native": "0.67.4", "react-native": "0.67.4",
"react-native-calendars": "^1.1287.0", "react-native-calendars": "^1.1287.0",
"react-native-document-picker": "^8.1.1", "react-native-document-picker": "^8.1.1",
@@ -58,17 +58,18 @@
"sympto": "3.0.1" "sympto": "3.0.1"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.12.9", "@babel/core": "^7.20.2",
"@babel/eslint-parser": "^7.19.1", "@babel/eslint-parser": "^7.19.1",
"@babel/preset-react": "^7.16.0", "@babel/preset-react": "^7.18.6",
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@testing-library/jest-native": "^4.0.12", "@testing-library/jest-native": "^4.0.12",
"@testing-library/react-native": "^11.1.0", "@testing-library/react-native": "^11.1.0",
"basic-changelog": "gitlab:bloodyhealth/basic-changelog", "basic-changelog": "gitlab:bloodyhealth/basic-changelog",
"eslint": "7.14.0", "eslint": "^7.32.0",
"eslint-plugin-react": "^7.8.2", "eslint-plugin-react": "^7.31.10",
"husky": "^8.0.0", "husky": "^8.0.0",
"jest": "^28.1.3", "jest": "^29.1.2",
"jest-watch-typeahead": "^2.2.0",
"jetifier": "^1.6.6", "jetifier": "^1.6.6",
"metro-react-native-babel-preset": "^0.66.2", "metro-react-native-babel-preset": "^0.66.2",
"prettier": "2.4.0", "prettier": "2.4.0",
+5 -13
View File
@@ -1,27 +1,19 @@
import React from 'react' import React from 'react'
import { render, screen, fireEvent } from '@testing-library/react-native'
import AcceptLicense from '../components/AcceptLicense' import AcceptLicense from '../components/AcceptLicense'
import { saveLicenseFlag } from '../local-storage' import { saveLicenseFlag } from '../local-storage'
import { render, screen, fireEvent } from './test-utils'
jest.mock('../local-storage', () => ({ jest.mock('../local-storage', () => ({
saveLicenseFlag: jest.fn(() => Promise.resolve()), saveLicenseFlag: jest.fn(() => Promise.resolve()),
})) }))
jest.mock('react-i18next', () => ({
useTranslation: () => ({
t: (str, options) => {
return str + (options ? JSON.stringify(options) : '')
},
}),
}))
describe('AcceptLicense', () => { describe('AcceptLicense', () => {
test('On clicking OK button, the license is accepted', async () => { test('should accept license when clicking ok button', async () => {
const mockedSetLicense = jest.fn() const mockedSetLicense = jest.fn()
render(<AcceptLicense setLicense={mockedSetLicense} />) render(<AcceptLicense setLicense={mockedSetLicense} />)
const okButton = screen.getByText('ok', { exact: false }) const okButton = screen.getByText('OK')
fireEvent(okButton, 'click') fireEvent(okButton, 'click')
@@ -29,9 +21,9 @@ describe('AcceptLicense', () => {
expect(mockedSetLicense).toHaveBeenCalled() expect(mockedSetLicense).toHaveBeenCalled()
}) })
test('There is a Cancel button', async () => { test('should render cancel button', async () => {
render(<AcceptLicense setLicense={jest.fn()} />) render(<AcceptLicense setLicense={jest.fn()} />)
screen.getByText('cancel', { exact: false }) screen.getByText('Cancel')
}) })
}) })
+3 -11
View File
@@ -1,24 +1,16 @@
import React from 'react' import React from 'react'
import { render, screen } from '@testing-library/react-native'
import License from '../components/settings/License' import License from '../components/settings/License'
import { render, screen } from './test-utils'
jest.mock('react-i18next', () => ({
useTranslation: () => ({
t: (str, options) => {
return str + (options ? JSON.stringify(options) : '')
},
}),
}))
describe('License screen', () => { describe('License screen', () => {
test('It should have a correct year', async () => { test('should display license text with correct year', async () => {
render(<License />) render(<License />)
const year = new Date().getFullYear().toString() const year = new Date().getFullYear().toString()
screen.getByText(year, { exact: false }) screen.getByText(year, { exact: false })
}) })
test('It should match the snapshot', async () => { test('should match the snapshot', async () => {
const licenseScreen = render(<License />) const licenseScreen = render(<License />)
expect(licenseScreen).toMatchSnapshot() expect(licenseScreen).toMatchSnapshot()
+15 -13
View File
@@ -1,9 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`License screen It should match the snapshot 1`] = ` exports[`License screen should match the snapshot 1`] = `
<View <View
style={ style={
Object { {
"backgroundColor": "#E9F2ED", "backgroundColor": "#E9F2ED",
"flex": 1, "flex": 1,
} }
@@ -11,8 +11,8 @@ exports[`License screen It should match the snapshot 1`] = `
> >
<RCTScrollView <RCTScrollView
contentContainerStyle={ contentContainerStyle={
Array [ [
Object { {
"backgroundColor": "#E9F2ED", "backgroundColor": "#E9F2ED",
"flexGrow": 1, "flexGrow": 1,
}, },
@@ -23,13 +23,13 @@ exports[`License screen It should match the snapshot 1`] = `
<View> <View>
<Text <Text
style={ style={
Array [ [
Object { {
"color": "#555", "color": "#555",
"fontFamily": "Jost-Book", "fontFamily": "Jost-Book",
"fontSize": 34.285714285714285, "fontSize": 34.285714285714285,
}, },
Object { {
"alignSelf": "center", "alignSelf": "center",
"color": "#3A2671", "color": "#3A2671",
"fontFamily": "Jost-Bold", "fontFamily": "Jost-Bold",
@@ -41,11 +41,11 @@ exports[`License screen It should match the snapshot 1`] = `
] ]
} }
> >
title drip. an open-source cycle tracking app
</Text> </Text>
<View <View
style={ style={
Object { {
"marginBottom": 34.285714285714285, "marginBottom": 34.285714285714285,
"marginHorizontal": 34.285714285714285, "marginHorizontal": 34.285714285714285,
} }
@@ -53,8 +53,8 @@ exports[`License screen It should match the snapshot 1`] = `
> >
<Text <Text
style={ style={
Array [ [
Object { {
"color": "#555", "color": "#555",
"fontFamily": "Jost-Book", "fontFamily": "Jost-Book",
"fontSize": 34.285714285714285, "fontSize": 34.285714285714285,
@@ -63,12 +63,14 @@ exports[`License screen It should match the snapshot 1`] = `
] ]
} }
> >
text{"currentYear":2022} Copyright (C) 2023 Heart of Code e.V.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details:
</Text> </Text>
<Text <Text
onPress={[Function]} onPress={[Function]}
style={ style={
Object { {
"color": "#3A2671", "color": "#3A2671",
"fontFamily": "Jost-Book", "fontFamily": "Jost-Book",
"fontSize": 34.285714285714285, "fontSize": 34.285714285714285,
@@ -3,7 +3,7 @@
exports[`Footnote component when children are present, renders them 1`] = ` exports[`Footnote component when children are present, renders them 1`] = `
<View <View
style={ style={
Object { {
"alignContent": "flex-start", "alignContent": "flex-start",
"flexDirection": "row", "flexDirection": "row",
"marginBottom": 8.571428571428571, "marginBottom": 8.571428571428571,
@@ -13,13 +13,13 @@ exports[`Footnote component when children are present, renders them 1`] = `
> >
<Text <Text
style={ style={
Array [ [
Object { {
"color": "#555", "color": "#555",
"fontFamily": "Jost-Book", "fontFamily": "Jost-Book",
"fontSize": 34.285714285714285, "fontSize": 34.285714285714285,
}, },
Object { {
"color": "#F38337", "color": "#F38337",
}, },
] ]
@@ -29,18 +29,18 @@ exports[`Footnote component when children are present, renders them 1`] = `
</Text> </Text>
<Text <Text
linkStyle={ linkStyle={
Object { {
"color": "white", "color": "white",
} }
} }
style={ style={
Array [ [
Object { {
"color": "#555", "color": "#555",
"fontFamily": "Jost-Book", "fontFamily": "Jost-Book",
"fontSize": 34.285714285714285, "fontSize": 34.285714285714285,
}, },
Object { {
"color": "#555", "color": "#555",
"paddingLeft": 21.428571428571427, "paddingLeft": 21.428571428571427,
}, },
+10
View File
@@ -0,0 +1,10 @@
import { render } from '@testing-library/react-native'
import '../i18n/i18n'
const customRender = (ui, options) => render(ui, { ...options })
// re-export everything
export * from '@testing-library/react-native'
// override render method
export { customRender as render }
+894 -715
View File
File diff suppressed because it is too large Load Diff