Repository Public
1// SP Notes iOS2// File: Features/Settings/TaskNotificationsSettings.swift3// Description: Réglages → « Notifications des tâches »: turns the due-date notifications of the tasks on or off. Turning it on4// asks the system permission the first time; a refusal is explained with a link to the system settings.5//6// Author: Simon-Pierre Boucher7// Contact: contact@spboucher.ai8import SPNotesDesign9import SwiftUI10import UIKit1112struct TaskNotificationsSettingsSection: View {13 @State private var notifications = AppRuntime.taskNotifications14 @Environment(\.openURL) private var openURL1516 var body: some View {17 if let notifications {18 Section {19 Toggle(isOn: Binding(get: { notifications.isEnabled }, set: { wanted in Task { await notifications.setEnabled(wanted) } })) {20 Label("Notifications des tâches", systemImage: "bell.badge")21 }22 .accessibilityIdentifier("task-notifications-toggle")23 if notifications.isDenied {24 Button("Ouvrir les réglages de notification") {25 if let url = URL(string: UIApplication.openNotificationSettingsURLString) { openURL(url) }26 }27 }28 } header: { Text("Tâches") } footer: {29 if notifications.isDenied {30 Text("Les notifications de SP Notes sont refusées dans les réglages de l’appareil. Autorise-les pour être averti de l’échéance de tes tâches.")31 } else {32 Text("Une notification à l’échéance de chaque tâche ouverte : à 9 h le jour même pour une date sans heure, à l’heure dite sinon. Tu peux terminer la tâche ou la reporter à demain depuis la notification.")33 }34 }35 .task { await notifications.refreshAuthorization() }36 }37 }38}39