// // 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 @StateObject private var appDefaults = AppDefaults.shared @StateObject private var viewModel = SettingsViewModel() @Binding var isConfigureAppearanceShown: Bool var body: some View { NavigationView { List { // Device Permissions Section(header: Text("Device Permissions", comment: "Settings: Device Permissions section header."), footer: Text("Configure NetNewsWire's access to Siri, background app refresh, mobile data, and more.", comment: "Settings: Device Permissions section footer.")) { SettingsViewRows.openSystemSettings } // Account/Extensions/OPML Management Section(header: Text("Accounts & Extensions", comment: "Settings: Accounts and Extensions section header."), footer: Text("Add, delete, enable, or disable accounts and extensions.", comment: "Settings: Accounts and Extensions section footer.")) { SettingsViewRows.addAccount SettingsViewRows.manageExtensions SettingsViewRows.importOPML(showImportActionSheet: $viewModel.showImportActionSheet) .confirmationDialog(Text("Choose an account to receive the imported feeds and folders", comment: "Import OPML confirmation title."), isPresented: $viewModel.showImportActionSheet, titleVisibility: .visible) { ForEach(AccountManager.shared.sortedActiveAccounts, id: \.self) { account in Button(account.nameForDisplay) { viewModel.importAccount = account viewModel.showImportView = true } } } SettingsViewRows.exportOPML(showExportActionSheet: $viewModel.showExportActionSheet) .confirmationDialog(Text("Choose an account with the subscriptions to export", comment: "Export OPML confirmation title."), 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("Appearance", comment: "Settings: Appearance section header."), footer: Text("Manage the look, feel, and behavior of NetNewsWire.", comment: "Settings: Appearance section footer.")) { SettingsViewRows.configureAppearance($isConfigureAppearanceShown) if viewModel.notificationPermissions == .authorized { SettingsViewRows.configureNewArticleNotifications } } // Help Section { ForEach(0..