From 959eef6a1ac6e1520bbf7f680d75778cc39025b0 Mon Sep 17 00:00:00 2001 From: Rizwan Mohamed Ibrahim Date: Thu, 2 Jul 2020 21:01:56 +0530 Subject: [PATCH 1/5] Add color palette implementation for Appearance settings --- Multiplatform/iOS/AppDelegate.swift | 29 +++++++++ Multiplatform/iOS/Settings/SettingsView.swift | 6 +- .../Submenus/ColorPaletteContainerView.swift | 60 +++++++++++++++++++ NetNewsWire.xcodeproj/project.pbxproj | 7 ++- 4 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 Multiplatform/iOS/Settings/Submenus/ColorPaletteContainerView.swift diff --git a/Multiplatform/iOS/AppDelegate.swift b/Multiplatform/iOS/AppDelegate.swift index 3df75f60d..a3539f5da 100644 --- a/Multiplatform/iOS/AppDelegate.swift +++ b/Multiplatform/iOS/AppDelegate.swift @@ -103,6 +103,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD UNUserNotificationCenter.current().delegate = self userNotificationManager = UserNotificationManager() + NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange), name: UserDefaults.didChangeNotification, object: nil) + + // extensionContainersFile = ExtensionContainersFile() // extensionFeedAddRequestFile = ExtensionFeedAddRequestFile() @@ -388,3 +391,29 @@ private extension AppDelegate { } } + +private extension AppDelegate { + @objc func userDefaultsDidChange() { + updateUserInterfaceStyle() + } + + var window: UIWindow? { + guard let scene = UIApplication.shared.connectedScenes.first, + let windowSceneDelegate = scene.delegate as? UIWindowSceneDelegate, + let window = windowSceneDelegate.window else { + return nil + } + return window + } + + func updateUserInterfaceStyle() { + switch AppDefaults.shared.userInterfaceColorPalette { + case .automatic: + window?.overrideUserInterfaceStyle = .unspecified + case .light: + window?.overrideUserInterfaceStyle = .light + case .dark: + window?.overrideUserInterfaceStyle = .dark + } + } +} diff --git a/Multiplatform/iOS/Settings/SettingsView.swift b/Multiplatform/iOS/Settings/SettingsView.swift index b08cd249b..9aca56100 100644 --- a/Multiplatform/iOS/Settings/SettingsView.swift +++ b/Multiplatform/iOS/Settings/SettingsView.swift @@ -155,12 +155,12 @@ struct SettingsView: View { var appearance: some View { Section(header: Text("Appearance"), content: { NavigationLink( - destination: EmptyView(), + destination: ColorPaletteContainerView().environmentObject(settings), label: { HStack { - Text("Color Pallete") + Text("Color Palette") Spacer() - Text("Automatic") + Text(settings.userInterfaceColorPalette.description) .foregroundColor(.secondary) } }) diff --git a/Multiplatform/iOS/Settings/Submenus/ColorPaletteContainerView.swift b/Multiplatform/iOS/Settings/Submenus/ColorPaletteContainerView.swift new file mode 100644 index 000000000..79190c06e --- /dev/null +++ b/Multiplatform/iOS/Settings/Submenus/ColorPaletteContainerView.swift @@ -0,0 +1,60 @@ +// +// ColorPaletteContainerView.swift +// Multiplatform iOS +// +// Created by Rizwan on 02/07/20. +// Copyright © 2020 Ranchero Software. All rights reserved. +// + +import SwiftUI + +struct ColorPaletteContainerView: View { + private let colorPalettes = UserInterfaceColorPalette.allCases + @EnvironmentObject private var appSettings: AppDefaults + @Environment(\.presentationMode) var presentationMode + + var body: some View { + List { + ForEach.init(0 ..< colorPalettes.count) { index in + Button(action: { + onTapColorPalette(at:index) + }) { + ColorPaletteView(colorPalette: colorPalettes[index]) + } + } + } + .listStyle(InsetGroupedListStyle()) + .navigationBarTitle("Color Palette", displayMode: .inline) + } + + func onTapColorPalette(at index: Int) { + if let colorPalette = UserInterfaceColorPalette(rawValue: index) { + appSettings.userInterfaceColorPalette = colorPalette + } + presentationMode.wrappedValue.dismiss() + } +} + +struct ColorPaletteView: View { + var colorPalette: UserInterfaceColorPalette + @EnvironmentObject private var appSettings: AppDefaults + + var body: some View { + HStack { + Text(colorPalette.description).foregroundColor(.primary) + Spacer() + if colorPalette == appSettings.userInterfaceColorPalette { + Image(systemName: "checkmark") + .foregroundColor(.blue) + } + } + } +} + +struct ColorPaletteContainerView_Previews: PreviewProvider { + static var previews: some View { + NavigationView { + ColorPaletteContainerView() + } + } +} diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 32ea67edc..e39067881 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -23,7 +23,6 @@ 1776E88F24AC5F8A00E78166 /* AppDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1776E88D24AC5F8A00E78166 /* AppDefaults.swift */; }; 179DB1DFBCF9177104B12E0F /* AccountsNewsBlurWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DBBA2B22A659F81EED6F9 /* AccountsNewsBlurWindowController.swift */; }; 179DB3CE822BFCC2D774D9F4 /* AccountsNewsBlurWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DBBA2B22A659F81EED6F9 /* AccountsNewsBlurWindowController.swift */; }; - 17B223DC24AC24D2001E4592 /* TimelineLayoutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17B223DB24AC24D2001E4592 /* TimelineLayoutView.swift */; }; 3B3A32A5238B820900314204 /* FeedWranglerAccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B3A328B238B820900314204 /* FeedWranglerAccountViewController.swift */; }; 3B826DCB2385C84800FC1ADB /* AccountsFeedWrangler.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3B826DB02385C84800FC1ADB /* AccountsFeedWrangler.xib */; }; 3B826DCC2385C84800FC1ADB /* AccountsFeedWranglerWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B826DCA2385C84800FC1ADB /* AccountsFeedWranglerWindowController.swift */; }; @@ -621,6 +620,8 @@ 6581C73D20CED60100F4AD34 /* SafariExtensionViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6581C73B20CED60100F4AD34 /* SafariExtensionViewController.xib */; }; 6581C74020CED60100F4AD34 /* netnewswire-subscribe-to-feed.js in Resources */ = {isa = PBXBuildFile; fileRef = 6581C73F20CED60100F4AD34 /* netnewswire-subscribe-to-feed.js */; }; 6581C74220CED60100F4AD34 /* ToolbarItemIcon.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 6581C74120CED60100F4AD34 /* ToolbarItemIcon.pdf */; }; + 65CBAD3624AE02D50006DD91 /* TimelineLayoutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17B223DB24AC24D2001E4592 /* TimelineLayoutView.swift */; }; + 65CBAD5A24AE03C20006DD91 /* ColorPaletteContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65CBAD5924AE03C20006DD91 /* ColorPaletteContainerView.swift */; }; 65ED3FB7235DEF6C0081F399 /* ArticleArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F204DF1FAACBB30076E152 /* ArticleArray.swift */; }; 65ED3FB8235DEF6C0081F399 /* CrashReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 848B937121C8C5540038DC0D /* CrashReporter.swift */; }; 65ED3FB9235DEF6C0081F399 /* IconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847CD6C9232F4CBF00FAC46D /* IconView.swift */; }; @@ -1985,6 +1986,7 @@ 6581C73F20CED60100F4AD34 /* netnewswire-subscribe-to-feed.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = "netnewswire-subscribe-to-feed.js"; sourceTree = ""; }; 6581C74120CED60100F4AD34 /* ToolbarItemIcon.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = ToolbarItemIcon.pdf; sourceTree = ""; }; 6581C74320CED60100F4AD34 /* Subscribe_to_Feed.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Subscribe_to_Feed.entitlements; sourceTree = ""; }; + 65CBAD5924AE03C20006DD91 /* ColorPaletteContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorPaletteContainerView.swift; sourceTree = ""; }; 65ED4083235DEF6C0081F399 /* NetNewsWire.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NetNewsWire.app; sourceTree = BUILT_PRODUCTS_DIR; }; 65ED409D235DEF770081F399 /* Subscribe to Feed.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "Subscribe to Feed.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; 65ED409F235DEFF00081F399 /* container-migration.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "container-migration.plist"; sourceTree = ""; }; @@ -2389,6 +2391,7 @@ isa = PBXGroup; children = ( 17B223DB24AC24D2001E4592 /* TimelineLayoutView.swift */, + 65CBAD5924AE03C20006DD91 /* ColorPaletteContainerView.swift */, ); path = Submenus; sourceTree = ""; @@ -4774,6 +4777,7 @@ 51E498F524A8085D00B667CB /* TodayFeedDelegate.swift in Sources */, 172952B024AA287100D65E66 /* CompactSidebarContainerView.swift in Sources */, 172199F124AB716900A31D04 /* SidebarToolbar.swift in Sources */, + 65CBAD5A24AE03C20006DD91 /* ColorPaletteContainerView.swift in Sources */, 51E4990B24A808C500B667CB /* ImageDownloader.swift in Sources */, 51E498F424A8085D00B667CB /* SmartFeedDelegate.swift in Sources */, 514E6BFF24AD255D00AC6F6E /* PreviewArticles.swift in Sources */, @@ -4805,6 +4809,7 @@ 51E4992624A80AAB00B667CB /* AppAssets.swift in Sources */, 514E6C0624AD2B5F00AC6F6E /* Image-Extensions.swift in Sources */, 51E4995624A8734D00B667CB /* TwitterFeedProvider-Extensions.swift in Sources */, + 65CBAD3624AE02D50006DD91 /* TimelineLayoutView.swift in Sources */, 51E4996824A8760C00B667CB /* ArticleStyle.swift in Sources */, 51E4990024A808BB00B667CB /* FaviconGenerator.swift in Sources */, 51E4997124A8764C00B667CB /* ActivityType.swift in Sources */, From 782ae1c5cd9f7c87b9dfea0db172af19800e42e9 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 3 Jul 2020 01:01:38 -0500 Subject: [PATCH 2/5] Removed obsolete AppDefaults values --- Multiplatform/Shared/AppDefaults.swift | 81 ++------------------------ 1 file changed, 5 insertions(+), 76 deletions(-) diff --git a/Multiplatform/Shared/AppDefaults.swift b/Multiplatform/Shared/AppDefaults.swift index 1031c7ef0..9e96f843b 100644 --- a/Multiplatform/Shared/AppDefaults.swift +++ b/Multiplatform/Shared/AppDefaults.swift @@ -26,13 +26,6 @@ enum UserInterfaceColorPalette: Int, CustomStringConvertible, CaseIterable { } } -enum FontSize: Int { - case small = 0 - case medium = 1 - case large = 2 - case veryLarge = 3 -} - final class AppDefaults: ObservableObject { #if os(macOS) @@ -64,24 +57,19 @@ final class AppDefaults: ObservableObject { static let addFolderAccountID = "addFolderAccountID" static let timelineSortDirection = "timelineSortDirection" - // iOS Defaults static let userInterfaceColorPalette = "userInterfaceColorPalette" static let timelineGroupByFeed = "timelineGroupByFeed" - static let refreshClearsReadArticles = "refreshClearsReadArticles" - static let timelineNumberOfLines = "timelineNumberOfLines" static let timelineIconSize = "timelineIconSize" - static let articleFullscreenAvailable = "articleFullscreenAvailable" + static let timelineNumberOfLines = "timelineNumberOfLines" + + // iOS Defaults + static let refreshClearsReadArticles = "refreshClearsReadArticles" + static let articleFullscreenAvailable = "articleFullscreenAvailable" static let articleFullscreenEnabled = "articleFullscreenEnabled" static let confirmMarkAllAsRead = "confirmMarkAllAsRead" // macOS Defaults - static let windowState = "windowState" - static let sidebarFontSize = "sidebarFontSize" - static let timelineFontSize = "timelineFontSize" - static let detailFontSize = "detailFontSize" static let openInBrowserInBackground = "openInBrowserInBackground" - static let importOPMLAccountID = "importOPMLAccountID" - static let exportOPMLAccountID = "exportOPMLAccountID" static let defaultBrowserID = "defaultBrowserID" static let checkForUpdatesAutomatically = "checkForUpdatesAutomatically" static let downloadTestBuilds = "downloadTestBuild" @@ -99,9 +87,6 @@ final class AppDefaults: ObservableObject { } - private static let smallestFontSizeRawValue = FontSize.small.rawValue - private static let largestFontSizeRawValue = FontSize.veryLarge.rawValue - // MARK: Development Builds let isDeveloperBuild: Bool = { if let dev = Bundle.main.object(forInfoDictionaryKey: "DeveloperEntitlements") as? String, dev == "-dev" { @@ -220,64 +205,12 @@ final class AppDefaults: ObservableObject { } // MARK: Window State - var windowState: [AnyHashable : Any]? { - get { - return AppDefaults.store.object(forKey: Key.windowState) as? [AnyHashable : Any] - } - set { - UserDefaults.standard.set(newValue, forKey: Key.windowState) - objectWillChange.send() - } - } - @AppStorage(wrappedValue: false, Key.openInBrowserInBackground, store: store) var openInBrowserInBackground: Bool { didSet { objectWillChange.send() } } - var sidebarFontSize: FontSize { - get { - return fontSize(for: Key.sidebarFontSize) - } - set { - AppDefaults.store.set(newValue.rawValue, forKey: Key.sidebarFontSize) - objectWillChange.send() - } - } - - var timelineFontSize: FontSize { - get { - return fontSize(for: Key.timelineFontSize) - } - set { - AppDefaults.store.set(newValue.rawValue, forKey: Key.timelineFontSize) - objectWillChange.send() - } - } - - var detailFontSize: FontSize { - get { - return fontSize(for: Key.detailFontSize) - } - set { - AppDefaults.store.set(newValue.rawValue, forKey: Key.detailFontSize) - objectWillChange.send() - } - } - - @AppStorage(Key.importOPMLAccountID, store: store) var importOPMLAccountID: String? { - didSet { - objectWillChange.send() - } - } - - @AppStorage(Key.exportOPMLAccountID, store: store) var exportOPMLAccountID: String? { - didSet { - objectWillChange.send() - } - } - @AppStorage(Key.defaultBrowserID, store: store) var defaultBrowserID: String? { didSet { objectWillChange.send() @@ -346,8 +279,4 @@ extension AppDefaults { return true } - func fontSize(for key: String) -> FontSize { - // Punted till after 1.0. - return .medium - } } From 88d03586ae56792e99312d20a3f1f8d7f32b7921 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 3 Jul 2020 01:24:35 -0500 Subject: [PATCH 3/5] Register AppDefaults. Issue #2190 --- Multiplatform/Shared/AppDefaults.swift | 23 +++++++++++++++---- .../Shared/Timeline/TimelineItemView.swift | 2 +- Multiplatform/iOS/AppDelegate.swift | 2 +- .../Submenus/TimelineLayoutView.swift | 6 ++--- Multiplatform/macOS/AppDelegate.swift | 2 +- iOS/AppDefaults.swift | 8 +++---- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Multiplatform/Shared/AppDefaults.swift b/Multiplatform/Shared/AppDefaults.swift index 9e96f843b..270841646 100644 --- a/Multiplatform/Shared/AppDefaults.swift +++ b/Multiplatform/Shared/AppDefaults.swift @@ -55,11 +55,11 @@ final class AppDefaults: ObservableObject { static let addWebFeedAccountID = "addWebFeedAccountID" static let addWebFeedFolderName = "addWebFeedFolderName" static let addFolderAccountID = "addFolderAccountID" - static let timelineSortDirection = "timelineSortDirection" - + static let userInterfaceColorPalette = "userInterfaceColorPalette" + static let timelineSortDirection = "timelineSortDirection" static let timelineGroupByFeed = "timelineGroupByFeed" - static let timelineIconSize = "timelineIconSize" + static let timelineIconDimensions = "timelineIconDimensions" static let timelineNumberOfLines = "timelineNumberOfLines" // iOS Defaults @@ -178,7 +178,7 @@ final class AppDefaults: ObservableObject { } } - @AppStorage(wrappedValue: 40.0, Key.timelineIconSize, store: store) var timelineIconSize: Double { + @AppStorage(wrappedValue: 40.0, Key.timelineIconDimensions, store: store) var timelineIconDimensions: Double { didSet { objectWillChange.send() } @@ -266,6 +266,21 @@ final class AppDefaults: ObservableObject { objectWillChange.send() } } + + static func registerDefaults() { + let defaults: [String : Any] = [Key.userInterfaceColorPalette: UserInterfaceColorPalette.automatic.rawValue, + Key.timelineGroupByFeed: false, + Key.refreshClearsReadArticles: false, + Key.timelineNumberOfLines: 2, + Key.timelineIconDimensions: 40, + Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue, + Key.articleFullscreenAvailable: false, + Key.articleFullscreenEnabled: false, + Key.confirmMarkAllAsRead: true, + "NSScrollViewShouldScrollUnderTitlebar": false, + Key.refreshInterval: RefreshInterval.everyHour.rawValue] + AppDefaults.store.register(defaults: defaults) + } } diff --git a/Multiplatform/Shared/Timeline/TimelineItemView.swift b/Multiplatform/Shared/Timeline/TimelineItemView.swift index d4f4f172a..1e1a25ae8 100644 --- a/Multiplatform/Shared/Timeline/TimelineItemView.swift +++ b/Multiplatform/Shared/Timeline/TimelineItemView.swift @@ -21,7 +21,7 @@ struct TimelineItemView: View { TimelineItemStatusView(status: timelineItem.status) if let image = articleIconImageLoader.image { IconImageView(iconImage: image) - .frame(width: CGFloat(defaults.timelineIconSize), height: CGFloat(defaults.timelineIconSize), alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/) + .frame(width: CGFloat(defaults.timelineIconDimensions), height: CGFloat(defaults.timelineIconDimensions), alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/) } VStack { Text(verbatim: timelineItem.article.title ?? "N/A") diff --git a/Multiplatform/iOS/AppDelegate.swift b/Multiplatform/iOS/AppDelegate.swift index 3df75f60d..b9d62d6c1 100644 --- a/Multiplatform/iOS/AppDelegate.swift +++ b/Multiplatform/iOS/AppDelegate.swift @@ -71,7 +71,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD } func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - //AppDefaults.registerDefaults() + AppDefaults.registerDefaults() let isFirstRun = AppDefaults.shared.isFirstRun() if isFirstRun { diff --git a/Multiplatform/iOS/Settings/Submenus/TimelineLayoutView.swift b/Multiplatform/iOS/Settings/Submenus/TimelineLayoutView.swift index 2b064917c..679d65e4a 100644 --- a/Multiplatform/iOS/Settings/Submenus/TimelineLayoutView.swift +++ b/Multiplatform/iOS/Settings/Submenus/TimelineLayoutView.swift @@ -33,8 +33,8 @@ struct TimelineLayoutView: View { } var iconSize: some View { - Slider(value: $appSettings.timelineIconSize, in: 20...60, step: 10, minimumValueLabel: Text("Small"), maximumValueLabel: Text("Large"), label: { - Text(String(appSettings.timelineIconSize)) + Slider(value: $appSettings.timelineIconDimensions, in: 20...60, step: 10, minimumValueLabel: Text("Small"), maximumValueLabel: Text("Large"), label: { + Text(String(appSettings.timelineIconDimensions)) }) } @@ -54,7 +54,7 @@ struct TimelineLayoutView: View { Image(systemName: "paperplane.circle") .resizable() - .frame(width: CGFloat(appSettings.timelineIconSize), height: CGFloat(appSettings.timelineIconSize), alignment: .top) + .frame(width: CGFloat(appSettings.timelineIconDimensions), height: CGFloat(appSettings.timelineIconDimensions), alignment: .top) .foregroundColor(.accentColor) VStack(alignment: .leading, spacing: 4) { diff --git a/Multiplatform/macOS/AppDelegate.swift b/Multiplatform/macOS/AppDelegate.swift index e01a4f244..2ad541197 100644 --- a/Multiplatform/macOS/AppDelegate.swift +++ b/Multiplatform/macOS/AppDelegate.swift @@ -133,7 +133,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele } #endif - //AppDefaults.registerDefaults() + AppDefaults.registerDefaults() let isFirstRun = AppDefaults.shared.isFirstRun() if isFirstRun { os_log(.debug, log: log, "Is first run.") diff --git a/iOS/AppDefaults.swift b/iOS/AppDefaults.swift index a9ad904d0..d1e7ec909 100644 --- a/iOS/AppDefaults.swift +++ b/iOS/AppDefaults.swift @@ -45,7 +45,7 @@ final class AppDefaults { static let timelineGroupByFeed = "timelineGroupByFeed" static let refreshClearsReadArticles = "refreshClearsReadArticles" static let timelineNumberOfLines = "timelineNumberOfLines" - static let timelineIconSize = "timelineIconSize" + static let timelineIconDimension = "timelineIconSize" static let timelineSortDirection = "timelineSortDirection" static let articleFullscreenAvailable = "articleFullscreenAvailable" static let articleFullscreenEnabled = "articleFullscreenEnabled" @@ -202,11 +202,11 @@ final class AppDefaults { var timelineIconSize: IconSize { get { - let rawValue = AppDefaults.store.integer(forKey: Key.timelineIconSize) + let rawValue = AppDefaults.store.integer(forKey: Key.timelineIconDimension) return IconSize(rawValue: rawValue) ?? IconSize.medium } set { - AppDefaults.store.set(newValue.rawValue, forKey: Key.timelineIconSize) + AppDefaults.store.set(newValue.rawValue, forKey: Key.timelineIconDimension) } } @@ -215,7 +215,7 @@ final class AppDefaults { Key.timelineGroupByFeed: false, Key.refreshClearsReadArticles: false, Key.timelineNumberOfLines: 2, - Key.timelineIconSize: IconSize.medium.rawValue, + Key.timelineIconDimension: IconSize.medium.rawValue, Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue, Key.articleFullscreenAvailable: false, Key.articleFullscreenEnabled: false, From fc548ac913938c0f092121e89f5c8f9ba8de4167 Mon Sep 17 00:00:00 2001 From: Rizwan Mohamed Ibrahim Date: Fri, 3 Jul 2020 12:35:12 +0530 Subject: [PATCH 4/5] Try conditional modifier for preferredColorScheme --- Multiplatform/Shared/MainApp.swift | 21 ++++++++++++++++++- .../Shared/Sidebar/SidebarToolbar.swift | 5 +++-- Multiplatform/iOS/AppDelegate.swift | 16 +++++++------- .../Submenus/ColorPaletteContainerView.swift | 2 +- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Multiplatform/Shared/MainApp.swift b/Multiplatform/Shared/MainApp.swift index 634dea81c..79c0a7669 100644 --- a/Multiplatform/Shared/MainApp.swift +++ b/Multiplatform/Shared/MainApp.swift @@ -146,7 +146,9 @@ struct MainApp: App { SceneNavigationView() .environmentObject(sceneModel) .environmentObject(defaults) - }.commands { + .modifier(PreferredColorSchemeModifier(preferredColorScheme: defaults.userInterfaceColorPalette)) + } + .commands { CommandGroup(after: .newItem, addition: { Button("New Feed", action: {}) .keyboardShortcut("N") @@ -193,3 +195,20 @@ struct MainApp: App { #endif } } + +struct PreferredColorSchemeModifier: ViewModifier { + + var preferredColorScheme: UserInterfaceColorPalette + + @ViewBuilder + func body(content: Content) -> some View { + switch preferredColorScheme { + case .automatic: + content + case .dark: + content.preferredColorScheme(.dark) + case .light: + content.preferredColorScheme(.light) + } + } +} diff --git a/Multiplatform/Shared/Sidebar/SidebarToolbar.swift b/Multiplatform/Shared/Sidebar/SidebarToolbar.swift index e7df534f6..dafe70564 100644 --- a/Multiplatform/Shared/Sidebar/SidebarToolbar.swift +++ b/Multiplatform/Shared/Sidebar/SidebarToolbar.swift @@ -9,7 +9,8 @@ import SwiftUI struct SidebarToolbar: View { - + + @EnvironmentObject private var appSettings: AppDefaults @State private var showSettings: Bool = false var body: some View { @@ -40,7 +41,7 @@ struct SidebarToolbar: View { } .background(VisualEffectBlur(blurStyle: .systemChromeMaterial).edgesIgnoringSafeArea(.bottom)) .sheet(isPresented: $showSettings, onDismiss: { showSettings = false }) { - SettingsView() + SettingsView().modifier(PreferredColorSchemeModifier(preferredColorScheme: appSettings.userInterfaceColorPalette)) } } diff --git a/Multiplatform/iOS/AppDelegate.swift b/Multiplatform/iOS/AppDelegate.swift index a3539f5da..717065ff6 100644 --- a/Multiplatform/iOS/AppDelegate.swift +++ b/Multiplatform/iOS/AppDelegate.swift @@ -407,13 +407,13 @@ private extension AppDelegate { } func updateUserInterfaceStyle() { - switch AppDefaults.shared.userInterfaceColorPalette { - case .automatic: - window?.overrideUserInterfaceStyle = .unspecified - case .light: - window?.overrideUserInterfaceStyle = .light - case .dark: - window?.overrideUserInterfaceStyle = .dark - } +// switch AppDefaults.shared.userInterfaceColorPalette { +// case .automatic: +// window?.overrideUserInterfaceStyle = .unspecified +// case .light: +// window?.overrideUserInterfaceStyle = .light +// case .dark: +// window?.overrideUserInterfaceStyle = .dark +// } } } diff --git a/Multiplatform/iOS/Settings/Submenus/ColorPaletteContainerView.swift b/Multiplatform/iOS/Settings/Submenus/ColorPaletteContainerView.swift index 79190c06e..3cf4ee25a 100644 --- a/Multiplatform/iOS/Settings/Submenus/ColorPaletteContainerView.swift +++ b/Multiplatform/iOS/Settings/Submenus/ColorPaletteContainerView.swift @@ -31,7 +31,7 @@ struct ColorPaletteContainerView: View { if let colorPalette = UserInterfaceColorPalette(rawValue: index) { appSettings.userInterfaceColorPalette = colorPalette } - presentationMode.wrappedValue.dismiss() + self.presentationMode.wrappedValue.dismiss() } } From e621e5e0f720462acd3b1f8cce6a2c4251d0768a Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 3 Jul 2020 09:48:14 -0500 Subject: [PATCH 5/5] Add prebuild script to generate Secrets for new multiplaform targets --- .../xcschemes/Multiplatform iOS.xcscheme | 20 +++- .../xcschemes/Multiplatform macOS.xcscheme | 96 +++++++++++++++++++ 2 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 NetNewsWire.xcodeproj/xcshareddata/xcschemes/Multiplatform macOS.xcscheme diff --git a/NetNewsWire.xcodeproj/xcshareddata/xcschemes/Multiplatform iOS.xcscheme b/NetNewsWire.xcodeproj/xcshareddata/xcschemes/Multiplatform iOS.xcscheme index eafbe066c..e06266bca 100644 --- a/NetNewsWire.xcodeproj/xcshareddata/xcschemes/Multiplatform iOS.xcscheme +++ b/NetNewsWire.xcodeproj/xcshareddata/xcschemes/Multiplatform iOS.xcscheme @@ -1,10 +1,28 @@ + version = "1.7"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +