no message

This commit is contained in:
Peter 2018-06-29 20:14:18 +03:00
parent 3dfd2af198
commit f3ec180e4d
14 changed files with 127 additions and 88 deletions

View File

@ -1404,7 +1404,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-DMINIMAL_ASDK";
OTHER_CFLAGS = "-DMINIMAL_ASDK=1";
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
@ -1446,7 +1446,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CFLAGS = "-DMINIMAL_ASDK";
OTHER_CFLAGS = "-DMINIMAL_ASDK=1";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
@ -1572,7 +1572,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-DMINIMAL_ASDK";
OTHER_CFLAGS = "-DMINIMAL_ASDK=1";
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
@ -1652,7 +1652,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CFLAGS = "-DMINIMAL_ASDK";
OTHER_CFLAGS = "-DMINIMAL_ASDK=1";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
@ -1732,7 +1732,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CFLAGS = "-DMINIMAL_ASDK";
OTHER_CFLAGS = "-DMINIMAL_ASDK=1";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;

View File

@ -12,7 +12,7 @@
<key>DisplayMac.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>25</integer>
<integer>24</integer>
</dict>
<key>DisplayTests.xcscheme</key>
<dict>

View File

@ -38,8 +38,8 @@ public class ActionSheetCheckboxItemNode: ActionSheetItemNode {
private var item: ActionSheetCheckboxItem?
private let button: HighlightTrackingButton
private let titleNode: ASTextNode
private let labelNode: ASTextNode
private let titleNode: ImmediateTextNode
private let labelNode: ImmediateTextNode
private let checkNode: ASImageNode
override public init(theme: ActionSheetControllerTheme) {
@ -47,14 +47,13 @@ public class ActionSheetCheckboxItemNode: ActionSheetItemNode {
self.button = HighlightTrackingButton()
self.titleNode = ASTextNode()
self.titleNode = ImmediateTextNode()
self.titleNode.maximumNumberOfLines = 1
self.titleNode.isUserInteractionEnabled = false
self.titleNode.displaysAsynchronously = false
self.labelNode = ASTextNode()
self.labelNode = ImmediateTextNode()
self.labelNode.maximumNumberOfLines = 1
self.labelNode.truncationMode = .byTruncatingTail
self.labelNode.isUserInteractionEnabled = false
self.labelNode.displaysAsynchronously = false
@ -115,8 +114,8 @@ public class ActionSheetCheckboxItemNode: ActionSheetItemNode {
self.button.frame = CGRect(origin: CGPoint(), size: size)
let labelSize = self.labelNode.measure(CGSize(width: size.width - 44.0 - 15.0 - 8.0, height: size.height))
let titleSize = self.titleNode.measure(CGSize(width: size.width - 44.0 - labelSize.width - 15.0 - 8.0, height: size.height))
let labelSize = self.labelNode.updateLayout(CGSize(width: size.width - 44.0 - 15.0 - 8.0, height: size.height))
let titleSize = self.titleNode.updateLayout(CGSize(width: size.width - 44.0 - labelSize.width - 15.0 - 8.0, height: size.height))
self.titleNode.frame = CGRect(origin: CGPoint(x: 44.0, y: floorToScreenPixels((size.height - titleSize.height) / 2.0)), size: titleSize)
self.labelNode.frame = CGRect(origin: CGPoint(x: size.width - 15.0 - labelSize.width, y: floorToScreenPixels((size.height - labelSize.height) / 2.0)), size: labelSize)

View File

@ -588,7 +588,7 @@ open class GridNode: GridNodeScroller, UIScrollViewDelegate {
}
if scrollToItem.adjustForTopInset {
additionalOffset += -gridLayout.insets.top + self.initialOffset
additionalOffset += -gridLayout.insets.top// + self.initialOffset
}
} else if scrollToItem.adjustForTopInset {
additionalOffset = -gridLayout.insets.top
@ -712,7 +712,7 @@ open class GridNode: GridNodeScroller, UIScrollViewDelegate {
var lowestHeaderNode: ASDisplayNode?
var lowestHeaderNodeIndex: Int?
for (_, headerNode) in self.sectionNodes {
if let index = self.subnodes.index(of: headerNode) {
if let index = self.subnodes?.index(of: headerNode) {
if lowestHeaderNodeIndex == nil || index < lowestHeaderNodeIndex! {
lowestHeaderNodeIndex = index
lowestHeaderNode = headerNode
@ -1039,7 +1039,7 @@ open class GridNode: GridNodeScroller, UIScrollViewDelegate {
var topVisible: (Int, GridItem) = (topIndex, self.items[topIndex])
let bottomVisible: (Int, GridItem) = (bottomIndex, self.items[bottomIndex])
let lowerDisplayBound = presentationLayoutTransition.layout.contentOffset.y
let lowerDisplayBound = presentationLayoutTransition.layout.contentOffset.y + presentationLayoutTransition.layout.layout.insets.top
//let upperDisplayBound = presentationLayoutTransition.layout.contentOffset.y + self.gridLayout.size.height
for item in presentationLayoutTransition.layout.items {

View File

@ -61,7 +61,7 @@ final class ListViewBackingView: UIView {
}
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
if let target = target, target.limitHitTestToNodes {
if let target = self.target, target.limitHitTestToNodes {
if !target.internalHitTest(point, with: event) {
return nil
}
@ -1695,7 +1695,7 @@ open class ListView: ASDisplayNode, UIScrollViewDelegate, UIGestureRecognizerDel
if let _ = previousFrame, animated && node.index != nil && nodeIndex != self.itemNodes.count - 1 {
let nextNode = self.itemNodes[nodeIndex + 1]
if nextNode.index == nil && nextNode.subnodes.isEmpty {
if nextNode.index == nil && nextNode.subnodes == nil || nextNode.subnodes!.isEmpty {
let nextHeight = nextNode.apparentHeight
if abs(nextHeight - previousApparentHeight) < CGFloat.ulpOfOne {
if let animation = nextNode.animationForKey("apparentHeight") {
@ -1836,7 +1836,7 @@ open class ListView: ASDisplayNode, UIScrollViewDelegate, UIGestureRecognizerDel
var lowestHeaderNode: ASDisplayNode?
var lowestHeaderNodeIndex: Int?
for (_, headerNode) in self.itemHeaderNodes {
if let index = self.subnodes.index(of: headerNode) {
if let index = self.subnodes?.index(of: headerNode) {
if lowestHeaderNodeIndex == nil || index < lowestHeaderNodeIndex! {
lowestHeaderNodeIndex = index
lowestHeaderNode = headerNode

View File

@ -52,13 +52,7 @@ final class NavigationBarBadgeNode: ASDisplayNode {
let backgroundSize = CGSize(width: max(18.0, badgeSize.width + 10.0 + 1.0), height: 18.0)
let backgroundFrame = CGRect(origin: CGPoint(), size: backgroundSize)
self.backgroundNode.frame = backgroundFrame
let textOffset: CGFloat
if UIScreenPixel.isLessThanOrEqualTo(1.0 / 3.0) {
textOffset = UIScreenPixel * 2.0
} else {
textOffset = UIScreenPixel
}
self.textNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels(backgroundFrame.midX - badgeSize.width / 2.0), y: floorToScreenPixels((backgroundFrame.size.height - badgeSize.height) / 2.0) + textOffset), size: badgeSize)
self.textNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels(backgroundFrame.midX - badgeSize.width / 2.0), y: floorToScreenPixels((backgroundFrame.size.height - badgeSize.height) / 2.0)), size: badgeSize)
return backgroundSize
}

View File

@ -120,14 +120,16 @@ private final class NavigationButtonItemNode: ASTextNode {
self.displaysAsynchronously = false
}
override public func calculateSizeThatFits(_ constrainedSize: CGSize) -> CGSize {
func updateLayout(_ constrainedSize: CGSize) -> CGSize {
let superSize = super.calculateSizeThatFits(constrainedSize)
if let node = self.node {
let nodeSize = node.measure(constrainedSize)
return CGSize(width: max(nodeSize.width, superSize.width), height: max(nodeSize.height, superSize.height))
let size = CGSize(width: max(nodeSize.width, superSize.width), height: max(nodeSize.height, superSize.height))
node.frame = CGRect(origin: CGPoint(), size: nodeSize)
return size
} else if let imageNode = self.imageNode {
let nodeSize = imageNode.measure(constrainedSize)
let nodeSize = imageNode.image?.size ?? CGSize()
let size = CGSize(width: max(nodeSize.width, superSize.width), height: max(nodeSize.height, superSize.height))
imageNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((size.width - nodeSize.width) / 2.0) + 5.0, y: floorToScreenPixels((size.height - nodeSize.height) / 2.0)), size: nodeSize)
return size
@ -135,14 +137,6 @@ private final class NavigationButtonItemNode: ASTextNode {
return superSize
}
override public func layout() {
super.layout()
if let node = self.node {
node.frame = CGRect(origin: CGPoint(), size: node.calculatedSize)
}
}
private func touchInsideApparentBounds(_ touch: UITouch) -> Bool {
var apparentBounds = self.bounds
let hitTestSlop = self.hitTestSlop
@ -330,7 +324,7 @@ final class NavigationButtonNode: ASDisplayNode {
totalSize.width += 16.0
nodeOrigin.x += 16.0
}
var nodeSize = node.calculateSizeThatFits(constrainedSize)
var nodeSize = node.updateLayout(constrainedSize)
nodeSize.width = ceil(nodeSize.width)
nodeSize.height = ceil(nodeSize.height)
totalSize.width += nodeSize.width

View File

@ -127,9 +127,13 @@ public final class PeekControllerGestureRecognizer: UIPanGestureRecognizer {
override public func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent) {
super.touchesEnded(touches, with: event)
if self.activateBySingleTap, self.candidateContent != nil, self.presentedController == nil {
self.longTapTimerFired()
self.pressTimerFired()
if self.activateBySingleTap, self.presentedController == nil {
self.longTapTimer?.invalidate()
self.pressTimer?.invalidate()
if let tapLocation = self.tapLocation {
self.checkCandidateContent(at: tapLocation, forceActivate: true)
}
self.state = .ended
} else {
let velocity = self.velocity(in: self.view)
@ -184,7 +188,10 @@ public final class PeekControllerGestureRecognizer: UIPanGestureRecognizer {
(presentedController.displayNode as? PeekControllerNode)?.activateMenu()
self.menuActivation = nil
self.presentedController = nil
self.candidateContent = nil
self.state = .ended
self.candidateContentDisposable.set(nil)
return
}
}
}
@ -216,12 +223,25 @@ public final class PeekControllerGestureRecognizer: UIPanGestureRecognizer {
}
}
private func checkCandidateContent(at touchLocation: CGPoint) {
private func checkCandidateContent(at touchLocation: CGPoint, forceActivate: Bool = false) {
//print("check begin")
if let contentSignal = self.contentAtPoint(touchLocation) {
self.candidateContentDisposable.set((contentSignal |> deliverOnMainQueue).start(next: { [weak self] result in
self.candidateContentDisposable.set((contentSignal
|> deliverOnMainQueue).start(next: { [weak self] result in
if let strongSelf = self {
let processResult: Bool
if forceActivate {
processResult = true
} else {
switch strongSelf.state {
case .possible, .changed:
processResult = true
default:
processResult = false
}
}
//print("check received, will process: \(processResult), force: \(forceActivate), state: \(strongSelf.state)")
if processResult {
if let (sourceNode, content) = result {
if let currentContent = strongSelf.candidateContent {
if !currentContent.1.isEqual(to: content) {
@ -237,9 +257,16 @@ public final class PeekControllerGestureRecognizer: UIPanGestureRecognizer {
}
} else {
if let presentedController = strongSelf.present(content, sourceNode) {
if forceActivate {
strongSelf.candidateContent = nil
if case .press = content.menuActivation() {
(presentedController.displayNode as? PeekControllerNode)?.activateMenu()
}
} else {
strongSelf.candidateContent = (sourceNode, content)
strongSelf.menuActivation = content.menuActivation()
strongSelf.presentedController = presentedController
strongSelf.state = .began
switch content.menuActivation() {
@ -256,11 +283,12 @@ public final class PeekControllerGestureRecognizer: UIPanGestureRecognizer {
}
}
}
}
} else if strongSelf.presentedController == nil {
if strongSelf.state != .possible && strongSelf.state != .ended {
strongSelf.state = .failed
}
default:
break
}
}
}
}))

View File

@ -34,7 +34,7 @@ open class TabBarController: ViewController {
}
}
private var controllers: [ViewController] = []
public private(set) var controllers: [ViewController] = []
private var _selectedIndex: Int?
public var selectedIndex: Int {
@ -50,10 +50,6 @@ open class TabBarController: ViewController {
_selectedIndex = index
self.updateSelectedIndex()
} else {
if let controller = self.currentController {
controller.scrollToTopWithTabBar?()
}
}
}
}
@ -116,8 +112,14 @@ open class TabBarController: ViewController {
}
strongSelf.pendingControllerDisposable.set((strongSelf.controllers[index].ready.get() |> deliverOnMainQueue).start(next: { _ in
if let strongSelf = self {
if strongSelf.selectedIndex == index {
if let controller = strongSelf.currentController {
controller.scrollToTopWithTabBar?()
}
} else {
strongSelf.selectedIndex = index
}
}
}))
}
})

View File

@ -35,7 +35,7 @@ private final class TextAlertContentActionNode: HighlightableButtonNode {
super.init()
self.titleNode.maximumNumberOfLines = 2
let font = Font.regular(17.0)
var font = Font.regular(17.0)
var color = theme.accentColor
switch action.type {
case .defaultAction, .genericAction:
@ -43,6 +43,12 @@ private final class TextAlertContentActionNode: HighlightableButtonNode {
case .destructiveAction:
color = theme.destructiveColor
}
switch action.type {
case .defaultAction:
font = Font.semibold(17.0)
case .destructiveAction, .genericAction:
break
}
self.setAttributedTitle(NSAttributedString(string: action.title, font: font, textColor: color, paragraphAlignment: .center), for: [])
self.highligthedChanged = { [weak self] value in

View File

@ -479,6 +479,9 @@ public class TextNode: ASDisplayNode {
return (layout, {
node.cachedLayout = layout
if updated {
if layout.size.width.isZero && layout.size.height.isZero {
node.contents = nil
}
node.setNeedsDisplay()
}

View File

@ -15,6 +15,7 @@ final class VolumeControlStatusBar: UIView {
var valueChanged: ((Float, Float) -> Void)?
private var disposable: Disposable?
private var ignoreAdjustmentOnce = false
init(frame: CGRect, shouldBeVisible: Signal<Bool, NoError>) {
self.control = MPVolumeView(frame: CGRect(origin: CGPoint(), size: CGSize(width: 100.0, height: 20.0)))
@ -24,15 +25,25 @@ 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 {
if let volume = notification.userInfo?[volumeParameterKey] as? Float {
if let strongSelf = self, let userInfo = notification.userInfo {
/*guard let category = userInfo["AVSystemController_AudioCategoryNotificationParameter"] as? String else {
return
}*/
if let volume = userInfo[volumeParameterKey] as? Float {
let previous = strongSelf.currentValue
if !previous.isEqual(to: volume) {
strongSelf.currentValue = volume
if strongSelf.ignoreAdjustmentOnce {
strongSelf.ignoreAdjustmentOnce = false
} else {
if strongSelf.control.superview != nil {
strongSelf.valueChanged?(previous, volume)
}
}
}
}
}
})
self.disposable = (shouldBeVisible
@ -42,10 +53,12 @@ final class VolumeControlStatusBar: UIView {
}
if value {
if strongSelf.control.superview == nil {
strongSelf.ignoreAdjustmentOnce = true
strongSelf.addSubview(strongSelf.control)
}
} else {
strongSelf.control.removeFromSuperview()
strongSelf.ignoreAdjustmentOnce = false
}
})
}

View File

@ -154,7 +154,7 @@ private func encodeText(_ string: String, _ key: Int) -> String {
return result
}
private func doesViewTreeDisableInteractiveTransitionGestureRecognizer(_ view: UIView) -> Bool {
public func doesViewTreeDisableInteractiveTransitionGestureRecognizer(_ view: UIView) -> Bool {
if view.disablesInteractiveTransitionGestureRecognizer {
return true
}
@ -204,7 +204,7 @@ private func applyThemeToPreviewingEffectView(_ view: UIView) {
}
}
private func getFirstResponderAndAccessoryHeight(_ view: UIView, _ accessoryHeight: CGFloat? = nil) -> (UIView?, CGFloat?) {
public func getFirstResponderAndAccessoryHeight(_ view: UIView, _ accessoryHeight: CGFloat? = nil) -> (UIView?, CGFloat?) {
if view.isFirstResponder {
return (view, accessoryHeight)
} else {
@ -283,12 +283,12 @@ private func safeInsetsForScreenSize(_ size: CGSize) -> UIEdgeInsets {
return UIEdgeInsets()
}
private final class KeyboardGestureRecognizerDelegate: NSObject, UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
public final class WindowKeyboardGestureRecognizerDelegate: NSObject, UIGestureRecognizerDelegate {
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: UIGestureRecognizer) -> Bool {
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return false
}
}
@ -330,7 +330,7 @@ public class Window1 {
}
private var windowPanRecognizer: WindowPanRecognizer?
private let keyboardGestureRecognizerDelegate = KeyboardGestureRecognizerDelegate()
private let keyboardGestureRecognizerDelegate = WindowKeyboardGestureRecognizerDelegate()
private var keyboardGestureBeginLocation: CGPoint?
private var keyboardGestureAccessoryHeight: CGFloat?

View File

@ -1,13 +1,13 @@
import Foundation
final class WindowPanRecognizer: UIGestureRecognizer {
var began: ((CGPoint) -> Void)?
var moved: ((CGPoint) -> Void)?
var ended: ((CGPoint, CGPoint?) -> Void)?
public final class WindowPanRecognizer: UIGestureRecognizer {
public var began: ((CGPoint) -> Void)?
public var moved: ((CGPoint) -> Void)?
public var ended: ((CGPoint, CGPoint?) -> Void)?
private var previousPoints: [(CGPoint, Double)] = []
override func reset() {
override public func reset() {
super.reset()
self.previousPoints.removeAll()
@ -40,7 +40,7 @@ final class WindowPanRecognizer: UIGestureRecognizer {
}
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) {
override public func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) {
super.touchesBegan(touches, with: event)
if let touch = touches.first {
@ -50,7 +50,7 @@ final class WindowPanRecognizer: UIGestureRecognizer {
}
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent) {
override public func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent) {
super.touchesMoved(touches, with: event)
if let touch = touches.first {
@ -60,7 +60,7 @@ final class WindowPanRecognizer: UIGestureRecognizer {
}
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent) {
override public func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent) {
super.touchesEnded(touches, with: event)
if let touch = touches.first {
@ -70,7 +70,7 @@ final class WindowPanRecognizer: UIGestureRecognizer {
}
}
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent) {
override public func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent) {
super.touchesCancelled(touches, with: event)
if let touch = touches.first {