// // SettingsView.swift // NetNewsWire-iOS // // Created by Stuart Breckenridge on 12/11/2022. // Copyright © 2022 Ranchero Software. All rights reserved. // import SwiftUI import Account import UniformTypeIdentifiers import UserNotifications struct SettingsView: View { @Environment(\.dismiss) var dismiss @Environment(\.scenePhase) var scenePhase @StateObject private var appDefaults = AppDefaults.shared @StateObject private var viewModel = SettingsViewModel() @Binding var isConfigureAppearanceShown: Bool var body: some View { NavigationStack { List { // Device Permissions Section(header: Text("label.text.device-permissions", comment: "Device Permissions"), footer: Text("label.text.device-permissions-explainer", comment: "Configure NetNewsWire's access to Siri, background app refresh, mobile data, and more.")) { SettingsRow.openSystemSettings } // Account/Extensions/OPML Management Section(header: Text("label.text.accounts-and-extensions", comment: "Settings: Accounts & Extensions section header."), footer: Text("label.text.account-and-extensions-explainer", comment: "Add, delete, enable, or disable accounts and extensions.")) { SettingsRow.addAccount SettingsRow.manageExtensions SettingsRow.importOPML(showImportActionSheet: $viewModel.showImportActionSheet) .confirmationDialog(Text("actionsheet.title.choose-opml-destination", comment: "Choose an account to receive the imported feeds and folders"), isPresented: $viewModel.showImportActionSheet, titleVisibility: .visible) { ForEach(AccountManager.shared.sortedActiveAccounts, id: \.self) { account in Button(account.nameForDisplay) { viewModel.importAccount = account viewModel.showImportView = true } } } SettingsRow.exportOPML(showExportActionSheet: $viewModel.showExportActionSheet) .confirmationDialog(Text("actionsheet.title.choose-opml-export-account", comment: "Choose an account with the subscriptions to export"), isPresented: $viewModel.showExportActionSheet, titleVisibility: .visible) { ForEach(AccountManager.shared.sortedAccounts, id: \.self) { account in Button(account.nameForDisplay) { do { let document = try OPMLDocument(account) viewModel.exportDocument = document viewModel.showExportView = true } catch { viewModel.importExportError = error viewModel.showImportExportError = true } } } } } // Appearance Section(header: Text("label.text.appearance", comment: "Settings: Appearance section header."), footer: Text("label.text.appearance-explainer", comment: "Manage the look, feel, and behavior of NetNewsWire.")) { SettingsRow.configureAppearance($isConfigureAppearanceShown) if viewModel.notificationPermissions == .authorized { SettingsRow.configureNewArticleNotifications } } // Help Section { ForEach(0..