Skip to content

Commit

Permalink
fix: ButtonRow update image behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
rakuyoMo committed May 25, 2024
1 parent 743dfd8 commit 15036d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Sources/Epoxy/Row/ButtonRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ extension ButtonRow: ContentConfigurableView {
extension ButtonRow: BehaviorsConfigurableView {
/// For a custom Row inherited from `UIControl`, you can also use this type to set the control behavior,
/// and use the generic T to access the custom `UIImageView` that may exist in the control.
public struct Behaviors<T: UIImageView> {
public struct Behaviors<T> {
/// Asynchronously updates the image.
public let updateImage: ImageRow.Behaviors<T>?

Expand All @@ -253,7 +253,7 @@ extension ButtonRow: BehaviorsConfigurableView {
}
}

public func setBehaviors(_ behaviors: Behaviors<UIImageView>?) {
public func setBehaviors(_ behaviors: Behaviors<ButtonRow>?) {
if let updateImage = behaviors?.updateImage {
if let asyncUpdateImage = updateImage.asyncUpdateImage {
asyncUpdateImage { [weak self] in self?.imageView?.image = $0 }
Expand All @@ -267,8 +267,8 @@ extension ButtonRow: BehaviorsConfigurableView {
}

if let customUpdateImage = updateImage.customUpdateImage {
weak var imageView = imageView
customUpdateImage(imageView)
weak var this = self
customUpdateImage(this)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Epoxy/Row/ImageRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ extension ImageRow: ContentConfigurableView {
// MARK: BehaviorsConfigurableView

extension ImageRow: BehaviorsConfigurableView {
public struct Behaviors<T: UIImageView> {
public struct Behaviors<T> {
public typealias AsyncUpdateImage = ((UIImage?) -> Void) -> Void

public typealias ConcurrencyUpdateImage = () async -> UIImage?
Expand Down

0 comments on commit 15036d5

Please sign in to comment.