Various fixes

This commit is contained in:
Ilya Laktyushin 2024-06-18 02:18:43 +04:00
parent 0add36f341
commit 2292e8cac8
3 changed files with 43 additions and 10 deletions

View File

@ -98,7 +98,7 @@ public final class StatsGraphItem: ListViewItem, ItemListItem, ListItemComponent
public var selectable: Bool = false
}
class StatsGraphItemNode: ListViewItemNode {
public final class StatsGraphItemNode: ListViewItemNode {
private let backgroundNode: ASDisplayNode
private let topStripeNode: ASDisplayNode
private let bottomStripeNode: ASDisplayNode
@ -139,7 +139,7 @@ class StatsGraphItemNode: ListViewItemNode {
self.chartContainerNode.addSubnode(self.activityIndicator)
}
override func didLoad() {
public override func didLoad() {
super.didLoad()
self.view.interactiveTransitionGestureRecognizerTest = { point -> Bool in
@ -147,7 +147,7 @@ class StatsGraphItemNode: ListViewItemNode {
}
}
func resetInteraction() {
public func resetInteraction() {
self.chartNode.resetInteraction()
}
@ -313,15 +313,15 @@ class StatsGraphItemNode: ListViewItemNode {
}
}
override func animateInsertion(_ currentTimestamp: Double, duration: Double, options: ListViewItemAnimationOptions) {
public override func animateInsertion(_ currentTimestamp: Double, duration: Double, options: ListViewItemAnimationOptions) {
self.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.4)
}
override func animateAdded(_ currentTimestamp: Double, duration: Double) {
public override func animateAdded(_ currentTimestamp: Double, duration: Double) {
self.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
}
override func animateRemoved(_ currentTimestamp: Double, duration: Double) {
public override func animateRemoved(_ currentTimestamp: Double, duration: Double) {
self.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.15, removeOnCompletion: false)
}
}

View File

@ -46,7 +46,7 @@ public final class ListItemComponentAdaptor: Component {
}
public final class View: UIView {
private var itemNode: ListViewItemNode?
public var itemNode: ListViewItemNode?
func update(component: ListItemComponentAdaptor, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
let item = component.itemImpl()

View File

@ -82,6 +82,35 @@ final class StarsStatisticsScreenComponent: Component {
return super.contentOffset
}
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool {
if let _ = otherGestureRecognizer as? UIPanGestureRecognizer {
return true
}
return false
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return false
}
override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
if gestureRecognizer is UIPanGestureRecognizer, let gestureRecognizers = gestureRecognizer.view?.gestureRecognizers {
for otherGestureRecognizer in gestureRecognizers {
if otherGestureRecognizer !== gestureRecognizer, let panGestureRecognizer = otherGestureRecognizer as? UIPanGestureRecognizer, panGestureRecognizer.minimumNumberOfTouches == 2 {
return gestureRecognizer.numberOfTouches < 2
}
}
if let view = gestureRecognizer.view?.hitTest(gestureRecognizer.location(in: gestureRecognizer.view), with: nil) as? UIControl {
return !view.isTracking
}
return true
} else {
return true
}
}
}
class View: UIView, UIScrollViewDelegate {
@ -179,7 +208,7 @@ final class StarsStatisticsScreenComponent: Component {
deinit {
self.stateDisposable?.dispose()
}
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
self.enableVelocityTracking = true
}
@ -194,6 +223,10 @@ final class StarsStatisticsScreenComponent: Component {
}
self.updateScrolling(transition: .immediate)
if let view = self.chartView.view as? ListItemComponentAdaptor.View, let node = view.itemNode as? StatsGraphItemNode {
node.resetInteraction()
}
}
}
@ -332,7 +365,7 @@ final class StarsStatisticsScreenComponent: Component {
transition.setBounds(view: titleView, bounds: CGRect(origin: .zero, size: titleSize))
}
if let revenueGraph = starsState?.revenueGraph {
if let revenueGraph = self.starsState?.revenueGraph {
let chartSize = self.chartView.update(
transition: .immediate,
component: AnyComponent(ListSectionComponent(
@ -348,7 +381,7 @@ final class StarsStatisticsScreenComponent: Component {
footer: nil,
items: [
AnyComponentWithIdentity(id: 0, component: AnyComponent(ListItemComponentAdaptor(
itemGenerator: StatsGraphItem(presentationData: ItemListPresentationData(presentationData), graph: revenueGraph, type: .stars, conversionRate: starsState?.usdRate ?? 0.0, sectionId: 0, style: .blocks),
itemGenerator: StatsGraphItem(presentationData: ItemListPresentationData(presentationData), graph: revenueGraph, type: .stars, noInitialZoom: true, conversionRate: starsState?.usdRate ?? 0.0, sectionId: 0, style: .blocks),
params: ListViewItemLayoutParams(width: availableSize.width - sideInsets, leftInset: 0.0, rightInset: 0.0, availableHeight: 10000.0, isStandalone: true)
))),
],