From 29cac6305b8486f1c7fe736e58864fdb483ff2b2 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Tue, 4 Apr 2023 14:44:57 +0700 Subject: [PATCH 1/3] REMOVED: test matter protocols This commit goes with [PerseusDarkModeSingle.swift] updated. --- PerseusDarkModeSingle.swift | 68 ++++++------------------------------- 1 file changed, 10 insertions(+), 58 deletions(-) diff --git a/PerseusDarkModeSingle.swift b/PerseusDarkModeSingle.swift index 4e3e2b6..fbdd4b7 100644 --- a/PerseusDarkModeSingle.swift +++ b/PerseusDarkModeSingle.swift @@ -1,6 +1,6 @@ // // PerseusDarkModeSingle.swift -// Version: 1.1.3 +// Version: 1.1.4 // // Created by Mikhail Zhigulin in 7530. // @@ -48,32 +48,19 @@ public typealias Responder = UIResponder public typealias Responder = NSResponder #endif -/* template - #if canImport(UIKit) - - #elseif canImport(Cocoa) - - #endif - */ - -/* template - #if os(iOS) - - #elseif os(macOS) - - #endif - */ - -// MARK: - Constants +// MARK: - Notifications public extension Notification.Name { - static let MakeAppearanceUpNotification = Notification.Name("MakeAppearanceUpNotification") + static let MakeAppearanceUpNotification = + Notification.Name("MakeAppearanceUpNotification") #if os(macOS) static let AppleInterfaceThemeChangedNotification = Notification.Name("AppleInterfaceThemeChangedNotification") #endif } +// MARK: - Constants + public let DARK_MODE_USER_CHOICE_KEY = "DarkModeUserChoiceOptionKey" public let DARK_MODE_USER_CHOICE_DEFAULT = DarkModeOption.auto public let DARK_MODE_STYLE_DEFAULT = AppearanceStyle.light @@ -83,7 +70,7 @@ public let OBSERVERED_VARIABLE_NAME = "styleObservable" // swiftlint:disable identifier_name public extension Responder { - var DarkMode: DarkModeProtocol { return AppearanceService.shared } + var DarkMode: DarkMode { return AppearanceService.shared } } // swiftlint:enable identifier_name @@ -117,26 +104,15 @@ public class AppearanceService { public static var isEnabled: Bool { return hidden_isEnabled } -#if DEBUG && os(macOS) - /// Used for mocking DistributedNotificationCenter in unit testing. - public static var distributedNCenter: NotificationCenterProtocol = - DistributedNotificationCenter.default -#elseif os(macOS) +#if os(macOS) /// Default Distributed NotificationCenter. public static var distributedNCenter = DistributedNotificationCenter.default #endif -#if DEBUG // Isolated for unit testing - /// Used for mocking NotificationCenter in unit testing. - public static var nCenter: NotificationCenterProtocol = NotificationCenter.default - /// Used for mocking UserDefaults in unit testing. - public static var ud: UserDefaultsProtocol = UserDefaults.standard -#else /// Default NotificationCenter. public static var nCenter = NotificationCenter.default /// Default UserDefaults. public static var ud = UserDefaults.standard -#endif public static var DarkModeUserChoice: DarkModeOption { get { @@ -264,6 +240,7 @@ public class AppearanceService { // MARK: - Dark Mode public class DarkMode: NSObject { + // MARK: - The App's current Appearance Style public var style: AppearanceStyle { return hidden_style } @@ -354,6 +331,7 @@ public class DarkModeDecision { // MARK: - Appearance Style Observering public class DarkModeObserver: NSObject { + public var action: ((_ newStyle: AppearanceStyle) -> Void)? private(set) var objectToObserve = AppearanceService.shared @@ -471,29 +449,3 @@ extension UIWindow { } } #endif - -// MARK: - Used only for unit testing purpose - -public protocol NotificationCenterProtocol { - func addObserver(_ observer: Any, - selector aSelector: Selector, - name aName: NSNotification.Name?, - object anObject: Any?) - func post(name aName: NSNotification.Name, object anObject: Any?) -} - -public protocol UserDefaultsProtocol { - func valueExists(forKey key: String) -> Bool - func integer(forKey defaultName: String) -> Int - func setValue(_ value: Any?, forKey key: String) -} - -public protocol DarkModeProtocol { - var style: AppearanceStyle { get } - var systemStyle: SystemStyle { get } - var styleObservable: Int { get } -} - -extension UserDefaults: UserDefaultsProtocol { } -extension NotificationCenter: NotificationCenterProtocol { } -extension DarkMode: DarkModeProtocol { } From 2548aa3745daf21a32561cf79d107ef337fe40c5 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Tue, 4 Apr 2023 14:47:24 +0700 Subject: [PATCH 2/3] UPDATED: README This commit goes with README updated. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3550388..7c59fd1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Perseus Dark Mode [![Actions Status](https://github.com/perseusrealdeal/DarkMode/actions/workflows/main.yml/badge.svg)](https://github.com/perseusrealdeal/PerseusDarkMode/actions) -![Version](https://img.shields.io/badge/Version-1.1.3-informational.svg) +![Version](https://img.shields.io/badge/Version-1.1.4-informational.svg) [![Pod](https://img.shields.io/badge/Pod-1.1.3-informational.svg)](/PerseusDarkMode.podspec) ![Platforms](https://img.shields.io/badge/Platforms-iOS%209.3+,%20macOS%2010.9+-orange.svg) [![Swift 4.2](https://img.shields.io/badge/Swift-4.2-red.svg)](https://docs.swift.org/swift-book/RevisionHistory/RevisionHistory.html) @@ -59,7 +59,7 @@ end Cartfile should contain: ```carthage -github "perseusrealdeal/PerseusDarkMode" == 1.1.3 +github "perseusrealdeal/PerseusDarkMode" == 1.1.4 ``` Some Carthage usage tips placed [here](https://gist.github.com/perseusrealdeal/8951b10f4330325df6347aaaa79d3cf2). @@ -71,7 +71,7 @@ Some Carthage usage tips placed [here](https://gist.github.com/perseusrealdeal/8 ```swift dependencies: [ .package(url: "https://github.com/perseusrealdeal/PerseusDarkMode.git", - .exact("1.1.3")) + .exact("1.1.4")) ], ``` From acb22a92351d5aad945b7b66ab9419fb23e5e6d5 Mon Sep 17 00:00:00 2001 From: "Mikhail A. Z" <50202963+perseusrealdeal@users.noreply.github.com> Date: Tue, 4 Apr 2023 08:19:41 +0000 Subject: [PATCH 3/3] UPDATED: swift package manifest This commit goes with swift package manifest updated. --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index a91b97f..bef5fbf 100644 --- a/Package.swift +++ b/Package.swift @@ -1,7 +1,7 @@ // swift-tools-version:4.2 /* Package.swift - Version: 1.1.3 + Version: 1.1.4 Created by Mikhail Zhigulin in 7530.