Merge commit '16eae46449c2c1252108d4d24958c2be3354f45d'

This commit is contained in:
Ali 2020-12-11 14:56:14 +04:00
commit 03ac9f35c3
24 changed files with 548 additions and 489 deletions

View File

@ -14,6 +14,15 @@ if [ "$BAZEL" = "" ]; then
exit 1
fi
BAZEL_x86_64="$BAZEL"
if [ "$(arch)" == "arm64" ]; then
BAZEL_x86_64="$(which bazel_x86_64)"
fi
if [ "$BAZEL_x86_64" = "" ]; then
echo "bazel_x86_64 not found in PATH"
exit 1
fi
XCODE_VERSION=$(cat "build-system/xcode_version")
INSTALLED_XCODE_VERSION=$(echo `plutil -p \`xcode-select -p\`/../Info.plist | grep -e CFBundleShortVersionString | sed 's/[^0-9\.]*//g'`)
@ -36,7 +45,7 @@ rm -rf "$GEN_DIRECTORY/${APP_TARGET}.tulsiproj"
rm -rf "$TULSI_APP"
pushd "build-system/tulsi"
"$BAZEL" build //:tulsi --xcode_version="$XCODE_VERSION"
"$BAZEL_x86_64" build //:tulsi --xcode_version="$XCODE_VERSION" --use_top_level_targets_for_symlinks
popd
mkdir -p "$TULSI_DIRECTORY"

View File

@ -57,6 +57,7 @@ swift_library(
"//submodules/GridMessageSelectionNode:GridMessageSelectionNode",
"//submodules/ChatListFilterSettingsHeaderItem:ChatListFilterSettingsHeaderItem",
"//submodules/TelegramStringFormatting:TelegramStringFormatting",
"//submodules/TelegramCallsUI:TelegramCallsUI",
],
visibility = [
"//visibility:public",

View File

@ -23,6 +23,7 @@ import AppBundle
import LocalizedPeerData
import TelegramIntents
import TooltipUI
import TelegramCallsUI
private func fixListNodeScrolling(_ listNode: ListView, searchNode: NavigationBarSearchContentNode) -> Bool {
if listNode.scroller.isDragging {
@ -1727,6 +1728,20 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
(strongSelf.parent as? TabBarController)?.updateIsTabBarHidden(true, transition: .animated(duration: 0.4, curve: .spring))
})
if let navigationController = self.navigationController as? NavigationController {
var voiceChatOverlayController: VoiceChatOverlayController?
for controller in navigationController.globalOverlayControllers {
if let controller = controller as? VoiceChatOverlayController {
voiceChatOverlayController = controller
break
}
}
if let controller = voiceChatOverlayController {
controller.update(hidden: true, slide: true, animated: true)
}
}
}
}
@ -1769,6 +1784,20 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
self.tabContainerNode.layer.animatePosition(from: CGPoint(x: 0.0, y: -64.0), to: CGPoint(), duration: 0.4, timingFunction: kCAMediaTimingFunctionSpring, additive: true)
}
}
if let navigationController = self.navigationController as? NavigationController {
var voiceChatOverlayController: VoiceChatOverlayController?
for controller in navigationController.globalOverlayControllers {
if let controller = controller as? VoiceChatOverlayController {
voiceChatOverlayController = controller
break
}
}
if let controller = voiceChatOverlayController {
controller.update(hidden: false, slide: true, animated: true)
}
}
}
}

View File

@ -177,14 +177,14 @@ open class NavigationController: UINavigationController, ContainableController,
}
}
private var _viewControllersPipe = ValuePipe<[UIViewController]>()
private var _viewControllersPromise = ValuePromise<[UIViewController]>()
public var viewControllersSignal: Signal<[UIViewController], NoError> {
return _viewControllersPipe.signal()
return _viewControllersPromise.get()
}
private var _overlayControllersPipe = ValuePipe<[UIViewController]>()
private var _overlayControllersPromise = ValuePromise<[UIViewController]>()
public var overlayControllersSignal: Signal<[UIViewController], NoError> {
return _overlayControllersPipe.signal()
return _overlayControllersPromise.get()
}
override open var topViewController: UIViewController? {
@ -1246,7 +1246,7 @@ open class NavigationController: UINavigationController, ContainableController,
if let layout = self.validLayout {
self.updateContainers(layout: layout, transition: animated ? .animated(duration: 0.5, curve: .spring) : .immediate)
}
self._viewControllersPipe.putNext(self.viewControllers)
self._viewControllersPromise.set(self.viewControllers)
}
public func presentOverlay(controller: ViewController, inGlobal: Bool = false, blockInteraction: Bool = false) {
@ -1270,7 +1270,7 @@ open class NavigationController: UINavigationController, ContainableController,
if overlayContainer.controller === controller {
overlayContainer.removeFromSupernode()
strongSelf.overlayContainers.remove(at: i)
strongSelf._overlayControllersPipe.putNext(strongSelf.overlayContainers.map({ $0.controller }))
strongSelf._overlayControllersPromise.set(strongSelf.overlayContainers.map({ $0.controller }))
strongSelf.internalOverlayControllersUpdated()
break
}
@ -1292,7 +1292,7 @@ open class NavigationController: UINavigationController, ContainableController,
self.globalOverlayContainers.append(container)
} else {
self.overlayContainers.append(container)
self._overlayControllersPipe.putNext(self.overlayContainers.map({ $0.controller }))
self._overlayControllersPromise.set(self.overlayContainers.map({ $0.controller }))
}
container.isReadyUpdated = { [weak self, weak container] in
guard let strongSelf = self, let _ = container else {

View File

@ -565,10 +565,12 @@ class TabBarNode: ASDisplayNode {
if let callsTabBarNodeContainer = callsTabBarNodeContainer {
tabBarNodeContainers.remove(at: 1)
transition.updateAlpha(node: callsTabBarNodeContainer.imageNode, alpha: 0.0)
callsTabBarNodeContainer.imageNode.isUserInteractionEnabled = false
}
} else {
if let callsTabBarNodeContainer = callsTabBarNodeContainer {
transition.updateAlpha(node: callsTabBarNodeContainer.imageNode, alpha: 1.0)
callsTabBarNodeContainer.imageNode.isUserInteractionEnabled = true
}
}
@ -641,6 +643,9 @@ class TabBarNode: ASDisplayNode {
for i in 0 ..< self.tabBarNodeContainers.count {
let node = self.tabBarNodeContainers[i].imageNode
if !node.isUserInteractionEnabled {
continue
}
let distance = abs(location.x - node.position.x)
if let previousClosestNode = closestNode {
if previousClosestNode.1 > distance {

View File

@ -1,9 +1,6 @@
import Foundation
import AsyncDisplayKit
import Display
import Postbox
import TelegramPresentationData
import GZip
private final class ShimmerEffectForegroundNode: ASDisplayNode {
private var currentBackgroundColor: UIColor?
@ -142,7 +139,7 @@ private func decodeStickerThumbnailData(_ data: Data) -> String {
return string
}
class StickerShimmerEffectNode: ASDisplayNode {
public class StickerShimmerEffectNode: ASDisplayNode {
private let backgroundNode: ASDisplayNode
private let effectNode: ShimmerEffectForegroundNode
private let foregroundNode: ASImageNode
@ -155,7 +152,7 @@ class StickerShimmerEffectNode: ASDisplayNode {
private var currentShimmeringColor: UIColor?
private var currentSize = CGSize()
override init() {
public override init() {
self.backgroundNode = ASDisplayNode()
self.effectNode = ShimmerEffectForegroundNode()
self.foregroundNode = ASImageNode()
@ -172,6 +169,9 @@ class StickerShimmerEffectNode: ASDisplayNode {
}
public func update(backgroundColor: UIColor?, foregroundColor: UIColor, shimmeringColor: UIColor, data: Data?, size: CGSize) {
if data == nil {
return
}
if self.currentData == data, let currentBackgroundColor = self.currentBackgroundColor, currentBackgroundColor.isEqual(backgroundColor), let currentForegroundColor = self.currentForegroundColor, currentForegroundColor.isEqual(foregroundColor), let currentShimmeringColor = self.currentShimmeringColor, currentShimmeringColor.isEqual(shimmeringColor), self.currentSize == size {
return
}

View File

@ -61,7 +61,7 @@ final class StickerPackPreviewGridItemNode: GridItemNode {
private var isEmpty: Bool?
private let imageNode: TransformImageNode
private var animationNode: AnimatedStickerNode?
private var placeholderNode: ShimmerEffectNode?
private var placeholderNode: StickerShimmerEffectNode?
private var theme: PresentationTheme?
@ -86,7 +86,8 @@ final class StickerPackPreviewGridItemNode: GridItemNode {
override init() {
self.imageNode = TransformImageNode()
self.imageNode.isLayerBacked = !smartInvertColorsEnabled()
self.placeholderNode = ShimmerEffectNode()
self.placeholderNode = StickerShimmerEffectNode()
self.placeholderNode?.isUserInteractionEnabled = false
super.init()
@ -117,9 +118,11 @@ final class StickerPackPreviewGridItemNode: GridItemNode {
if !animated {
placeholderNode.removeFromSupernode()
} else {
placeholderNode.allowsGroupOpacity = true
placeholderNode.alpha = 0.0
placeholderNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, completion: { [weak placeholderNode] _ in
placeholderNode?.removeFromSupernode()
placeholderNode?.allowsGroupOpacity = false
})
}
}
@ -181,9 +184,6 @@ final class StickerPackPreviewGridItemNode: GridItemNode {
self.setNeedsLayout()
}
self.isEmpty = isEmpty
//self.updateSelectionState(animated: false)
//self.updateHiddenMedia()
}
override func layout() {
@ -197,8 +197,8 @@ final class StickerPackPreviewGridItemNode: GridItemNode {
let placeholderFrame = CGRect(origin: CGPoint(x: floor((bounds.width - boundingSize.width) / 2.0), y: floor((bounds.height - boundingSize.height) / 2.0)), size: boundingSize)
placeholderNode.frame = bounds
if let theme = self.theme {
placeholderNode.update(backgroundColor: theme.list.itemBlocksBackgroundColor, foregroundColor: theme.list.mediaPlaceholderColor, shimmeringColor: theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.4), shapes: [.roundedRect(rect: placeholderFrame, cornerRadius: 10.0)], size: bounds.size)
if let theme = self.theme, let (_, stickerItem) = self.currentState, let item = stickerItem {
placeholderNode.update(backgroundColor: theme.list.itemBlocksBackgroundColor, foregroundColor: theme.list.mediaPlaceholderColor, shimmeringColor: theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.4), data: item.file.immediateThumbnailData, size: placeholderFrame.size)
}
}

View File

@ -26,21 +26,33 @@ private class CallStatusBarBackgroundNode: ASDisplayNode {
}
}
var speaking = false {
var connectingColor: UIColor = UIColor(rgb: 0xb6b6bb) {
didSet {
if self.connectingColor.rgb != oldValue.rgb {
self.updateGradientColors()
}
}
}
var speaking: Bool? = nil {
didSet {
if self.speaking != oldValue {
self.updateGradientColors()
}
}
}
private func updateGradientColors() {
let initialColors = self.foregroundGradientLayer.colors
let targetColors: [CGColor]
if speaking {
targetColors = [green.cgColor, blue.cgColor]
if let speaking = self.speaking {
targetColors = speaking ? [green.cgColor, blue.cgColor] : [blue.cgColor, lightBlue.cgColor]
} else {
targetColors = [blue.cgColor, lightBlue.cgColor]
targetColors = [connectingColor.cgColor, connectingColor.cgColor]
}
self.foregroundGradientLayer.colors = targetColors
self.foregroundGradientLayer.animate(from: initialColors as AnyObject, to: targetColors as AnyObject, keyPath: "colors", timingFunction: CAMediaTimingFunctionName.linear.rawValue, duration: 0.3)
}
}
}
private let hierarchyTrackingNode: HierarchyTrackingNode
private var isCurrentlyInHierarchy = true
@ -145,7 +157,6 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
}
private let backgroundNode: CallStatusBarBackgroundNode
private let microphoneNode: VoiceChatMicrophoneNode
private let titleNode: ImmediateTextNode
private let subtitleNode: ImmediateAnimatedCountLabelNode
@ -156,8 +167,9 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
private var currentSize: CGSize?
private var currentContent: Content?
private var strings: PresentationStrings?
private var nameDisplayOrder: PresentationPersonNameOrder = .firstLast
private var presentationData: PresentationData?
private let presentationDataDisposable = MetaDisposable()
private var currentPeer: Peer?
private var currentCallTimer: SwiftSignalKit.Timer?
private var currentCallState: PresentationCallState?
@ -167,7 +179,6 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
public override init() {
self.backgroundNode = CallStatusBarBackgroundNode()
self.microphoneNode = VoiceChatMicrophoneNode()
self.titleNode = ImmediateTextNode()
self.subtitleNode = ImmediateAnimatedCountLabelNode()
self.subtitleNode.reverseAnimationDirection = true
@ -180,6 +191,7 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
}
deinit {
self.presentationDataDisposable.dispose()
self.audioLevelDisposable.dispose()
self.stateDisposable.dispose()
self.currentCallTimer?.invalidate()
@ -203,11 +215,10 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
let wasEmpty = (self.titleNode.attributedText?.string ?? "").isEmpty
if !self.didSetupData {
self.didSetupData = true
switch content {
case let .call(sharedContext, account, call):
let presentationData = sharedContext.currentPresentationData.with { $0 }
self.strings = presentationData.strings
self.nameDisplayOrder = presentationData.nameDisplayOrder
self.presentationData = sharedContext.currentPresentationData.with { $0 }
self.stateDisposable.set(
(combineLatest(
account.postbox.loadedPeerWithId(call.peerId),
@ -219,13 +230,29 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
strongSelf.currentPeer = peer
strongSelf.currentCallState = state
strongSelf.currentIsMuted = isMuted
let currentIsConnected: Bool
switch state.state {
case .active, .terminating, .terminated:
currentIsConnected = true
default:
currentIsConnected = false
}
strongSelf.currentIsConnected = currentIsConnected
strongSelf.update()
}
}))
case let .groupCall(sharedContext, account, call):
let presentationData = sharedContext.currentPresentationData.with { $0 }
self.strings = presentationData.strings
self.nameDisplayOrder = presentationData.nameDisplayOrder
self.presentationData = sharedContext.currentPresentationData.with { $0 }
self.presentationDataDisposable.set((sharedContext.presentationData
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
if let strongSelf = self {
strongSelf.presentationData = presentationData
strongSelf.update()
}
}))
self.stateDisposable.set(
(combineLatest(
account.postbox.peerView(id: call.peerId),
@ -236,6 +263,11 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
if let strongSelf = self {
strongSelf.currentPeer = view.peers[view.peerId]
strongSelf.currentGroupCallState = state
var isMuted = isMuted
if let state = state, state.callState.muteState != nil {
isMuted = true
}
strongSelf.currentIsMuted = isMuted
let currentIsConnected: Bool
@ -263,7 +295,6 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
strongSelf.backgroundNode.audioLevel = effectiveLevel
}))
}
self.didSetupData = true
}
var title: String = ""
@ -272,9 +303,9 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
let textColor = UIColor.white
var segments: [AnimatedCountLabelNode.Segment] = []
if let strings = self.strings {
if let presentationData = self.presentationData {
if let currentPeer = self.currentPeer {
title = currentPeer.displayTitle(strings: strings, displayOrder: self.nameDisplayOrder)
title = currentPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
}
var membersCount: Int32?
if let groupCallState = self.currentGroupCallState {
@ -284,12 +315,12 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
}
if let membersCount = membersCount {
var membersPart = strings.VoiceChat_Status_Members(membersCount)
var membersPart = presentationData.strings.VoiceChat_Status_Members(membersCount)
if let startIndex = membersPart.firstIndex(of: "["), let endIndex = membersPart.firstIndex(of: "]") {
membersPart.removeSubrange(startIndex ... endIndex)
}
let rawTextAndRanges = strings.VoiceChat_Status_MembersFormat("\(membersCount)", membersPart)
let rawTextAndRanges = presentationData.strings.VoiceChat_Status_MembersFormat("\(membersCount)", membersPart)
let (rawText, ranges) = rawTextAndRanges
var textIndex = 0
@ -321,6 +352,16 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
textIndex += 1
}
}
let sourceColor = presentationData.theme.chatList.unreadBadgeInactiveBackgroundColor
let color: UIColor
if sourceColor.alpha < 1.0 {
color = presentationData.theme.chatList.unreadBadgeInactiveBackgroundColor.mixedWith(sourceColor.withAlphaComponent(1.0), alpha: sourceColor.alpha)
} else {
color = sourceColor
}
self.backgroundNode.connectingColor = color
}
if self.subtitleNode.segments != segments {
@ -329,8 +370,6 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
self.titleNode.attributedText = NSAttributedString(string: title, font: Font.semibold(13.0), textColor: .white)
let animationSize: CGFloat = 25.0
let iconSpacing: CGFloat = 0.0
let spacing: CGFloat = 5.0
let titleSize = self.titleNode.updateLayout(CGSize(width: 160.0, height: size.height))
let subtitleSize = self.subtitleNode.updateLayout(size: CGSize(width: 160.0, height: size.height), animated: true)
@ -342,14 +381,10 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
let verticalOrigin: CGFloat = size.height - contentHeight
let transition: ContainedViewLayoutTransition = wasEmpty ? .immediate : .animated(duration: 0.2, curve: .easeInOut)
// transition.updateFrame(node: self.microphoneNode, frame: CGRect(origin: CGPoint(x: horizontalOrigin, y: verticalOrigin + floor((contentHeight - animationSize) / 2.0)), size: CGSize(width: animationSize, height: animationSize)))
// self.microphoneNode.update(state: VoiceChatMicrophoneNode.State(muted: self.currentIsMuted, color: UIColor.white), animated: true)
transition.updateFrame(node: self.titleNode, frame: CGRect(origin: CGPoint(x: horizontalOrigin, y: verticalOrigin + floor((contentHeight - titleSize.height) / 2.0)), size: titleSize))
transition.updateFrame(node: self.subtitleNode, frame: CGRect(origin: CGPoint(x: horizontalOrigin + titleSize.width + spacing, y: verticalOrigin + floor((contentHeight - subtitleSize.height) / 2.0)), size: subtitleSize))
self.backgroundNode.speaking = self.currentIsConnected && !self.currentIsMuted
self.backgroundNode.speaking = self.currentIsConnected ? !self.currentIsMuted : nil
self.backgroundNode.frame = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: size.height + 18.0))
}
}

View File

@ -43,20 +43,42 @@ final class VoiceChatActionButton: HighlightTrackingButtonNode {
var outerColor: Signal<UIColor?, NoError> {
return outerColorPromise.get()
}
var connectingColor: UIColor = UIColor(rgb: 0xb6b6bb) {
didSet {
self.backgroundNode.connectingColor = self.connectingColor
}
}
var activeDisposable = MetaDisposable()
var isDisabled: Bool = false
var wasActiveWhenPressed = false
var pressing: Bool = false {
didSet {
var snap = false
if let (_, _, _, _, _, _, _, snapValue) = self.currentParams {
snap = snapValue
guard let (_, _, state, _, _, _, _, snap) = self.currentParams, !self.isDisabled else {
return
}
if self.pressing {
let transition: ContainedViewLayoutTransition = .animated(duration: 0.25, curve: .spring)
transition.updateTransformScale(node: self.iconNode, scale: snap ? 0.5 : 0.9)
switch state {
case let .active(state):
switch state {
case .on:
self.wasActiveWhenPressed = true
default:
break
}
case .connecting:
break
}
} else {
let transition: ContainedViewLayoutTransition = .animated(duration: 0.25, curve: .spring)
transition.updateTransformScale(node: self.iconNode, scale: snap ? 0.5 : 1.0)
self.wasActiveWhenPressed = false
}
}
}
@ -80,9 +102,8 @@ final class VoiceChatActionButton: HighlightTrackingButtonNode {
self.highligthedChanged = { [weak self] pressing in
if let strongSelf = self {
var snap = false
if let (_, _, _, _, _, _, _, snapValue) = strongSelf.currentParams {
snap = snapValue
guard let (_, _, _, _, _, _, _, snap) = strongSelf.currentParams, !strongSelf.isDisabled else {
return
}
if pressing {
let transition: ContainedViewLayoutTransition = .animated(duration: 0.25, curve: .spring)
@ -111,7 +132,7 @@ final class VoiceChatActionButton: HighlightTrackingButtonNode {
self.backgroundNode.audioLevel = level
}
func applyParams(animated: Bool) {
private func applyParams(animated: Bool) {
guard let (size, _, state, _, small, title, subtitle, snap) = self.currentParams else {
return
}
@ -153,31 +174,75 @@ final class VoiceChatActionButton: HighlightTrackingButtonNode {
self.backgroundNode.bounds = CGRect(origin: CGPoint(), size: size)
self.backgroundNode.position = CGPoint(x: size.width / 2.0, y: size.height / 2.0)
var active = false
switch state {
case let .active(state):
switch state {
case .on:
active = self.pressing && !self.wasActiveWhenPressed
default:
break
}
case .connecting:
break
}
let transition: ContainedViewLayoutTransition = animated ? .animated(duration: 0.2, curve: .easeInOut) : .immediate
if snap {
transition.updateTransformScale(node: self.backgroundNode, scale: self.pressing ? 0.75 : 0.5)
transition.updateTransformScale(node: self.backgroundNode, scale: active ? 0.75 : 0.5)
transition.updateTransformScale(node: self.iconNode, scale: 0.5)
transition.updateAlpha(node: self.titleLabel, alpha: 0.0)
transition.updateAlpha(node: self.subtitleLabel, alpha: 0.0)
transition.updateAlpha(layer: self.backgroundNode.maskProgressLayer, alpha: 0.0)
} else {
transition.updateTransformScale(node: self.backgroundNode, scale: small ? 0.85 : 1.0)
transition.updateTransformScale(node: self.iconNode, scale: self.pressing ? 0.9 : 1.0)
transition.updateAlpha(node: self.titleLabel, alpha: 1.0)
transition.updateAlpha(node: self.subtitleLabel, alpha: 1.0)
transition.updateAlpha(layer: self.backgroundNode.maskProgressLayer, alpha: 1.0)
}
let iconSize = CGSize(width: 90.0, height: 90.0)
self.iconNode.bounds = CGRect(origin: CGPoint(), size: iconSize)
self.iconNode.position = CGPoint(x: size.width / 2.0, y: size.height / 2.0)
self.wasActiveWhenPressed = false
}
func update(snap: Bool) {
private func applyIconParams() {
guard let (size, _, state, _, small, title, subtitle, snap) = self.currentParams else {
return
}
var iconMuted = true
var iconColor: UIColor = UIColor(rgb: 0xffffff)
switch state {
case let .active(state):
switch state {
case .on:
iconMuted = false
case .muted:
break
case .cantSpeak:
if !snap {
iconColor = UIColor(rgb: 0xff3b30)
}
}
case .connecting:
break
}
self.iconNode.update(state: VoiceChatMicrophoneNode.State(muted: iconMuted, color: iconColor), animated: true)
}
func update(snap: Bool, animated: Bool) {
if let previous = self.currentParams {
self.currentParams = (previous.size, previous.buttonSize, previous.state, previous.dark, previous.small, previous.title, previous.subtitle, snap)
self.backgroundNode.isSnap = snap
self.backgroundNode.glowHidden = snap
self.applyParams(animated: true)
self.backgroundNode.updateColors()
self.applyParams(animated: animated)
self.applyIconParams()
}
}
@ -186,27 +251,24 @@ final class VoiceChatActionButton: HighlightTrackingButtonNode {
let previousState = previous?.state
self.currentParams = (size, buttonSize, state, dark, small, title, subtitle, previous?.snap ?? false)
var iconMuted = true
var iconColor: UIColor = .white
var backgroundState: VoiceChatActionButtonBackgroundNode.State
switch state {
case let .active(state):
switch state {
case .on:
iconMuted = false
backgroundState = .blob(true)
case .muted:
backgroundState = .blob(false)
case .cantSpeak:
iconColor = UIColor(rgb: 0xff3b30)
backgroundState = .disabled
}
case .connecting:
backgroundState = .connecting
}
self.backgroundNode.updateColor(dark: dark)
self.applyIconParams()
self.backgroundNode.isDark = dark
self.backgroundNode.update(state: backgroundState, animated: true)
self.iconNode.update(state: VoiceChatMicrophoneNode.State(muted: iconMuted, color: iconColor), animated: true)
if case .active = state, let previousState = previousState, case .connecting = previousState, animated {
self.activeDisposable.set((self.activePromise.get()
@ -344,6 +406,7 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
private let backgroundCircleLayer = CAShapeLayer()
private let foregroundCircleLayer = CAShapeLayer()
private let growingForegroundCircleLayer = CAShapeLayer()
private let foregroundView = UIView()
private let foregroundGradientLayer = CAGradientLayer()
@ -353,7 +416,7 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
private let maskBlobView: VoiceBlobView
private let maskCircleLayer = CAShapeLayer()
private let maskProgressLayer = CAShapeLayer()
fileprivate let maskProgressLayer = CAShapeLayer()
private let maskMediumBlobLayer = CAShapeLayer()
private let maskBigBlobLayer = CAShapeLayer()
@ -387,6 +450,11 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
self.foregroundCircleLayer.transform = CATransform3DMakeScale(0.0, 0.0, 1)
self.foregroundCircleLayer.isHidden = true
self.growingForegroundCircleLayer.fillColor = greyColor.cgColor
self.growingForegroundCircleLayer.path = smallerCirclePath
self.growingForegroundCircleLayer.transform = CATransform3DMakeScale(1.0, 1.0, 1)
self.growingForegroundCircleLayer.isHidden = true
self.foregroundGradientLayer.type = .radial
self.foregroundGradientLayer.colors = [lightBlue.cgColor, blue.cgColor]
self.foregroundGradientLayer.startPoint = CGPoint(x: 1.0, y: 0.0)
@ -430,6 +498,7 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
self.view.addSubview(self.foregroundView)
self.layer.addSublayer(self.foregroundCircleLayer)
self.layer.addSublayer(self.growingForegroundCircleLayer)
self.foregroundView.mask = self.maskView
self.foregroundView.layer.addSublayer(self.foregroundGradientLayer)
@ -529,7 +598,11 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
}
}
var disableGlowAnimations = false
func updateGlowScale(_ scale: CGFloat?) {
if self.disableGlowAnimations {
return
}
if let scale = scale {
self.maskGradientLayer.transform = CATransform3DMakeScale(0.89 + 0.11 * scale, 0.89 + 0.11 * scale, 1.0)
} else {
@ -617,12 +690,19 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
CATransaction.commit()
}
var animatingDisappearance = false
private func playBlobsDisappearanceAnimation() {
if self.animatingDisappearance {
return
}
self.animatingDisappearance = true
CATransaction.begin()
CATransaction.setDisableActions(true)
self.foregroundCircleLayer.isHidden = false
self.growingForegroundCircleLayer.isHidden = false
CATransaction.commit()
self.disableGlowAnimations = true
self.maskGradientLayer.removeAllAnimations()
self.updateGlowAndGradientAnimations(active: nil, previousActive: nil)
self.maskBlobView.startAnimating()
@ -643,14 +723,16 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
CATransaction.setCompletionBlock {
CATransaction.begin()
CATransaction.setDisableActions(true)
self.disableGlowAnimations = false
self.maskGradientLayer.isHidden = true
self.maskCircleLayer.isHidden = true
self.foregroundCircleLayer.isHidden = true
self.foregroundCircleLayer.removeAllAnimations()
self.growingForegroundCircleLayer.isHidden = true
self.growingForegroundCircleLayer.removeAllAnimations()
self.animatingDisappearance = false
CATransaction.commit()
}
self.foregroundCircleLayer.add(growthAnimation, forKey: "insideGrowth")
self.growingForegroundCircleLayer.add(growthAnimation, forKey: "insideGrowth")
CATransaction.commit()
}
@ -663,6 +745,8 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
self.maskGradientLayer.isHidden = false
CATransaction.commit()
self.disableGlowAnimations = true
self.maskGradientLayer.removeAllAnimations()
self.updateGlowAndGradientAnimations(active: active, previousActive: nil)
self.maskBlobView.isHidden = false
@ -679,6 +763,7 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
CATransaction.setCompletionBlock {
CATransaction.begin()
CATransaction.setDisableActions(true)
self.disableGlowAnimations = false
self.foregroundCircleLayer.isHidden = true
CATransaction.commit()
}
@ -769,6 +854,13 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
switch self.state {
case .connecting:
self.updatedActive?(false)
if let transition = self.transition {
self.updateGlowScale(nil)
if case .blob = transition {
playBlobsDisappearanceAnimation()
}
self.transition = nil
}
self.setupProgressAnimations()
self.isActive = false
case let .blob(newActive):
@ -808,18 +900,46 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
}
}
func updateColor(dark: Bool) {
var isDark: Bool = false {
didSet {
if self.isDark != oldValue {
self.updateColors()
}
}
}
var isSnap: Bool = false {
didSet {
if self.isSnap != oldValue {
self.updateColors()
}
}
}
var connectingColor: UIColor = UIColor(rgb: 0xb6b6bb) {
didSet {
if self.connectingColor.rgb != oldValue.rgb {
self.updateColors()
}
}
}
fileprivate func updateColors() {
let previousColor: CGColor = self.backgroundCircleLayer.fillColor ?? greyColor.cgColor
let targetColor: CGColor
if dark {
if self.isSnap {
targetColor = self.connectingColor.cgColor
} else if self.isDark {
targetColor = secondaryGreyColor.cgColor
} else {
targetColor = greyColor.cgColor
}
self.backgroundCircleLayer.fillColor = targetColor
self.foregroundCircleLayer.fillColor = targetColor
self.growingForegroundCircleLayer.fillColor = targetColor
self.backgroundCircleLayer.animate(from: previousColor, to: targetColor, keyPath: "fillColor", timingFunction: CAMediaTimingFunctionName.linear.rawValue, duration: 0.3)
self.foregroundCircleLayer.animate(from: previousColor, to: targetColor, keyPath: "fillColor", timingFunction: CAMediaTimingFunctionName.linear.rawValue, duration: 0.3)
self.growingForegroundCircleLayer.animate(from: previousColor, to: targetColor, keyPath: "fillColor", timingFunction: CAMediaTimingFunctionName.linear.rawValue, duration: 0.3)
}
func update(state: State, animated: Bool) {
@ -850,6 +970,8 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
self.backgroundCircleLayer.frame = circleFrame
self.foregroundCircleLayer.position = center
self.foregroundCircleLayer.bounds = CGRect(origin: CGPoint(), size: CGSize(width: circleFrame.width - progressLineWidth, height: circleFrame.height - progressLineWidth))
self.growingForegroundCircleLayer.position = center
self.growingForegroundCircleLayer.bounds = self.foregroundCircleLayer.bounds
self.maskCircleLayer.frame = circleFrame.insetBy(dx: -progressLineWidth / 2.0, dy: -progressLineWidth / 2.0)
self.maskProgressLayer.frame = circleFrame.insetBy(dx: -3.0, dy: -3.0)
self.foregroundView.frame = self.bounds

View File

@ -376,6 +376,7 @@ public final class VoiceChatController: ViewController {
private let context: AccountContext
private let call: PresentationGroupCall
private var presentationData: PresentationData
private var presentationDataDisposable: Disposable?
private var darkTheme: PresentationTheme
private let dimNode: ASDisplayNode
@ -834,6 +835,22 @@ public final class VoiceChatController: ViewController {
}
}
self.presentationDataDisposable = (sharedContext.presentationData
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
if let strongSelf = self {
strongSelf.presentationData = presentationData
let sourceColor = presentationData.theme.chatList.unreadBadgeInactiveBackgroundColor
let color: UIColor
if sourceColor.alpha < 1.0 {
color = presentationData.theme.chatList.unreadBadgeInactiveBackgroundColor.mixedWith(sourceColor.withAlphaComponent(1.0), alpha: sourceColor.alpha)
} else {
color = sourceColor
}
strongSelf.actionButton.connectingColor = color
}
})
self.memberStatesDisposable = (combineLatest(queue: .mainQueue(),
self.call.state,
self.call.members,
@ -1093,6 +1110,7 @@ public final class VoiceChatController: ViewController {
}
deinit {
self.presentationDataDisposable?.dispose()
self.peerViewDisposable?.dispose()
self.leaveDisposable.dispose()
self.isMutedDisposable?.dispose()
@ -1121,7 +1139,7 @@ public final class VoiceChatController: ViewController {
panRecognizer.delegate = self
panRecognizer.delaysTouchesBegan = false
panRecognizer.cancelsTouchesInView = true
// self.view.addGestureRecognizer(panRecognizer)
self.view.addGestureRecognizer(panRecognizer)
}
@objc private func optionsPressed() {
@ -1152,7 +1170,7 @@ public final class VoiceChatController: ViewController {
private var pressTimer: SwiftSignalKit.Timer?
private func startPressTimer() {
self.pressTimer?.invalidate()
let pressTimer = SwiftSignalKit.Timer(timeout: 0.2, repeat: false, completion: { [weak self] in
let pressTimer = SwiftSignalKit.Timer(timeout: 0.185, repeat: false, completion: { [weak self] in
self?.pressTimerFired()
self?.pressTimer = nil
}, queue: Queue.mainQueue())
@ -1185,6 +1203,9 @@ public final class VoiceChatController: ViewController {
guard let callState = self.callState else {
return
}
if case .connecting = callState.networkState {
return
}
if let muteState = callState.muteState {
if !muteState.canUnmute {
if case .ended = gestureRecognizer.state {
@ -1581,7 +1602,7 @@ public final class VoiceChatController: ViewController {
actionButtonEnabled = false
}
self.actionButton.isUserInteractionEnabled = actionButtonEnabled
self.actionButton.isDisabled = !actionButtonEnabled
self.actionButton.update(size: centralButtonSize, buttonSize: CGSize(width: 144.0, height: 144.0), state: actionButtonState, title: actionButtonTitle, subtitle: actionButtonSubtitle, dark: self.isFullscreen, small: layout.size.width < 330.0, animated: true)
if self.actionButton.supernode === self.bottomPanelNode {
@ -1618,8 +1639,10 @@ public final class VoiceChatController: ViewController {
transition.animateView({
self.contentContainer.view.bounds = initialBounds
}, completion: { _ in
if self.actionButton.supernode !== self.bottomPanelNode {
self.bottomPanelNode.addSubnode(self.actionButton)
self.containerLayoutUpdated(layout, navigationHeight:navigationHeight, transition: .immediate)
}
self.controller?.currentOverlayController?.dismiss()
self.controller?.currentOverlayController = nil
@ -1673,16 +1696,17 @@ public final class VoiceChatController: ViewController {
self.enqueuedTransitions.remove(at: 0)
var options = ListViewDeleteAndInsertOptions()
if !isFirstTime {
if transition.crossFade {
options.insert(.AnimateCrossfade)
}
if transition.animated {
options.insert(.AnimateInsertion)
}
}
options.insert(.LowLatency)
options.insert(.PreferSynchronousResourceLoading)
var scrollToItem: ListViewScrollToItem?
if self.isFirstTime {
self.isFirstTime = false
@ -1915,7 +1939,7 @@ public final class VoiceChatController: ViewController {
self.idleTimerExtensionDisposable.dispose()
if let currentOverlayController = self.currentOverlayController {
currentOverlayController.animateOut(reclaim: false, completion: {})
currentOverlayController.animateOut(reclaim: false, completion: { _ in })
}
}
@ -1959,7 +1983,12 @@ public final class VoiceChatController: ViewController {
public func dismiss(closing: Bool) {
if !closing {
if let navigationController = self.navigationController as? NavigationController {
let count = navigationController.viewControllers.count
if count == 2 || navigationController.viewControllers[count - 2] is ChatController {
self.detachActionButton()
}
}
} else {
self.isDisconnected = true
}
@ -1981,7 +2010,11 @@ public final class VoiceChatController: ViewController {
self.reclaimActionButton = { [weak self, weak overlayController] in
if let strongSelf = self {
overlayController?.animateOut(reclaim: true, completion: {})
overlayController?.animateOut(reclaim: true, completion: { [weak self] immediate in
if let strongSelf = self, immediate {
strongSelf.controllerNode.bottomPanelNode.addSubnode(strongSelf.controllerNode.actionButton)
}
})
strongSelf.reclaimActionButton = nil
}
}

View File

@ -14,6 +14,9 @@ import SyncCore
import AppBundle
import ContextUI
import PresentationDataUtils
import TooltipUI
private let slideOffset: CGFloat = 80.0 + 44.0
public final class VoiceChatOverlayController: ViewController {
private final class Node: ViewControllerTracingNode, UIGestureRecognizerDelegate {
@ -23,12 +26,16 @@ public final class VoiceChatOverlayController: ViewController {
init(controller: VoiceChatOverlayController) {
self.controller = controller
super.init()
self.clipsToBounds = true
}
private var isButtonHidden = false
private var isSlidOffscreen = false
func update(hidden: Bool, slide: Bool, animated: Bool) {
guard let actionButton = self.controller?.actionButton, actionButton.supernode === self else {
guard let actionButton = self.controller?.actionButton else {
return
}
@ -36,13 +43,17 @@ public final class VoiceChatOverlayController: ViewController {
return
}
self.isButtonHidden = hidden
self.isSlidOffscreen = hidden && slide
guard actionButton.supernode === self else {
return
}
if animated {
let transition: ContainedViewLayoutTransition = .animated(duration: 0.4, curve: .spring)
if hidden {
if slide {
self.isSlidOffscreen = true
transition.updateSublayerTransformOffset(layer: actionButton.layer, offset: CGPoint(x: 70.0, y: 0.0))
transition.updateSublayerTransformOffset(layer: actionButton.layer, offset: CGPoint(x: slideOffset, y: 0.0))
} else {
actionButton.layer.removeAllAnimations()
actionButton.layer.animateScale(from: 1.0, to: 0.001, duration: 0.2, timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, removeOnCompletion: false, completion: { [weak actionButton] _ in
@ -51,7 +62,6 @@ public final class VoiceChatOverlayController: ViewController {
}
} else {
if slide {
self.isSlidOffscreen = false
transition.updateSublayerTransformOffset(layer: actionButton.layer, offset: CGPoint())
} else {
actionButton.layer.removeAllAnimations()
@ -60,7 +70,15 @@ public final class VoiceChatOverlayController: ViewController {
}
}
} else {
if hidden {
if slide {
actionButton.layer.sublayerTransform = CATransform3DMakeTranslation(slideOffset, 0.0, 0.0)
}
} else {
if slide {
actionButton.layer.sublayerTransform = CATransform3DIdentity
}
}
}
}
@ -69,6 +87,12 @@ public final class VoiceChatOverlayController: ViewController {
return
}
actionButton.update(snap: true, animated: !self.isSlidOffscreen)
if self.isSlidOffscreen {
actionButton.layer.sublayerTransform = CATransform3DMakeTranslation(slideOffset, 0.0, 0.0)
return
}
let targetPosition = actionButton.position
let sourcePoint = CGPoint(x: from.midX, y: from.midY)
let midPoint = CGPoint(x: (sourcePoint.x + targetPosition.x) / 2.0, y: sourcePoint.y + 120.0)
@ -96,15 +120,29 @@ public final class VoiceChatOverlayController: ViewController {
})
}
func animateOut(reclaim: Bool, completion: @escaping () -> Void) {
private var animating = false
func animateOut(reclaim: Bool, completion: @escaping (Bool) -> Void) {
guard let actionButton = self.controller?.actionButton, let layout = self.validLayout else {
return
}
if reclaim {
let targetPosition = CGPoint(x: layout.size.width / 2.0, y: layout.size.height - layout.intrinsicInsets.bottom - 268.0 / 2.0)
if self.isSlidOffscreen {
self.isSlidOffscreen = false
self.isButtonHidden = true
actionButton.layer.sublayerTransform = CATransform3DIdentity
actionButton.update(snap: false, animated: false)
actionButton.position = CGPoint(x: targetPosition.x, y: 268.0 / 2.0)
completion(true)
} else {
self.animating = true
let sourcePoint = actionButton.position
let midPoint = CGPoint(x: (sourcePoint.x + targetPosition.x) / 2.0 - 20.0, y: sourcePoint.y + 10.0)
var midPoint = CGPoint(x: (sourcePoint.x + targetPosition.x) / 2.0 - 60.0, y: sourcePoint.y)
if sourcePoint.y < layout.size.height - 100.0 {
midPoint.x = (sourcePoint.x + targetPosition.x) / 2.0 + 30.0
midPoint.y = (sourcePoint.y + targetPosition.y) / 2.0 + 40.0
}
let x1 = sourcePoint.x
let y1 = sourcePoint.y
@ -125,11 +163,13 @@ public final class VoiceChatOverlayController: ViewController {
keyframes.append(NSValue(cgPoint: CGPoint(x: x, y: y)))
}
actionButton.update(snap: false)
actionButton.update(snap: false, animated: true)
actionButton.position = targetPosition
actionButton.layer.animateKeyframes(values: keyframes, duration: 0.4, keyPath: "position", timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, completion: { _ in
completion()
actionButton.layer.animateKeyframes(values: keyframes, duration: 0.34, keyPath: "position", timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, completion: { _ in
self.animating = false
completion(false)
})
}
} else {
actionButton.layer.animateScale(from: 1.0, to: 0.001, duration: 0.2, timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, removeOnCompletion: false, completion: { [weak self, weak actionButton] _ in
actionButton?.removeFromSupernode()
@ -152,7 +192,7 @@ public final class VoiceChatOverlayController: ViewController {
func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
self.validLayout = layout
if let actionButton = self.controller?.actionButton {
if let actionButton = self.controller?.actionButton, !self.animating {
let convertedRect = actionButton.view.convert(actionButton.bounds, to: self.view)
let insets = layout.insets(options: [.input])
transition.updatePosition(node: actionButton, position: CGPoint(x: layout.size.width - layout.safeInsets.right - 21.0, y: layout.size.height - insets.bottom - 22.0))
@ -160,7 +200,6 @@ public final class VoiceChatOverlayController: ViewController {
if actionButton.supernode !== self {
self.addSubnode(actionButton)
actionButton.update(snap: true)
self.animateIn(from: convertedRect)
}
}
@ -192,23 +231,32 @@ public final class VoiceChatOverlayController: ViewController {
self.disposable = (combineLatest(queue: Queue.mainQueue(), controllers, overlayControllers)).start(next: { [weak self] controllers, overlayControllers in
if let strongSelf = self {
var hasVoiceChatController = false
var overlayControllersCount = 0
for controller in controllers {
if controller is VoiceChatController {
hasVoiceChatController = true
}
}
for controller in overlayControllers {
if controller is TooltipController || controller is TooltipScreen || controller is AlertController {
} else {
overlayControllersCount += 1
}
}
var hidden = true
var animated = true
if controllers.count == 1 || controllers.last is ChatController {
hidden = false
}
if overlayControllers.count > 0 {
if overlayControllersCount > 0 {
hidden = true
}
if hasVoiceChatController {
hidden = false
animated = false
}
strongSelf.controllerNode.update(hidden: hidden, slide: true, animated: true)
strongSelf.controllerNode.update(hidden: hidden, slide: true, animated: animated)
}
})
}
@ -233,7 +281,7 @@ public final class VoiceChatOverlayController: ViewController {
completion?()
}
func animateOut(reclaim: Bool, completion: @escaping () -> Void) {
func animateOut(reclaim: Bool, completion: @escaping (Bool) -> Void) {
self.controllerNode.animateOut(reclaim: reclaim, completion: completion)
}

View File

@ -159,7 +159,7 @@ public class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode {
private let actionContainerNode: ASDisplayNode
private var animationNode: VoiceChatMicrophoneNode?
private var iconNode: ASImageNode?
private var actionButtonNode: HighlightTrackingButtonNode
private var actionButtonNode: HighlightableButtonNode
private var audioLevelView: VoiceBlobView?
private let audioLevelDisposable = MetaDisposable()
@ -201,7 +201,7 @@ public class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode {
self.statusNode.contentsScale = UIScreen.main.scale
self.actionContainerNode = ASDisplayNode()
self.actionButtonNode = HighlightTrackingButtonNode()
self.actionButtonNode = HighlightableButtonNode()
self.highlightedBackgroundNode = ASDisplayNode()
self.highlightedBackgroundNode.isLayerBacked = true
@ -613,7 +613,7 @@ public class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode {
}
}
animationNode.update(state: VoiceChatMicrophoneNode.State(muted: muted, color: color), animated: true)
strongSelf.actionButtonNode.isUserInteractionEnabled = false
strongSelf.actionButtonNode.isUserInteractionEnabled = item.contextAction != nil
} else if let animationNode = strongSelf.animationNode {
strongSelf.animationNode = nil
animationNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false)
@ -643,7 +643,7 @@ public class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode {
} else {
iconNode.image = generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/AddUser"), color: item.presentationData.theme.list.itemAccentColor)
}
strongSelf.actionButtonNode.isUserInteractionEnabled = !invited
strongSelf.actionButtonNode.isUserInteractionEnabled = false
} else if let iconNode = strongSelf.iconNode {
strongSelf.iconNode = nil
iconNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false)
@ -734,15 +734,15 @@ public class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode {
}
@objc private func actionButtonPressed() {
if let item = self.layoutParams?.0 {
item.action?()
if let item = self.layoutParams?.0, let contextAction = item.contextAction {
contextAction(self.contextSourceNode, nil)
}
}
override public func updateRevealOffset(offset: CGFloat, transition: ContainedViewLayoutTransition) {
super.updateRevealOffset(offset: offset, transition: transition)
if let item = self.layoutParams?.0, let params = self.layoutParams?.1 {
if let _ = self.layoutParams?.0, let params = self.layoutParams?.1 {
let leftInset: CGFloat = 65.0 + params.leftInset
var avatarFrame = self.avatarNode.frame

View File

@ -778,7 +778,7 @@ public final class PresentationThemeChatMessage {
self.stickerPlaceholderShimmerColor = stickerPlaceholderShimmerColor
}
public func withUpdated(incoming: PresentationThemePartedColors? = nil, outgoing: PresentationThemePartedColors? = nil, freeform: PresentationThemeBubbleColor? = nil, infoPrimaryTextColor: UIColor? = nil, infoLinkTextColor: UIColor? = nil, outgoingCheckColor: UIColor? = nil, mediaDateAndStatusFillColor: UIColor? = nil, mediaDateAndStatusTextColor: UIColor? = nil, shareButtonFillColor: PresentationThemeVariableColor? = nil, shareButtonStrokeColor: PresentationThemeVariableColor? = nil, shareButtonForegroundColor: PresentationThemeVariableColor? = nil, mediaOverlayControlColors: PresentationThemeFillForeground? = nil, selectionControlColors: PresentationThemeFillStrokeForeground? = nil, deliveryFailedColors: PresentationThemeFillForeground? = nil, mediaHighlightOverlayColor: UIColor? = nil) -> PresentationThemeChatMessage {
public func withUpdated(incoming: PresentationThemePartedColors? = nil, outgoing: PresentationThemePartedColors? = nil, freeform: PresentationThemeBubbleColor? = nil, infoPrimaryTextColor: UIColor? = nil, infoLinkTextColor: UIColor? = nil, outgoingCheckColor: UIColor? = nil, mediaDateAndStatusFillColor: UIColor? = nil, mediaDateAndStatusTextColor: UIColor? = nil, shareButtonFillColor: PresentationThemeVariableColor? = nil, shareButtonStrokeColor: PresentationThemeVariableColor? = nil, shareButtonForegroundColor: PresentationThemeVariableColor? = nil, mediaOverlayControlColors: PresentationThemeFillForeground? = nil, selectionControlColors: PresentationThemeFillStrokeForeground? = nil, deliveryFailedColors: PresentationThemeFillForeground? = nil, mediaHighlightOverlayColor: UIColor? = nil, stickerPlaceholderColor: PresentationThemeVariableColor? = nil, stickerPlaceholderShimmerColor: PresentationThemeVariableColor? = nil) -> PresentationThemeChatMessage {
return PresentationThemeChatMessage(incoming: incoming ?? self.incoming, outgoing: outgoing ?? self.outgoing, freeform: freeform ?? self.freeform, infoPrimaryTextColor: infoPrimaryTextColor ?? self.infoPrimaryTextColor, infoLinkTextColor: infoLinkTextColor ?? self.infoLinkTextColor, outgoingCheckColor: outgoingCheckColor ?? self.outgoingCheckColor, mediaDateAndStatusFillColor: mediaDateAndStatusFillColor ?? self.mediaDateAndStatusFillColor, mediaDateAndStatusTextColor: mediaDateAndStatusTextColor ?? self.mediaDateAndStatusTextColor, shareButtonFillColor: shareButtonFillColor ?? self.shareButtonFillColor, shareButtonStrokeColor: shareButtonStrokeColor ?? self.shareButtonStrokeColor, shareButtonForegroundColor: shareButtonForegroundColor ?? self.shareButtonForegroundColor, mediaOverlayControlColors: mediaOverlayControlColors ?? self.mediaOverlayControlColors, selectionControlColors: selectionControlColors ?? self.selectionControlColors, deliveryFailedColors: deliveryFailedColors ?? self.deliveryFailedColors, mediaHighlightOverlayColor: mediaHighlightOverlayColor ?? self.mediaHighlightOverlayColor, stickerPlaceholderColor: stickerPlaceholderColor ?? self.stickerPlaceholderColor, stickerPlaceholderShimmerColor: stickerPlaceholderShimmerColor ?? self.stickerPlaceholderShimmerColor)
}
}

View File

@ -1245,11 +1245,7 @@ final class SharedApplicationContext {
|> map { loggedOutAccountPeerIds -> (AccountManager, Set<PeerId>) in
return (sharedContext.sharedContext.accountManager, loggedOutAccountPeerIds)
}
}).start(next: { [weak self] accountManager, loggedOutAccountPeerIds in
guard let strongSelf = self else {
return
}
}).start(next: { accountManager, loggedOutAccountPeerIds in
let _ = (updateIntentsSettingsInteractively(accountManager: accountManager) { current in
var updated = current
for peerId in loggedOutAccountPeerIds {
@ -1888,7 +1884,7 @@ final class SharedApplicationContext {
|> take(1)
|> deliverOnMainQueue).start(next: { sharedContext in
let type = ApplicationShortcutItemType(rawValue: shortcutItem.type)
var immediately = type == .account
let immediately = type == .account
let proceed: () -> Void = {
let _ = (self.context.get()
|> take(1)

View File

@ -5609,6 +5609,14 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
})
strongSelf.saveInterfaceState()
if let navigationController = strongSelf.navigationController as? NavigationController {
for controller in navigationController.globalOverlayControllers {
if controller is VoiceChatOverlayController {
return
}
}
}
var rect: CGRect? = strongSelf.chatDisplayNode.frameForInputPanelAccessoryButton(.silentPost(true))
if rect == nil {
rect = strongSelf.chatDisplayNode.frameForInputPanelAccessoryButton(.silentPost(false))
@ -7062,11 +7070,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
}
if let controller = voiceChatOverlayController {
var hidden = false
if self.presentationInterfaceState.interfaceState.editMessage != nil || self.presentationInterfaceState.interfaceState.composeInputState.inputText.string.count > 0 {
controller.update(hidden: true, slide: false, animated: true)
} else {
controller.update(hidden: false, slide: false, animated: true)
hidden = true
}
controller.update(hidden: hidden, slide: false, animated: true)
}
}
}

View File

@ -1556,6 +1556,10 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
apparentNavigateButtonsFrame.origin.y += verticalOffset
}
if layout.additionalInsets.right > 0.0 {
apparentNavigateButtonsFrame.origin.y -= 16.0
}
let previousInputPanelBackgroundFrame = self.inputPanelBackgroundNode.frame
transition.updateFrame(node: self.inputPanelBackgroundNode, frame: apparentInputBackgroundFrame)
transition.updateFrame(node: self.inputPanelBackgroundSeparatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: apparentInputBackgroundFrame.origin.y), size: CGSize(width: apparentInputBackgroundFrame.size.width, height: UIScreenPixel)))

View File

@ -234,9 +234,11 @@ final class ChatMediaInputStickerGridItemNode: GridItemNode {
if !animated {
placeholderNode.removeFromSupernode()
} else {
placeholderNode.allowsGroupOpacity = true
placeholderNode.alpha = 0.0
placeholderNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, completion: { [weak placeholderNode] _ in
placeholderNode?.removeFromSupernode()
placeholderNode?.allowsGroupOpacity = false
})
}
}

View File

@ -21,6 +21,7 @@ import Markdown
import ManagedAnimationNode
import SlotMachineAnimationNode
import UniversalMediaPlayer
import ShimmerEffect
private let nameFont = Font.medium(14.0)
private let inlineBotPrefixFont = Font.regular(14.0)

View File

@ -51,7 +51,7 @@ final class HorizontalStickerGridItemNode: GridItemNode {
private var currentState: (Account, HorizontalStickerGridItem, CGSize)?
private let imageNode: TransformImageNode
private var animationNode: AnimatedStickerNode?
private var placeholderNode: ShimmerEffectNode?
private var placeholderNode: StickerShimmerEffectNode?
private let stickerFetchedDisposable = MetaDisposable()
@ -81,7 +81,7 @@ final class HorizontalStickerGridItemNode: GridItemNode {
override init() {
self.imageNode = TransformImageNode()
self.placeholderNode = ShimmerEffectNode()
self.placeholderNode = StickerShimmerEffectNode()
super.init()
@ -114,9 +114,11 @@ final class HorizontalStickerGridItemNode: GridItemNode {
if !animated {
placeholderNode.removeFromSupernode()
} else {
placeholderNode.allowsGroupOpacity = true
placeholderNode.alpha = 0.0
placeholderNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, completion: { [weak placeholderNode] _ in
placeholderNode?.removeFromSupernode()
placeholderNode?.allowsGroupOpacity = false
})
}
}
@ -188,8 +190,8 @@ final class HorizontalStickerGridItemNode: GridItemNode {
let placeholderFrame = CGRect(origin: CGPoint(x: floor((bounds.width - boundingSize.width) / 2.0), y: floor((bounds.height - boundingSize.height) / 2.0)), size: boundingSize)
placeholderNode.frame = bounds
if let theme = self.currentState?.1.theme {
placeholderNode.update(backgroundColor: theme.list.plainBackgroundColor, foregroundColor: theme.list.mediaPlaceholderColor.mixedWith(theme.list.plainBackgroundColor, alpha: 0.4), shimmeringColor: theme.list.mediaPlaceholderColor.withAlphaComponent(0.3), shapes: [.roundedRect(rect: placeholderFrame, cornerRadius: 10.0)], size: bounds.size)
if let theme = self.currentState?.1.theme, let file = self.currentState?.1.file {
placeholderNode.update(backgroundColor: theme.list.plainBackgroundColor, foregroundColor: theme.list.mediaPlaceholderColor.mixedWith(theme.list.plainBackgroundColor, alpha: 0.4), shimmeringColor: theme.list.mediaPlaceholderColor.withAlphaComponent(0.3), data: file.immediateThumbnailData, size: bounds.size)
}
}

View File

@ -11,61 +11,7 @@ import StickerResources
import AccountContext
import AnimatedStickerNode
import TelegramAnimatedStickerNode
class MediaInputPaneTrendingItem: ListViewItem {
let account: Account
let theme: PresentationTheme
let strings: PresentationStrings
let interaction: TrendingPaneInteraction
let info: StickerPackCollectionInfo
let topItems: [StickerPackItem]
let installed: Bool
let unread: Bool
init(account: Account, theme: PresentationTheme, strings: PresentationStrings, interaction: TrendingPaneInteraction, info: StickerPackCollectionInfo, topItems: [StickerPackItem], installed: Bool, unread: Bool) {
self.account = account
self.theme = theme
self.strings = strings
self.interaction = interaction
self.info = info
self.topItems = topItems
self.installed = installed
self.unread = unread
}
func nodeConfiguredForParams(async: @escaping (@escaping () -> Void) -> Void, params: ListViewItemLayoutParams, synchronousLoads: Bool, previousItem: ListViewItem?, nextItem: ListViewItem?, completion: @escaping (ListViewItemNode, @escaping () -> (Signal<Void, NoError>?, (ListViewItemApply) -> Void)) -> Void) {
async {
let node = MediaInputPaneTrendingItemNode()
let (layout, apply) = node.asyncLayout()(self, params)
node.contentSize = layout.contentSize
node.insets = layout.insets
Queue.mainQueue().async {
completion(node, {
return (nil, { info in apply(synchronousLoads && info.isOnScreen) })
})
}
}
}
func updateNode(async: @escaping (@escaping () -> Void) -> Void, node: @escaping () -> ListViewItemNode, params: ListViewItemLayoutParams, previousItem: ListViewItem?, nextItem: ListViewItem?, animation: ListViewItemUpdateAnimation, completion: @escaping (ListViewItemNodeLayout, @escaping (ListViewItemApply) -> Void) -> Void) {
Queue.mainQueue().async {
if let nodeValue = node() as? MediaInputPaneTrendingItemNode {
let makeLayout = nodeValue.asyncLayout()
async {
let (layout, apply) = makeLayout(self, params)
Queue.mainQueue().async {
completion(layout, { _ in
apply(false)
})
}
}
}
}
}
}
import ShimmerEffect
private let titleFont = Font.bold(16.0)
private let statusFont = Font.regular(15.0)
@ -74,7 +20,10 @@ private let buttonFont = Font.medium(13.0)
final class TrendingTopItemNode: ASDisplayNode {
private let imageNode: TransformImageNode
private var animationNode: AnimatedStickerNode?
private var placeholderNode: StickerShimmerEffectNode?
public private(set) var file: TelegramMediaFile? = nil
public private(set) var theme: PresentationTheme?
private var listAppearance = false
private var itemSize: CGSize?
private let loadDisposable = MetaDisposable()
@ -91,15 +40,77 @@ final class TrendingTopItemNode: ASDisplayNode {
override init() {
self.imageNode = TransformImageNode()
self.imageNode.contentAnimations = [.subsequentUpdates]
self.placeholderNode = StickerShimmerEffectNode()
self.placeholderNode?.isUserInteractionEnabled = false
super.init()
self.addSubnode(self.imageNode)
if let placeholderNode = self.placeholderNode {
self.addSubnode(placeholderNode)
}
var firstTime = true
self.imageNode.imageUpdated = { [weak self] image in
guard let strongSelf = self else {
return
}
if image != nil {
strongSelf.removePlaceholder(animated: !firstTime)
}
firstTime = false
}
}
deinit {
self.loadDisposable.dispose()
}
private func removePlaceholder(animated: Bool) {
if let placeholderNode = self.placeholderNode {
self.placeholderNode = nil
if !animated {
placeholderNode.removeFromSupernode()
} else {
placeholderNode.allowsGroupOpacity = true
placeholderNode.alpha = 0.0
placeholderNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, completion: { [weak placeholderNode] _ in
placeholderNode?.removeFromSupernode()
placeholderNode?.allowsGroupOpacity = false
})
}
}
}
private var absoluteLocation: (CGRect, CGSize)?
func updateAbsoluteRect(_ rect: CGRect, within containerSize: CGSize) {
self.absoluteLocation = (rect, containerSize)
if let placeholderNode = placeholderNode {
placeholderNode.updateAbsoluteRect(rect, within: containerSize)
}
}
func update(theme: PresentationTheme, listAppearance: Bool) {
self.theme = theme
self.listAppearance = listAppearance
let backgroundColor: UIColor
let foregroundColor: UIColor
let shimmeringColor: UIColor
if listAppearance {
backgroundColor = theme.list.plainBackgroundColor
foregroundColor = theme.list.itemPlainSeparatorColor.blitOver(backgroundColor, alpha: 0.3)
shimmeringColor = theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.4)
} else {
backgroundColor = theme.chat.inputMediaPanel.stickersBackgroundColor.withAlphaComponent(1.0)
foregroundColor = theme.chat.inputMediaPanel.stickersSectionTextColor.blitOver(backgroundColor, alpha: 0.15)
shimmeringColor = theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.3)
}
if let placeholderNode = self.placeholderNode, let file = self.file {
placeholderNode.update(backgroundColor: backgroundColor, foregroundColor: foregroundColor, shimmeringColor: shimmeringColor, data: file.immediateThumbnailData, size: placeholderNode.frame.size)
}
}
func setup(account: Account, item: StickerPackItem, itemSize: CGSize, synchronousLoads: Bool) {
self.file = item.file
self.itemSize = itemSize
@ -112,8 +123,13 @@ final class TrendingTopItemNode: ASDisplayNode {
animationNode = AnimatedStickerNode()
animationNode.transform = self.imageNode.transform
animationNode.visibility = self.visibility
self.addSubnode(animationNode)
self.animationNode = animationNode
if let placeholderNode = self.placeholderNode {
self.insertSubnode(animationNode, belowSubnode: placeholderNode)
} else {
self.addSubnode(animationNode)
}
}
let dimensions = item.file.dimensions ?? PixelDimensions(width: 512, height: 512)
let fittedDimensions = dimensions.cgSize.aspectFitted(CGSize(width: 160.0, height: 160.0))
@ -161,285 +177,17 @@ final class TrendingTopItemNode: ASDisplayNode {
self.imageNode.frame = self.bounds
self.animationNode?.updateLayout(size: self.bounds.size)
let size = self.bounds.size
let boundingSize = size
if let placeholderNode = self.placeholderNode {
let placeholderFrame = CGRect(origin: CGPoint(x: floor((size.width - boundingSize.width) / 2.0), y: floor((size.height - boundingSize.height) / 2.0)), size: boundingSize)
placeholderNode.frame = placeholderFrame
if let theme = self.theme {
self.update(theme: theme, listAppearance: self.listAppearance)
}
}
class MediaInputPaneTrendingItemNode: ListViewItemNode {
private let titleNode: TextNode
private let descriptionNode: TextNode
private let unreadNode: ASImageNode
private let installTextNode: TextNode
private let installBackgroundNode: ASImageNode
private let installButtonNode: HighlightTrackingButtonNode
private var itemNodes: [TrendingTopItemNode]
private var item: MediaInputPaneTrendingItem?
private let preloadDisposable = MetaDisposable()
private let readDisposable = MetaDisposable()
override var visibility: ListViewItemNodeVisibility {
didSet {
let wasVisible = oldValue != .none
let isVisible = self.visibility != .none
if isVisible != wasVisible {
for node in self.itemNodes {
node.visibility = isVisible
}
if isVisible {
if let item = self.item, item.unread {
self.readDisposable.set((
markFeaturedStickerPacksAsSeenInteractively(postbox: item.account.postbox, ids: [item.info.id])
|> delay(1.0, queue: .mainQueue())
).start())
}
} else {
self.readDisposable.set(nil)
}
}
}
}
init() {
self.titleNode = TextNode()
self.titleNode.isUserInteractionEnabled = false
self.titleNode.contentMode = .left
self.titleNode.contentsScale = UIScreen.main.scale
self.descriptionNode = TextNode()
self.descriptionNode.isUserInteractionEnabled = false
self.descriptionNode.contentMode = .left
self.descriptionNode.contentsScale = UIScreen.main.scale
self.unreadNode = ASImageNode()
self.unreadNode.isLayerBacked = true
self.unreadNode.displayWithoutProcessing = true
self.unreadNode.displaysAsynchronously = false
self.installTextNode = TextNode()
self.installTextNode.isUserInteractionEnabled = false
self.installTextNode.contentMode = .left
self.installTextNode.contentsScale = UIScreen.main.scale
self.installBackgroundNode = ASImageNode()
self.installBackgroundNode.isLayerBacked = true
self.installBackgroundNode.displayWithoutProcessing = true
self.installBackgroundNode.displaysAsynchronously = false
self.installButtonNode = HighlightTrackingButtonNode()
self.itemNodes = []
super.init(layerBacked: false, dynamicBounce: false)
self.addSubnode(self.titleNode)
self.addSubnode(self.descriptionNode)
self.addSubnode(self.unreadNode)
self.addSubnode(self.installBackgroundNode)
self.addSubnode(self.installTextNode)
self.addSubnode(self.installButtonNode)
self.installButtonNode.highligthedChanged = { [weak self] highlighted in
if let strongSelf = self {
if highlighted {
strongSelf.installBackgroundNode.layer.removeAnimation(forKey: "opacity")
strongSelf.installBackgroundNode.alpha = 0.4
strongSelf.installTextNode.layer.removeAnimation(forKey: "opacity")
strongSelf.installTextNode.alpha = 0.4
} else {
strongSelf.installBackgroundNode.alpha = 1.0
strongSelf.installBackgroundNode.layer.animateAlpha(from: 0.4, to: 1.0, duration: 0.2)
strongSelf.installTextNode.alpha = 1.0
strongSelf.installTextNode.layer.animateAlpha(from: 0.4, to: 1.0, duration: 0.2)
}
}
}
self.installButtonNode.addTarget(self, action: #selector(self.installPressed), forControlEvents: .touchUpInside)
}
deinit {
self.preloadDisposable.dispose()
self.readDisposable.dispose()
}
override func didLoad() {
super.didLoad()
self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:))))
}
func asyncLayout() -> (_ item: MediaInputPaneTrendingItem, _ params: ListViewItemLayoutParams) -> (ListViewItemNodeLayout, (Bool) -> Void) {
let makeInstallLayout = TextNode.asyncLayout(self.installTextNode)
let makeTitleLayout = TextNode.asyncLayout(self.titleNode)
let makeDescriptionLayout = TextNode.asyncLayout(self.descriptionNode)
let currentItem = self.item
return { item, params in
var updateButtonBackgroundImage: UIImage?
if currentItem?.theme !== item.theme {
updateButtonBackgroundImage = PresentationResourcesChat.chatInputMediaPanelAddPackButtonImage(item.theme)
}
let unreadImage = PresentationResourcesItemList.stickerUnreadDotImage(item.theme)
let leftInset: CGFloat = 14.0
let rightInset: CGFloat = 16.0
let (installLayout, installApply) = makeInstallLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.strings.Stickers_Install, font: buttonFont, textColor: item.theme.list.itemAccentColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - params.leftInset - params.rightInset - leftInset - rightInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.info.title, font: titleFont, textColor: item.theme.list.itemPrimaryTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - params.leftInset - params.rightInset - leftInset - rightInset - 20.0 - installLayout.size.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
let (descriptionLayout, descriptionApply) = makeDescriptionLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.strings.StickerPack_StickerCount(item.info.count), font: statusFont, textColor: item.theme.chat.inputMediaPanel.stickersSectionTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - params.leftInset - params.rightInset - leftInset - rightInset - 20.0, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
let contentSize: CGSize = CGSize(width: params.width, height: 120.0)
let insets: UIEdgeInsets = UIEdgeInsets(top: 8.0, left: 0.0, bottom: 0.0, right: 0.0)
let layout = ListViewItemNodeLayout(contentSize: contentSize, insets: insets)
var topItems = item.topItems
if topItems.count > 5 {
topItems.removeSubrange(5 ..< topItems.count)
}
return (layout, { [weak self] synchronousLoads in
if let strongSelf = self {
if (item.topItems.count < Int(item.info.count) || item.topItems.count < 5) && strongSelf.item?.info.id != item.info.id {
strongSelf.preloadDisposable.set(preloadedFeaturedStickerSet(network: item.account.network, postbox: item.account.postbox, id: item.info.id).start())
}
strongSelf.item = item
let _ = installApply()
let _ = titleApply()
let _ = descriptionApply()
if let updateButtonBackgroundImage = updateButtonBackgroundImage {
strongSelf.installBackgroundNode.image = updateButtonBackgroundImage
}
let installWidth: CGFloat = installLayout.size.width + 20.0
let buttonFrame = CGRect(origin: CGPoint(x: params.width - params.rightInset - rightInset - installWidth, y: 4.0), size: CGSize(width: installWidth, height: 26.0))
strongSelf.installBackgroundNode.frame = buttonFrame
strongSelf.installTextNode.frame = CGRect(origin: CGPoint(x: buttonFrame.minX + floor((buttonFrame.width - installLayout.size.width) / 2.0), y: buttonFrame.minY + floor((buttonFrame.height - installLayout.size.height) / 2.0) + 1.0), size: installLayout.size)
strongSelf.installButtonNode.frame = buttonFrame
if item.installed {
strongSelf.installButtonNode.isHidden = true
strongSelf.installBackgroundNode.isHidden = true
strongSelf.installTextNode.isHidden = true
} else {
strongSelf.installButtonNode.isHidden = false
strongSelf.installBackgroundNode.isHidden = false
strongSelf.installTextNode.isHidden = false
}
let titleFrame = CGRect(origin: CGPoint(x: params.leftInset + leftInset, y: 2.0), size: titleLayout.size)
strongSelf.titleNode.frame = titleFrame
strongSelf.descriptionNode.frame = CGRect(origin: CGPoint(x: params.leftInset + leftInset, y: 23.0), size: descriptionLayout.size)
if item.unread {
strongSelf.unreadNode.isHidden = false
} else {
strongSelf.unreadNode.isHidden = true
}
if let image = unreadImage {
strongSelf.unreadNode.image = image
strongSelf.unreadNode.frame = CGRect(origin: CGPoint(x: titleFrame.maxX + 2.0, y: titleFrame.minY + 7.0), size: image.size)
}
let sideInset: CGFloat = 2.0
let availableWidth = params.width - params.leftInset - params.rightInset - sideInset * 2.0
var itemSide: CGFloat = floor(availableWidth / 5.0)
itemSide = min(itemSide, 75.0)
let itemSize = CGSize(width: itemSide, height: itemSide)
var offset = sideInset
let itemSpacing = (max(0, availableWidth - 5.0 * itemSide - sideInset * 2.0)) / 4.0
let isVisible = strongSelf.visibility != .none
for i in 0 ..< topItems.count {
let file = topItems[i].file
let node: TrendingTopItemNode
if i < strongSelf.itemNodes.count {
node = strongSelf.itemNodes[i]
} else {
node = TrendingTopItemNode()
node.visibility = isVisible
strongSelf.itemNodes.append(node)
strongSelf.addSubnode(node)
}
if file.fileId != node.file?.fileId {
node.setup(account: item.account, item: topItems[i], itemSize: itemSize, synchronousLoads: synchronousLoads)
}
if let dimensions = file.dimensions {
let imageSize = dimensions.cgSize.aspectFitted(itemSize)
node.frame = CGRect(origin: CGPoint(x: offset, y: 48.0), size: imageSize)
offset += itemSize.width + itemSpacing
}
}
if topItems.count < strongSelf.itemNodes.count {
for i in (topItems.count ..< strongSelf.itemNodes.count).reversed() {
strongSelf.itemNodes[i].removeFromSupernode()
strongSelf.itemNodes.remove(at: i)
}
}
strongSelf.updatePreviewing(animated: false)
}
})
}
}
override func animateInsertion(_ currentTimestamp: Double, duration: Double, short: Bool) {
self.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.4)
}
override func animateRemoved(_ currentTimestamp: Double, duration: Double) {
self.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.15, removeOnCompletion: false)
}
@objc func installPressed() {
if let item = self.item {
item.interaction.installPack(item.info)
}
}
@objc func tapGesture(_ recognizer: UITapGestureRecognizer) {
if case .ended = recognizer.state {
if let item = self.item {
item.interaction.openPack(item.info)
}
}
}
func itemAt(point: CGPoint) -> (ASDisplayNode, StickerPackItem)? {
guard let item = self.item else {
return nil
}
var index = 0
for itemNode in self.itemNodes {
if itemNode.frame.contains(point), index < item.topItems.count {
return (itemNode, item.topItems[index])
}
index += 1
}
return nil
}
func updatePreviewing(animated: Bool) {
guard let item = self.item else {
return
}
var index = 0
for itemNode in self.itemNodes {
if index < item.topItems.count {
let isPreviewing = item.interaction.getItemIsPreviewed(item.topItems[index])
itemNode.updatePreviewing(animated: animated, isPreviewing: isPreviewing)
}
index += 1
}
}
}

View File

@ -302,6 +302,16 @@ class StickerPaneSearchGlobalItemNode: GridItemNode {
self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:))))
}
private var absoluteLocation: (CGRect, CGSize)?
override public func updateAbsoluteRect(_ rect: CGRect, within containerSize: CGSize) {
self.absoluteLocation = (rect, containerSize)
for node in self.itemNodes {
let nodeRect = CGRect(origin: CGPoint(x: rect.minX + node.frame.minX, y: rect.minY + node.frame.minY), size: node.frame.size)
node.updateAbsoluteRect(nodeRect, within: containerSize)
}
}
func setup(item: StickerPaneSearchGlobalItem) {
if item.topItems.count < Int(item.info.count) && item.topItems.count < 5 && self.item?.info.id != item.info.id {
self.preloadDisposable.set(preloadedFeaturedStickerSet(network: item.account.network, postbox: item.account.postbox, id: item.info.id).start())
@ -451,11 +461,17 @@ class StickerPaneSearchGlobalItemNode: GridItemNode {
if file.fileId != node.file?.fileId {
node.setup(account: item.account, item: topItems[i], itemSize: itemSize, synchronousLoads: synchronousLoads)
}
if item.theme !== node.theme {
node.update(theme: item.theme, listAppearance: item.listAppearance)
}
if let dimensions = file.dimensions {
let imageSize = dimensions.cgSize.aspectFitted(itemSize)
node.frame = CGRect(origin: CGPoint(x: offset, y: 48.0 + topOffset), size: imageSize)
offset += itemSize.width + itemSpacing
}
if let (rect, size) = strongSelf.absoluteLocation {
strongSelf.updateAbsoluteRect(rect, within: size)
}
}
if topItems.count < strongSelf.itemNodes.count {

View File

@ -59,7 +59,7 @@ genrule(
mkdir -p "$$BUILD_DIR/Public/libvpx"
sh $$BUILD_DIR/build-libvpx-bazel.sh $$BUILD_ARCH "$$BUILD_DIR/libvpx" "$$BUILD_DIR"
arch -x86_64 sh $$BUILD_DIR/build-libvpx-bazel.sh $$BUILD_ARCH "$$BUILD_DIR/libvpx" "$$BUILD_DIR"
""" +
"\n".join([
"cp -f \"$$BUILD_DIR/VPX.framework/Headers/vpx/{}\" \"$(location Public/vpx/{})\"".format(header, header) for header in headers

View File

@ -55,7 +55,7 @@ genrule(
mkdir -p "$$BUILD_DIR/Public/mozjpeg"
PATH="$$PATH:$$CMAKE_DIR/cmake-3.18.4-Darwin-x86_64/CMake.app/Contents/bin" sh $$BUILD_DIR/build-mozjpeg-bazel.sh $$BUILD_ARCH "$$BUILD_DIR/mozjpeg" "$$BUILD_DIR"
PATH="$$PATH:$$CMAKE_DIR/cmake-3.18.4-Darwin-x86_64/CMake.app/Contents/bin" arch -x86_64 sh $$BUILD_DIR/build-mozjpeg-bazel.sh $$BUILD_ARCH "$$BUILD_DIR/mozjpeg" "$$BUILD_DIR"
""" +
"\n".join([
"cp -f \"$$BUILD_DIR/mozjpeg/{}\" \"$(location Public/mozjpeg/{})\"".format(header, header) for header in headers

View File

@ -23,8 +23,8 @@ set -x
pushd "$$BUILD_DIR/yasm-1.3.0"
mkdir build
cd build
PATH="$$PATH:$$CMAKE_DIR/cmake-3.18.4-Darwin-x86_64/CMake.app/Contents/bin" cmake .. -DYASM_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF
make -j $$core_count
PATH="$$PATH:$$CMAKE_DIR/cmake-3.18.4-Darwin-x86_64/CMake.app/Contents/bin" arch -x86_64 cmake .. -DYASM_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF
arch -x86_64 make -j $$core_count
popd
tar -cf "$(location yasm.tar)" -C "$$BUILD_DIR/yasm-1.3.0/build" .