Merge commit 'b9621400b08e417b198c4ea73ee1e2db9421ecd3'

This commit is contained in:
Peter 2019-02-19 00:06:17 +03:00
commit 26b55adfb3
3 changed files with 10 additions and 7 deletions

View File

@ -2973,8 +2973,9 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
var visibility: ListViewItemNodeVisibility = .none
if visibilityRect.intersects(itemFrame) {
let itemContentFrame = itemNode.apparentContentFrame
let full = itemContentFrame.minY >= visibilityRect.minY && itemContentFrame.maxY <= visibilityRect.maxY
visibility = .visible(full)
let intersection = itemContentFrame.intersection(visibilityRect)
let fraction = intersection.height / itemContentFrame.height
visibility = .visible(fraction)
}
var updateVisibility = false
if !onlyPositive {

View File

@ -52,7 +52,7 @@ public struct ListViewItemNodeLayout {
public enum ListViewItemNodeVisibility: Equatable {
case none
case visible(Bool)
case visible(CGFloat)
public static func ==(lhs: ListViewItemNodeVisibility, rhs: ListViewItemNodeVisibility) -> Bool {
switch lhs {
@ -62,8 +62,8 @@ public enum ListViewItemNodeVisibility: Equatable {
} else {
return false
}
case let .visible(full):
if case .visible(full) = rhs {
case let .visible(fraction):
if case .visible(fraction) = rhs {
return true
} else {
return false

View File

@ -6,6 +6,8 @@ import SwiftSignalKit
private let volumeNotificationKey = "AVSystemController_SystemVolumeDidChangeNotification"
private let volumeParameterKey = "AVSystemController_AudioVolumeNotificationParameter"
private let changeReasonParameterKey = "AVSystemController_AudioVolumeChangeReasonNotificationParameter"
private let explicitChangeReasonValue = "ExplicitVolumeChange"
final class VolumeControlStatusBar: UIView {
private let control: MPVolumeView
@ -27,9 +29,9 @@ final class VolumeControlStatusBar: UIView {
self.addSubview(self.control)
self.observer = NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: volumeNotificationKey), object: nil, queue: OperationQueue.main, using: { [weak self] notification in
if let strongSelf = self, let userInfo = notification.userInfo {
/*guard let category = userInfo["AVSystemController_AudioCategoryNotificationParameter"] as? String else {
if let reason = userInfo[changeReasonParameterKey], reason as? String != explicitChangeReasonValue {
return
}*/
}
if let volume = userInfo[volumeParameterKey] as? Float {
let previous = strongSelf.currentValue