diff --git a/components/settings/customization/advance-notice-days-slider.js b/components/settings/customization/advance-notice-days-slider.js index ece11f0..982692b 100644 --- a/components/settings/customization/advance-notice-days-slider.js +++ b/components/settings/customization/advance-notice-days-slider.js @@ -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, diff --git a/components/settings/customization/slider-styles.js b/components/settings/customization/slider-styles.js index e28f31e..6a4f876 100644 --- a/components/settings/customization/slider-styles.js +++ b/components/settings/customization/slider-styles.js @@ -8,7 +8,6 @@ export const styles = StyleSheet.create({ }, marker: { backgroundColor: Colors.turquoiseDark, - borderRadius: 50, elevation: 4, height: Sizes.subtitle, diff --git a/components/settings/customization/temperature-slider.js b/components/settings/customization/temperature-slider.js index 463b001..485d786 100644 --- a/components/settings/customization/temperature-slider.js +++ b/components/settings/customization/temperature-slider.js @@ -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 diff --git a/components/settings/reminders/period-reminder.js b/components/settings/reminders/period-reminder.js index b0bf81f..0f0c3a8 100644 --- a/components/settings/reminders/period-reminder.js +++ b/components/settings/reminders/period-reminder.js @@ -32,18 +32,23 @@ const PeriodReminder = () => { saveAdvanceNoticeDays(days) } + const reminderText = + advanceNoticeDays == 1 + ? labels.periodReminder.reminderTextSingular + : labels.periodReminder.reminderTextPlural(advanceNoticeDays) + return ( <> {isPeriodReminderEnabled && ( )} diff --git a/i18n/en/settings.js b/i18n/en/settings.js index 7c09c14..958a203 100644 --- a/i18n/en/settings.js +++ b/i18n/en/settings.js @@ -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: { diff --git a/lib/notifications.js b/lib/notifications.js index 566ac0d..46a0b96 100644 --- a/lib/notifications.js +++ b/lib/notifications.js @@ -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 diff --git a/local-storage.js b/local-storage.js index 63bd55a..6900511 100644 --- a/local-storage.js +++ b/local-storage.js @@ -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) {