mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 19:30:29 +00:00
Merge commit '16eae46449c2c1252108d4d24958c2be3354f45d'
This commit is contained in:
commit
03ac9f35c3
@ -14,6 +14,15 @@ if [ "$BAZEL" = "" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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")
|
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'`)
|
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"
|
rm -rf "$TULSI_APP"
|
||||||
|
|
||||||
pushd "build-system/tulsi"
|
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
|
popd
|
||||||
|
|
||||||
mkdir -p "$TULSI_DIRECTORY"
|
mkdir -p "$TULSI_DIRECTORY"
|
||||||
|
|||||||
@ -57,6 +57,7 @@ swift_library(
|
|||||||
"//submodules/GridMessageSelectionNode:GridMessageSelectionNode",
|
"//submodules/GridMessageSelectionNode:GridMessageSelectionNode",
|
||||||
"//submodules/ChatListFilterSettingsHeaderItem:ChatListFilterSettingsHeaderItem",
|
"//submodules/ChatListFilterSettingsHeaderItem:ChatListFilterSettingsHeaderItem",
|
||||||
"//submodules/TelegramStringFormatting:TelegramStringFormatting",
|
"//submodules/TelegramStringFormatting:TelegramStringFormatting",
|
||||||
|
"//submodules/TelegramCallsUI:TelegramCallsUI",
|
||||||
],
|
],
|
||||||
visibility = [
|
visibility = [
|
||||||
"//visibility:public",
|
"//visibility:public",
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import AppBundle
|
|||||||
import LocalizedPeerData
|
import LocalizedPeerData
|
||||||
import TelegramIntents
|
import TelegramIntents
|
||||||
import TooltipUI
|
import TooltipUI
|
||||||
|
import TelegramCallsUI
|
||||||
|
|
||||||
private func fixListNodeScrolling(_ listNode: ListView, searchNode: NavigationBarSearchContentNode) -> Bool {
|
private func fixListNodeScrolling(_ listNode: ListView, searchNode: NavigationBarSearchContentNode) -> Bool {
|
||||||
if listNode.scroller.isDragging {
|
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))
|
(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)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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> {
|
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> {
|
public var overlayControllersSignal: Signal<[UIViewController], NoError> {
|
||||||
return _overlayControllersPipe.signal()
|
return _overlayControllersPromise.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
override open var topViewController: UIViewController? {
|
override open var topViewController: UIViewController? {
|
||||||
@ -1246,7 +1246,7 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||||||
if let layout = self.validLayout {
|
if let layout = self.validLayout {
|
||||||
self.updateContainers(layout: layout, transition: animated ? .animated(duration: 0.5, curve: .spring) : .immediate)
|
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) {
|
public func presentOverlay(controller: ViewController, inGlobal: Bool = false, blockInteraction: Bool = false) {
|
||||||
@ -1270,7 +1270,7 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||||||
if overlayContainer.controller === controller {
|
if overlayContainer.controller === controller {
|
||||||
overlayContainer.removeFromSupernode()
|
overlayContainer.removeFromSupernode()
|
||||||
strongSelf.overlayContainers.remove(at: i)
|
strongSelf.overlayContainers.remove(at: i)
|
||||||
strongSelf._overlayControllersPipe.putNext(strongSelf.overlayContainers.map({ $0.controller }))
|
strongSelf._overlayControllersPromise.set(strongSelf.overlayContainers.map({ $0.controller }))
|
||||||
strongSelf.internalOverlayControllersUpdated()
|
strongSelf.internalOverlayControllersUpdated()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -1292,7 +1292,7 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||||||
self.globalOverlayContainers.append(container)
|
self.globalOverlayContainers.append(container)
|
||||||
} else {
|
} else {
|
||||||
self.overlayContainers.append(container)
|
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
|
container.isReadyUpdated = { [weak self, weak container] in
|
||||||
guard let strongSelf = self, let _ = container else {
|
guard let strongSelf = self, let _ = container else {
|
||||||
|
|||||||
@ -565,10 +565,12 @@ class TabBarNode: ASDisplayNode {
|
|||||||
if let callsTabBarNodeContainer = callsTabBarNodeContainer {
|
if let callsTabBarNodeContainer = callsTabBarNodeContainer {
|
||||||
tabBarNodeContainers.remove(at: 1)
|
tabBarNodeContainers.remove(at: 1)
|
||||||
transition.updateAlpha(node: callsTabBarNodeContainer.imageNode, alpha: 0.0)
|
transition.updateAlpha(node: callsTabBarNodeContainer.imageNode, alpha: 0.0)
|
||||||
|
callsTabBarNodeContainer.imageNode.isUserInteractionEnabled = false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if let callsTabBarNodeContainer = callsTabBarNodeContainer {
|
if let callsTabBarNodeContainer = callsTabBarNodeContainer {
|
||||||
transition.updateAlpha(node: callsTabBarNodeContainer.imageNode, alpha: 1.0)
|
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 {
|
for i in 0 ..< self.tabBarNodeContainers.count {
|
||||||
let node = self.tabBarNodeContainers[i].imageNode
|
let node = self.tabBarNodeContainers[i].imageNode
|
||||||
|
if !node.isUserInteractionEnabled {
|
||||||
|
continue
|
||||||
|
}
|
||||||
let distance = abs(location.x - node.position.x)
|
let distance = abs(location.x - node.position.x)
|
||||||
if let previousClosestNode = closestNode {
|
if let previousClosestNode = closestNode {
|
||||||
if previousClosestNode.1 > distance {
|
if previousClosestNode.1 > distance {
|
||||||
|
|||||||
@ -1,9 +1,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Display
|
import Display
|
||||||
import Postbox
|
|
||||||
import TelegramPresentationData
|
|
||||||
import GZip
|
|
||||||
|
|
||||||
private final class ShimmerEffectForegroundNode: ASDisplayNode {
|
private final class ShimmerEffectForegroundNode: ASDisplayNode {
|
||||||
private var currentBackgroundColor: UIColor?
|
private var currentBackgroundColor: UIColor?
|
||||||
@ -142,7 +139,7 @@ private func decodeStickerThumbnailData(_ data: Data) -> String {
|
|||||||
return string
|
return string
|
||||||
}
|
}
|
||||||
|
|
||||||
class StickerShimmerEffectNode: ASDisplayNode {
|
public class StickerShimmerEffectNode: ASDisplayNode {
|
||||||
private let backgroundNode: ASDisplayNode
|
private let backgroundNode: ASDisplayNode
|
||||||
private let effectNode: ShimmerEffectForegroundNode
|
private let effectNode: ShimmerEffectForegroundNode
|
||||||
private let foregroundNode: ASImageNode
|
private let foregroundNode: ASImageNode
|
||||||
@ -155,7 +152,7 @@ class StickerShimmerEffectNode: ASDisplayNode {
|
|||||||
private var currentShimmeringColor: UIColor?
|
private var currentShimmeringColor: UIColor?
|
||||||
private var currentSize = CGSize()
|
private var currentSize = CGSize()
|
||||||
|
|
||||||
override init() {
|
public override init() {
|
||||||
self.backgroundNode = ASDisplayNode()
|
self.backgroundNode = ASDisplayNode()
|
||||||
self.effectNode = ShimmerEffectForegroundNode()
|
self.effectNode = ShimmerEffectForegroundNode()
|
||||||
self.foregroundNode = ASImageNode()
|
self.foregroundNode = ASImageNode()
|
||||||
@ -172,6 +169,9 @@ class StickerShimmerEffectNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func update(backgroundColor: UIColor?, foregroundColor: UIColor, shimmeringColor: UIColor, data: Data?, size: CGSize) {
|
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 {
|
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
|
return
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ final class StickerPackPreviewGridItemNode: GridItemNode {
|
|||||||
private var isEmpty: Bool?
|
private var isEmpty: Bool?
|
||||||
private let imageNode: TransformImageNode
|
private let imageNode: TransformImageNode
|
||||||
private var animationNode: AnimatedStickerNode?
|
private var animationNode: AnimatedStickerNode?
|
||||||
private var placeholderNode: ShimmerEffectNode?
|
private var placeholderNode: StickerShimmerEffectNode?
|
||||||
|
|
||||||
private var theme: PresentationTheme?
|
private var theme: PresentationTheme?
|
||||||
|
|
||||||
@ -86,7 +86,8 @@ final class StickerPackPreviewGridItemNode: GridItemNode {
|
|||||||
override init() {
|
override init() {
|
||||||
self.imageNode = TransformImageNode()
|
self.imageNode = TransformImageNode()
|
||||||
self.imageNode.isLayerBacked = !smartInvertColorsEnabled()
|
self.imageNode.isLayerBacked = !smartInvertColorsEnabled()
|
||||||
self.placeholderNode = ShimmerEffectNode()
|
self.placeholderNode = StickerShimmerEffectNode()
|
||||||
|
self.placeholderNode?.isUserInteractionEnabled = false
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
@ -117,9 +118,11 @@ final class StickerPackPreviewGridItemNode: GridItemNode {
|
|||||||
if !animated {
|
if !animated {
|
||||||
placeholderNode.removeFromSupernode()
|
placeholderNode.removeFromSupernode()
|
||||||
} else {
|
} else {
|
||||||
|
placeholderNode.allowsGroupOpacity = true
|
||||||
placeholderNode.alpha = 0.0
|
placeholderNode.alpha = 0.0
|
||||||
placeholderNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, completion: { [weak placeholderNode] _ in
|
placeholderNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, completion: { [weak placeholderNode] _ in
|
||||||
placeholderNode?.removeFromSupernode()
|
placeholderNode?.removeFromSupernode()
|
||||||
|
placeholderNode?.allowsGroupOpacity = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,9 +184,6 @@ final class StickerPackPreviewGridItemNode: GridItemNode {
|
|||||||
self.setNeedsLayout()
|
self.setNeedsLayout()
|
||||||
}
|
}
|
||||||
self.isEmpty = isEmpty
|
self.isEmpty = isEmpty
|
||||||
|
|
||||||
//self.updateSelectionState(animated: false)
|
|
||||||
//self.updateHiddenMedia()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func layout() {
|
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)
|
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
|
placeholderNode.frame = bounds
|
||||||
|
|
||||||
if let theme = self.theme {
|
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), shapes: [.roundedRect(rect: placeholderFrame, cornerRadius: 10.0)], size: bounds.size)
|
placeholderNode.update(backgroundColor: theme.list.itemBlocksBackgroundColor, foregroundColor: theme.list.mediaPlaceholderColor, shimmeringColor: theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.4), data: item.file.immediateThumbnailData, size: placeholderFrame.size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,22 +26,34 @@ private class CallStatusBarBackgroundNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var speaking = false {
|
var connectingColor: UIColor = UIColor(rgb: 0xb6b6bb) {
|
||||||
didSet {
|
didSet {
|
||||||
if self.speaking != oldValue {
|
if self.connectingColor.rgb != oldValue.rgb {
|
||||||
let initialColors = self.foregroundGradientLayer.colors
|
self.updateGradientColors()
|
||||||
let targetColors: [CGColor]
|
|
||||||
if speaking {
|
|
||||||
targetColors = [green.cgColor, blue.cgColor]
|
|
||||||
} else {
|
|
||||||
targetColors = [blue.cgColor, lightBlue.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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var speaking: Bool? = nil {
|
||||||
|
didSet {
|
||||||
|
if self.speaking != oldValue {
|
||||||
|
self.updateGradientColors()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func updateGradientColors() {
|
||||||
|
let initialColors = self.foregroundGradientLayer.colors
|
||||||
|
let targetColors: [CGColor]
|
||||||
|
if let speaking = self.speaking {
|
||||||
|
targetColors = speaking ? [green.cgColor, blue.cgColor] : [blue.cgColor, lightBlue.cgColor]
|
||||||
|
} else {
|
||||||
|
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 let hierarchyTrackingNode: HierarchyTrackingNode
|
||||||
private var isCurrentlyInHierarchy = true
|
private var isCurrentlyInHierarchy = true
|
||||||
|
|
||||||
@ -145,7 +157,6 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private let backgroundNode: CallStatusBarBackgroundNode
|
private let backgroundNode: CallStatusBarBackgroundNode
|
||||||
private let microphoneNode: VoiceChatMicrophoneNode
|
|
||||||
private let titleNode: ImmediateTextNode
|
private let titleNode: ImmediateTextNode
|
||||||
private let subtitleNode: ImmediateAnimatedCountLabelNode
|
private let subtitleNode: ImmediateAnimatedCountLabelNode
|
||||||
|
|
||||||
@ -156,8 +167,9 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||||||
private var currentSize: CGSize?
|
private var currentSize: CGSize?
|
||||||
private var currentContent: Content?
|
private var currentContent: Content?
|
||||||
|
|
||||||
private var strings: PresentationStrings?
|
private var presentationData: PresentationData?
|
||||||
private var nameDisplayOrder: PresentationPersonNameOrder = .firstLast
|
private let presentationDataDisposable = MetaDisposable()
|
||||||
|
|
||||||
private var currentPeer: Peer?
|
private var currentPeer: Peer?
|
||||||
private var currentCallTimer: SwiftSignalKit.Timer?
|
private var currentCallTimer: SwiftSignalKit.Timer?
|
||||||
private var currentCallState: PresentationCallState?
|
private var currentCallState: PresentationCallState?
|
||||||
@ -167,7 +179,6 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||||||
|
|
||||||
public override init() {
|
public override init() {
|
||||||
self.backgroundNode = CallStatusBarBackgroundNode()
|
self.backgroundNode = CallStatusBarBackgroundNode()
|
||||||
self.microphoneNode = VoiceChatMicrophoneNode()
|
|
||||||
self.titleNode = ImmediateTextNode()
|
self.titleNode = ImmediateTextNode()
|
||||||
self.subtitleNode = ImmediateAnimatedCountLabelNode()
|
self.subtitleNode = ImmediateAnimatedCountLabelNode()
|
||||||
self.subtitleNode.reverseAnimationDirection = true
|
self.subtitleNode.reverseAnimationDirection = true
|
||||||
@ -180,6 +191,7 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
|
self.presentationDataDisposable.dispose()
|
||||||
self.audioLevelDisposable.dispose()
|
self.audioLevelDisposable.dispose()
|
||||||
self.stateDisposable.dispose()
|
self.stateDisposable.dispose()
|
||||||
self.currentCallTimer?.invalidate()
|
self.currentCallTimer?.invalidate()
|
||||||
@ -203,11 +215,10 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||||||
let wasEmpty = (self.titleNode.attributedText?.string ?? "").isEmpty
|
let wasEmpty = (self.titleNode.attributedText?.string ?? "").isEmpty
|
||||||
|
|
||||||
if !self.didSetupData {
|
if !self.didSetupData {
|
||||||
|
self.didSetupData = true
|
||||||
switch content {
|
switch content {
|
||||||
case let .call(sharedContext, account, call):
|
case let .call(sharedContext, account, call):
|
||||||
let presentationData = sharedContext.currentPresentationData.with { $0 }
|
self.presentationData = sharedContext.currentPresentationData.with { $0 }
|
||||||
self.strings = presentationData.strings
|
|
||||||
self.nameDisplayOrder = presentationData.nameDisplayOrder
|
|
||||||
self.stateDisposable.set(
|
self.stateDisposable.set(
|
||||||
(combineLatest(
|
(combineLatest(
|
||||||
account.postbox.loadedPeerWithId(call.peerId),
|
account.postbox.loadedPeerWithId(call.peerId),
|
||||||
@ -219,13 +230,29 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||||||
strongSelf.currentPeer = peer
|
strongSelf.currentPeer = peer
|
||||||
strongSelf.currentCallState = state
|
strongSelf.currentCallState = state
|
||||||
strongSelf.currentIsMuted = isMuted
|
strongSelf.currentIsMuted = isMuted
|
||||||
|
|
||||||
|
let currentIsConnected: Bool
|
||||||
|
switch state.state {
|
||||||
|
case .active, .terminating, .terminated:
|
||||||
|
currentIsConnected = true
|
||||||
|
default:
|
||||||
|
currentIsConnected = false
|
||||||
|
}
|
||||||
|
|
||||||
|
strongSelf.currentIsConnected = currentIsConnected
|
||||||
|
|
||||||
strongSelf.update()
|
strongSelf.update()
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
case let .groupCall(sharedContext, account, call):
|
case let .groupCall(sharedContext, account, call):
|
||||||
let presentationData = sharedContext.currentPresentationData.with { $0 }
|
self.presentationData = sharedContext.currentPresentationData.with { $0 }
|
||||||
self.strings = presentationData.strings
|
self.presentationDataDisposable.set((sharedContext.presentationData
|
||||||
self.nameDisplayOrder = presentationData.nameDisplayOrder
|
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
|
||||||
|
if let strongSelf = self {
|
||||||
|
strongSelf.presentationData = presentationData
|
||||||
|
strongSelf.update()
|
||||||
|
}
|
||||||
|
}))
|
||||||
self.stateDisposable.set(
|
self.stateDisposable.set(
|
||||||
(combineLatest(
|
(combineLatest(
|
||||||
account.postbox.peerView(id: call.peerId),
|
account.postbox.peerView(id: call.peerId),
|
||||||
@ -236,6 +263,11 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.currentPeer = view.peers[view.peerId]
|
strongSelf.currentPeer = view.peers[view.peerId]
|
||||||
strongSelf.currentGroupCallState = state
|
strongSelf.currentGroupCallState = state
|
||||||
|
|
||||||
|
var isMuted = isMuted
|
||||||
|
if let state = state, state.callState.muteState != nil {
|
||||||
|
isMuted = true
|
||||||
|
}
|
||||||
strongSelf.currentIsMuted = isMuted
|
strongSelf.currentIsMuted = isMuted
|
||||||
|
|
||||||
let currentIsConnected: Bool
|
let currentIsConnected: Bool
|
||||||
@ -263,7 +295,6 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||||||
strongSelf.backgroundNode.audioLevel = effectiveLevel
|
strongSelf.backgroundNode.audioLevel = effectiveLevel
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
self.didSetupData = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var title: String = ""
|
var title: String = ""
|
||||||
@ -272,9 +303,9 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||||||
let textColor = UIColor.white
|
let textColor = UIColor.white
|
||||||
var segments: [AnimatedCountLabelNode.Segment] = []
|
var segments: [AnimatedCountLabelNode.Segment] = []
|
||||||
|
|
||||||
if let strings = self.strings {
|
if let presentationData = self.presentationData {
|
||||||
if let currentPeer = self.currentPeer {
|
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?
|
var membersCount: Int32?
|
||||||
if let groupCallState = self.currentGroupCallState {
|
if let groupCallState = self.currentGroupCallState {
|
||||||
@ -284,12 +315,12 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let membersCount = membersCount {
|
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: "]") {
|
if let startIndex = membersPart.firstIndex(of: "["), let endIndex = membersPart.firstIndex(of: "]") {
|
||||||
membersPart.removeSubrange(startIndex ... endIndex)
|
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
|
let (rawText, ranges) = rawTextAndRanges
|
||||||
var textIndex = 0
|
var textIndex = 0
|
||||||
@ -321,6 +352,16 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||||||
textIndex += 1
|
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 {
|
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)
|
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 spacing: CGFloat = 5.0
|
||||||
let titleSize = self.titleNode.updateLayout(CGSize(width: 160.0, height: size.height))
|
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)
|
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 verticalOrigin: CGFloat = size.height - contentHeight
|
||||||
|
|
||||||
let transition: ContainedViewLayoutTransition = wasEmpty ? .immediate : .animated(duration: 0.2, curve: .easeInOut)
|
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.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))
|
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))
|
self.backgroundNode.frame = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: size.height + 18.0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,20 +43,42 @@ final class VoiceChatActionButton: HighlightTrackingButtonNode {
|
|||||||
var outerColor: Signal<UIColor?, NoError> {
|
var outerColor: Signal<UIColor?, NoError> {
|
||||||
return outerColorPromise.get()
|
return outerColorPromise.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var connectingColor: UIColor = UIColor(rgb: 0xb6b6bb) {
|
||||||
|
didSet {
|
||||||
|
self.backgroundNode.connectingColor = self.connectingColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var activeDisposable = MetaDisposable()
|
var activeDisposable = MetaDisposable()
|
||||||
|
|
||||||
|
var isDisabled: Bool = false
|
||||||
|
|
||||||
|
var wasActiveWhenPressed = false
|
||||||
var pressing: Bool = false {
|
var pressing: Bool = false {
|
||||||
didSet {
|
didSet {
|
||||||
var snap = false
|
guard let (_, _, state, _, _, _, _, snap) = self.currentParams, !self.isDisabled else {
|
||||||
if let (_, _, _, _, _, _, _, snapValue) = self.currentParams {
|
return
|
||||||
snap = snapValue
|
|
||||||
}
|
}
|
||||||
if self.pressing {
|
if self.pressing {
|
||||||
let transition: ContainedViewLayoutTransition = .animated(duration: 0.25, curve: .spring)
|
let transition: ContainedViewLayoutTransition = .animated(duration: 0.25, curve: .spring)
|
||||||
transition.updateTransformScale(node: self.iconNode, scale: snap ? 0.5 : 0.9)
|
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 {
|
} else {
|
||||||
let transition: ContainedViewLayoutTransition = .animated(duration: 0.25, curve: .spring)
|
let transition: ContainedViewLayoutTransition = .animated(duration: 0.25, curve: .spring)
|
||||||
transition.updateTransformScale(node: self.iconNode, scale: snap ? 0.5 : 1.0)
|
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
|
self.highligthedChanged = { [weak self] pressing in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
var snap = false
|
guard let (_, _, _, _, _, _, _, snap) = strongSelf.currentParams, !strongSelf.isDisabled else {
|
||||||
if let (_, _, _, _, _, _, _, snapValue) = strongSelf.currentParams {
|
return
|
||||||
snap = snapValue
|
|
||||||
}
|
}
|
||||||
if pressing {
|
if pressing {
|
||||||
let transition: ContainedViewLayoutTransition = .animated(duration: 0.25, curve: .spring)
|
let transition: ContainedViewLayoutTransition = .animated(duration: 0.25, curve: .spring)
|
||||||
@ -111,7 +132,7 @@ final class VoiceChatActionButton: HighlightTrackingButtonNode {
|
|||||||
self.backgroundNode.audioLevel = level
|
self.backgroundNode.audioLevel = level
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyParams(animated: Bool) {
|
private func applyParams(animated: Bool) {
|
||||||
guard let (size, _, state, _, small, title, subtitle, snap) = self.currentParams else {
|
guard let (size, _, state, _, small, title, subtitle, snap) = self.currentParams else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -153,31 +174,75 @@ final class VoiceChatActionButton: HighlightTrackingButtonNode {
|
|||||||
self.backgroundNode.bounds = CGRect(origin: CGPoint(), size: size)
|
self.backgroundNode.bounds = CGRect(origin: CGPoint(), size: size)
|
||||||
self.backgroundNode.position = CGPoint(x: size.width / 2.0, y: size.height / 2.0)
|
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
|
let transition: ContainedViewLayoutTransition = animated ? .animated(duration: 0.2, curve: .easeInOut) : .immediate
|
||||||
if snap {
|
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.updateTransformScale(node: self.iconNode, scale: 0.5)
|
||||||
transition.updateAlpha(node: self.titleLabel, alpha: 0.0)
|
transition.updateAlpha(node: self.titleLabel, alpha: 0.0)
|
||||||
transition.updateAlpha(node: self.subtitleLabel, alpha: 0.0)
|
transition.updateAlpha(node: self.subtitleLabel, alpha: 0.0)
|
||||||
|
transition.updateAlpha(layer: self.backgroundNode.maskProgressLayer, alpha: 0.0)
|
||||||
} else {
|
} else {
|
||||||
transition.updateTransformScale(node: self.backgroundNode, scale: small ? 0.85 : 1.0)
|
transition.updateTransformScale(node: self.backgroundNode, scale: small ? 0.85 : 1.0)
|
||||||
transition.updateTransformScale(node: self.iconNode, scale: self.pressing ? 0.9 : 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.titleLabel, alpha: 1.0)
|
||||||
transition.updateAlpha(node: self.subtitleLabel, 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)
|
let iconSize = CGSize(width: 90.0, height: 90.0)
|
||||||
self.iconNode.bounds = CGRect(origin: CGPoint(), size: iconSize)
|
self.iconNode.bounds = CGRect(origin: CGPoint(), size: iconSize)
|
||||||
self.iconNode.position = CGPoint(x: size.width / 2.0, y: size.height / 2.0)
|
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 {
|
if let previous = self.currentParams {
|
||||||
self.currentParams = (previous.size, previous.buttonSize, previous.state, previous.dark, previous.small, previous.title, previous.subtitle, snap)
|
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.backgroundNode.glowHidden = snap
|
||||||
|
self.backgroundNode.updateColors()
|
||||||
self.applyParams(animated: true)
|
self.applyParams(animated: animated)
|
||||||
|
self.applyIconParams()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,28 +250,25 @@ final class VoiceChatActionButton: HighlightTrackingButtonNode {
|
|||||||
let previous = self.currentParams
|
let previous = self.currentParams
|
||||||
let previousState = previous?.state
|
let previousState = previous?.state
|
||||||
self.currentParams = (size, buttonSize, state, dark, small, title, subtitle, previous?.snap ?? false)
|
self.currentParams = (size, buttonSize, state, dark, small, title, subtitle, previous?.snap ?? false)
|
||||||
|
|
||||||
var iconMuted = true
|
|
||||||
var iconColor: UIColor = .white
|
|
||||||
var backgroundState: VoiceChatActionButtonBackgroundNode.State
|
var backgroundState: VoiceChatActionButtonBackgroundNode.State
|
||||||
switch state {
|
switch state {
|
||||||
case let .active(state):
|
case let .active(state):
|
||||||
switch state {
|
switch state {
|
||||||
case .on:
|
case .on:
|
||||||
iconMuted = false
|
|
||||||
backgroundState = .blob(true)
|
backgroundState = .blob(true)
|
||||||
case .muted:
|
case .muted:
|
||||||
backgroundState = .blob(false)
|
backgroundState = .blob(false)
|
||||||
case .cantSpeak:
|
case .cantSpeak:
|
||||||
iconColor = UIColor(rgb: 0xff3b30)
|
|
||||||
backgroundState = .disabled
|
backgroundState = .disabled
|
||||||
}
|
}
|
||||||
case .connecting:
|
case .connecting:
|
||||||
backgroundState = .connecting
|
backgroundState = .connecting
|
||||||
}
|
}
|
||||||
self.backgroundNode.updateColor(dark: dark)
|
self.applyIconParams()
|
||||||
|
|
||||||
|
self.backgroundNode.isDark = dark
|
||||||
self.backgroundNode.update(state: backgroundState, animated: true)
|
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 {
|
if case .active = state, let previousState = previousState, case .connecting = previousState, animated {
|
||||||
self.activeDisposable.set((self.activePromise.get()
|
self.activeDisposable.set((self.activePromise.get()
|
||||||
@ -344,6 +406,7 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
|
|||||||
|
|
||||||
private let backgroundCircleLayer = CAShapeLayer()
|
private let backgroundCircleLayer = CAShapeLayer()
|
||||||
private let foregroundCircleLayer = CAShapeLayer()
|
private let foregroundCircleLayer = CAShapeLayer()
|
||||||
|
private let growingForegroundCircleLayer = CAShapeLayer()
|
||||||
|
|
||||||
private let foregroundView = UIView()
|
private let foregroundView = UIView()
|
||||||
private let foregroundGradientLayer = CAGradientLayer()
|
private let foregroundGradientLayer = CAGradientLayer()
|
||||||
@ -353,7 +416,7 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
|
|||||||
private let maskBlobView: VoiceBlobView
|
private let maskBlobView: VoiceBlobView
|
||||||
private let maskCircleLayer = CAShapeLayer()
|
private let maskCircleLayer = CAShapeLayer()
|
||||||
|
|
||||||
private let maskProgressLayer = CAShapeLayer()
|
fileprivate let maskProgressLayer = CAShapeLayer()
|
||||||
|
|
||||||
private let maskMediumBlobLayer = CAShapeLayer()
|
private let maskMediumBlobLayer = CAShapeLayer()
|
||||||
private let maskBigBlobLayer = 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.transform = CATransform3DMakeScale(0.0, 0.0, 1)
|
||||||
self.foregroundCircleLayer.isHidden = true
|
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.type = .radial
|
||||||
self.foregroundGradientLayer.colors = [lightBlue.cgColor, blue.cgColor]
|
self.foregroundGradientLayer.colors = [lightBlue.cgColor, blue.cgColor]
|
||||||
self.foregroundGradientLayer.startPoint = CGPoint(x: 1.0, y: 0.0)
|
self.foregroundGradientLayer.startPoint = CGPoint(x: 1.0, y: 0.0)
|
||||||
@ -430,7 +498,8 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
|
|||||||
|
|
||||||
self.view.addSubview(self.foregroundView)
|
self.view.addSubview(self.foregroundView)
|
||||||
self.layer.addSublayer(self.foregroundCircleLayer)
|
self.layer.addSublayer(self.foregroundCircleLayer)
|
||||||
|
self.layer.addSublayer(self.growingForegroundCircleLayer)
|
||||||
|
|
||||||
self.foregroundView.mask = self.maskView
|
self.foregroundView.mask = self.maskView
|
||||||
self.foregroundView.layer.addSublayer(self.foregroundGradientLayer)
|
self.foregroundView.layer.addSublayer(self.foregroundGradientLayer)
|
||||||
|
|
||||||
@ -529,7 +598,11 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var disableGlowAnimations = false
|
||||||
func updateGlowScale(_ scale: CGFloat?) {
|
func updateGlowScale(_ scale: CGFloat?) {
|
||||||
|
if self.disableGlowAnimations {
|
||||||
|
return
|
||||||
|
}
|
||||||
if let scale = scale {
|
if let scale = scale {
|
||||||
self.maskGradientLayer.transform = CATransform3DMakeScale(0.89 + 0.11 * scale, 0.89 + 0.11 * scale, 1.0)
|
self.maskGradientLayer.transform = CATransform3DMakeScale(0.89 + 0.11 * scale, 0.89 + 0.11 * scale, 1.0)
|
||||||
} else {
|
} else {
|
||||||
@ -617,12 +690,19 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
|
|||||||
CATransaction.commit()
|
CATransaction.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var animatingDisappearance = false
|
||||||
private func playBlobsDisappearanceAnimation() {
|
private func playBlobsDisappearanceAnimation() {
|
||||||
|
if self.animatingDisappearance {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self.animatingDisappearance = true
|
||||||
CATransaction.begin()
|
CATransaction.begin()
|
||||||
CATransaction.setDisableActions(true)
|
CATransaction.setDisableActions(true)
|
||||||
self.foregroundCircleLayer.isHidden = false
|
self.growingForegroundCircleLayer.isHidden = false
|
||||||
CATransaction.commit()
|
CATransaction.commit()
|
||||||
|
|
||||||
|
self.disableGlowAnimations = true
|
||||||
|
self.maskGradientLayer.removeAllAnimations()
|
||||||
self.updateGlowAndGradientAnimations(active: nil, previousActive: nil)
|
self.updateGlowAndGradientAnimations(active: nil, previousActive: nil)
|
||||||
|
|
||||||
self.maskBlobView.startAnimating()
|
self.maskBlobView.startAnimating()
|
||||||
@ -643,14 +723,16 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
|
|||||||
CATransaction.setCompletionBlock {
|
CATransaction.setCompletionBlock {
|
||||||
CATransaction.begin()
|
CATransaction.begin()
|
||||||
CATransaction.setDisableActions(true)
|
CATransaction.setDisableActions(true)
|
||||||
|
self.disableGlowAnimations = false
|
||||||
self.maskGradientLayer.isHidden = true
|
self.maskGradientLayer.isHidden = true
|
||||||
self.maskCircleLayer.isHidden = true
|
self.maskCircleLayer.isHidden = true
|
||||||
self.foregroundCircleLayer.isHidden = true
|
self.growingForegroundCircleLayer.isHidden = true
|
||||||
self.foregroundCircleLayer.removeAllAnimations()
|
self.growingForegroundCircleLayer.removeAllAnimations()
|
||||||
|
self.animatingDisappearance = false
|
||||||
CATransaction.commit()
|
CATransaction.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
self.foregroundCircleLayer.add(growthAnimation, forKey: "insideGrowth")
|
self.growingForegroundCircleLayer.add(growthAnimation, forKey: "insideGrowth")
|
||||||
CATransaction.commit()
|
CATransaction.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -663,6 +745,8 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
|
|||||||
self.maskGradientLayer.isHidden = false
|
self.maskGradientLayer.isHidden = false
|
||||||
CATransaction.commit()
|
CATransaction.commit()
|
||||||
|
|
||||||
|
self.disableGlowAnimations = true
|
||||||
|
self.maskGradientLayer.removeAllAnimations()
|
||||||
self.updateGlowAndGradientAnimations(active: active, previousActive: nil)
|
self.updateGlowAndGradientAnimations(active: active, previousActive: nil)
|
||||||
|
|
||||||
self.maskBlobView.isHidden = false
|
self.maskBlobView.isHidden = false
|
||||||
@ -679,6 +763,7 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
|
|||||||
CATransaction.setCompletionBlock {
|
CATransaction.setCompletionBlock {
|
||||||
CATransaction.begin()
|
CATransaction.begin()
|
||||||
CATransaction.setDisableActions(true)
|
CATransaction.setDisableActions(true)
|
||||||
|
self.disableGlowAnimations = false
|
||||||
self.foregroundCircleLayer.isHidden = true
|
self.foregroundCircleLayer.isHidden = true
|
||||||
CATransaction.commit()
|
CATransaction.commit()
|
||||||
}
|
}
|
||||||
@ -769,6 +854,13 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
|
|||||||
switch self.state {
|
switch self.state {
|
||||||
case .connecting:
|
case .connecting:
|
||||||
self.updatedActive?(false)
|
self.updatedActive?(false)
|
||||||
|
if let transition = self.transition {
|
||||||
|
self.updateGlowScale(nil)
|
||||||
|
if case .blob = transition {
|
||||||
|
playBlobsDisappearanceAnimation()
|
||||||
|
}
|
||||||
|
self.transition = nil
|
||||||
|
}
|
||||||
self.setupProgressAnimations()
|
self.setupProgressAnimations()
|
||||||
self.isActive = false
|
self.isActive = false
|
||||||
case let .blob(newActive):
|
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 previousColor: CGColor = self.backgroundCircleLayer.fillColor ?? greyColor.cgColor
|
||||||
let targetColor: CGColor
|
let targetColor: CGColor
|
||||||
if dark {
|
if self.isSnap {
|
||||||
|
targetColor = self.connectingColor.cgColor
|
||||||
|
} else if self.isDark {
|
||||||
targetColor = secondaryGreyColor.cgColor
|
targetColor = secondaryGreyColor.cgColor
|
||||||
} else {
|
} else {
|
||||||
targetColor = greyColor.cgColor
|
targetColor = greyColor.cgColor
|
||||||
}
|
}
|
||||||
self.backgroundCircleLayer.fillColor = targetColor
|
self.backgroundCircleLayer.fillColor = targetColor
|
||||||
self.foregroundCircleLayer.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.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.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) {
|
func update(state: State, animated: Bool) {
|
||||||
@ -850,6 +970,8 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
|
|||||||
self.backgroundCircleLayer.frame = circleFrame
|
self.backgroundCircleLayer.frame = circleFrame
|
||||||
self.foregroundCircleLayer.position = center
|
self.foregroundCircleLayer.position = center
|
||||||
self.foregroundCircleLayer.bounds = CGRect(origin: CGPoint(), size: CGSize(width: circleFrame.width - progressLineWidth, height: circleFrame.height - progressLineWidth))
|
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.maskCircleLayer.frame = circleFrame.insetBy(dx: -progressLineWidth / 2.0, dy: -progressLineWidth / 2.0)
|
||||||
self.maskProgressLayer.frame = circleFrame.insetBy(dx: -3.0, dy: -3.0)
|
self.maskProgressLayer.frame = circleFrame.insetBy(dx: -3.0, dy: -3.0)
|
||||||
self.foregroundView.frame = self.bounds
|
self.foregroundView.frame = self.bounds
|
||||||
|
|||||||
@ -376,6 +376,7 @@ public final class VoiceChatController: ViewController {
|
|||||||
private let context: AccountContext
|
private let context: AccountContext
|
||||||
private let call: PresentationGroupCall
|
private let call: PresentationGroupCall
|
||||||
private var presentationData: PresentationData
|
private var presentationData: PresentationData
|
||||||
|
private var presentationDataDisposable: Disposable?
|
||||||
private var darkTheme: PresentationTheme
|
private var darkTheme: PresentationTheme
|
||||||
|
|
||||||
private let dimNode: ASDisplayNode
|
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.memberStatesDisposable = (combineLatest(queue: .mainQueue(),
|
||||||
self.call.state,
|
self.call.state,
|
||||||
self.call.members,
|
self.call.members,
|
||||||
@ -1093,6 +1110,7 @@ public final class VoiceChatController: ViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
|
self.presentationDataDisposable?.dispose()
|
||||||
self.peerViewDisposable?.dispose()
|
self.peerViewDisposable?.dispose()
|
||||||
self.leaveDisposable.dispose()
|
self.leaveDisposable.dispose()
|
||||||
self.isMutedDisposable?.dispose()
|
self.isMutedDisposable?.dispose()
|
||||||
@ -1121,7 +1139,7 @@ public final class VoiceChatController: ViewController {
|
|||||||
panRecognizer.delegate = self
|
panRecognizer.delegate = self
|
||||||
panRecognizer.delaysTouchesBegan = false
|
panRecognizer.delaysTouchesBegan = false
|
||||||
panRecognizer.cancelsTouchesInView = true
|
panRecognizer.cancelsTouchesInView = true
|
||||||
// self.view.addGestureRecognizer(panRecognizer)
|
self.view.addGestureRecognizer(panRecognizer)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func optionsPressed() {
|
@objc private func optionsPressed() {
|
||||||
@ -1152,7 +1170,7 @@ public final class VoiceChatController: ViewController {
|
|||||||
private var pressTimer: SwiftSignalKit.Timer?
|
private var pressTimer: SwiftSignalKit.Timer?
|
||||||
private func startPressTimer() {
|
private func startPressTimer() {
|
||||||
self.pressTimer?.invalidate()
|
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?.pressTimerFired()
|
||||||
self?.pressTimer = nil
|
self?.pressTimer = nil
|
||||||
}, queue: Queue.mainQueue())
|
}, queue: Queue.mainQueue())
|
||||||
@ -1185,6 +1203,9 @@ public final class VoiceChatController: ViewController {
|
|||||||
guard let callState = self.callState else {
|
guard let callState = self.callState else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if case .connecting = callState.networkState {
|
||||||
|
return
|
||||||
|
}
|
||||||
if let muteState = callState.muteState {
|
if let muteState = callState.muteState {
|
||||||
if !muteState.canUnmute {
|
if !muteState.canUnmute {
|
||||||
if case .ended = gestureRecognizer.state {
|
if case .ended = gestureRecognizer.state {
|
||||||
@ -1581,7 +1602,7 @@ public final class VoiceChatController: ViewController {
|
|||||||
actionButtonEnabled = false
|
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)
|
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 {
|
if self.actionButton.supernode === self.bottomPanelNode {
|
||||||
@ -1618,8 +1639,10 @@ public final class VoiceChatController: ViewController {
|
|||||||
transition.animateView({
|
transition.animateView({
|
||||||
self.contentContainer.view.bounds = initialBounds
|
self.contentContainer.view.bounds = initialBounds
|
||||||
}, completion: { _ in
|
}, completion: { _ in
|
||||||
self.bottomPanelNode.addSubnode(self.actionButton)
|
if self.actionButton.supernode !== self.bottomPanelNode {
|
||||||
self.containerLayoutUpdated(layout, navigationHeight:navigationHeight, transition: .immediate)
|
self.bottomPanelNode.addSubnode(self.actionButton)
|
||||||
|
self.containerLayoutUpdated(layout, navigationHeight:navigationHeight, transition: .immediate)
|
||||||
|
}
|
||||||
|
|
||||||
self.controller?.currentOverlayController?.dismiss()
|
self.controller?.currentOverlayController?.dismiss()
|
||||||
self.controller?.currentOverlayController = nil
|
self.controller?.currentOverlayController = nil
|
||||||
@ -1673,16 +1696,17 @@ public final class VoiceChatController: ViewController {
|
|||||||
self.enqueuedTransitions.remove(at: 0)
|
self.enqueuedTransitions.remove(at: 0)
|
||||||
|
|
||||||
var options = ListViewDeleteAndInsertOptions()
|
var options = ListViewDeleteAndInsertOptions()
|
||||||
if transition.crossFade {
|
if !isFirstTime {
|
||||||
options.insert(.AnimateCrossfade)
|
if transition.crossFade {
|
||||||
}
|
options.insert(.AnimateCrossfade)
|
||||||
if transition.animated {
|
}
|
||||||
options.insert(.AnimateInsertion)
|
if transition.animated {
|
||||||
|
options.insert(.AnimateInsertion)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
options.insert(.LowLatency)
|
options.insert(.LowLatency)
|
||||||
options.insert(.PreferSynchronousResourceLoading)
|
options.insert(.PreferSynchronousResourceLoading)
|
||||||
|
|
||||||
|
|
||||||
var scrollToItem: ListViewScrollToItem?
|
var scrollToItem: ListViewScrollToItem?
|
||||||
if self.isFirstTime {
|
if self.isFirstTime {
|
||||||
self.isFirstTime = false
|
self.isFirstTime = false
|
||||||
@ -1915,7 +1939,7 @@ public final class VoiceChatController: ViewController {
|
|||||||
self.idleTimerExtensionDisposable.dispose()
|
self.idleTimerExtensionDisposable.dispose()
|
||||||
|
|
||||||
if let currentOverlayController = self.currentOverlayController {
|
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) {
|
public func dismiss(closing: Bool) {
|
||||||
if !closing {
|
if !closing {
|
||||||
self.detachActionButton()
|
if let navigationController = self.navigationController as? NavigationController {
|
||||||
|
let count = navigationController.viewControllers.count
|
||||||
|
if count == 2 || navigationController.viewControllers[count - 2] is ChatController {
|
||||||
|
self.detachActionButton()
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self.isDisconnected = true
|
self.isDisconnected = true
|
||||||
}
|
}
|
||||||
@ -1981,7 +2010,11 @@ public final class VoiceChatController: ViewController {
|
|||||||
|
|
||||||
self.reclaimActionButton = { [weak self, weak overlayController] in
|
self.reclaimActionButton = { [weak self, weak overlayController] in
|
||||||
if let strongSelf = self {
|
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
|
strongSelf.reclaimActionButton = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,9 @@ import SyncCore
|
|||||||
import AppBundle
|
import AppBundle
|
||||||
import ContextUI
|
import ContextUI
|
||||||
import PresentationDataUtils
|
import PresentationDataUtils
|
||||||
|
import TooltipUI
|
||||||
|
|
||||||
|
private let slideOffset: CGFloat = 80.0 + 44.0
|
||||||
|
|
||||||
public final class VoiceChatOverlayController: ViewController {
|
public final class VoiceChatOverlayController: ViewController {
|
||||||
private final class Node: ViewControllerTracingNode, UIGestureRecognizerDelegate {
|
private final class Node: ViewControllerTracingNode, UIGestureRecognizerDelegate {
|
||||||
@ -23,12 +26,16 @@ public final class VoiceChatOverlayController: ViewController {
|
|||||||
|
|
||||||
init(controller: VoiceChatOverlayController) {
|
init(controller: VoiceChatOverlayController) {
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
|
|
||||||
|
super.init()
|
||||||
|
|
||||||
|
self.clipsToBounds = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private var isButtonHidden = false
|
private var isButtonHidden = false
|
||||||
private var isSlidOffscreen = false
|
private var isSlidOffscreen = false
|
||||||
func update(hidden: Bool, slide: Bool, animated: Bool) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,13 +43,17 @@ public final class VoiceChatOverlayController: ViewController {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.isButtonHidden = hidden
|
self.isButtonHidden = hidden
|
||||||
|
self.isSlidOffscreen = hidden && slide
|
||||||
|
|
||||||
|
guard actionButton.supernode === self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if animated {
|
if animated {
|
||||||
let transition: ContainedViewLayoutTransition = .animated(duration: 0.4, curve: .spring)
|
let transition: ContainedViewLayoutTransition = .animated(duration: 0.4, curve: .spring)
|
||||||
if hidden {
|
if hidden {
|
||||||
if slide {
|
if slide {
|
||||||
self.isSlidOffscreen = true
|
transition.updateSublayerTransformOffset(layer: actionButton.layer, offset: CGPoint(x: slideOffset, y: 0.0))
|
||||||
transition.updateSublayerTransformOffset(layer: actionButton.layer, offset: CGPoint(x: 70.0, y: 0.0))
|
|
||||||
} else {
|
} else {
|
||||||
actionButton.layer.removeAllAnimations()
|
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
|
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 {
|
} else {
|
||||||
if slide {
|
if slide {
|
||||||
self.isSlidOffscreen = false
|
|
||||||
transition.updateSublayerTransformOffset(layer: actionButton.layer, offset: CGPoint())
|
transition.updateSublayerTransformOffset(layer: actionButton.layer, offset: CGPoint())
|
||||||
} else {
|
} else {
|
||||||
actionButton.layer.removeAllAnimations()
|
actionButton.layer.removeAllAnimations()
|
||||||
@ -60,7 +70,15 @@ public final class VoiceChatOverlayController: ViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
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 targetPosition = actionButton.position
|
||||||
let sourcePoint = CGPoint(x: from.midX, y: from.midY)
|
let sourcePoint = CGPoint(x: from.midX, y: from.midY)
|
||||||
let midPoint = CGPoint(x: (sourcePoint.x + targetPosition.x) / 2.0, y: sourcePoint.y + 120.0)
|
let midPoint = CGPoint(x: (sourcePoint.x + targetPosition.x) / 2.0, y: sourcePoint.y + 120.0)
|
||||||
@ -96,40 +120,56 @@ 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 {
|
guard let actionButton = self.controller?.actionButton, let layout = self.validLayout else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if reclaim {
|
if reclaim {
|
||||||
let targetPosition = CGPoint(x: layout.size.width / 2.0, y: layout.size.height - layout.intrinsicInsets.bottom - 268.0 / 2.0)
|
let targetPosition = CGPoint(x: layout.size.width / 2.0, y: layout.size.height - layout.intrinsicInsets.bottom - 268.0 / 2.0)
|
||||||
let sourcePoint = actionButton.position
|
if self.isSlidOffscreen {
|
||||||
let midPoint = CGPoint(x: (sourcePoint.x + targetPosition.x) / 2.0 - 20.0, y: sourcePoint.y + 10.0)
|
self.isSlidOffscreen = false
|
||||||
|
self.isButtonHidden = true
|
||||||
let x1 = sourcePoint.x
|
actionButton.layer.sublayerTransform = CATransform3DIdentity
|
||||||
let y1 = sourcePoint.y
|
actionButton.update(snap: false, animated: false)
|
||||||
let x2 = midPoint.x
|
actionButton.position = CGPoint(x: targetPosition.x, y: 268.0 / 2.0)
|
||||||
let y2 = midPoint.y
|
completion(true)
|
||||||
let x3 = targetPosition.x
|
} else {
|
||||||
let y3 = targetPosition.y
|
self.animating = true
|
||||||
|
let sourcePoint = actionButton.position
|
||||||
let a = (x3 * (y2 - y1) + x2 * (y1 - y3) + x1 * (y3 - y2)) / ((x1 - x2) * (x1 - x3) * (x2 - x3))
|
var midPoint = CGPoint(x: (sourcePoint.x + targetPosition.x) / 2.0 - 60.0, y: sourcePoint.y)
|
||||||
let b = (x1 * x1 * (y2 - y3) + x3 * x3 * (y1 - y2) + x2 * x2 * (y3 - y1)) / ((x1 - x2) * (x1 - x3) * (x2 - x3))
|
if sourcePoint.y < layout.size.height - 100.0 {
|
||||||
let c = (x2 * x2 * (x3 * y1 - x1 * y3) + x2 * (x1 * x1 * y3 - x3 * x3 * y1) + x1 * x3 * (x3 - x1) * y2) / ((x1 - x2) * (x1 - x3) * (x2 - x3))
|
midPoint.x = (sourcePoint.x + targetPosition.x) / 2.0 + 30.0
|
||||||
|
midPoint.y = (sourcePoint.y + targetPosition.y) / 2.0 + 40.0
|
||||||
var keyframes: [AnyObject] = []
|
}
|
||||||
for i in 0 ..< 10 {
|
|
||||||
let k = CGFloat(i) / CGFloat(10 - 1)
|
let x1 = sourcePoint.x
|
||||||
let x = sourcePoint.x * (1.0 - k) + targetPosition.x * k
|
let y1 = sourcePoint.y
|
||||||
let y = a * x * x + b * x + c
|
let x2 = midPoint.x
|
||||||
keyframes.append(NSValue(cgPoint: CGPoint(x: x, y: y)))
|
let y2 = midPoint.y
|
||||||
|
let x3 = targetPosition.x
|
||||||
|
let y3 = targetPosition.y
|
||||||
|
|
||||||
|
let a = (x3 * (y2 - y1) + x2 * (y1 - y3) + x1 * (y3 - y2)) / ((x1 - x2) * (x1 - x3) * (x2 - x3))
|
||||||
|
let b = (x1 * x1 * (y2 - y3) + x3 * x3 * (y1 - y2) + x2 * x2 * (y3 - y1)) / ((x1 - x2) * (x1 - x3) * (x2 - x3))
|
||||||
|
let c = (x2 * x2 * (x3 * y1 - x1 * y3) + x2 * (x1 * x1 * y3 - x3 * x3 * y1) + x1 * x3 * (x3 - x1) * y2) / ((x1 - x2) * (x1 - x3) * (x2 - x3))
|
||||||
|
|
||||||
|
var keyframes: [AnyObject] = []
|
||||||
|
for i in 0 ..< 10 {
|
||||||
|
let k = CGFloat(i) / CGFloat(10 - 1)
|
||||||
|
let x = sourcePoint.x * (1.0 - k) + targetPosition.x * k
|
||||||
|
let y = a * x * x + b * x + c
|
||||||
|
keyframes.append(NSValue(cgPoint: CGPoint(x: x, y: y)))
|
||||||
|
}
|
||||||
|
|
||||||
|
actionButton.update(snap: false, animated: true)
|
||||||
|
actionButton.position = targetPosition
|
||||||
|
actionButton.layer.animateKeyframes(values: keyframes, duration: 0.34, keyPath: "position", timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, completion: { _ in
|
||||||
|
self.animating = false
|
||||||
|
completion(false)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
actionButton.update(snap: false)
|
|
||||||
actionButton.position = targetPosition
|
|
||||||
actionButton.layer.animateKeyframes(values: keyframes, duration: 0.4, keyPath: "position", timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, completion: { _ in
|
|
||||||
completion()
|
|
||||||
})
|
|
||||||
} else {
|
} 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.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()
|
actionButton?.removeFromSupernode()
|
||||||
@ -152,15 +192,14 @@ public final class VoiceChatOverlayController: ViewController {
|
|||||||
func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||||
self.validLayout = layout
|
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 convertedRect = actionButton.view.convert(actionButton.bounds, to: self.view)
|
||||||
let insets = layout.insets(options: [.input])
|
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))
|
transition.updatePosition(node: actionButton, position: CGPoint(x: layout.size.width - layout.safeInsets.right - 21.0, y: layout.size.height - insets.bottom - 22.0))
|
||||||
|
|
||||||
if actionButton.supernode !== self {
|
if actionButton.supernode !== self {
|
||||||
self.addSubnode(actionButton)
|
self.addSubnode(actionButton)
|
||||||
|
|
||||||
actionButton.update(snap: true)
|
|
||||||
self.animateIn(from: convertedRect)
|
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
|
self.disposable = (combineLatest(queue: Queue.mainQueue(), controllers, overlayControllers)).start(next: { [weak self] controllers, overlayControllers in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
var hasVoiceChatController = false
|
var hasVoiceChatController = false
|
||||||
|
var overlayControllersCount = 0
|
||||||
for controller in controllers {
|
for controller in controllers {
|
||||||
if controller is VoiceChatController {
|
if controller is VoiceChatController {
|
||||||
hasVoiceChatController = true
|
hasVoiceChatController = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for controller in overlayControllers {
|
||||||
|
if controller is TooltipController || controller is TooltipScreen || controller is AlertController {
|
||||||
|
} else {
|
||||||
|
overlayControllersCount += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var hidden = true
|
var hidden = true
|
||||||
|
var animated = true
|
||||||
if controllers.count == 1 || controllers.last is ChatController {
|
if controllers.count == 1 || controllers.last is ChatController {
|
||||||
hidden = false
|
hidden = false
|
||||||
}
|
}
|
||||||
if overlayControllers.count > 0 {
|
if overlayControllersCount > 0 {
|
||||||
hidden = true
|
hidden = true
|
||||||
}
|
}
|
||||||
if hasVoiceChatController {
|
if hasVoiceChatController {
|
||||||
hidden = false
|
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?()
|
completion?()
|
||||||
}
|
}
|
||||||
|
|
||||||
func animateOut(reclaim: Bool, completion: @escaping () -> Void) {
|
func animateOut(reclaim: Bool, completion: @escaping (Bool) -> Void) {
|
||||||
self.controllerNode.animateOut(reclaim: reclaim, completion: completion)
|
self.controllerNode.animateOut(reclaim: reclaim, completion: completion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -159,7 +159,7 @@ public class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode {
|
|||||||
private let actionContainerNode: ASDisplayNode
|
private let actionContainerNode: ASDisplayNode
|
||||||
private var animationNode: VoiceChatMicrophoneNode?
|
private var animationNode: VoiceChatMicrophoneNode?
|
||||||
private var iconNode: ASImageNode?
|
private var iconNode: ASImageNode?
|
||||||
private var actionButtonNode: HighlightTrackingButtonNode
|
private var actionButtonNode: HighlightableButtonNode
|
||||||
|
|
||||||
private var audioLevelView: VoiceBlobView?
|
private var audioLevelView: VoiceBlobView?
|
||||||
private let audioLevelDisposable = MetaDisposable()
|
private let audioLevelDisposable = MetaDisposable()
|
||||||
@ -201,7 +201,7 @@ public class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode {
|
|||||||
self.statusNode.contentsScale = UIScreen.main.scale
|
self.statusNode.contentsScale = UIScreen.main.scale
|
||||||
|
|
||||||
self.actionContainerNode = ASDisplayNode()
|
self.actionContainerNode = ASDisplayNode()
|
||||||
self.actionButtonNode = HighlightTrackingButtonNode()
|
self.actionButtonNode = HighlightableButtonNode()
|
||||||
|
|
||||||
self.highlightedBackgroundNode = ASDisplayNode()
|
self.highlightedBackgroundNode = ASDisplayNode()
|
||||||
self.highlightedBackgroundNode.isLayerBacked = true
|
self.highlightedBackgroundNode.isLayerBacked = true
|
||||||
@ -613,7 +613,7 @@ public class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
animationNode.update(state: VoiceChatMicrophoneNode.State(muted: muted, color: color), animated: true)
|
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 {
|
} else if let animationNode = strongSelf.animationNode {
|
||||||
strongSelf.animationNode = nil
|
strongSelf.animationNode = nil
|
||||||
animationNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false)
|
animationNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false)
|
||||||
@ -643,7 +643,7 @@ public class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode {
|
|||||||
} else {
|
} else {
|
||||||
iconNode.image = generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/AddUser"), color: item.presentationData.theme.list.itemAccentColor)
|
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 {
|
} else if let iconNode = strongSelf.iconNode {
|
||||||
strongSelf.iconNode = nil
|
strongSelf.iconNode = nil
|
||||||
iconNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false)
|
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() {
|
@objc private func actionButtonPressed() {
|
||||||
if let item = self.layoutParams?.0 {
|
if let item = self.layoutParams?.0, let contextAction = item.contextAction {
|
||||||
item.action?()
|
contextAction(self.contextSourceNode, nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override public func updateRevealOffset(offset: CGFloat, transition: ContainedViewLayoutTransition) {
|
override public func updateRevealOffset(offset: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||||
super.updateRevealOffset(offset: offset, transition: transition)
|
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
|
let leftInset: CGFloat = 65.0 + params.leftInset
|
||||||
|
|
||||||
var avatarFrame = self.avatarNode.frame
|
var avatarFrame = self.avatarNode.frame
|
||||||
|
|||||||
@ -778,7 +778,7 @@ public final class PresentationThemeChatMessage {
|
|||||||
self.stickerPlaceholderShimmerColor = stickerPlaceholderShimmerColor
|
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)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1245,11 +1245,7 @@ final class SharedApplicationContext {
|
|||||||
|> map { loggedOutAccountPeerIds -> (AccountManager, Set<PeerId>) in
|
|> map { loggedOutAccountPeerIds -> (AccountManager, Set<PeerId>) in
|
||||||
return (sharedContext.sharedContext.accountManager, loggedOutAccountPeerIds)
|
return (sharedContext.sharedContext.accountManager, loggedOutAccountPeerIds)
|
||||||
}
|
}
|
||||||
}).start(next: { [weak self] accountManager, loggedOutAccountPeerIds in
|
}).start(next: { accountManager, loggedOutAccountPeerIds in
|
||||||
guard let strongSelf = self else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let _ = (updateIntentsSettingsInteractively(accountManager: accountManager) { current in
|
let _ = (updateIntentsSettingsInteractively(accountManager: accountManager) { current in
|
||||||
var updated = current
|
var updated = current
|
||||||
for peerId in loggedOutAccountPeerIds {
|
for peerId in loggedOutAccountPeerIds {
|
||||||
@ -1888,7 +1884,7 @@ final class SharedApplicationContext {
|
|||||||
|> take(1)
|
|> take(1)
|
||||||
|> deliverOnMainQueue).start(next: { sharedContext in
|
|> deliverOnMainQueue).start(next: { sharedContext in
|
||||||
let type = ApplicationShortcutItemType(rawValue: shortcutItem.type)
|
let type = ApplicationShortcutItemType(rawValue: shortcutItem.type)
|
||||||
var immediately = type == .account
|
let immediately = type == .account
|
||||||
let proceed: () -> Void = {
|
let proceed: () -> Void = {
|
||||||
let _ = (self.context.get()
|
let _ = (self.context.get()
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|
|||||||
@ -5609,6 +5609,14 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
})
|
})
|
||||||
strongSelf.saveInterfaceState()
|
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))
|
var rect: CGRect? = strongSelf.chatDisplayNode.frameForInputPanelAccessoryButton(.silentPost(true))
|
||||||
if rect == nil {
|
if rect == nil {
|
||||||
rect = strongSelf.chatDisplayNode.frameForInputPanelAccessoryButton(.silentPost(false))
|
rect = strongSelf.chatDisplayNode.frameForInputPanelAccessoryButton(.silentPost(false))
|
||||||
@ -7062,11 +7070,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let controller = voiceChatOverlayController {
|
if let controller = voiceChatOverlayController {
|
||||||
|
var hidden = false
|
||||||
if self.presentationInterfaceState.interfaceState.editMessage != nil || self.presentationInterfaceState.interfaceState.composeInputState.inputText.string.count > 0 {
|
if self.presentationInterfaceState.interfaceState.editMessage != nil || self.presentationInterfaceState.interfaceState.composeInputState.inputText.string.count > 0 {
|
||||||
controller.update(hidden: true, slide: false, animated: true)
|
hidden = true
|
||||||
} else {
|
|
||||||
controller.update(hidden: false, slide: false, animated: true)
|
|
||||||
}
|
}
|
||||||
|
controller.update(hidden: hidden, slide: false, animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1556,6 +1556,10 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
apparentNavigateButtonsFrame.origin.y += verticalOffset
|
apparentNavigateButtonsFrame.origin.y += verticalOffset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if layout.additionalInsets.right > 0.0 {
|
||||||
|
apparentNavigateButtonsFrame.origin.y -= 16.0
|
||||||
|
}
|
||||||
|
|
||||||
let previousInputPanelBackgroundFrame = self.inputPanelBackgroundNode.frame
|
let previousInputPanelBackgroundFrame = self.inputPanelBackgroundNode.frame
|
||||||
transition.updateFrame(node: self.inputPanelBackgroundNode, frame: apparentInputBackgroundFrame)
|
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)))
|
transition.updateFrame(node: self.inputPanelBackgroundSeparatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: apparentInputBackgroundFrame.origin.y), size: CGSize(width: apparentInputBackgroundFrame.size.width, height: UIScreenPixel)))
|
||||||
|
|||||||
@ -234,9 +234,11 @@ final class ChatMediaInputStickerGridItemNode: GridItemNode {
|
|||||||
if !animated {
|
if !animated {
|
||||||
placeholderNode.removeFromSupernode()
|
placeholderNode.removeFromSupernode()
|
||||||
} else {
|
} else {
|
||||||
|
placeholderNode.allowsGroupOpacity = true
|
||||||
placeholderNode.alpha = 0.0
|
placeholderNode.alpha = 0.0
|
||||||
placeholderNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, completion: { [weak placeholderNode] _ in
|
placeholderNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, completion: { [weak placeholderNode] _ in
|
||||||
placeholderNode?.removeFromSupernode()
|
placeholderNode?.removeFromSupernode()
|
||||||
|
placeholderNode?.allowsGroupOpacity = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import Markdown
|
|||||||
import ManagedAnimationNode
|
import ManagedAnimationNode
|
||||||
import SlotMachineAnimationNode
|
import SlotMachineAnimationNode
|
||||||
import UniversalMediaPlayer
|
import UniversalMediaPlayer
|
||||||
|
import ShimmerEffect
|
||||||
|
|
||||||
private let nameFont = Font.medium(14.0)
|
private let nameFont = Font.medium(14.0)
|
||||||
private let inlineBotPrefixFont = Font.regular(14.0)
|
private let inlineBotPrefixFont = Font.regular(14.0)
|
||||||
|
|||||||
@ -51,7 +51,7 @@ final class HorizontalStickerGridItemNode: GridItemNode {
|
|||||||
private var currentState: (Account, HorizontalStickerGridItem, CGSize)?
|
private var currentState: (Account, HorizontalStickerGridItem, CGSize)?
|
||||||
private let imageNode: TransformImageNode
|
private let imageNode: TransformImageNode
|
||||||
private var animationNode: AnimatedStickerNode?
|
private var animationNode: AnimatedStickerNode?
|
||||||
private var placeholderNode: ShimmerEffectNode?
|
private var placeholderNode: StickerShimmerEffectNode?
|
||||||
|
|
||||||
private let stickerFetchedDisposable = MetaDisposable()
|
private let stickerFetchedDisposable = MetaDisposable()
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ final class HorizontalStickerGridItemNode: GridItemNode {
|
|||||||
|
|
||||||
override init() {
|
override init() {
|
||||||
self.imageNode = TransformImageNode()
|
self.imageNode = TransformImageNode()
|
||||||
self.placeholderNode = ShimmerEffectNode()
|
self.placeholderNode = StickerShimmerEffectNode()
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
@ -114,9 +114,11 @@ final class HorizontalStickerGridItemNode: GridItemNode {
|
|||||||
if !animated {
|
if !animated {
|
||||||
placeholderNode.removeFromSupernode()
|
placeholderNode.removeFromSupernode()
|
||||||
} else {
|
} else {
|
||||||
|
placeholderNode.allowsGroupOpacity = true
|
||||||
placeholderNode.alpha = 0.0
|
placeholderNode.alpha = 0.0
|
||||||
placeholderNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, completion: { [weak placeholderNode] _ in
|
placeholderNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, completion: { [weak placeholderNode] _ in
|
||||||
placeholderNode?.removeFromSupernode()
|
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)
|
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
|
placeholderNode.frame = bounds
|
||||||
|
|
||||||
if let theme = self.currentState?.1.theme {
|
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), shapes: [.roundedRect(rect: placeholderFrame, cornerRadius: 10.0)], size: bounds.size)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,61 +11,7 @@ import StickerResources
|
|||||||
import AccountContext
|
import AccountContext
|
||||||
import AnimatedStickerNode
|
import AnimatedStickerNode
|
||||||
import TelegramAnimatedStickerNode
|
import TelegramAnimatedStickerNode
|
||||||
|
import ShimmerEffect
|
||||||
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)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private let titleFont = Font.bold(16.0)
|
private let titleFont = Font.bold(16.0)
|
||||||
private let statusFont = Font.regular(15.0)
|
private let statusFont = Font.regular(15.0)
|
||||||
@ -74,7 +20,10 @@ private let buttonFont = Font.medium(13.0)
|
|||||||
final class TrendingTopItemNode: ASDisplayNode {
|
final class TrendingTopItemNode: ASDisplayNode {
|
||||||
private let imageNode: TransformImageNode
|
private let imageNode: TransformImageNode
|
||||||
private var animationNode: AnimatedStickerNode?
|
private var animationNode: AnimatedStickerNode?
|
||||||
|
private var placeholderNode: StickerShimmerEffectNode?
|
||||||
public private(set) var file: TelegramMediaFile? = nil
|
public private(set) var file: TelegramMediaFile? = nil
|
||||||
|
public private(set) var theme: PresentationTheme?
|
||||||
|
private var listAppearance = false
|
||||||
private var itemSize: CGSize?
|
private var itemSize: CGSize?
|
||||||
private let loadDisposable = MetaDisposable()
|
private let loadDisposable = MetaDisposable()
|
||||||
|
|
||||||
@ -91,15 +40,77 @@ final class TrendingTopItemNode: ASDisplayNode {
|
|||||||
override init() {
|
override init() {
|
||||||
self.imageNode = TransformImageNode()
|
self.imageNode = TransformImageNode()
|
||||||
self.imageNode.contentAnimations = [.subsequentUpdates]
|
self.imageNode.contentAnimations = [.subsequentUpdates]
|
||||||
|
self.placeholderNode = StickerShimmerEffectNode()
|
||||||
|
self.placeholderNode?.isUserInteractionEnabled = false
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
self.addSubnode(self.imageNode)
|
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 {
|
deinit {
|
||||||
self.loadDisposable.dispose()
|
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) {
|
func setup(account: Account, item: StickerPackItem, itemSize: CGSize, synchronousLoads: Bool) {
|
||||||
self.file = item.file
|
self.file = item.file
|
||||||
self.itemSize = itemSize
|
self.itemSize = itemSize
|
||||||
@ -112,8 +123,13 @@ final class TrendingTopItemNode: ASDisplayNode {
|
|||||||
animationNode = AnimatedStickerNode()
|
animationNode = AnimatedStickerNode()
|
||||||
animationNode.transform = self.imageNode.transform
|
animationNode.transform = self.imageNode.transform
|
||||||
animationNode.visibility = self.visibility
|
animationNode.visibility = self.visibility
|
||||||
self.addSubnode(animationNode)
|
|
||||||
self.animationNode = 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 dimensions = item.file.dimensions ?? PixelDimensions(width: 512, height: 512)
|
||||||
let fittedDimensions = dimensions.cgSize.aspectFitted(CGSize(width: 160.0, height: 160.0))
|
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.imageNode.frame = self.bounds
|
||||||
self.animationNode?.updateLayout(size: self.bounds.size)
|
self.animationNode?.updateLayout(size: self.bounds.size)
|
||||||
}
|
|
||||||
}
|
let size = self.bounds.size
|
||||||
|
let boundingSize = size
|
||||||
class MediaInputPaneTrendingItemNode: ListViewItemNode {
|
|
||||||
private let titleNode: TextNode
|
if let placeholderNode = self.placeholderNode {
|
||||||
private let descriptionNode: TextNode
|
let placeholderFrame = CGRect(origin: CGPoint(x: floor((size.width - boundingSize.width) / 2.0), y: floor((size.height - boundingSize.height) / 2.0)), size: boundingSize)
|
||||||
private let unreadNode: ASImageNode
|
placeholderNode.frame = placeholderFrame
|
||||||
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 {
|
if let theme = self.theme {
|
||||||
for node in self.itemNodes {
|
self.update(theme: theme, listAppearance: self.listAppearance)
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -302,6 +302,16 @@ class StickerPaneSearchGlobalItemNode: GridItemNode {
|
|||||||
self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:))))
|
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) {
|
func setup(item: StickerPaneSearchGlobalItem) {
|
||||||
if item.topItems.count < Int(item.info.count) && item.topItems.count < 5 && self.item?.info.id != item.info.id {
|
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())
|
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 {
|
if file.fileId != node.file?.fileId {
|
||||||
node.setup(account: item.account, item: topItems[i], itemSize: itemSize, synchronousLoads: synchronousLoads)
|
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 {
|
if let dimensions = file.dimensions {
|
||||||
let imageSize = dimensions.cgSize.aspectFitted(itemSize)
|
let imageSize = dimensions.cgSize.aspectFitted(itemSize)
|
||||||
node.frame = CGRect(origin: CGPoint(x: offset, y: 48.0 + topOffset), size: imageSize)
|
node.frame = CGRect(origin: CGPoint(x: offset, y: 48.0 + topOffset), size: imageSize)
|
||||||
offset += itemSize.width + itemSpacing
|
offset += itemSize.width + itemSpacing
|
||||||
}
|
}
|
||||||
|
if let (rect, size) = strongSelf.absoluteLocation {
|
||||||
|
strongSelf.updateAbsoluteRect(rect, within: size)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if topItems.count < strongSelf.itemNodes.count {
|
if topItems.count < strongSelf.itemNodes.count {
|
||||||
|
|||||||
2
third-party/libvpx/BUILD
vendored
2
third-party/libvpx/BUILD
vendored
@ -59,7 +59,7 @@ genrule(
|
|||||||
|
|
||||||
mkdir -p "$$BUILD_DIR/Public/libvpx"
|
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([
|
"\n".join([
|
||||||
"cp -f \"$$BUILD_DIR/VPX.framework/Headers/vpx/{}\" \"$(location Public/vpx/{})\"".format(header, header) for header in headers
|
"cp -f \"$$BUILD_DIR/VPX.framework/Headers/vpx/{}\" \"$(location Public/vpx/{})\"".format(header, header) for header in headers
|
||||||
|
|||||||
2
third-party/mozjpeg/BUILD
vendored
2
third-party/mozjpeg/BUILD
vendored
@ -55,7 +55,7 @@ genrule(
|
|||||||
|
|
||||||
mkdir -p "$$BUILD_DIR/Public/mozjpeg"
|
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([
|
"\n".join([
|
||||||
"cp -f \"$$BUILD_DIR/mozjpeg/{}\" \"$(location Public/mozjpeg/{})\"".format(header, header) for header in headers
|
"cp -f \"$$BUILD_DIR/mozjpeg/{}\" \"$(location Public/mozjpeg/{})\"".format(header, header) for header in headers
|
||||||
|
|||||||
4
third-party/yasm/BUILD
vendored
4
third-party/yasm/BUILD
vendored
@ -23,8 +23,8 @@ set -x
|
|||||||
pushd "$$BUILD_DIR/yasm-1.3.0"
|
pushd "$$BUILD_DIR/yasm-1.3.0"
|
||||||
mkdir build
|
mkdir build
|
||||||
cd 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
|
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
|
||||||
make -j $$core_count
|
arch -x86_64 make -j $$core_count
|
||||||
popd
|
popd
|
||||||
|
|
||||||
tar -cf "$(location yasm.tar)" -C "$$BUILD_DIR/yasm-1.3.0/build" .
|
tar -cf "$(location yasm.tar)" -C "$$BUILD_DIR/yasm-1.3.0/build" .
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user