All files / src/app/settings notifications.tsx

100% Statements 7/7
100% Branches 0/0
100% Functions 2/2
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156                      1x 1x     1x                                               1x   1x 1x     1x                                                                                                                                                                                                                            
import React, { useEffect } from "react";
import { useNotificationSettings } from "../../hooks/useNotificationSettings";
import { useTheme } from "../../hooks/useTheme";
import { SettingsScreenScaffold } from "../../components/settings/SettingsScreenScaffold";
import {
  SettingsCard,
  SettingsDivider,
  SettingsSectionLabel,
  SettingsSwitchRow,
} from "../../components/settings";
 
const PREF_TITLE = { fontSize: 14, fontWeight: "600" as const };
const PREF_SUBTITLE = { fontSize: 13, marginTop: 2 };
 
export default function SettingsNotifications() {
  const { colors } = useTheme();
  const {
    pushEnabled,
    soundEnabled,
    vibrationEnabled,
    badgeEnabled,
    classUpdates,
    eventReminders,
    campusAlerts,
    navigationUpdates,
    promotionsTips,
    quietHoursActive,
    quietHoursLabel,
    setPushEnabled,
    setSoundEnabled,
    setVibrationEnabled,
    setBadgeEnabled,
    setClassUpdates,
    setEventReminders,
    setCampusAlerts,
    setNavigationUpdates,
    setPromotionsTips,
    setQuietHoursActive,
    hydrateFromStorage,
  } = useNotificationSettings();
 
  useEffect(() => {
    void hydrateFromStorage();
  }, [hydrateFromStorage]);
 
  return (
    <SettingsScreenScaffold title="Notifications">
      <SettingsCard>
        <SettingsSwitchRow
          title="Push Notifications"
          subtitle="Receive notifications from the app."
          value={pushEnabled}
          onValueChange={setPushEnabled}
          subtitleBelow
        />
      </SettingsCard>
 
      <SettingsCard>
        <SettingsSectionLabel>Notification Style</SettingsSectionLabel>
        <SettingsSwitchRow
          title="Sound"
          subtitle="Play sound for notifications."
          value={soundEnabled}
          onValueChange={setSoundEnabled}
          compact
          titleStyle={[PREF_TITLE, { color: colors.text }]}
          subtitleStyle={[PREF_SUBTITLE, { color: colors.textMuted }]}
        />
        <SettingsDivider />
        <SettingsSwitchRow
          title="Vibration"
          subtitle="Vibrate for notifications."
          value={vibrationEnabled}
          onValueChange={setVibrationEnabled}
          compact
          titleStyle={[PREF_TITLE, { color: colors.text }]}
          subtitleStyle={[PREF_SUBTITLE, { color: colors.textMuted }]}
        />
        <SettingsDivider />
        <SettingsSwitchRow
          title="Badge App Icon"
          subtitle="Show notification count on app icon."
          value={badgeEnabled}
          onValueChange={setBadgeEnabled}
          compact
          titleStyle={[PREF_TITLE, { color: colors.text }]}
          subtitleStyle={[PREF_SUBTITLE, { color: colors.textMuted }]}
        />
      </SettingsCard>
 
      <SettingsCard>
        <SettingsSectionLabel>Notification Types</SettingsSectionLabel>
        <SettingsSwitchRow
          title="Class Updates"
          subtitle="Changes to class schedules and locations."
          value={classUpdates}
          onValueChange={setClassUpdates}
          compact
          titleStyle={[PREF_TITLE, { color: colors.text }]}
          subtitleStyle={[PREF_SUBTITLE, { color: colors.textMuted }]}
        />
        <SettingsDivider />
        <SettingsSwitchRow
          title="Event Reminders"
          subtitle="Upcoming campus events and activities."
          value={eventReminders}
          onValueChange={setEventReminders}
          compact
          titleStyle={[PREF_TITLE, { color: colors.text }]}
          subtitleStyle={[PREF_SUBTITLE, { color: colors.textMuted }]}
        />
        <SettingsDivider />
        <SettingsSwitchRow
          title="Campus Alerts"
          subtitle="Important safety and emergency notifications."
          value={campusAlerts}
          onValueChange={setCampusAlerts}
          compact
          titleStyle={[PREF_TITLE, { color: colors.text }]}
          subtitleStyle={[PREF_SUBTITLE, { color: colors.textMuted }]}
        />
        <SettingsDivider />
        <SettingsSwitchRow
          title="Navigation Updates"
          subtitle="Real-time navigation and route updates."
          value={navigationUpdates}
          onValueChange={setNavigationUpdates}
          compact
          titleStyle={[PREF_TITLE, { color: colors.text }]}
          subtitleStyle={[PREF_SUBTITLE, { color: colors.textMuted }]}
        />
        <SettingsDivider />
        <SettingsSwitchRow
          title="Promotions & Tips"
          subtitle="News, tips, and promotional content."
          value={promotionsTips}
          onValueChange={setPromotionsTips}
          compact
          titleStyle={[PREF_TITLE, { color: colors.text }]}
          subtitleStyle={[PREF_SUBTITLE, { color: colors.textMuted }]}
        />
      </SettingsCard>
 
      <SettingsCard>
        <SettingsSwitchRow
          title="Quiet Hours"
          subtitle={quietHoursLabel}
          value={quietHoursActive}
          onValueChange={setQuietHoursActive}
          subtitleBelow
        />
      </SettingsCard>
    </SettingsScreenScaffold>
  );
}