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 var visibility: ListViewItemNodeVisibility = .none
if visibilityRect.intersects(itemFrame) { if visibilityRect.intersects(itemFrame) {
let itemContentFrame = itemNode.apparentContentFrame let itemContentFrame = itemNode.apparentContentFrame
let full = itemContentFrame.minY >= visibilityRect.minY && itemContentFrame.maxY <= visibilityRect.maxY let intersection = itemContentFrame.intersection(visibilityRect)
visibility = .visible(full) let fraction = intersection.height / itemContentFrame.height
visibility = .visible(fraction)
} }
var updateVisibility = false var updateVisibility = false
if !onlyPositive { if !onlyPositive {

View File

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

View File

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