mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Various fixes
This commit is contained in:
parent
2a95f774e3
commit
2fa059477c
@ -181,8 +181,8 @@ final class StarsStatisticsScreenComponent: Component {
|
||||
|
||||
super.init(frame: frame)
|
||||
|
||||
self.scrollView.delaysContentTouches = true
|
||||
self.scrollView.canCancelContentTouches = true
|
||||
self.scrollView.delaysContentTouches = false
|
||||
// self.scrollView.canCancelContentTouches = true
|
||||
self.scrollView.clipsToBounds = false
|
||||
if #available(iOSApplicationExtension 11.0, iOS 11.0, *) {
|
||||
self.scrollView.contentInsetAdjustmentBehavior = .never
|
||||
@ -217,6 +217,28 @@ final class StarsStatisticsScreenComponent: Component {
|
||||
self.stateDisposable?.dispose()
|
||||
}
|
||||
|
||||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
guard let result = super.hitTest(point, with: event) else {
|
||||
return nil
|
||||
}
|
||||
var currentParent: UIView? = result
|
||||
while true {
|
||||
if currentParent == nil || currentParent === self {
|
||||
break
|
||||
}
|
||||
if let scrollView = currentParent as? UIScrollView {
|
||||
if scrollView === self.scrollView {
|
||||
break
|
||||
}
|
||||
if scrollView.isDecelerating && scrollView.contentOffset.y < -scrollView.contentInset.top {
|
||||
return self.scrollView
|
||||
}
|
||||
}
|
||||
currentParent = currentParent?.superview
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func scrollToTop() {
|
||||
self.scrollView.setContentOffset(CGPoint(x: 0.0, y: -self.scrollView.contentInset.top), animated: true)
|
||||
}
|
||||
|
@ -136,8 +136,8 @@ final class StarsTransactionsListPanelComponent: Component {
|
||||
|
||||
super.init(frame: frame)
|
||||
|
||||
self.scrollView.delaysContentTouches = true
|
||||
self.scrollView.canCancelContentTouches = true
|
||||
self.scrollView.delaysContentTouches = false
|
||||
// self.scrollView.canCancelContentTouches = true
|
||||
self.scrollView.clipsToBounds = false
|
||||
if #available(iOSApplicationExtension 11.0, iOS 11.0, *) {
|
||||
self.scrollView.contentInsetAdjustmentBehavior = .never
|
||||
@ -164,6 +164,15 @@ final class StarsTransactionsListPanelComponent: Component {
|
||||
self.itemsDisposable?.dispose()
|
||||
}
|
||||
|
||||
func scrollToTop() -> Bool {
|
||||
if self.scrollView.contentOffset.y > 0.0 {
|
||||
self.scrollView.setContentOffset(CGPoint(), animated: true)
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
if !self.ignoreScrolling {
|
||||
self.updateScrolling(transition: .immediate)
|
||||
|
@ -610,6 +610,13 @@ final class StarsTransactionsPanelContainerComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
func scrollToTop() -> Bool {
|
||||
if let currentPanelView = self.currentPanelView as? StarsTransactionsListPanelComponent.View {
|
||||
return currentPanelView.scrollToTop()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func update(component: StarsTransactionsPanelContainerComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<StarsTransactionsPanelContainerEnvironment>, transition: ComponentTransition) -> CGSize {
|
||||
let environment = environment[StarsTransactionsPanelContainerEnvironment.self].value
|
||||
|
||||
|
@ -152,8 +152,8 @@ final class StarsTransactionsScreenComponent: Component {
|
||||
|
||||
super.init(frame: frame)
|
||||
|
||||
self.scrollView.delaysContentTouches = true
|
||||
self.scrollView.canCancelContentTouches = true
|
||||
self.scrollView.delaysContentTouches = false
|
||||
// self.scrollView.canCancelContentTouches = true
|
||||
self.scrollView.clipsToBounds = false
|
||||
if #available(iOSApplicationExtension 11.0, iOS 11.0, *) {
|
||||
self.scrollView.contentInsetAdjustmentBehavior = .never
|
||||
@ -185,21 +185,44 @@ final class StarsTransactionsScreenComponent: Component {
|
||||
self.stateDisposable?.dispose()
|
||||
}
|
||||
|
||||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
guard let result = super.hitTest(point, with: event) else {
|
||||
return nil
|
||||
}
|
||||
var currentParent: UIView? = result
|
||||
while true {
|
||||
if currentParent == nil || currentParent === self {
|
||||
break
|
||||
}
|
||||
if let scrollView = currentParent as? UIScrollView {
|
||||
if scrollView === self.scrollView {
|
||||
break
|
||||
}
|
||||
if scrollView.isDecelerating && scrollView.contentOffset.y < -scrollView.contentInset.top {
|
||||
return self.scrollView
|
||||
}
|
||||
}
|
||||
currentParent = currentParent?.superview
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
|
||||
self.enableVelocityTracking = true
|
||||
}
|
||||
|
||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
if !self.ignoreScrolling {
|
||||
if self.enableVelocityTracking {
|
||||
self.previousVelocityM1 = self.previousVelocity
|
||||
if let value = (scrollView.value(forKey: (["_", "verticalVelocity"] as [String]).joined()) as? NSNumber)?.doubleValue {
|
||||
self.previousVelocity = CGFloat(value)
|
||||
}
|
||||
}
|
||||
|
||||
self.updateScrolling(transition: .immediate)
|
||||
guard !self.ignoreScrolling else {
|
||||
return
|
||||
}
|
||||
if self.enableVelocityTracking {
|
||||
self.previousVelocityM1 = self.previousVelocity
|
||||
if let value = (scrollView.value(forKey: (["_", "verticalVelocity"] as [String]).joined()) as? NSNumber)?.doubleValue {
|
||||
self.previousVelocity = CGFloat(value)
|
||||
}
|
||||
}
|
||||
|
||||
self.updateScrolling(transition: .immediate)
|
||||
}
|
||||
|
||||
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
|
||||
@ -229,6 +252,12 @@ final class StarsTransactionsScreenComponent: Component {
|
||||
self.previousVelocityM1 = 0.0
|
||||
}
|
||||
}
|
||||
|
||||
func scrollToTop() {
|
||||
if let panelContainerView = self.panelContainer.view as? StarsTransactionsPanelContainerComponent.View, !panelContainerView.scrollToTop() {
|
||||
self.scrollView.setContentOffset(.zero, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
private func updateScrolling(transition: ComponentTransition) {
|
||||
let scrollBounds = self.scrollView.bounds
|
||||
@ -1124,6 +1153,15 @@ public final class StarsTransactionsScreen: ViewControllerComponentContainer {
|
||||
|
||||
self.starsContext.load(force: false)
|
||||
self.subscriptionsContext.loadMore()
|
||||
|
||||
self.scrollToTop = { [weak self] in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
if let componentView = self.node.hostView.componentView as? StarsTransactionsScreenComponent.View {
|
||||
componentView.scrollToTop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
required public init(coder aDecoder: NSCoder) {
|
||||
|
@ -865,6 +865,28 @@ final class StorageUsageScreenComponent: Component {
|
||||
self.keepScreenActiveDisposable?.dispose()
|
||||
}
|
||||
|
||||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
guard let result = super.hitTest(point, with: event) else {
|
||||
return nil
|
||||
}
|
||||
var currentParent: UIView? = result
|
||||
while true {
|
||||
if currentParent == nil || currentParent === self {
|
||||
break
|
||||
}
|
||||
if let scrollView = currentParent as? UIScrollView {
|
||||
if scrollView === self.scrollView {
|
||||
break
|
||||
}
|
||||
if scrollView.isDecelerating && scrollView.contentOffset.y < -scrollView.contentInset.top {
|
||||
return self.scrollView
|
||||
}
|
||||
}
|
||||
currentParent = currentParent?.superview
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
|
||||
self.enableVelocityTracking = true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user