This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public extension UserDefaults { | |
| var overridedUserInterfaceStyle: UIUserInterfaceStyle { | |
| get { | |
| UIUserInterfaceStyle(rawValue: integer(forKey: #function)) ?? .unspecified | |
| } | |
| set { | |
| set(newValue.rawValue, forKey: #function) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { | |
| super.traitCollectionDidChange(previousTraitCollection) | |
| traitCollection.hasDifferentColorAppearance(comparedTo: traitCollection) { | |
| layer.backgroundColor = UIColor.layer.cgColor | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| public extension UIApplication { | |
| func override(_ userInterfaceStyle: UIUserInterfaceStyle) { | |
| if supportsMultipleScenes { | |
| for connectedScene in connectedScenes { | |
| if let scene = connectedScene as? UIWindowScene { | |
| for window in scene.windows { | |
| window.overrideUserInterfaceStyle = userInterfaceStyle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| public extension JSONDecoder { | |
| func decode<T>(_ type: T.Type, from data: Data) -> Result<T, Error> where T: Decodable { | |
| do { | |
| let decodedData: T = try decode(T.self, from: data) | |
| return .success(decodedData) | |
| } | |
| catch { |
OlderNewer