mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
Various Fixes
This commit is contained in:
@@ -94,6 +94,7 @@ enum BotCheckoutInfoControllerStatus {
|
||||
|
||||
final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, UIScrollViewDelegate {
|
||||
private let context: AccountContext
|
||||
private weak var navigationBar: NavigationBar?
|
||||
private let invoice: BotPaymentInvoice
|
||||
private let messageId: EngineMessage.Id
|
||||
private var focus: BotCheckoutInfoControllerFocus?
|
||||
@@ -111,6 +112,8 @@ final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, UIScrollVi
|
||||
|
||||
private let scrollNode: BotCheckoutInfoControllerScrollerNode
|
||||
private let itemNodes: [[BotPaymentItemNode]]
|
||||
private let leftOverlayNode: ASDisplayNode
|
||||
private let rightOverlayNode: ASDisplayNode
|
||||
|
||||
private let addressItems: BotCheckoutInfoAddressItems?
|
||||
private let nameItem: BotPaymentFieldItemNode?
|
||||
@@ -125,6 +128,7 @@ final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, UIScrollVi
|
||||
|
||||
init(
|
||||
context: AccountContext,
|
||||
navigationBar: NavigationBar?,
|
||||
invoice: BotPaymentInvoice,
|
||||
messageId: EngineMessage.Id,
|
||||
formInfo: BotPaymentRequestedInfo,
|
||||
@@ -138,6 +142,7 @@ final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, UIScrollVi
|
||||
present: @escaping (ViewController, Any?) -> Void
|
||||
) {
|
||||
self.context = context
|
||||
self.navigationBar = navigationBar
|
||||
self.invoice = invoice
|
||||
self.messageId = messageId
|
||||
self.formInfo = formInfo
|
||||
@@ -152,6 +157,10 @@ final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, UIScrollVi
|
||||
self.strings = strings
|
||||
|
||||
self.scrollNode = BotCheckoutInfoControllerScrollerNode()
|
||||
self.leftOverlayNode = ASDisplayNode()
|
||||
self.leftOverlayNode.isUserInteractionEnabled = false
|
||||
self.rightOverlayNode = ASDisplayNode()
|
||||
self.rightOverlayNode.isUserInteractionEnabled = false
|
||||
|
||||
var itemNodes: [[BotPaymentItemNode]] = []
|
||||
|
||||
@@ -227,6 +236,9 @@ final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, UIScrollVi
|
||||
super.init()
|
||||
|
||||
self.backgroundColor = self.theme.list.blocksBackgroundColor
|
||||
self.leftOverlayNode.backgroundColor = self.theme.list.blocksBackgroundColor
|
||||
self.rightOverlayNode.backgroundColor = self.theme.list.blocksBackgroundColor
|
||||
|
||||
self.scrollNode.backgroundColor = nil
|
||||
self.scrollNode.isOpaque = false
|
||||
self.scrollNode.view.alwaysBounceVertical = true
|
||||
@@ -319,6 +331,12 @@ final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, UIScrollVi
|
||||
self.verifyDisposable.dispose()
|
||||
}
|
||||
|
||||
override func didLoad() {
|
||||
super.didLoad()
|
||||
|
||||
self.navigationBar?.updateBackgroundAlpha(0.0, transition: .immediate)
|
||||
}
|
||||
|
||||
func updateCountry(_ iso2: String) {
|
||||
if self.formInfo.shippingAddress?.countryIso2 != iso2, let name = AuthorizationSequenceCountrySelectionController.lookupCountryNameById(iso2, strings: self.strings) {
|
||||
let shippingAddress: BotPaymentShippingAddress
|
||||
@@ -435,6 +453,12 @@ final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, UIScrollVi
|
||||
}
|
||||
}
|
||||
|
||||
let inset = max(16.0, floor((layout.size.width - 674.0) / 2.0))
|
||||
var sideInset: CGFloat = 0.0
|
||||
if layout.size.width >= 375.0 {
|
||||
sideInset = inset
|
||||
}
|
||||
|
||||
for items in self.itemNodes {
|
||||
if !items.isEmpty && items[0] is BotPaymentHeaderItemNode {
|
||||
contentHeight += 24.0
|
||||
@@ -444,7 +468,7 @@ final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, UIScrollVi
|
||||
|
||||
for i in 0 ..< items.count {
|
||||
let item = items[i]
|
||||
let itemHeight = item.updateLayout(theme: self.theme, width: layout.size.width, measuredInset: commonInset, previousItemNode: i == 0 ? nil : items[i - 1], nextItemNode: i == (items.count - 1) ? nil : items[i + 1], transition: transition)
|
||||
let itemHeight = item.updateLayout(theme: self.theme, width: layout.size.width, sideInset: sideInset, measuredInset: commonInset, previousItemNode: i == 0 ? nil : items[i - 1], nextItemNode: i == (items.count - 1) ? nil : items[i + 1], transition: transition)
|
||||
transition.updateFrame(node: item, frame: CGRect(origin: CGPoint(x: 0.0, y: contentHeight), size: CGSize(width: layout.size.width, height: itemHeight)))
|
||||
contentHeight += itemHeight
|
||||
}
|
||||
@@ -462,6 +486,16 @@ final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, UIScrollVi
|
||||
self.scrollNode.view.scrollIndicatorInsets = insets
|
||||
self.scrollNode.view.ignoreUpdateBounds = false
|
||||
|
||||
if self.rightOverlayNode.supernode == nil {
|
||||
self.insertSubnode(self.rightOverlayNode, aboveSubnode: self.scrollNode)
|
||||
}
|
||||
if self.leftOverlayNode.supernode == nil {
|
||||
self.insertSubnode(self.leftOverlayNode, aboveSubnode: self.scrollNode)
|
||||
}
|
||||
|
||||
self.leftOverlayNode.frame = CGRect(x: 0.0, y: 0.0, width: sideInset, height: layout.size.height)
|
||||
self.rightOverlayNode.frame = CGRect(x: layout.size.width - sideInset, y: 0.0, width: sideInset, height: layout.size.height)
|
||||
|
||||
if let focus = self.focus {
|
||||
var focusItem: ASDisplayNode?
|
||||
switch focus {
|
||||
@@ -525,6 +559,11 @@ final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, UIScrollVi
|
||||
})
|
||||
}
|
||||
|
||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
let value = scrollView.contentOffset.y + scrollView.contentInset.top
|
||||
self.navigationBar?.updateBackgroundAlpha(min(30.0, value) / 30.0, transition: .immediate)
|
||||
}
|
||||
|
||||
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
|
||||
self.focus = nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user