From 401ce5d2b8832a832c364a4f9427289d6e1a485c Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Mon, 14 Nov 2022 21:42:37 +1300 Subject: [PATCH] Disable 24 hour checking and battery for ios --- SettingsPage.tsx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/SettingsPage.tsx b/SettingsPage.tsx index d08e0c0..a9154d8 100644 --- a/SettingsPage.tsx +++ b/SettingsPage.tsx @@ -2,7 +2,13 @@ import {Picker} from '@react-native-picker/picker' import {useFocusEffect} from '@react-navigation/native' import {format} from 'date-fns' import {useCallback, useMemo, useState} from 'react' -import {DeviceEventEmitter, FlatList, NativeModules, View} from 'react-native' +import { + DeviceEventEmitter, + FlatList, + NativeModules, + Platform, + View, +} from 'react-native' import DeviceTimeFormat from 'react-native-device-time-format' import DocumentPicker from 'react-native-document-picker' import {Button} from 'react-native-paper' @@ -33,12 +39,16 @@ export default function SettingsPage() { const {theme, setTheme, color, setColor} = useTheme() const [showDate, setShowDate] = useState(false) const [noSound, setNoSound] = useState(false) - const [formatOptions, setFormatOptions] = useState([]) + const [formatOptions, setFormatOptions] = useState([ + 'P', + 'Pp', + 'ccc p', + 'p', + ]) const today = new Date() useFocusEffect( useCallback(() => { - NativeModules.AlarmModule.ignoringBattery(setIgnoring) settingsRepo.findOne({where: {}}).then(settings => { setAlarm(settings.alarm) setVibrate(settings.vibrate) @@ -51,9 +61,10 @@ export default function SettingsPage() { setShowDate(settings.showDate) setNoSound(settings.noSound) }) + if (Platform.OS !== 'android') return + NativeModules.AlarmModule.ignoringBattery(setIgnoring) DeviceTimeFormat.is24HourFormat().then(is24 => { - if (is24) return setFormatOptions(['P', 'P, k:m', 'ccc k:m', 'k:m']) - setFormatOptions(['P', 'Pp', 'ccc p', 'p']) + if (is24) setFormatOptions(['P', 'P, k:m', 'ccc k:m', 'k:m']) }) }, []), )