Video Chat Improvements

This commit is contained in:
Ilya Laktyushin
2021-05-20 20:06:58 +04:00
parent d956de870c
commit 31067a651a
3 changed files with 11 additions and 44 deletions

View File

@@ -186,7 +186,7 @@ private class VoiceChatCameraPreviewControllerNode: ViewControllerTracingNode, U
if #available(iOS 12.0, *) { if #available(iOS 12.0, *) {
let broadcastPickerView = RPSystemBroadcastPickerView(frame: CGRect(x: 0, y: 0, width: 50, height: 52.0)) let broadcastPickerView = RPSystemBroadcastPickerView(frame: CGRect(x: 0, y: 0, width: 50, height: 52.0))
broadcastPickerView.alpha = 0.05 broadcastPickerView.alpha = 0.02
broadcastPickerView.preferredExtension = "\(self.context.sharedContext.applicationBindings.appBundleId).BroadcastUpload" broadcastPickerView.preferredExtension = "\(self.context.sharedContext.applicationBindings.appBundleId).BroadcastUpload"
broadcastPickerView.showsMicrophoneButton = false broadcastPickerView.showsMicrophoneButton = false
self.broadcastPickerView = broadcastPickerView self.broadcastPickerView = broadcastPickerView

View File

@@ -40,7 +40,6 @@ private final class VoiceChatShareScreenContextItemNode: ASDisplayNode, ContextM
private let highlightedBackgroundNode: ASDisplayNode private let highlightedBackgroundNode: ASDisplayNode
private let textNode: ImmediateTextNode private let textNode: ImmediateTextNode
private let iconNode: ASImageNode private let iconNode: ASImageNode
private let buttonNode: HighlightTrackingButtonNode
private var timer: SwiftSignalKit.Timer? private var timer: SwiftSignalKit.Timer?
@@ -70,12 +69,15 @@ private final class VoiceChatShareScreenContextItemNode: ASDisplayNode, ContextM
self.textNode.isUserInteractionEnabled = false self.textNode.isUserInteractionEnabled = false
self.textNode.displaysAsynchronously = false self.textNode.displaysAsynchronously = false
self.textNode.attributedText = NSAttributedString(string: item.text, font: textFont, textColor: presentationData.theme.contextMenu.primaryColor) self.textNode.attributedText = NSAttributedString(string: item.text, font: textFont, textColor: presentationData.theme.contextMenu.primaryColor)
self.textNode.maximumNumberOfLines = 1 self.textNode.maximumNumberOfLines = 1
self.buttonNode = HighlightTrackingButtonNode() if #available(iOS 12.0, *) {
self.buttonNode.isAccessibilityElement = true let broadcastPickerView = RPSystemBroadcastPickerView(frame: CGRect(x: 0, y: 0, width: 50, height: 52.0))
self.buttonNode.accessibilityLabel = presentationData.strings.VoiceChat_StopRecording broadcastPickerView.alpha = 0.02
broadcastPickerView.preferredExtension = "\(item.context.sharedContext.applicationBindings.appBundleId).BroadcastUpload"
broadcastPickerView.showsMicrophoneButton = false
self.broadcastPickerView = broadcastPickerView
}
self.iconNode = ASImageNode() self.iconNode = ASImageNode()
self.iconNode.isAccessibilityElement = false self.iconNode.isAccessibilityElement = false
@@ -84,38 +86,15 @@ private final class VoiceChatShareScreenContextItemNode: ASDisplayNode, ContextM
self.iconNode.isUserInteractionEnabled = false self.iconNode.isUserInteractionEnabled = false
self.iconNode.image = item.icon(presentationData.theme) self.iconNode.image = item.icon(presentationData.theme)
if #available(iOS 12.0, *) {
let broadcastPickerView = RPSystemBroadcastPickerView(frame: CGRect(x: 0, y: 0, width: 50, height: 52.0))
broadcastPickerView.alpha = 0.05
broadcastPickerView.preferredExtension = "\(item.context.sharedContext.applicationBindings.appBundleId).BroadcastUpload"
broadcastPickerView.showsMicrophoneButton = false
self.broadcastPickerView = broadcastPickerView
}
super.init() super.init()
self.addSubnode(self.backgroundNode) self.addSubnode(self.backgroundNode)
self.addSubnode(self.highlightedBackgroundNode) self.addSubnode(self.highlightedBackgroundNode)
self.addSubnode(self.textNode)
self.addSubnode(self.iconNode)
self.addSubnode(self.buttonNode)
if let broadcastPickerView = self.broadcastPickerView { if let broadcastPickerView = self.broadcastPickerView {
self.view.addSubview(broadcastPickerView) self.view.addSubview(broadcastPickerView)
} }
self.addSubnode(self.textNode)
self.buttonNode.highligthedChanged = { [weak self] highligted in self.addSubnode(self.iconNode)
guard let strongSelf = self else {
return
}
if highligted {
strongSelf.highlightedBackgroundNode.alpha = 1.0
} else {
strongSelf.highlightedBackgroundNode.alpha = 0.0
strongSelf.highlightedBackgroundNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3)
}
}
self.buttonNode.addTarget(self, action: #selector(self.buttonPressed), forControlEvents: .touchUpInside)
} }
deinit { deinit {
@@ -126,16 +105,6 @@ private final class VoiceChatShareScreenContextItemNode: ASDisplayNode, ContextM
override func didLoad() { override func didLoad() {
super.didLoad() super.didLoad()
self.pointerInteraction = PointerInteraction(node: self.buttonNode, style: .hover, willEnter: { [weak self] in
if let strongSelf = self {
strongSelf.highlightedBackgroundNode.alpha = 0.75
}
}, willExit: { [weak self] in
if let strongSelf = self {
strongSelf.highlightedBackgroundNode.alpha = 0.0
}
})
self.applicationStateDisposable = (self.item.context.sharedContext.applicationBindings.applicationIsActive self.applicationStateDisposable = (self.item.context.sharedContext.applicationBindings.applicationIsActive
|> filter { !$0 } |> filter { !$0 }
|> take(1) |> take(1)
@@ -167,7 +136,6 @@ private final class VoiceChatShareScreenContextItemNode: ASDisplayNode, ContextM
let verticalSpacing: CGFloat = 2.0 let verticalSpacing: CGFloat = 2.0
let combinedTextHeight = textSize.height + verticalSpacing let combinedTextHeight = textSize.height + verticalSpacing
return (CGSize(width: textSize.width + sideInset + rightTextInset, height: verticalInset * 2.0 + combinedTextHeight), { size, transition in return (CGSize(width: textSize.width + sideInset + rightTextInset, height: verticalInset * 2.0 + combinedTextHeight), { size, transition in
let hadLayout = self.validLayout != nil
self.validLayout = size self.validLayout = size
let verticalOrigin = floor((size.height - combinedTextHeight) / 2.0) let verticalOrigin = floor((size.height - combinedTextHeight) / 2.0)
@@ -180,7 +148,6 @@ private final class VoiceChatShareScreenContextItemNode: ASDisplayNode, ContextM
transition.updateFrame(node: self.backgroundNode, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: size.width, height: size.height))) transition.updateFrame(node: self.backgroundNode, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: size.width, height: size.height)))
transition.updateFrame(node: self.highlightedBackgroundNode, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: size.width, height: size.height))) transition.updateFrame(node: self.highlightedBackgroundNode, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: size.width, height: size.height)))
transition.updateFrame(node: self.buttonNode, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: size.width, height: size.height)))
if let broadcastPickerView = self.broadcastPickerView { if let broadcastPickerView = self.broadcastPickerView {
broadcastPickerView.frame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: size.width, height: size.height)) broadcastPickerView.frame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: size.width, height: size.height))