Merge commit '8bb25ff12edfd2d82a958ce6189d0ab05ee5c699' into beta

This commit is contained in:
Ali 2022-04-21 21:59:15 +04:00
commit ff4c4f963b
3 changed files with 51 additions and 18 deletions

View File

@ -103,7 +103,7 @@ class InviteLinkHeaderItemNode: ListViewItemNode {
return { item, params, neighbors in
let leftInset: CGFloat = 32.0 + params.leftInset
let topInset: CGFloat = 92.0
let topInset: CGFloat = 124.0
let attributedText = parseMarkdownIntoAttributedString(item.text, attributes: MarkdownAttributes(body: MarkdownAttributeSet(font: titleFont, textColor: item.theme.list.freeTextColor), bold: MarkdownAttributeSet(font: titleFont, textColor: item.theme.list.freeTextColor), link: MarkdownAttributeSet(font: titleFont, textColor: item.theme.list.itemAccentColor), linkAttribute: { contents in
return (TelegramTextAttributes.URL, contents)

View File

@ -1063,6 +1063,8 @@ public final class SparseItemGrid: ASDisplayNode {
}
}
private var previousScrollingUpdate: (timestamp: Double, date: String?, tag: Int32?)?
private func updateScrollingArea() {
guard let layout = self.layout, let items = self.items, !items.items.isEmpty else {
return
@ -1089,16 +1091,38 @@ public final class SparseItemGrid: ASDisplayNode {
}
}
scrollingArea.update(
containerSize: layout.containerLayout.size,
containerInsets: layout.containerLayout.insets,
contentHeight: contentHeight,
contentOffset: self.scrollView.bounds.minY,
isScrolling: self.scrollView.isDragging || self.scrollView.isDecelerating || self.decelerationAnimator != nil,
date: (dateString ?? "", tag ?? 0),
theme: self.theme,
transition: .immediate
)
let currentTimestamp = CACurrentMediaTime()
let update: (String?, Int32?) -> Void = { dateString, tag in
scrollingArea.update(
containerSize: layout.containerLayout.size,
containerInsets: layout.containerLayout.insets,
contentHeight: contentHeight,
contentOffset: self.scrollView.bounds.minY,
isScrolling: self.scrollView.isDragging || self.scrollView.isDecelerating || self.decelerationAnimator != nil,
date: (dateString ?? "", tag ?? 0),
theme: self.theme,
transition: .immediate
)
}
if let (timestamp, previousDateString, previousTag) = self.previousScrollingUpdate {
let delta = currentTimestamp - timestamp
let delay = 0.1
if delta < delay {
update(previousDateString, previousTag)
Queue.mainQueue().after(max(0.0, min(delay, timestamp + delay - currentTimestamp)), {
if self.currentScrollingTag == tag {
self.previousScrollingUpdate = (CACurrentMediaTime(), dateString, tag)
update(dateString, tag)
}
})
} else {
self.previousScrollingUpdate = (currentTimestamp, dateString, tag)
update(dateString, tag)
}
} else {
self.previousScrollingUpdate = (currentTimestamp, dateString, tag)
update(dateString, tag)
}
}
}
}

View File

@ -481,6 +481,7 @@ private final class RoundedRectangle: Component {
}
}
private let shadowInset: CGFloat = 10.0
private final class ShadowRoundedRectangle: Component {
let color: UIColor
@ -514,7 +515,6 @@ private final class ShadowRoundedRectangle: Component {
}
func update(component: ShadowRoundedRectangle, availableSize: CGSize, environment: Environment<Empty>, transition: Transition) -> CGSize {
let shadowInset: CGFloat = 10.0
let diameter = min(availableSize.width, availableSize.height)
var updated = false
@ -540,9 +540,10 @@ private final class ShadowRoundedRectangle: Component {
})?.stretchableImage(withLeftCapWidth: Int(diameter + shadowInset * 2.0) / 2, topCapHeight: Int(diameter + shadowInset * 2.0) / 2)
}
transition.setFrame(view: self.backgroundView, frame: CGRect(origin: CGPoint(x: -shadowInset, y: -shadowInset), size: CGSize(width: availableSize.width + shadowInset * 2.0, height: availableSize.height + shadowInset * 2.0)))
let shadowFrame = CGRect(origin: CGPoint(x: -shadowInset, y: -shadowInset), size: CGSize(width: availableSize.width + shadowInset * 2.0, height: availableSize.height + shadowInset * 2.0))
transition.setFrame(view: self.backgroundView, frame: shadowFrame)
return availableSize
return shadowFrame.size
}
}
@ -817,7 +818,7 @@ final class SparseItemGridScrollingIndicatorComponent: CombinedComponent {
))
context.add(rect
.position(CGPoint(x: rectFrame.midX, y: rectFrame.midY))
.position(CGPoint(x: rectFrame.midX + shadowInset, y: rectFrame.midY + shadowInset))
)
let offset = CGSize(width: textMonth.size.width + 3.0 + textYear.size.width, height: textMonth.size.height).centered(in: rectFrame)
@ -926,6 +927,7 @@ public final class SparseItemGridScrollingArea: ASDisplayNode {
}
}
private let dateIndicatorContainer: UIView
private let dateIndicator: ComponentHostView<Empty>
private let lineIndicator: ComponentHostView<Empty>
@ -978,6 +980,9 @@ public final class SparseItemGridScrollingArea: ASDisplayNode {
private var theme: PresentationTheme?
override public init() {
self.dateIndicatorContainer = UIView()
self.dateIndicatorContainer.isUserInteractionEnabled = false
self.dateIndicator = ComponentHostView<Empty>()
self.lineIndicator = ComponentHostView<Empty>()
@ -989,7 +994,8 @@ public final class SparseItemGridScrollingArea: ASDisplayNode {
self.dateIndicator.isUserInteractionEnabled = false
self.lineIndicator.isUserInteractionEnabled = false
self.view.addSubview(self.dateIndicator)
self.view.addSubview(self.dateIndicatorContainer)
self.dateIndicatorContainer.addSubview(self.dateIndicator)
self.view.addSubview(self.lineIndicator)
let dragGesture = DragGesture(
@ -1180,11 +1186,14 @@ public final class SparseItemGridScrollingArea: ASDisplayNode {
scrollableHeight: contentHeight - containerSize.height
)
self.dateIndicatorContainer.frame = CGRect(origin: CGPoint(x: 0.0, y: dateIndicatorPosition), size: CGSize(width: containerSize.width, height: indicatorSize.height))
var indicatorFrameTransition = transition
if animateIndicatorFrame {
indicatorFrameTransition = .animated(duration: 0.2, curve: .easeInOut)
}
indicatorFrameTransition.updateFrame(view: self.dateIndicator, frame: CGRect(origin: CGPoint(x: containerSize.width - 12.0 - indicatorSize.width, y: dateIndicatorPosition), size: indicatorSize))
indicatorFrameTransition.updateFrame(view: self.dateIndicator, frame: CGRect(origin: CGPoint(x: containerSize.width - 12.0 - indicatorSize.width, y: 0.0), size: indicatorSize))
if isScrolling {
let transition: ContainedViewLayoutTransition = .animated(duration: 0.3, curve: .easeInOut)
transition.updateAlpha(layer: self.dateIndicator.layer, alpha: 1.0)
@ -1318,7 +1327,7 @@ public final class SparseItemGridScrollingArea: ASDisplayNode {
if self.dateIndicator.alpha <= 0.01 {
return nil
}
if self.dateIndicator.frame.contains(point) {
if self.dateIndicator.frame.offsetBy(dx: self.dateIndicatorContainer.frame.minX, dy: self.dateIndicatorContainer.frame.minY).contains(point) {
return super.hitTest(point, with: event)
}