From 3ac8c7057e09038ad8559e224891693eb73fe509 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Tue, 14 Mar 2023 12:28:14 +0800 Subject: [PATCH] Adds Mark As Read on Scroll to SwiftUI views. --- iOS/AppDefaults.swift | 1 + iOS/Settings/Appearance/DisplayAndBehaviorsView.swift | 1 + iOS/Settings/General/SettingsRows.swift | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/iOS/AppDefaults.swift b/iOS/AppDefaults.swift index f7b153aaf..418d16877 100644 --- a/iOS/AppDefaults.swift +++ b/iOS/AppDefaults.swift @@ -273,6 +273,7 @@ final class AppDefaults: ObservableObject { } set { AppDefaults.setBool(for: Key.markArticlesAsReadOnScroll, newValue) + AppDefaults.shared.objectWillChange.send() } } diff --git a/iOS/Settings/Appearance/DisplayAndBehaviorsView.swift b/iOS/Settings/Appearance/DisplayAndBehaviorsView.swift index b4eb40972..1fed884ea 100644 --- a/iOS/Settings/Appearance/DisplayAndBehaviorsView.swift +++ b/iOS/Settings/Appearance/DisplayAndBehaviorsView.swift @@ -22,6 +22,7 @@ struct DisplayAndBehaviorsView: View { Section(header: Text("Timeline", comment: "Display & Behaviours: Timeline section header")) { SettingsViewRows.sortOldestToNewest($appDefaults.timelineSortDirectionBool) SettingsViewRows.groupByFeed($appDefaults.timelineGroupByFeed) + SettingsViewRows.markAsReadOnScroll($appDefaults.markArticlesAsReadOnScroll) SettingsViewRows.refreshToClearReadArticles($appDefaults.refreshClearsReadArticles) SettingsViewRows.timelineLayout } diff --git a/iOS/Settings/General/SettingsRows.swift b/iOS/Settings/General/SettingsRows.swift index 44def8f62..18c335a6b 100644 --- a/iOS/Settings/General/SettingsRows.swift +++ b/iOS/Settings/General/SettingsRows.swift @@ -61,6 +61,16 @@ struct SettingsViewRows { } } + + /// Toggle for determining if articles are marked as read when scrolling the timeline view. + /// - Parameter preference: `Binding` + /// - Returns: `some View` + static func markAsReadOnScroll(_ preference: Binding) -> some View { + Toggle(isOn: preference) { + Text("Mark As Read on Scroll", comment: "Mark As Read on Scroll") + } + } + /// This row, when tapped, will push the the Manage Extension screen /// in to view. static var manageExtensions: some View {