Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
Ilya Laktyushin
2022-07-08 14:30:56 +02:00
3 changed files with 18 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ import TelegramPresentationData
import ItemListUI
import PresentationDataUtils
import PhotoResources
import Postbox
class BotCheckoutHeaderItem: ListViewItem, ItemListItem {
let account: Account
@@ -77,6 +78,8 @@ class BotCheckoutHeaderItemNode: ListViewItemNode {
private var item: BotCheckoutHeaderItem?
private let fetchDisposable = MetaDisposable()
init() {
self.backgroundNode = ASDisplayNode()
self.backgroundNode.isLayerBacked = true
@@ -119,6 +122,10 @@ class BotCheckoutHeaderItemNode: ListViewItemNode {
self.addSubnode(self.botNameNode)
}
deinit {
self.fetchDisposable.dispose()
}
func asyncLayout() -> (_ item: BotCheckoutHeaderItem, _ params: ListViewItemLayoutParams, _ neighbors: ItemListNeighbors) -> (ListViewItemNodeLayout, () -> Void) {
let makeTitleLayout = TextNode.asyncLayout(self.titleNode)
let makeTextLayout = TextNode.asyncLayout(self.textNode)
@@ -159,12 +166,14 @@ class BotCheckoutHeaderItemNode: ListViewItemNode {
var imageApply: (() -> Void)?
var updatedImageSignal: Signal<(TransformImageArguments) -> DrawingContext?, NoError>?
var updatedFetchSignal: Signal<FetchResourceSourceType, FetchResourceError>?
if let photo = item.invoice.photo, let dimensions = photo.dimensions {
let arguments = TransformImageArguments(corners: ImageCorners(radius: 4.0), imageSize: dimensions.cgSize.aspectFilled(imageSize), boundingSize: imageSize, intrinsicInsets: UIEdgeInsets(), emptyColor: item.theme.list.mediaPlaceholderColor)
imageApply = makeImageLayout(arguments)
maxTextWidth = max(1.0, maxTextWidth - imageSize.width - imageTextSpacing)
if imageUpdated {
updatedImageSignal = chatWebFileImage(account: item.account, file: photo)
updatedFetchSignal = fetchedMediaResource(mediaBox: item.account.postbox.mediaBox, reference: .standalone(resource: photo.resource))
}
}
@@ -206,6 +215,9 @@ class BotCheckoutHeaderItemNode: ListViewItemNode {
if let updatedImageSignal = updatedImageSignal {
strongSelf.imageNode.setSignal(updatedImageSignal)
}
if let updatedFetchSignal = updatedFetchSignal {
strongSelf.fetchDisposable.set(updatedFetchSignal.start())
}
strongSelf.imageNode.isHidden = false
} else {
strongSelf.imageNode.isHidden = true

View File

@@ -109,8 +109,11 @@ public final class ComponentHostView<EnvironmentType>: UIView {
if self.alpha.isZero {
return nil
}
if !self.isUserInteractionEnabled {
return nil
}
for view in self.subviews.reversed() {
if let result = view.hitTest(self.convert(point, to: view), with: event), result.isUserInteractionEnabled {
if view.isUserInteractionEnabled, view.alpha != 0.0, let result = view.hitTest(self.convert(point, to: view), with: event) {
return result
}
}

View File

@@ -48,7 +48,6 @@ public final class AudioTranscriptionButtonComponent: Component {
override init(frame: CGRect) {
self.backgroundLayer = SimpleLayer()
self.animationView = ComponentHostView<Empty>()
self.animationView.isUserInteractionEnabled = false
super.init(frame: frame)
@@ -56,6 +55,8 @@ public final class AudioTranscriptionButtonComponent: Component {
self.backgroundLayer.cornerRadius = 10.0
self.layer.addSublayer(self.backgroundLayer)
self.animationView.isUserInteractionEnabled = false
self.addSubview(self.animationView)
self.addTarget(self, action: #selector(self.pressed), for: .touchUpInside)