Fixing binding to wrong view
This commit is contained in:
parent
1a4abe5a56
commit
d8e27b70ea
@ -41,9 +41,9 @@ extension UIView {
|
|||||||
to srcTag: Int,
|
to srcTag: Int,
|
||||||
srcProp: KeyPath<SrcView,Published<Src>.Publisher>) -> Self where Dst: InitConvertible, Dst.Param == Src {
|
srcProp: KeyPath<SrcView,Published<Src>.Publisher>) -> Self where Dst: InitConvertible, Dst.Param == Src {
|
||||||
|
|
||||||
bindings.add(BindingModel(srcTag: srcTag, dstTag: tag, bind: { container, srcTag, dstTag in
|
bindings.add(BindingModel(srcTag: srcTag, dstView: self, bind: { container, srcTag, dstView in
|
||||||
guard let srcView = container.viewWithTag(srcTag) as? SrcView,
|
guard let srcView = container.viewWithTag(srcTag) as? SrcView,
|
||||||
let dstView = container.viewWithTag(dstTag) as? DstView
|
let dstView = dstView as? DstView
|
||||||
else {
|
else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,17 +5,17 @@
|
|||||||
// Created by Мустафаев Селим Мустафаевич on 03.08.2023.
|
// Created by Мустафаев Селим Мустафаевич on 03.08.2023.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import UIKit
|
||||||
|
|
||||||
class BindingModel {
|
class BindingModel {
|
||||||
|
|
||||||
var srcTag: Int
|
var srcTag: Int
|
||||||
var dstTag: Int
|
weak var dstView: UIView?
|
||||||
var bind: (ContainerView, Int, Int) -> Bool
|
var bind: (ContainerView, Int, UIView?) -> Bool
|
||||||
|
|
||||||
init(srcTag: Int, dstTag: Int, bind: @escaping (ContainerView, Int, Int) -> Bool) {
|
init(srcTag: Int, dstView: UIView, bind: @escaping (ContainerView, Int, UIView?) -> Bool) {
|
||||||
self.srcTag = srcTag
|
self.srcTag = srcTag
|
||||||
self.dstTag = dstTag
|
self.dstView = dstView
|
||||||
self.bind = bind
|
self.bind = bind
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@ open class ContainerView: UIView {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if !binding.bind(self, binding.srcTag, binding.dstTag) {
|
if !binding.bind(self, binding.srcTag, binding.dstView) {
|
||||||
failedBindings.append(binding)
|
failedBindings.append(binding)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user