Files
iOS/Sources/App/Settings/Notifications/NotificationDebugNotificationsView.swift
Bruno Pantaleão Gonçalves c59cd48a6d Migrate Notification settings + leaf screens to SwiftUI (#4562)
## Summary
Migrate the notification settings screen and its three leaf screens to
SwiftUI:
- `NotificationSettingsView`: permission status, learn-more link, sounds
/ categories / rate-limit / debug navigation, badge reset + auto-clear,
push ID share, push ID reset.
- `NotificationSoundsView`: imported / bundled / system segmented lists,
audio playback, swipe delete, `.fileImporter`, file-sharing + system
import, AKConverter progress HUD, alert handling.
- `NotificationRateLimitView`: pull-to-refresh on iOS, toolbar refresh
on Catalyst, 1-second reset countdown, retry state, parent
remaining-count callback.
- `NotificationDebugNotificationsView`: `UserDefaults`-backed toggles.

Removes the Eureka `row(for:)` extensions in
`NotificationRateLimitsAPI.swift`, deletes the four old
`*ViewController.swift` files, and rewires `SettingsItem.notifications`
and `NotificationManager.openSettingsFor` to the SwiftUI view.

## Screenshots
_Pending — to be added before merge._

## Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#

## Any other notes
Part of a five-PR Eureka → SwiftUI migration tracked in
`UIKitToSwiftUIMigration.md` (siblings: #4560, #4561, #4563, #4564). The
`Eureka`, `ColorPickerRow`, and `ViewRow` pods stay until all slices
land.

**Reconciliation with #4563:** the categories PR temporarily embeds
`NotificationCategoryListView` inside the old
`NotificationSettingsViewController` via `UIHostingController`. This PR
deletes that controller entirely; after both merge, the
`categoriesDestination` in `NotificationSettingsView` should link
directly to `NotificationCategoryListView` from the categories PR.

`bundle exec fastlane lint` passes. Not build-verified locally yet.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-28 20:55:21 +02:00

74 lines
2.3 KiB
Swift

import Shared
import SwiftUI
struct NotificationDebugNotificationsView: View {
private struct Toggle: Identifiable {
let id: String
let title: String
}
private let toggles: [Toggle] = [
.init(id: "enterNotifications", title: L10n.SettingsDetails.Location.Notifications.Enter.title),
.init(id: "exitNotifications", title: L10n.SettingsDetails.Location.Notifications.Exit.title),
.init(id: "beaconEnterNotifications", title: L10n.SettingsDetails.Location.Notifications.BeaconEnter.title),
.init(id: "beaconExitNotifications", title: L10n.SettingsDetails.Location.Notifications.BeaconExit.title),
.init(
id: "significantLocationChangeNotifications",
title: L10n.SettingsDetails.Location.Notifications.LocationChange.title
),
.init(
id: "backgroundFetchLocationChangeNotifications",
title: L10n.SettingsDetails.Location.Notifications.BackgroundFetch.title
),
.init(
id: "pushLocationRequestNotifications",
title: L10n.SettingsDetails.Location.Notifications.PushNotification.title
),
.init(
id: "urlSchemeLocationRequestNotifications",
title: L10n.SettingsDetails.Location.Notifications.UrlScheme.title
),
.init(
id: "xCallbackURLLocationRequestNotifications",
title: L10n.SettingsDetails.Location.Notifications.XCallbackUrl.title
),
]
var body: some View {
List {
Section {
ForEach(toggles) { toggle in
PrefsToggleRow(key: toggle.id, title: toggle.title)
}
}
}
.navigationTitle(L10n.SettingsDetails.Location.Notifications.header)
.navigationBarTitleDisplayMode(.inline)
}
}
private struct PrefsToggleRow: View {
let key: String
let title: String
@State private var value: Bool
init(key: String, title: String) {
self.key = key
self.title = title
_value = State(initialValue: prefs.bool(forKey: key))
}
var body: some View {
SwiftUI.Toggle(isOn: Binding(
get: { value },
set: { newValue in
value = newValue
prefs.set(newValue, forKey: key)
}
)) {
Text(title)
}
}
}