diff --git a/Sources/Combine/Core/DelegateProxy/DelegateProxy.swift b/Sources/Combine/Core/DelegateProxy/DelegateProxy.swift index 382e8fb..092fa5d 100644 --- a/Sources/Combine/Core/DelegateProxy/DelegateProxy.swift +++ b/Sources/Combine/Core/DelegateProxy/DelegateProxy.swift @@ -8,22 +8,22 @@ import Combine open class DelegateProxy: ObjcDelegateProxy { private var dict: [Selector: [([Any]) -> Void]] = [:] private var subscribers = [AnySubscriber<[Any], Never>?]() - + override public required init() { super.init() } - + deinit { for subscriber in subscribers { subscriber?.receive(completion: .finished) } subscribers = [] } - + override public func interceptedSelector(_ selector: Selector, arguments: [Any]) { dict[selector]?.forEach { handler in handler(arguments) } } - + public func intercept(_ selector: Selector, _ handler: @escaping ([Any]) -> Void) { if dict[selector] != nil { dict[selector]?.append(handler) @@ -31,7 +31,7 @@ open class DelegateProxy: ObjcDelegateProxy { dict[selector] = [handler] } } - + public func interceptSelectorPublisher(_ selector: Selector) -> AnyPublisher<[Any], Never> { DelegateProxyPublisher<[Any]> { subscriber in self.subscribers.append(subscriber) diff --git a/Sources/Combine/Core/DelegateProxy/DelegateProxyPublisher.swift b/Sources/Combine/Core/DelegateProxy/DelegateProxyPublisher.swift index 91b2d3b..46d45b0 100644 --- a/Sources/Combine/Core/DelegateProxy/DelegateProxyPublisher.swift +++ b/Sources/Combine/Core/DelegateProxy/DelegateProxyPublisher.swift @@ -6,13 +6,13 @@ import Combine @available(iOS 13.0, *) final class DelegateProxyPublisher: Publisher { typealias Failure = Never - + private let handler: (AnySubscriber) -> Void - + init(_ handler: @escaping (AnySubscriber) -> Void) { self.handler = handler } - + func receive(subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input { let subscription = Subscription(subscriber: AnySubscriber(subscriber), handler: handler) subscriber.receive(subscription: subscription) @@ -23,16 +23,16 @@ final class DelegateProxyPublisher: Publisher { extension DelegateProxyPublisher { fileprivate class Subscription: Combine.Subscription where S: Subscriber, Failure == S.Failure, Output == S.Input { private var subscriber: S? - + init(subscriber: S, handler: @escaping (S) -> Void) { self.subscriber = subscriber handler(subscriber) } - + func request(_: Subscribers.Demand) { // We don't care for the demand. } - + func cancel() { subscriber = nil } diff --git a/Sources/Combine/Core/DelegateProxy/DelegateProxyType.swift b/Sources/Combine/Core/DelegateProxy/DelegateProxyType.swift index e4df962..2620e16 100644 --- a/Sources/Combine/Core/DelegateProxy/DelegateProxyType.swift +++ b/Sources/Combine/Core/DelegateProxy/DelegateProxyType.swift @@ -5,7 +5,7 @@ private var associatedKey: Void? public protocol DelegateProxyType { associatedtype Object - + func setDelegate(to object: Object) } @@ -14,9 +14,9 @@ extension DelegateProxyType where Self: DelegateProxy { public static func createDelegateProxy(for object: Object) -> Self { objc_sync_enter(self) defer { objc_sync_exit(self) } - + let delegateProxy: Self - + if let associatedObject = objc_getAssociatedObject(object, &associatedKey) as? Self { delegateProxy = associatedObject } else { @@ -25,7 +25,7 @@ extension DelegateProxyType where Self: DelegateProxy { } delegateProxy.setDelegate(to: object) - + return delegateProxy } } diff --git a/Sources/Combine/Core/Extendable/AnyPublisher+SAK.swift b/Sources/Combine/Core/Extendable/AnyPublisher+SAK.swift index 954e8be..ff8616e 100644 --- a/Sources/Combine/Core/Extendable/AnyPublisher+SAK.swift +++ b/Sources/Combine/Core/Extendable/AnyPublisher+SAK.swift @@ -7,7 +7,7 @@ extension AnyPublisher { public static func empty(completeImmediately: Bool = true) -> Self { Empty(completeImmediately: completeImmediately).eraseToAnyPublisher() } - + /// 直接发送一个信号 public static func send(value: Self.Output) -> Self { Result.Publisher(.success(value)).eraseToAnyPublisher() diff --git a/Sources/Combine/Core/Extendable/NSTextStorage+Combine.swift b/Sources/Combine/Core/Extendable/NSTextStorage+Combine.swift index 1475443..840d874 100644 --- a/Sources/Combine/Core/Extendable/NSTextStorage+Combine.swift +++ b/Sources/Combine/Core/Extendable/NSTextStorage+Combine.swift @@ -11,14 +11,14 @@ extension Extendable where Base: NSTextStorage { editedRange: NSRange, delta: Int ) - + /// Combine publisher for `NSTextStorageDelegate.textStorage(_:didProcessEditing:range:changeInLength:)` public var didProcessEditingRangeChangeInLengthPublisher: AnyPublisher< // swiftlint:disable:this identifier_name ProcessEditingRangeChangeOutput, Never > { let selector = #selector(NSTextStorageDelegate.textStorage(_:didProcessEditing:range:changeInLength:)) - + return delegateProxy .interceptSelectorPublisher(selector) .map { args -> (editedMask: NSTextStorage.EditActions, editedRange: NSRange, delta: Int) in @@ -31,7 +31,7 @@ extension Extendable where Base: NSTextStorage { } .eraseToAnyPublisher() } - + private var delegateProxy: NSTextStorageDelegateProxy { .createDelegateProxy(for: base) } diff --git a/Sources/Combine/Core/Extendable/Publisher+UITextField.swift b/Sources/Combine/Core/Extendable/Publisher+UITextField.swift index 98adf23..8e0d690 100644 --- a/Sources/Combine/Core/Extendable/Publisher+UITextField.swift +++ b/Sources/Combine/Core/Extendable/Publisher+UITextField.swift @@ -11,12 +11,12 @@ extension Publisher where Self.Output: UITextField { public func limitInputLength(max: Int?) -> Publishers.Map { map { var content = $0.text ?? "" - + if let max, content.rak.length > max { content = content.rak.prefixed(max) $0.text = content } - + return content } } diff --git a/Sources/Combine/Core/Extendable/Publishers+CombineLatest.swift b/Sources/Combine/Core/Extendable/Publishers+CombineLatest.swift index 2d9b7c7..34e57a8 100644 --- a/Sources/Combine/Core/Extendable/Publishers+CombineLatest.swift +++ b/Sources/Combine/Core/Extendable/Publishers+CombineLatest.swift @@ -14,7 +14,7 @@ extension Publishers { guard let first = array.first else { return Empty().eraseToAnyPublisher() } - + return array .dropFirst() .reduce( diff --git a/Sources/Combine/Core/Extendable/UITextView+Combine.swift b/Sources/Combine/Core/Extendable/UITextView+Combine.swift index 34fddf1..ae5f086 100644 --- a/Sources/Combine/Core/Extendable/UITextView+Combine.swift +++ b/Sources/Combine/Core/Extendable/UITextView+Combine.swift @@ -22,7 +22,7 @@ extension Extendable where Base: UITextView { } .eraseToAnyPublisher() } - + /// Combine wrapper for `textViewDidBeginEditing(_:)` public var didBeginEditingPublisher: AnyPublisher { let selector = #selector(UITextViewDelegate.textViewDidBeginEditing(_:)) @@ -30,7 +30,7 @@ extension Extendable where Base: UITextView { .map { _ in } .eraseToAnyPublisher() } - + /// Combine wrapper for `textViewDidEndEditing(_:)` public var didEndEditingPublisher: AnyPublisher { let selector = #selector(UITextViewDelegate.textViewDidEndEditing(_:)) @@ -38,7 +38,7 @@ extension Extendable where Base: UITextView { .map { _ in } .eraseToAnyPublisher() } - + /// A publisher emits on first responder changes public var isFirstResponderPublisher: AnyPublisher { Just(()) @@ -48,7 +48,7 @@ extension Extendable where Base: UITextView { } .eraseToAnyPublisher() } - + /// A publisher emits on selected range changes public var selectedRangePublisher: AnyPublisher { let selector = #selector(UITextViewDelegate.textViewDidChangeSelection(_:)) @@ -58,7 +58,7 @@ extension Extendable where Base: UITextView { } .eraseToAnyPublisher() } - + private var delegateProxy: DelegateProxy { TextViewDelegateProxy.createDelegateProxy(for: base) } diff --git a/Sources/Combine/Core/Keyboard/KeyboardChangeContext.swift b/Sources/Combine/Core/Keyboard/KeyboardChangeContext.swift index 5289a89..f079801 100644 --- a/Sources/Combine/Core/Keyboard/KeyboardChangeContext.swift +++ b/Sources/Combine/Core/Keyboard/KeyboardChangeContext.swift @@ -5,24 +5,24 @@ import UIKit /// The context of an upcoming change in the frame of the system keyboard. public struct _KeyboardChangeContext { // swiftlint:enable type_name - + private let base: [AnyHashable: Any] - + /// The event type of the system keyboard. public let event: KeyboardEvent - + /// The current frame of the system keyboard. public var beginFrame: CGRect { // swiftlint:disable:next force_cast base[UIResponder.keyboardFrameBeginUserInfoKey] as! CGRect } - + /// The final frame of the system keyboard. public var endFrame: CGRect { // swiftlint:disable:next force_cast base[UIResponder.keyboardFrameEndUserInfoKey] as! CGRect } - + /// The animation curve which the system keyboard will use to animate the /// change in its frame. public var animationCurve: UIView.AnimationCurve { @@ -32,14 +32,14 @@ public struct _KeyboardChangeContext { return UIView.AnimationCurve(rawValue: value.intValue)! // swiftlint:enable force_unwrapping } - + /// The duration in which the system keyboard expects to animate the change in /// its frame. public var animationDuration: Double { // swiftlint:disable:next force_cast base[UIResponder.keyboardAnimationDurationUserInfoKey] as! Double } - + /// Indicates whether the change is triggered locally. Used in iPad /// multitasking, where all foreground apps would be notified of any changes /// in the system keyboard's frame. @@ -48,7 +48,7 @@ public struct _KeyboardChangeContext { // swiftlint:disable:next force_cast base[UIResponder.keyboardIsLocalUserInfoKey] as! Bool } - + init(userInfo: [AnyHashable: Any], event: KeyboardEvent) { base = userInfo self.event = event diff --git a/Sources/Combine/Core/Keyboard/KeyboardEvent.swift b/Sources/Combine/Core/Keyboard/KeyboardEvent.swift index 097ac5c..7cae6a6 100644 --- a/Sources/Combine/Core/Keyboard/KeyboardEvent.swift +++ b/Sources/Combine/Core/Keyboard/KeyboardEvent.swift @@ -11,7 +11,7 @@ public enum KeyboardEvent { case willChangeFrame case didChangeFrame // swiftlint:enable sorted_enum_cases - + /// The name of the notification to observe system keyboard events. var notificationName: Notification.Name { switch self { diff --git a/Sources/Combine/Core/Keyboard/KeyboardListenable.swift b/Sources/Combine/Core/Keyboard/KeyboardListenable.swift index 1010fc4..f00a833 100644 --- a/Sources/Combine/Core/Keyboard/KeyboardListenable.swift +++ b/Sources/Combine/Core/Keyboard/KeyboardListenable.swift @@ -6,13 +6,13 @@ import Combine public protocol KeyboardListenable: NSObjectProtocol { // swiftlint:disable:next implicitly_unwrapped_optional var view: UIView! { get set } - + /// 适用于列表 var listView: UIScrollView? { get } - + /// 可取消的绑定 var cancellable: Set { get set } - + #if !os(tvOS) /// 键盘监听之后的逻辑 func keyboardChange(_ context: _KeyboardChangeContext) @@ -23,7 +23,7 @@ public protocol KeyboardListenable: NSObjectProtocol { extension KeyboardListenable { public var listView: UIScrollView? { nil } - + #if !os(tvOS) @available(iOSApplicationExtension, unavailable, message: "This method is NS_EXTENSION_UNAVAILABLE.") public func keyboardChange(_ context: _KeyboardChangeContext) { @@ -43,22 +43,22 @@ extension KeyboardListenable { .sink { [weak self] in (handle ?? self?.keyboardChange)?($0) } .store(in: &cancellable) } - + /// 键盘监听事件的默认行为 @available(iOSApplicationExtension, unavailable, message: "This method is NS_EXTENSION_UNAVAILABLE.") public func defaultKeyboardChangeBehavior(_ context: _KeyboardChangeContext) { // visionOS 应该不需要处理键盘弹起 #if !os(visionOS) guard let _listView = listView else { return } - + let height = UIApplication.shared.rak.statusBarHeight(in: view) + 44 - + if context.endFrame.minY != UIScreen.rak.mainBounds.height { // 弹 let bottom = context.endFrame.height - height _listView.contentInset = .init(top: 0, left: 0, bottom: bottom, right: 0) _listView.scrollIndicatorInsets = .init(top: 0, left: 0, bottom: bottom, right: 0) - + } else { // 收 _listView.contentInset = .zero diff --git a/Sources/Combine/Core/Keyboard/NotificationCenter+CombineKeyboard.swift b/Sources/Combine/Core/Keyboard/NotificationCenter+CombineKeyboard.swift index d3ff790..c1f13a6 100644 --- a/Sources/Combine/Core/Keyboard/NotificationCenter+CombineKeyboard.swift +++ b/Sources/Combine/Core/Keyboard/NotificationCenter+CombineKeyboard.swift @@ -6,13 +6,13 @@ import RAKCore extension Extendable where Base: NotificationCenter { public typealias KeyboardPublisher = AnyPublisher<_KeyboardChangeContext, Never> - + public var keyboardChange: KeyboardPublisher { keyboard(.willChangeFrame) .removeDuplicates { $0.endFrame == $1.endFrame } .eraseToAnyPublisher() } - + public func keyboard(_ event: KeyboardEvent) -> KeyboardPublisher { NotificationCenter.default .publisher(for: event.notificationName) diff --git a/Sources/Combine/Core/ObservableProperty/BindableProperty.swift b/Sources/Combine/Core/ObservableProperty/BindableProperty.swift index a19cc4e..3eb5221 100644 --- a/Sources/Combine/Core/ObservableProperty/BindableProperty.swift +++ b/Sources/Combine/Core/ObservableProperty/BindableProperty.swift @@ -9,7 +9,7 @@ public final class BindableProperty: BindableConvertibleProperty: BindableConvertibleProperty { public typealias Wrapper = ObservablePropertyWrapper - + public typealias ObservableMapBlock = Wrapper.ObservableMapBlock - + public var value: Value { observableWrapper.value } - + public var valuePublisher: AnyPublisher { observableWrapper.valuePublisher } - + public var valueMapPublisher: AnyPublisher { observableWrapper.valueMapPublisher } - + private let observableWrapper: Wrapper - + public init(_ value: Value, map: ObservableMapBlock?) { observableWrapper = .init(value, map: map) } - + public func update(_ value: Value) { observableWrapper.update(value) } diff --git a/Sources/Combine/Core/ObservableProperty/ObservableProperty.swift b/Sources/Combine/Core/ObservableProperty/ObservableProperty.swift index e9cb161..77bd75c 100644 --- a/Sources/Combine/Core/ObservableProperty/ObservableProperty.swift +++ b/Sources/Combine/Core/ObservableProperty/ObservableProperty.swift @@ -7,32 +7,32 @@ import Combine protocol ObservableProperty { associatedtype ValueType associatedtype ConvertType - + typealias ObservableMapBlock = (ValueType) -> ConvertType - + // swiftlint:disable:next private_subject var subject: CurrentValueSubject { get } - + var mapBlock: ObservableMapBlock? { get } - + init(_ value: ValueType, map: ObservableMapBlock?) - + func createValuePublisher() -> AnyPublisher - + func createValueMapPublisher() -> AnyPublisher } extension ObservableProperty { var value: ValueType { subject.value } - + func update(_ value: ValueType) { subject.send(value) } - + func createValuePublisher() -> AnyPublisher { subject.eraseToAnyPublisher() } - + func createValueMapPublisher() -> AnyPublisher { subject .compactMap { self.mapBlock?($0) } diff --git a/Sources/Combine/Core/ObservableProperty/ObservablePropertyWrapper.swift b/Sources/Combine/Core/ObservableProperty/ObservablePropertyWrapper.swift index ddc7a27..320bf02 100644 --- a/Sources/Combine/Core/ObservableProperty/ObservablePropertyWrapper.swift +++ b/Sources/Combine/Core/ObservableProperty/ObservablePropertyWrapper.swift @@ -4,18 +4,18 @@ import Combine public final class ObservablePropertyWrapper: ObservableProperty { public typealias ObservableMapBlock = (ValueType) -> ConvertType - + // swiftlint:disable:next private_subject let subject: CurrentValueSubject - + let mapBlock: ObservableMapBlock? - + /// 对外提供的绑定属性 lazy var valuePublisher = createValuePublisher() - + /// 对外提供的,值转换之后的可绑定属性 lazy var valueMapPublisher = createValueMapPublisher() - + required init(_ value: ValueType, map: ObservableMapBlock?) { subject = .init(value) mapBlock = map diff --git a/Sources/Combine/Core/Publisher/ControlEventsPublisher.swift b/Sources/Combine/Core/Publisher/ControlEventsPublisher.swift index 03da035..b8a2299 100644 --- a/Sources/Combine/Core/Publisher/ControlEventsPublisher.swift +++ b/Sources/Combine/Core/Publisher/ControlEventsPublisher.swift @@ -6,15 +6,15 @@ import Combine public struct ControlEventsPublisher: Publisher { public typealias Output = Control public typealias Failure = Never - + private let control: Control private let event: UIControl.Event - + public init(control: Control, event: UIControl.Event) { self.control = control self.event = event } - + public func receive(subscriber: S) where S: Subscriber, S.Failure == Failure, S.Input == Output { let subscription = Subscription( subscriber: subscriber, @@ -29,21 +29,21 @@ extension ControlEventsPublisher { private final class Subscription: Combine.Subscription where S.Input == C { private var subscriber: S? private var control: C? - + init(subscriber: S, control: C, event: C.Event) { self.subscriber = subscriber self.control = control - + control.addTarget(self, action: #selector(interaction), for: event) } - + func request(_: Subscribers.Demand) { } - + func cancel() { subscriber = nil control = nil } - + @objc private func interaction() { guard let control else { return } diff --git a/Sources/Combine/Core/Publisher/ControlPropertyPublisher.swift b/Sources/Combine/Core/Publisher/ControlPropertyPublisher.swift index 62b81e6..fef4e5a 100644 --- a/Sources/Combine/Core/Publisher/ControlPropertyPublisher.swift +++ b/Sources/Combine/Core/Publisher/ControlPropertyPublisher.swift @@ -6,11 +6,11 @@ import Combine public struct ControlPropertyPublisher: Publisher { public typealias Output = Value public typealias Failure = Never - + private let control: Control private let controlEvents: Control.Event private let keyPath: KeyPath - + public init( control: Control, events: Control.Event, @@ -20,7 +20,7 @@ public struct ControlPropertyPublisher: Publisher { controlEvents = events self.keyPath = keyPath } - + public func receive(subscriber: S) where S: Subscriber, S.Failure == Failure, S.Input == Output { let subscription = Subscription( subscriber: subscriber, @@ -35,13 +35,13 @@ public struct ControlPropertyPublisher: Publisher { extension ControlPropertyPublisher { private final class Subscription: Combine.Subscription where S.Input == V { let keyPath: KeyPath - + private var subscriber: S? private var control: C? - + private var didEmitInitial = false private let event: C.Event - + init(subscriber: S, control: C, event: C.Event, keyPath: KeyPath) { self.subscriber = subscriber self.control = control @@ -49,7 +49,7 @@ extension ControlPropertyPublisher { self.event = event control.addTarget(self, action: #selector(handleEvent), for: event) } - + func request(_ demand: Subscribers.Demand) { // 在第一次需求请求时发出初始值 if @@ -67,7 +67,7 @@ extension ControlPropertyPublisher { control?.removeTarget(self, action: #selector(handleEvent), for: event) subscriber = nil } - + @objc private func handleEvent() { guard let control else { return } diff --git a/Sources/Combine/Core/Publisher/ControlTargetPublisher.swift b/Sources/Combine/Core/Publisher/ControlTargetPublisher.swift index 69370e7..d790e52 100644 --- a/Sources/Combine/Core/Publisher/ControlTargetPublisher.swift +++ b/Sources/Combine/Core/Publisher/ControlTargetPublisher.swift @@ -6,14 +6,14 @@ import Combine public struct ControlTargetPublisher: Publisher { public typealias Output = Control public typealias Failure = Never - + public typealias AddTargetAction = (Control, AnyObject, Selector) -> Void public typealias RemoveTargetAction = (Control?, AnyObject, Selector) -> Void - + private let control: Control private let addTargetAction: AddTargetAction private let removeTargetAction: RemoveTargetAction - + public init( control: Control, addTargetAction: @escaping AddTargetAction, @@ -23,7 +23,7 @@ public struct ControlTargetPublisher: Publisher { self.addTargetAction = addTargetAction self.removeTargetAction = removeTargetAction } - + public func receive(subscriber: S) where S: Subscriber, S.Failure == Failure, S.Input == Output { let subscription = Subscription( subscriber: subscriber, @@ -39,13 +39,13 @@ extension ControlTargetPublisher { private final class Subscription: Combine.Subscription where S.Input == C { typealias AddTargetAction = (C, AnyObject, Selector) -> Void typealias RemoveTargetAction = (C?, AnyObject, Selector) -> Void - + private var subscriber: S? private var control: C? - + private let removeTargetAction: RemoveTargetAction private let action = #selector(interaction) - + init( subscriber: S, control: C, @@ -58,14 +58,14 @@ extension ControlTargetPublisher { addTargetAction(control, self, action) } - + func request(_: Subscribers.Demand) { } - + func cancel() { subscriber = nil removeTargetAction(control, self, action) } - + @objc private func interaction() { guard let control else { return } diff --git a/Sources/Config/Mediator/ConfigMediator.swift b/Sources/Config/Mediator/ConfigMediator.swift index cb5fc89..db2119e 100755 --- a/Sources/Config/Mediator/ConfigMediator.swift +++ b/Sources/Config/Mediator/ConfigMediator.swift @@ -16,17 +16,17 @@ public let Config = ConfigMediator() // swiftlint:disable:this identifier_name /// Mediator for calling configuration public final class ConfigMediator: ConfigSourceProtocol { private typealias Mediator = any ConfigMediatorProtocol - + private var this: Mediator { guard let mediator = self as? Mediator else { fatalError("Please make \(Self.self) implement \(Mediator.self) protocol in the main project!") } return mediator } - + public var color: ColorConfig { this.source.color } - + public var appStoreConnectAppleID: String { this.source.appStoreConnectAppleID } - + public var appGroupIdentifier: String { this.source.appGroupIdentifier } } diff --git a/Sources/Config/Mediator/ConfigMediatorProtocol.swift b/Sources/Config/Mediator/ConfigMediatorProtocol.swift index 9f7f538..b0fef14 100755 --- a/Sources/Config/Mediator/ConfigMediatorProtocol.swift +++ b/Sources/Config/Mediator/ConfigMediatorProtocol.swift @@ -11,6 +11,6 @@ import Foundation /// The middleman protocol serves as the bridge between `Mediator` and `SourceProtocol`. public protocol ConfigMediatorProtocol { associatedtype SourceProtocol: ConfigSourceProtocol - + var source: SourceProtocol { get } } diff --git a/Sources/Config/Mediator/ConfigSourceProtocol.swift b/Sources/Config/Mediator/ConfigSourceProtocol.swift index d9769e4..1b8a4dd 100755 --- a/Sources/Config/Mediator/ConfigSourceProtocol.swift +++ b/Sources/Config/Mediator/ConfigSourceProtocol.swift @@ -16,10 +16,10 @@ import Foundation public protocol ConfigSourceProtocol { /// Color configuration. var color: ColorConfig { get } - + /// App’s Apple ID on App Store Connect. var appStoreConnectAppleID: String { get } - + /// App's AppGroups identifier var appGroupIdentifier: String { get } } @@ -28,9 +28,9 @@ public protocol ConfigSourceProtocol { extension ConfigSourceProtocol { public var color: ColorConfig { .placeholder } - + public var appStoreConnectAppleID: String { "" } - + public var appGroupIdentifier: String { "" } } @@ -44,7 +44,7 @@ extension ConfigSourceProtocol { public func appDownloadURL(with area: String = "cn") -> URL? { let baseURLString = "https://itunes.apple.com/\(area)/app/id" let urlString = baseURLString + appStoreConnectAppleID - + guard let url = URL(string: urlString) else { return nil } return url } diff --git a/Sources/Config/Model/ColorConfig.swift b/Sources/Config/Model/ColorConfig.swift index 937746b..91b4c82 100644 --- a/Sources/Config/Model/ColorConfig.swift +++ b/Sources/Config/Model/ColorConfig.swift @@ -19,44 +19,44 @@ import RAKCore @dynamicMemberLookup public struct ColorConfig { public typealias Color = UIColor - + /// From the perspective of color design specifications, the higher the level, the lighter the color should be. public class SecondLevel { public let main: Color - + public let secondary: Color - + public init(main: ConvertibleToColor, secondary: ConvertibleToColor) { self.main = main.color self.secondary = secondary.color } } - + /// From the perspective of color design specifications, the higher the level, the lighter the color should be. public class ThreeLevel: SecondLevel { public let tertiary: Color - + public init(main: ConvertibleToColor, secondary: ConvertibleToColor, tertiary: ConvertibleToColor) { self.tertiary = tertiary.color super.init(main: main, secondary: secondary) } } - + /// Tool color without usage scenarios or emotional overtones. public struct Tool { /// background gray public let backgroundGray: ThreeLevel - + /// auxiliary gray public let auxiliaryGray: ThreeLevel - + /// Please use this property instead of `UIColor.white` when using white in your project public let white: Color - + /// Please use this property instead of `UIColor.black` when using white in your project public let black: Color - + public init( backgroundGray: ThreeLevel, auxiliaryGray: ThreeLevel, @@ -69,47 +69,47 @@ public struct ColorConfig { self.black = black.color } } - + /// Define different colors according to usage scenarios. public struct Semantic { /// Theme color /// - /// Provides two levels of theme colors, + /// Provides three levels of theme colors, /// you can use different levels of theme colors according to the situation. - public let theme: SecondLevel - + public let theme: ThreeLevel + /// Text color public let text: ThreeLevel - + /// The color of the list dividing line. /// /// Generally refers to the color of the dividing line of UITableView, /// which means that it does not include the "separator bar". public let separator: Color - + /// Emphasis color. /// /// Provides three levels of choices for expressing *errors*, *warnings*, and *emphasis*. /// Recommendation: As the level increases, the degree should decrease: `main` represents `error`. public let emphasis: ThreeLevel - + /// Border color /// /// If you need transparency, you need to handle it yourself when defining the color value. public let border: Color - + /// Shadow color. /// /// If you need transparency, you need to handle it yourself when defining the color value. public let shadow: Color - + /// Text color when expressing "unavailable". /// /// Color commonly used when buttons are not clickable. public let unavailableText: Color - + public init( - theme: SecondLevel, + theme: ThreeLevel, text: ThreeLevel, separator: ConvertibleToColor, emphasis: ThreeLevel, @@ -126,13 +126,13 @@ public struct ColorConfig { self.unavailableText = unavailableText.color } } - + /// Tool color without usage scenarios or emotional overtones. public let tool: Tool - + /// Define different colors according to usage scenarios. public let semantic: Semantic - + public init(tool: Tool, semantic: Semantic) { self.tool = tool self.semantic = semantic @@ -145,7 +145,7 @@ extension ColorConfig { public subscript(dynamicMember keyPath: KeyPath) -> T { tool[keyPath: keyPath] } - + public subscript(dynamicMember keyPath: KeyPath) -> T { semantic[keyPath: keyPath] } @@ -171,11 +171,12 @@ extension ColorConfig { white: UIColor.tertiarySystemBackground, black: UIColor.label ) - + let semanticConfig = Semantic( theme: .init( main: UIColor.systemIndigo, - secondary: UIColor.systemIndigo.withAlphaComponent(0.8) + secondary: UIColor.systemIndigo.withAlphaComponent(0.8), + tertiary: UIColor.systemIndigo.withAlphaComponent(0.6) ), text: .init( main: UIColor.label, @@ -192,7 +193,7 @@ extension ColorConfig { shadow: toolConfig.black.color.withAlphaComponent(0.2), unavailableText: UIColor.systemGray ) - + return Self(tool: toolConfig, semantic: semanticConfig) }() @@ -217,7 +218,8 @@ extension ColorConfig { let semanticConfig = Semantic( theme: .init( main: UIColor.blue, - secondary: UIColor.blue.withAlphaComponent(0.8) + secondary: UIColor.blue.withAlphaComponent(0.8), + tertiary: UIColor.blue.withAlphaComponent(0.6) ), text: .init( main: UIColor.black, @@ -259,7 +261,8 @@ extension ColorConfig { let semanticConfig = Semantic( theme: .init( main: UIColor.blue, - secondary: UIColor.blue.withAlphaComponent(0.8) + secondary: UIColor.blue.withAlphaComponent(0.8), + tertiary: UIColor.blue.withAlphaComponent(0.6) ), text: .init( main: UIColor.black, diff --git a/Sources/Config/Model/EmptyConfig.swift b/Sources/Config/Model/EmptyConfig.swift index c2e93f4..bd5f369 100644 --- a/Sources/Config/Model/EmptyConfig.swift +++ b/Sources/Config/Model/EmptyConfig.swift @@ -18,6 +18,6 @@ import Foundation /// ``` public final class EmptyConfig: ConfigSourceProtocol { public static let shared = EmptyConfig() - + private init() { } }