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