Skip to content

Commit

Permalink
isOn
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanPodymov committed Apr 1, 2024
1 parent 118474c commit c1fbded
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions Sources/CommonAppleKit/CommonAppleKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@
#endif
public typealias CAControl = UIControl

public extension CAControl {
func addTargetForPrimaryActionTriggered(
_ target: AnyObject,
action: Selector
) {
addTarget(target, action: action, for: .primaryActionTriggered)
}

func addTargetForValueChanged(
_ target: AnyObject,
action: Selector
) {
addTarget(target, action: action, for: .valueChanged)
}

func actions(for target: Any) -> [String] {
actions(forTarget: target, forControlEvent: .primaryActionTriggered) ?? []
}
}

public extension CALabel {
var stringValue: String {
get {
Expand Down Expand Up @@ -91,17 +111,6 @@
setImage(image, for: state)
}
}

func addTargetForPrimaryActionTriggered(
_ target: AnyObject,
action: Selector
) {
addTarget(target, action: action, for: .primaryActionTriggered)
}

func actions(for target: Any) -> [String] {
actions(forTarget: target, forControlEvent: .primaryActionTriggered) ?? []
}
}

public extension CAViewController {
Expand Down Expand Up @@ -201,6 +210,12 @@
}
}

public extension CASwitch {
var isOn: Bool {
state == .on
}
}

public extension CAButton {
func setTitle(_ title: String) {
self.title = title
Expand Down

0 comments on commit c1fbded

Please sign in to comment.