506: Review changes.

This commit is contained in:
Hannelore Meier
2024-10-02 15:29:29 +02:00
parent dddb095463
commit 79b268fe4c
7 changed files with 22 additions and 14 deletions
@@ -2,8 +2,8 @@ import React from 'react'
import { View } from 'react-native' import { View } from 'react-native'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import Slider from '@ptomasroos/react-native-multi-slider' import Slider from '@ptomasroos/react-native-multi-slider'
import SliderLabel from './slider-label'
import SliderLabel from './slider-label'
import { styles } from './slider-styles' import { styles } from './slider-styles'
import { import {
ADVANCE_PERIOD_NOTICE_DAYS_MIN, ADVANCE_PERIOD_NOTICE_DAYS_MIN,
@@ -8,7 +8,6 @@ export const styles = StyleSheet.create({
}, },
marker: { marker: {
backgroundColor: Colors.turquoiseDark, backgroundColor: Colors.turquoiseDark,
borderRadius: 50, borderRadius: 50,
elevation: 4, elevation: 4,
height: Sizes.subtitle, height: Sizes.subtitle,
@@ -3,13 +3,12 @@ import { View } from 'react-native'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import Slider from '@ptomasroos/react-native-multi-slider' import Slider from '@ptomasroos/react-native-multi-slider'
import alertError from '../common/alert-error'
import SliderLabel from './slider-label' import SliderLabel from './slider-label'
import { styles } from './slider-styles'
import alertError from '../common/alert-error'
import { scaleObservable, saveTempScale } from '../../../local-storage' import { scaleObservable, saveTempScale } from '../../../local-storage'
import labels from '../../../i18n/en/settings' import labels from '../../../i18n/en/settings'
import { TEMP_MIN, TEMP_MAX, TEMP_SLIDER_STEP } from '../../../config' import { TEMP_MIN, TEMP_MAX, TEMP_SLIDER_STEP } from '../../../config'
import { styles } from './slider-styles'
const TemperatureSlider = ({ disabled }) => { const TemperatureSlider = ({ disabled }) => {
const savedValue = scaleObservable.value const savedValue = scaleObservable.value
@@ -32,18 +32,23 @@ const PeriodReminder = () => {
saveAdvanceNoticeDays(days) saveAdvanceNoticeDays(days)
} }
const reminderText =
advanceNoticeDays == 1
? labels.periodReminder.reminderTextSingular
: labels.periodReminder.reminderTextPlural(advanceNoticeDays)
return ( return (
<> <>
<AppSwitch <AppSwitch
onToggle={periodReminderToggle} onToggle={periodReminderToggle}
text={labels.periodReminder.reminderText(advanceNoticeDays)} text={reminderText}
value={isPeriodReminderEnabled} value={isPeriodReminderEnabled}
disabled={isPeriodPredictionDisabled} disabled={isPeriodPredictionDisabled}
/> />
{isPeriodReminderEnabled && ( {isPeriodReminderEnabled && (
<AdvanceNoticeDaysSlider <AdvanceNoticeDaysSlider
disabled={isPeriodPredictionDisabled} disabled={isPeriodPredictionDisabled}
advanceNoticeDays={parseInt(advanceNoticeDays, 10)} advanceNoticeDays={parseInt(advanceNoticeDays)}
onAdvanceNoticeDaysChange={handleAdvanceNoticeDaysChange} onAdvanceNoticeDaysChange={handleAdvanceNoticeDaysChange}
/> />
)} )}
+4 -5
View File
@@ -60,11 +60,10 @@ export default {
}, },
periodReminder: { periodReminder: {
title: 'Next period reminder', title: 'Next period reminder',
reminderText: (days) => { reminderTextSingular:
const dayCount = parseInt(days, 10) 'Get a notification 1 day before your next period is likely to start.',
const dayText = dayCount === 1 ? '1 day' : `${dayCount} days` reminderTextPlural: (days) =>
return `Get a notification ${dayText} before your next period is likely to start.` `Get a notification ${days} days before your next period is likely to start.`,
},
notification: (advanceNoticeDays, daysToEndOfPrediction) => notification: (advanceNoticeDays, daysToEndOfPrediction) =>
`Your next period is likely to start in ${advanceNoticeDays} to ${daysToEndOfPrediction} days.`, `Your next period is likely to start in ${advanceNoticeDays} to ${daysToEndOfPrediction} days.`,
alertNoPeriodReminder: { alertNoPeriodReminder: {
+7 -1
View File
@@ -5,6 +5,7 @@ import {
advanceNoticeDaysObservable, advanceNoticeDaysObservable,
} from '../local-storage' } from '../local-storage'
import * as PN from 'react-native-push-notification' import * as PN from 'react-native-push-notification'
import { requestNotifications } from 'react-native-permissions'
import Moment from 'moment' import Moment from 'moment'
import { LocalDate } from '@js-joda/core' import { LocalDate } from '@js-joda/core'
@@ -19,6 +20,11 @@ const PERIOD_REMINDER_ID = '2'
const PushNotification = Platform.OS === 'ios' ? PN : PN.default const PushNotification = Platform.OS === 'ios' ? PN : PN.default
export default function setupNotifications(navigate, setDate) { export default function setupNotifications(navigate, setDate) {
// for Android, this method call is necessary
if (Platform.OS === 'android') {
requestNotifications()
}
PushNotification.createChannel({ PushNotification.createChannel({
channelId: DRIP_CHANNEL_ID, // (required) channelId: DRIP_CHANNEL_ID, // (required)
channelName: 'drip reminder', // (required) channelName: 'drip reminder', // (required)
@@ -99,7 +105,7 @@ function schedulePeriodNotification() {
'YYYY-MM-DD' 'YYYY-MM-DD'
) )
const advanceNoticeDays = parseInt(advanceNoticeDaysObservable.value, 10) const advanceNoticeDays = parseInt(advanceNoticeDaysObservable.value)
// ${advanceNoticeDays} days before and at 6 am // ${advanceNoticeDays} days before and at 6 am
const reminderDate = predictedBleedingStart const reminderDate = predictedBleedingStart
+1 -1
View File
@@ -65,7 +65,7 @@ export const advanceNoticeDaysObservable = Observable()
setObvWithInitValue( setObvWithInitValue(
'advanceNoticeDays', 'advanceNoticeDays',
advanceNoticeDaysObservable, advanceNoticeDaysObservable,
parseInt(ADVANCE_PERIOD_NOTICE_DAYS_INIT_VALUE, 10) parseInt(ADVANCE_PERIOD_NOTICE_DAYS_INIT_VALUE)
) )
export async function saveAdvanceNoticeDays(days) { export async function saveAdvanceNoticeDays(days) {