camelCase SettingsViewRows

This commit is contained in:
Stuart Breckenridge
2022-12-13 07:08:45 +08:00
parent a9b0d05c83
commit 07d9c3dd08
3 changed files with 31 additions and 38 deletions

View File

@@ -20,16 +20,16 @@ struct DisplayAndBehaviorsView: View {
}
Section("Timeline") {
SettingsViewRows.SortOldestToNewest($appDefaults.timelineSortDirectionBool)
SettingsViewRows.GroupByFeed($appDefaults.timelineGroupByFeed)
SettingsViewRows.RefreshToClearReadArticles($appDefaults.refreshClearsReadArticles)
SettingsViewRows.TimelineLayout
SettingsViewRows.sortOldestToNewest($appDefaults.timelineSortDirectionBool)
SettingsViewRows.groupByFeed($appDefaults.timelineGroupByFeed)
SettingsViewRows.refreshToClearReadArticles($appDefaults.refreshClearsReadArticles)
SettingsViewRows.timelineLayout
}
Section("Article") {
SettingsViewRows.ThemeSelection
SettingsViewRows.ConfirmMarkAllAsRead($appDefaults.confirmMarkAllAsRead)
SettingsViewRows.OpenLinksInNetNewsWire(Binding<Bool>(
SettingsViewRows.themeSelection
SettingsViewRows.confirmMarkAllAsRead($appDefaults.confirmMarkAllAsRead)
SettingsViewRows.openLinksInNetNewsWire(Binding<Bool>(
get: { !appDefaults.useSystemBrowser },
set: { appDefaults.useSystemBrowser = !$0 }
))

View File

@@ -16,7 +16,7 @@ import UniformTypeIdentifiers
struct SettingsViewRows {
/// This row, when tapped, will open iOS System Settings.
static var OpenSystemSettings: some View {
static var openSystemSettings: some View {
Label {
Text("Open System Settings")
} icon: {
@@ -33,7 +33,7 @@ struct SettingsViewRows {
/// This row, when tapped, will push the New Article Notifications
/// screen in to view.
static var ConfigureNewArticleNotifications: some View {
static var configureNewArticleNotifications: some View {
NavigationLink(destination: NewArticleNotificationsView()) {
Label {
Text("New Article Notifications")
@@ -48,7 +48,7 @@ struct SettingsViewRows {
/// This row, when tapped, will push the the Add Account screen
/// in to view.
static var AddAccount: some View {
static var addAccount: some View {
NavigationLink(destination: AccountsManagementView()) {
Label {
Text("Manage Accounts")
@@ -63,7 +63,7 @@ struct SettingsViewRows {
/// This row, when tapped, will push the the Manage Extension screen
/// in to view.
static var ManageExtensions: some View {
static var manageExtensions: some View {
NavigationLink(destination: ExtensionsManagementView()) {
Label {
Text("Manage Extensions")
@@ -78,7 +78,7 @@ struct SettingsViewRows {
/// This row, when tapped, will present an Import/Export
/// menu.
static func ImportExportOPML(showImportView: Binding<Bool>, showExportView: Binding<Bool>, importAccount: Binding<Account?>, exportDocument: Binding<OPMLDocument?>) -> some View {
static func importExportOPML(showImportView: Binding<Bool>, showExportView: Binding<Bool>, importAccount: Binding<Account?>, exportDocument: Binding<OPMLDocument?>) -> some View {
Menu {
Menu {
ForEach(AccountManager.shared.sortedActiveAccounts, id: \.self) { account in
@@ -123,27 +123,27 @@ struct SettingsViewRows {
/// Returns a `Toggle` which triggers changes to the user's sort order preference.
/// - Parameter preference: `Binding<Bool>`
/// - Returns: `Toggle`
static func SortOldestToNewest(_ preference: Binding<Bool>) -> some View {
static func sortOldestToNewest(_ preference: Binding<Bool>) -> some View {
Toggle("Sort Oldest to Newest", isOn: preference)
}
/// Returns a `Toggle` which triggers changes to the user's grouping preference.
/// - Parameter preference: `Binding<Bool>`
/// - Returns: `Toggle`
static func GroupByFeed(_ preference: Binding<Bool>) -> some View {
static func groupByFeed(_ preference: Binding<Bool>) -> some View {
Toggle("Group by Feed", isOn: preference)
}
/// Returns a `Toggle` which triggers changes to the user's refresh to clear preferences.
/// - Parameter preference: `Binding<Bool>`
/// - Returns: `Toggle`
static func RefreshToClearReadArticles(_ preference: Binding<Bool>) -> some View {
static func refreshToClearReadArticles(_ preference: Binding<Bool>) -> some View {
Toggle("Refresh To Clear Read Articles", isOn: preference)
}
/// This row, when tapped, will push the the Timeline Layout screen
/// in to view.
static var TimelineLayout: some View {
static var timelineLayout: some View {
NavigationLink(destination: TimelineCustomizerWrapper().edgesIgnoringSafeArea(.all).navigationTitle(Text("Timeline Layout"))) {
Text("Timeline Layout")
}
@@ -151,7 +151,7 @@ struct SettingsViewRows {
/// This row, when tapped, will push the the Theme Selector screen
/// in to view.
static var ThemeSelection: some View {
static var themeSelection: some View {
NavigationLink(destination: ArticleThemesWrapper().edgesIgnoringSafeArea(.all)) {
HStack {
Text("Article Theme")
@@ -163,16 +163,16 @@ struct SettingsViewRows {
}
}
static func ConfirmMarkAllAsRead(_ preference: Binding<Bool>) -> some View {
static func confirmMarkAllAsRead(_ preference: Binding<Bool>) -> some View {
Toggle("Confirm Mark All as Read", isOn: preference)
}
static func OpenLinksInNetNewsWire(_ preference: Binding<Bool>) -> some View {
static func openLinksInNetNewsWire(_ preference: Binding<Bool>) -> some View {
Toggle("Open Links in NetNewsWire", isOn: preference)
}
// TODO: Add Reader Mode Defaults here. See #3684.
static func EnableFullScreenArticles(_ preference: Binding<Bool>) -> some View {
static func enableFullScreenArticles(_ preference: Binding<Bool>) -> some View {
Toggle(isOn: preference) {
VStack(alignment: .leading, spacing: 4) {
Text("Enable Full Screen Articles")
@@ -185,7 +185,7 @@ struct SettingsViewRows {
/// This row, when tapped, will push the New Article Notifications
/// screen in to view.
static func ConfigureAppearance(_ isShown: Binding<Bool>) -> some View {
static func configureAppearance(_ isShown: Binding<Bool>) -> some View {
NavigationLink(destination: DisplayAndBehaviorsView(), isActive: isShown) {
Label {
Text("Display & Behaviors")
@@ -204,7 +204,7 @@ struct SettingsViewRows {
/// - selectedSheet: A `Binding` to the currently selected sheet. This is set, followed by `show`.
/// - show: A `Binding` to `Bool` which triggers the sheet to display.
/// - Returns: `View`
static func ShowHelpSheet(sheet: HelpSheet, selectedSheet: Binding<HelpSheet>, _ show: Binding<Bool>) -> some View {
static func showHelpSheet(sheet: HelpSheet, selectedSheet: Binding<HelpSheet>, _ show: Binding<Bool>) -> some View {
Label {
Text(sheet.description)
} icon: {
@@ -221,7 +221,7 @@ struct SettingsViewRows {
}
}
static var AboutNetNewsWire: some View {
static var aboutNetNewsWire: some View {
NavigationLink {
AboutView()
} label: {
@@ -238,10 +238,3 @@ struct SettingsViewRows {
}
}
}
extension Binding where Value == Bool {
func negate() -> Bool {
return !(self.wrappedValue)
}
}

View File

@@ -24,30 +24,30 @@ struct SettingsView: View {
// Device Permissions
Section(header: Text("Device Permissions"), footer: Text("Configure NetNewsWire's access to Siri, background app refresh, mobile data, and more.")) {
SettingsViewRows.OpenSystemSettings
SettingsViewRows.openSystemSettings
}
// Account/Extensions/OPML Management
Section(header: Text("Accounts & Extensions"), footer: Text("Add, delete, enable, or disable accounts and extensions.")) {
SettingsViewRows.AddAccount
SettingsViewRows.ManageExtensions
SettingsViewRows.ImportExportOPML(showImportView: $viewModel.showImportView, showExportView: $viewModel.showExportView, importAccount: $viewModel.importAccount, exportDocument: $viewModel.exportDocument)
SettingsViewRows.addAccount
SettingsViewRows.manageExtensions
SettingsViewRows.importExportOPML(showImportView: $viewModel.showImportView, showExportView: $viewModel.showExportView, importAccount: $viewModel.importAccount, exportDocument: $viewModel.exportDocument)
}
// Appearance
Section(header: Text("Appearance"), footer: Text("Manage the look, feel, and behavior of NetNewsWire.")) {
SettingsViewRows.ConfigureAppearance($isConfigureAppearanceShown)
SettingsViewRows.configureAppearance($isConfigureAppearanceShown)
if viewModel.notificationPermissions == .authorized {
SettingsViewRows.ConfigureNewArticleNotifications
SettingsViewRows.configureNewArticleNotifications
}
}
// Help
Section {
ForEach(0..<HelpSheet.allCases.count, id: \.self) { i in
SettingsViewRows.ShowHelpSheet(sheet: HelpSheet.allCases[i], selectedSheet: $viewModel.helpSheet, $viewModel.showHelpSheet)
SettingsViewRows.showHelpSheet(sheet: HelpSheet.allCases[i], selectedSheet: $viewModel.helpSheet, $viewModel.showHelpSheet)
}
SettingsViewRows.AboutNetNewsWire
SettingsViewRows.aboutNetNewsWire
}
}
.tint(Color(uiColor: AppAssets.primaryAccentColor))