Tusker/Tusker/Screens/Preferences/Notifications/NotificationsPrefsView.swift

59 lines
2.0 KiB
Swift

//
// NotificationsPrefsView.swift
// Tusker
//
// Created by Shadowfacts on 4/6/24.
// Copyright © 2024 Shadowfacts. All rights reserved.
//
import SwiftUI
import UserNotifications
import UserAccounts
import PushNotifications
import TuskerComponents
struct NotificationsPrefsView: View {
@ObservedObject private var userAccounts = UserAccountsManager.shared
var body: some View {
List {
NavigationLink {
TipJarView()
} label: {
Text("Push notifications are available for free to all users, but providing them has an ongoing cost. If you like the app, please consider \(Text("supporting Tusker").foregroundColor(.accentColor)).")
.font(.callout)
.foregroundStyle(.secondary)
}
.listRowBackground(Color.accentColor.opacity(0.1))
Section {
ForEach(userAccounts.accounts) { account in
PushInstanceSettingsView(account: account)
}
}
.appGroupedListRowBackground()
if #available(iOS 15.4, *) {
Section {
Button {
let str = if #available(iOS 16.0, *) {
UIApplication.openNotificationSettingsURLString
} else {
UIApplicationOpenNotificationSettingsURLString
}
if let url = URL(string: str) {
UIApplication.shared.open(url)
}
} label: {
Text("Open Notification Settings…")
}
}
.appGroupedListRowBackground()
}
}
.listStyle(.insetGrouped)
.appGroupedListBackground(container: PreferencesNavigationController.self)
.navigationTitle("Notifications")
}
}