mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Various Fixes
This commit is contained in:
@@ -4,12 +4,17 @@ import AsyncDisplayKit
|
||||
import Display
|
||||
import TelegramPresentationData
|
||||
|
||||
private func botPaymentListHasRoundedBlockLayout(_ width: CGFloat) -> Bool {
|
||||
return width >= 375.0
|
||||
}
|
||||
|
||||
class BotPaymentItemNode: ASDisplayNode {
|
||||
private let needsBackground: Bool
|
||||
|
||||
let backgroundNode: ASDisplayNode
|
||||
private let topSeparatorNode: ASDisplayNode
|
||||
private let bottomSeparatorNode: ASDisplayNode
|
||||
private let maskNode: ASImageNode
|
||||
|
||||
private var theme: PresentationTheme?
|
||||
|
||||
@@ -20,6 +25,9 @@ class BotPaymentItemNode: ASDisplayNode {
|
||||
self.topSeparatorNode = ASDisplayNode()
|
||||
self.bottomSeparatorNode = ASDisplayNode()
|
||||
|
||||
self.maskNode = ASImageNode()
|
||||
self.maskNode.isUserInteractionEnabled = false
|
||||
|
||||
super.init()
|
||||
|
||||
if needsBackground {
|
||||
@@ -33,7 +41,7 @@ class BotPaymentItemNode: ASDisplayNode {
|
||||
return 0.0
|
||||
}
|
||||
|
||||
final func updateLayout(theme: PresentationTheme, width: CGFloat, measuredInset: CGFloat, previousItemNode: BotPaymentItemNode?, nextItemNode: BotPaymentItemNode?, transition: ContainedViewLayoutTransition) -> CGFloat {
|
||||
final func updateLayout(theme: PresentationTheme, width: CGFloat, sideInset: CGFloat, measuredInset: CGFloat, previousItemNode: BotPaymentItemNode?, nextItemNode: BotPaymentItemNode?, transition: ContainedViewLayoutTransition) -> CGFloat {
|
||||
if self.theme !== theme {
|
||||
self.theme = theme
|
||||
self.backgroundNode.backgroundColor = theme.list.itemBlocksBackgroundColor
|
||||
@@ -41,28 +49,43 @@ class BotPaymentItemNode: ASDisplayNode {
|
||||
self.bottomSeparatorNode.backgroundColor = theme.list.itemBlocksSeparatorColor
|
||||
}
|
||||
|
||||
let height = self.layoutContents(theme: theme, width: width, measuredInset: measuredInset, transition: transition)
|
||||
let height = self.layoutContents(theme: theme, width: width, sideInset: sideInset, measuredInset: measuredInset, transition: transition)
|
||||
|
||||
var topSeparatorInset: CGFloat = 0.0
|
||||
|
||||
if self.maskNode.supernode == nil {
|
||||
self.addSubnode(self.maskNode)
|
||||
}
|
||||
|
||||
let hasCorners = botPaymentListHasRoundedBlockLayout(width)
|
||||
var hasTopCorners = false
|
||||
var hasBottomCorners = false
|
||||
|
||||
if let previousItemNode = previousItemNode, previousItemNode.needsBackground {
|
||||
topSeparatorInset = 16.0
|
||||
} else {
|
||||
hasTopCorners = true
|
||||
self.topSeparatorNode.isHidden = hasCorners
|
||||
}
|
||||
if let nextItemNode = nextItemNode, nextItemNode.needsBackground {
|
||||
self.bottomSeparatorNode.isHidden = true
|
||||
} else {
|
||||
hasBottomCorners = true
|
||||
self.bottomSeparatorNode.isHidden = hasCorners
|
||||
}
|
||||
|
||||
if let nextItemNode = nextItemNode, nextItemNode.needsBackground {
|
||||
bottomSeparatorNode.isHidden = true
|
||||
} else {
|
||||
bottomSeparatorNode.isHidden = false
|
||||
}
|
||||
self.maskNode.image = hasCorners ? PresentationResourcesItemList.cornersImage(theme, top: hasTopCorners, bottom: hasBottomCorners) : nil
|
||||
|
||||
transition.updateFrame(node: self.backgroundNode, frame: CGRect(origin: CGPoint(), size: CGSize(width: width, height: height)))
|
||||
transition.updateFrame(node: self.topSeparatorNode, frame: CGRect(origin: CGPoint(x: topSeparatorInset, y: 0.0), size: CGSize(width: width - topSeparatorInset, height: UIScreenPixel)))
|
||||
transition.updateFrame(node: self.bottomSeparatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: height - UIScreenPixel), size: CGSize(width: width, height: UIScreenPixel)))
|
||||
transition.updateFrame(node: self.maskNode, frame: self.backgroundNode.frame.insetBy(dx: sideInset, dy: 0.0))
|
||||
|
||||
transition.updateFrame(node: self.topSeparatorNode, frame: CGRect(origin: CGPoint(x: topSeparatorInset + sideInset, y: 0.0), size: CGSize(width: width - topSeparatorInset - sideInset - sideInset, height: UIScreenPixel)))
|
||||
transition.updateFrame(node: self.bottomSeparatorNode, frame: CGRect(origin: CGPoint(x: sideInset, y: height - UIScreenPixel), size: CGSize(width: width - sideInset - sideInset, height: UIScreenPixel)))
|
||||
|
||||
return height
|
||||
}
|
||||
|
||||
func layoutContents(theme: PresentationTheme, width: CGFloat, measuredInset: CGFloat, transition: ContainedViewLayoutTransition) -> CGFloat {
|
||||
func layoutContents(theme: PresentationTheme, width: CGFloat, sideInset: CGFloat, measuredInset: CGFloat, transition: ContainedViewLayoutTransition) -> CGFloat {
|
||||
return 0.0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user