// // ArticleThemeManagerView.swift // NetNewsWire-iOS // // Created by Stuart Breckenridge on 20/12/2022. // Copyright © 2022 Ranchero Software. All rights reserved. // import SwiftUI struct ArticleThemeManagerView: View { @StateObject private var themeManager = ArticleThemesManager.shared @State private var showDeleteConfirmation: (String, Bool) = ("", false) @State private var showImportThemeView: Bool = false @State private var showImportConfirmationAlert: (ArticleTheme?, Bool) = (nil, false) @State private var showImportErrorAlert: (Error?, Bool) = (nil, false) @State private var showImportSuccessAlert: Bool = false var body: some View { Form { Section(header: Text("label.text.default-themes", comment: "Default Themes"), footer: Text("label.text.default-themes-explainer", comment: "These themes cannot be deleted.")) { articleThemeRow(try! themeManager.articleThemeWithThemeName("Default")) ForEach(0.. some View { Button { themeManager.currentThemeName = theme.name } label: { HStack { VStack(alignment: .leading) { Text(verbatim: theme.name) .foregroundColor(.primary) Text("label.text.theme-created-byline.\(theme.creatorName)", comment: "Created by %@") .font(.caption) .foregroundColor(.secondary) } Spacer() if themeManager.currentThemeName == theme.name { Image(systemName: "checkmark") .foregroundColor(Color(uiColor: AppAssets.primaryAccentColor)) } } } .swipeActions(edge: .trailing, allowsFullSwipe: false) { if theme.isAppTheme || theme.name == themeManager.currentThemeName { } else { Button { showDeleteConfirmation = (theme.name, true) } label: { Text("button.title.delete", comment: "Delete") Image(systemName: "trash") } .tint(.red) } } } } struct ArticleThemeImporterView_Previews: PreviewProvider { static var previews: some View { ArticleThemeManagerView() } }