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
/// Reflects notification publisher functionality of `NotificationCenter`. | |
public protocol NotificationPublisherProtocol: AnyObject { | |
/// Returns a publisher that emits events when broadcasting notifications. | |
/// - Parameters: | |
/// - name: The name of the notification to publish. | |
/// - object: The object posting the named notification. If `nil`, the publisher emits elements for any object | |
/// producing a notification with the given name. | |
/// - Returns: A publisher that emits events when broadcasting notifications. | |
func publisher(for name: Notification.Name, object: AnyObject?) -> NotificationCenter.Publisher | |
} |
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
/// Reflects notification observer functionality of `NotificationCenter`. | |
public protocol NotificationObserverProtocol: AnyObject { | |
/// Adds an entry to the notification center to call the provided selector with the notification. | |
/// - Parameters: | |
/// - observer: An object to register as an observer. | |
/// - aSelector: A selector that specifies the message the receiver sends observer to alert it to the notification | |
/// posting. The method that aSelector specifies must have one and only one argument | |
/// (an instance of NSNotification). | |
/// - aName: The name of the notification to register for delivery to the observer. Specify a notification name to | |
/// deliver only entries with this notification name. |
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
/// Reflects notification posting functionality of `NotificationCenter`. | |
public protocol NotificationPosterProtocol: AnyObject { | |
/// Creates a notification with a given name, sender and user info and posts it to the notification center. | |
/// - Parameters: | |
/// - aName: The name of the notification. | |
/// - anObject: The object posting the notification. | |
/// - userInfo: A user info dictionary with optional information about the notification. | |
func post(name aName: NSNotification.Name, object anObject: Any?, userInfo: [AnyHashable: Any]?) | |
/// Creates a notification with a given name and sender and posts it to the notification center. | |
/// - Parameters: |
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
default_platform(:ios) | |
GITHUB_REPO_NAME="your-repo-name" # Example: mdb1/fastlane-example | |
GIT_DEFAULT_BRANCH="main" | |
platform :ios do | |
desc "Description of what the lane does" | |
lane :custom_lane do | |
# add actions here: https://docs.fastlane.tools/actions | |
end |
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
if [[ "$(uname -m)" == arm64 ]]; then | |
export PATH="/opt/homebrew/bin:$PATH" | |
fi | |
SWIFTLINT_VERSION=$(swiftlint --version | awk '{print $NF}') | |
MIN_VERSION="0.52.4" | |
# Only run if `installed version` >= `minimum version`. | |
if [[ "$(printf '%s\n' "$MIN_VERSION" "$SWIFTLINT_VERSION" | sort -V | head -n1)" == "$MIN_VERSION" ]]; then | |
echo "SwiftLint version: $SWIFTLINT_VERSION" |
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 SwiftUI | |
struct LoggerVerbosityPicker: View { | |
/// User defaults value. | |
@AppStorage(Logger.defaultsKey) private var storedSelection: String? | |
/// Current selection. | |
@State var selection: Logger.Verbosity = Logger.Verbosity.verbose | |
var body: some View { | |
Picker("Verbosity", selection: $selection) { |
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 | |
/// The Console Logger to use across the app. | |
/// You can change the verbosity level like this: `Logger.verbosity = $newValue`. | |
public enum Logger { | |
/// The key for user defaults. | |
public static let defaultsKey = "logger.verbosity" | |
/// The verbosity level of the logger. |
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
final class UserPreferencesTests: XCTestCase { | |
private var userPreferences: UserPreferences! | |
override func setUp() { | |
super.setUp() | |
let userDefaults = UserDefaults(suiteName: #file) | |
userDefaults?.removePersistentDomain(forName: #file) | |
userPreferences = .init(userDefaults: userDefaults!) | |
} |
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
/// A class that provides a centralized way to access and modify stored preferences. | |
final class UserPreferences { | |
static let shared = UserPreferences() | |
private let userDefaults: UserDefaults | |
/// Initializes the UserPreferences object with a UserDefaults instance. | |
init(userDefaults: UserDefaults = .standard) { | |
self.userDefaults = userDefaults | |
} |
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
extension View { | |
func embedInStack() -> some View { | |
modifier(EmbedInStack()) | |
} | |
} | |
struct EmbedInStack: ViewModifier { | |
@Environment(\.sizeCategory) var sizeCategory | |
func body(content: Content) -> some View { |