diff --git a/submodules/StatisticsUI/Sources/StatsGraphItem.swift b/submodules/StatisticsUI/Sources/StatsGraphItem.swift index 834625e9a6..c462f1bd27 100644 --- a/submodules/StatisticsUI/Sources/StatsGraphItem.swift +++ b/submodules/StatisticsUI/Sources/StatsGraphItem.swift @@ -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) } } diff --git a/submodules/TelegramUI/Components/ListItemComponentAdaptor/Sources/ListItemComponentAdaptor.swift b/submodules/TelegramUI/Components/ListItemComponentAdaptor/Sources/ListItemComponentAdaptor.swift index 0b9af02a61..0b8b5a87ea 100644 --- a/submodules/TelegramUI/Components/ListItemComponentAdaptor/Sources/ListItemComponentAdaptor.swift +++ b/submodules/TelegramUI/Components/ListItemComponentAdaptor/Sources/ListItemComponentAdaptor.swift @@ -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, transition: ComponentTransition) -> CGSize { let item = component.itemImpl() diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsStatisticsScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsStatisticsScreen.swift index 336b85bc18..f2c86b8306 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsStatisticsScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsStatisticsScreen.swift @@ -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) ))), ],