Voice Chat UI fixes

This commit is contained in:
Ilya Laktyushin 2020-12-06 21:10:37 +04:00
parent 8f96ea06b6
commit 63bd91f33b
7 changed files with 3840 additions and 3775 deletions

View File

@ -5970,12 +5970,14 @@ Sorry for the inconvenience.";
"VoiceChat.Panel.Members_3_10" = "%@ members";
"VoiceChat.Panel.Members_many" = "%@ members";
"VoiceChat.Panel.Members_any" = "%@ members";
"VoiceChat.Panel.MembersSpeaking_0" = "%@ members speaking";
"VoiceChat.Panel.MembersSpeaking_1" = "%@ member speaking";
"VoiceChat.Panel.MembersSpeaking_2" = "%@ members speaking";
"VoiceChat.Panel.MembersSpeaking_3_10" = "%@ members speaking";
"VoiceChat.Panel.MembersSpeaking_many" = "%@ members speaking";
"VoiceChat.Panel.MembersSpeaking_any" = "%@ members speaking";
"VoiceChat.Status.Members_0" = "[%@]members";
"VoiceChat.Status.Members_1" = "[%@]member";
"VoiceChat.Status.Members_2" = "[%@]members";
"VoiceChat.Status.Members_3_10" = "[%@]members";
"VoiceChat.Status.Members_many" = "[%@]members";
"VoiceChat.Status.Members_any" = "[%@]members";
"VoiceChat.Status.MembersFormat" = "%1$@ %2$@";
"ChannelInfo.CreateVoiceChat" = "Start Voice Chat";

View File

@ -962,7 +962,11 @@ open class NavigationController: UINavigationController, ContainableController,
let resolvedStatusBarStyle: NavigationStatusBarStyle
switch statusBarStyle {
case .Ignore, .Hide:
resolvedStatusBarStyle = self.theme.statusBar
if self.inCallStatusBar != nil {
resolvedStatusBarStyle = .white
} else {
resolvedStatusBarStyle = self.theme.statusBar
}
case .Black:
resolvedStatusBarStyle = .black
case .White:

View File

@ -271,6 +271,9 @@ class ChannelMembersSearchControllerNode: ASDisplayNode {
if peer.id == context.account.peerId {
continue
}
if let user = peer as? TelegramUser, user.botInfo != nil || user.flags.contains(.isSupport) {
continue
}
for filter in filters {
switch filter {
case let .exclude(ids):
@ -379,6 +382,9 @@ class ChannelMembersSearchControllerNode: ASDisplayNode {
if participant.peer.id == context.account.peerId {
continue
}
if let user = participant.peer as? TelegramUser, user.botInfo != nil || user.flags.contains(.isSupport) {
continue
}
for filter in filters {
switch filter {
case let .exclude(ids):

View File

@ -147,7 +147,7 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
private let backgroundNode: CallStatusBarBackgroundNode
private let microphoneNode: VoiceChatMicrophoneNode
private let titleNode: ImmediateTextNode
private let subtitleNode: ImmediateTextNode
private let subtitleNode: ImmediateAnimatedCountLabelNode
private let audioLevelDisposable = MetaDisposable()
private let stateDisposable = MetaDisposable()
@ -169,7 +169,7 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
self.backgroundNode = CallStatusBarBackgroundNode()
self.microphoneNode = VoiceChatMicrophoneNode()
self.titleNode = ImmediateTextNode()
self.subtitleNode = ImmediateTextNode()
self.subtitleNode = ImmediateAnimatedCountLabelNode()
super.init()
@ -267,6 +267,10 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
var title: String = ""
var subtitle: String = ""
let textFont = Font.regular(13.0)
let textColor = UIColor.white
var segments: [AnimatedCountLabelNode.Segment] = []
if let strings = self.strings {
if let currentPeer = self.currentPeer {
title = currentPeer.displayTitle(strings: strings, displayOrder: self.nameDisplayOrder)
@ -277,18 +281,58 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
} else if let content = self.currentContent, case .groupCall = content {
membersCount = 1
}
if let membersCount = membersCount {
subtitle = strings.VoiceChat_Panel_Members(membersCount)
var membersPart = strings.VoiceChat_Status_Members(membersCount)
if let startIndex = membersPart.firstIndex(of: "["), let endIndex = membersPart.firstIndex(of: "]") {
membersPart.removeSubrange(startIndex ... endIndex)
}
let rawTextAndRanges = strings.VoiceChat_Status_MembersFormat("\(membersCount)", membersPart)
let (rawText, ranges) = rawTextAndRanges
var textIndex = 0
var latestIndex = 0
for (index, range) in ranges {
var lowerSegmentIndex = range.lowerBound
if index != 0 {
lowerSegmentIndex = min(lowerSegmentIndex, latestIndex)
} else {
if latestIndex < range.lowerBound {
let part = String(rawText[rawText.index(rawText.startIndex, offsetBy: latestIndex) ..< rawText.index(rawText.startIndex, offsetBy: range.lowerBound)])
segments.append(.text(textIndex, NSAttributedString(string: part, font: textFont, textColor: textColor)))
textIndex += 1
}
}
latestIndex = range.upperBound
let part = String(rawText[rawText.index(rawText.startIndex, offsetBy: lowerSegmentIndex) ..< rawText.index(rawText.startIndex, offsetBy: range.upperBound)])
if index == 0 {
segments.append(.number(Int(membersCount), NSAttributedString(string: part, font: textFont, textColor: textColor)))
} else {
segments.append(.text(textIndex, NSAttributedString(string: part, font: textFont, textColor: textColor)))
textIndex += 1
}
}
if latestIndex < rawText.count {
let part = String(rawText[rawText.index(rawText.startIndex, offsetBy: latestIndex)...])
segments.append(.text(textIndex, NSAttributedString(string: part, font: textFont, textColor: textColor)))
textIndex += 1
}
}
}
self.titleNode.attributedText = NSAttributedString(string: title, font: Font.semibold(13.0), textColor: .white)
self.subtitleNode.attributedText = NSAttributedString(string: subtitle, font: Font.regular(13.0), textColor: .white)
if self.subtitleNode.segments != segments {
self.subtitleNode.segments = segments
}
self.titleNode.attributedText = NSAttributedString(string: title, font: Font.semibold(13.0), textColor: .white)
let animationSize: CGFloat = 25.0
let iconSpacing: CGFloat = 0.0
let spacing: CGFloat = 5.0
let titleSize = self.titleNode.updateLayout(CGSize(width: 160.0, height: size.height))
let subtitleSize = self.subtitleNode.updateLayout(CGSize(width: 160.0, height: size.height))
let subtitleSize = self.subtitleNode.updateLayout(size: CGSize(width: 160.0, height: size.height), animated: true)
let totalWidth = animationSize + iconSpacing + titleSize.width + spacing + subtitleSize.width
let horizontalOrigin: CGFloat = floor((size.width - totalWidth) / 2.0)

View File

@ -1115,14 +1115,13 @@ public final class VoiceChatController: ViewController {
}
self.updateMembers(muteState: self.effectiveMuteState, groupMembers: self.currentGroupMembers ?? [], callMembers: self.currentCallMembers ?? [], invitedPeers: self.currentInvitedPeers ?? [], speakingPeers: self.currentSpeakingPeers ?? Set())
case .ended, .cancelled:
self.hapticFeedback.impact(.light)
self.pushingToTalk = false
self.actionButton.pressing = false
let timestamp = CACurrentMediaTime()
if timestamp - self.actionButtonPressGestureStartTime < 0.2 {
self.call.toggleIsMuted()
} else {
self.hapticFeedback.impact(.light)
self.call.setIsMuted(action: .muted(isPushToTalkActive: false))
}
@ -1335,8 +1334,6 @@ public final class VoiceChatController: ViewController {
let (duration, curve) = listViewAnimationDurationAndCurve(transition: transition)
let updateSizeAndInsets = ListViewUpdateSizeAndInsets(size: listSize, insets: insets, duration: duration, curve: curve)
// let updateSizeAndInsets = ListViewUpdateSizeAndInsets(size: listFrame.size, insets: UIEdgeInsets(top: -1.0, left: -6.0, bottom: -1.0, right: -6.0), scrollIndicatorInsets: UIEdgeInsets(top: 10.0, left: 0.0, bottom: 10.0, right: 0.0), duration: duration, curve: curve)
self.listNode.transaction(deleteIndices: [], insertIndicesAndItems: [], updateIndicesAndItems: [], options: [.Synchronous, .LowLatency], scrollToItem: nil, updateSizeAndInsets: updateSizeAndInsets, stationaryItemRange: nil, updateOpaqueState: nil, completion: { _ in })
transition.updateFrame(node: self.topCornersNode, frame: CGRect(origin: CGPoint(x: sideInset, y: 63.0), size: CGSize(width: layout.size.width - sideInset * 2.0, height: 50.0)))
@ -1464,21 +1461,30 @@ public final class VoiceChatController: ViewController {
}
func animateIn() {
self.layer.animateBoundsOriginYAdditive(from: -self.bounds.size.height, to: 0.0, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring)
self.dimNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
self.dimNode.layer.animatePosition(from: CGPoint(x: 0.0, y: -self.bounds.size.height), to: CGPoint(), duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: true, additive: true)
guard let (layout, _) = self.validLayout else {
return
}
let transition = ContainedViewLayoutTransition.animated(duration: 0.4, curve: .spring)
let topPanelFrame = self.topPanelNode.view.convert(self.topPanelNode.bounds, to: self.view)
let initialBounds = self.contentContainer.bounds
self.contentContainer.bounds = initialBounds.offsetBy(dx: 0.0, dy: -(layout.size.height - topPanelFrame.minY))
transition.animateView {
self.contentContainer.view.bounds = initialBounds
}
self.dimNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
}
func animateOut(completion: (() -> Void)?) {
var dimCompleted = false
var offsetCompleted = false
let internalCompletion: () -> Void = { [weak self] in
if dimCompleted && offsetCompleted {
if offsetCompleted {
if let strongSelf = self {
strongSelf.layer.removeAllAnimations()
strongSelf.contentContainer.layer.removeAllAnimations()
strongSelf.dimNode.layer.removeAllAnimations()
var bounds = strongSelf.bounds
var bounds = strongSelf.contentContainer.bounds
bounds.origin.y = 0.0
strongSelf.contentContainer.bounds = bounds
}
@ -1486,15 +1492,11 @@ public final class VoiceChatController: ViewController {
}
}
self.layer.animateBoundsOriginYAdditive(from: self.bounds.origin.y, to: -self.bounds.size.height, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, completion: { _ in
self.contentContainer.layer.animateBoundsOriginYAdditive(from: self.contentContainer.bounds.origin.y, to: -self.contentContainer.bounds.size.height, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, completion: { _ in
offsetCompleted = true
internalCompletion()
})
self.dimNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false)
self.dimNode.layer.animatePosition(from: CGPoint(), to: CGPoint(x: 0.0, y: -self.bounds.size.height), duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, additive: true, completion: { _ in
dimCompleted = true
internalCompletion()
})
}
private func enqueueTransition(_ transition: ListTransition) {
@ -1665,8 +1667,8 @@ public final class VoiceChatController: ViewController {
if (bounds.minY < -60.0 || velocity.y > 300.0) {
self.controller?.dismiss()
} else {
let previousBounds = self.bounds
var bounds = self.bounds
var bounds = self.contentContainer.bounds
let previousBounds = bounds
bounds.origin.y = 0.0
self.contentContainer.bounds = bounds
self.contentContainer.layer.animateBounds(from: previousBounds, to: self.contentContainer.bounds, duration: 0.3, timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue)
@ -1685,7 +1687,11 @@ public final class VoiceChatController: ViewController {
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let result = super.hitTest(point, with: event)
if result === self.topPanelNode.view || result === self.bottomPanelNode.view {
if result === self.topPanelNode.view {
return self.listNode.view
}
if result === self.bottomPanelNode.view {
return self.view
}