import React, { useCallback, useState } from 'react'; import { Alert, StyleSheet, Switch, Text, TouchableOpacity, View } from 'react-native'; import { useFocusEffect } from '@react-navigation/native'; import { useTheme } from '@/theme/ThemeContext'; import { sendTestReminder } from '@/notifications/localReminders'; import { DEFAULT_LEAD_MINUTES, LEAD_STEP, MAX_LEAD_MINUTES, MIN_LEAD_MINUTES, getReminderLeadMinutes, getRemindersEnabled, setReminderLeadMinutes, setRemindersEnabled, } from '@/features/notifications/reminderPrefs'; export function NotificationsScreen() { const { colors } = useTheme(); const [enabled, setEnabled] = useState(true); const [lead, setLead] = useState(DEFAULT_LEAD_MINUTES); useFocusEffect( useCallback(() => { void getRemindersEnabled().then(setEnabled); void getReminderLeadMinutes().then(setLead); }, []), ); const toggle = (v: boolean) => { setEnabled(v); void setRemindersEnabled(v); }; const bump = (delta: number) => { const next = Math.min(MAX_LEAD_MINUTES, Math.max(MIN_LEAD_MINUTES, lead + delta)); setLead(next); void setReminderLeadMinutes(next); }; return ( Session expiry reminders A local notification before your parking runs out. Remind me bump(-LEAD_STEP)} > {lead} minutes before expiry = MAX_LEAD_MINUTES} onPress={() => bump(LEAD_STEP)} > + { const ok = await sendTestReminder(10); Alert.alert( ok ? 'Test scheduled' : 'Notifications blocked', ok ? 'A test reminder will appear in ~10 seconds (you can background the app).' : 'Allow notifications for BigBrainParking in system settings.', ); }} > Send a test reminder Reminders fire entirely on-device (AlarmManager) — no server, no push, no Google services. Adjusts in {LEAD_STEP}-minute steps, {MIN_LEAD_MINUTES}–{MAX_LEAD_MINUTES} min. ); } const styles = StyleSheet.create({ container: { flex: 1, padding: 16 }, card: { borderRadius: 12, padding: 16 }, row: { flexDirection: 'row', alignItems: 'center' }, rowTitle: { fontSize: 16, fontWeight: '600' }, rowSub: { fontSize: 13, marginTop: 2 }, section: { marginTop: 24, marginBottom: 8, marginLeft: 4, fontSize: 13, fontWeight: '600' }, stepper: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }, stepBtn: { width: 52, height: 52, borderRadius: 26, borderWidth: 1.5, alignItems: 'center', justifyContent: 'center', }, stepText: { fontSize: 26, fontWeight: '700' }, leadDisplay: { alignItems: 'center' }, leadValue: { fontSize: 40, fontWeight: '800' }, leadUnit: { fontSize: 13, marginTop: 2 }, testBtn: { marginTop: 20, borderWidth: 1.5, borderRadius: 12, padding: 14, alignItems: 'center', }, footnote: { fontSize: 12, marginTop: 16, lineHeight: 18 }, });