mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Voice Chat UI improvements
This commit is contained in:
parent
16eae46449
commit
f8760cd7db
@ -265,9 +265,11 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||||||
strongSelf.currentGroupCallState = state
|
strongSelf.currentGroupCallState = state
|
||||||
|
|
||||||
var isMuted = isMuted
|
var isMuted = isMuted
|
||||||
if let state = state, state.callState.muteState != nil {
|
if let state = state, let muteState = state.callState.muteState {
|
||||||
|
if !muteState.canUnmute {
|
||||||
isMuted = true
|
isMuted = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
strongSelf.currentIsMuted = isMuted
|
strongSelf.currentIsMuted = isMuted
|
||||||
|
|
||||||
let currentIsConnected: Bool
|
let currentIsConnected: Bool
|
||||||
|
@ -205,8 +205,6 @@ final class VoiceChatActionButton: HighlightTrackingButtonNode {
|
|||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func applyIconParams() {
|
private func applyIconParams() {
|
||||||
@ -520,8 +518,10 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
|
|||||||
} else {
|
} else {
|
||||||
let previousValue = self.foregroundGradientLayer.startPoint
|
let previousValue = self.foregroundGradientLayer.startPoint
|
||||||
let newValue: CGPoint
|
let newValue: CGPoint
|
||||||
if self.maskBlobView.presentationAudioLevel > 0.15 {
|
if self.maskBlobView.presentationAudioLevel > 0.22 {
|
||||||
newValue = CGPoint(x: CGFloat.random(in: 0.8 ..< 1.0), y: CGFloat.random(in: 0.1 ..< 0.45))
|
newValue = CGPoint(x: CGFloat.random(in: 0.9 ..< 1.0), y: CGFloat.random(in: 0.1 ..< 0.35))
|
||||||
|
} else if self.maskBlobView.presentationAudioLevel > 0.01 {
|
||||||
|
newValue = CGPoint(x: CGFloat.random(in: 0.77 ..< 0.95), y: CGFloat.random(in: 0.1 ..< 0.35))
|
||||||
} else {
|
} else {
|
||||||
newValue = CGPoint(x: CGFloat.random(in: 0.65 ..< 0.85), y: CGFloat.random(in: 0.1 ..< 0.45))
|
newValue = CGPoint(x: CGFloat.random(in: 0.65 ..< 0.85), y: CGFloat.random(in: 0.1 ..< 0.45))
|
||||||
}
|
}
|
||||||
|
@ -127,6 +127,7 @@ public final class VoiceChatController: ViewController {
|
|||||||
let isLoading: Bool
|
let isLoading: Bool
|
||||||
let isEmpty: Bool
|
let isEmpty: Bool
|
||||||
let crossFade: Bool
|
let crossFade: Bool
|
||||||
|
let count: Int
|
||||||
let animated: Bool
|
let animated: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,7 +369,7 @@ public final class VoiceChatController: ViewController {
|
|||||||
let insertions = indicesAndItems.map { ListViewInsertItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(context: context, presentationData: presentationData, interaction: interaction), directionHint: nil) }
|
let insertions = indicesAndItems.map { ListViewInsertItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(context: context, presentationData: presentationData, interaction: interaction), directionHint: nil) }
|
||||||
let updates = updateIndices.map { ListViewUpdateItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(context: context, presentationData: presentationData, interaction: interaction), directionHint: nil) }
|
let updates = updateIndices.map { ListViewUpdateItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(context: context, presentationData: presentationData, interaction: interaction), directionHint: nil) }
|
||||||
|
|
||||||
return ListTransition(deletions: deletions, insertions: insertions, updates: updates, isLoading: isLoading, isEmpty: isEmpty, crossFade: crossFade, animated: fromEntries.count != toEntries.count)
|
return ListTransition(deletions: deletions, insertions: insertions, updates: updates, isLoading: isLoading, isEmpty: isEmpty, crossFade: crossFade, count: toEntries.count, animated: fromEntries.count != toEntries.count)
|
||||||
}
|
}
|
||||||
|
|
||||||
private weak var controller: VoiceChatController?
|
private weak var controller: VoiceChatController?
|
||||||
@ -470,8 +471,8 @@ public final class VoiceChatController: ViewController {
|
|||||||
self.listNode = ListView()
|
self.listNode = ListView()
|
||||||
self.listNode.verticalScrollIndicatorColor = UIColor(white: 1.0, alpha: 0.3)
|
self.listNode.verticalScrollIndicatorColor = UIColor(white: 1.0, alpha: 0.3)
|
||||||
self.listNode.clipsToBounds = true
|
self.listNode.clipsToBounds = true
|
||||||
self.listNode.stackFromBottom = true
|
// self.listNode.stackFromBottom = true
|
||||||
self.listNode.keepMinimalScrollHeightWithTopInset = 0
|
// self.listNode.keepMinimalScrollHeightWithTopInset = 0
|
||||||
|
|
||||||
self.topPanelNode = ASDisplayNode()
|
self.topPanelNode = ASDisplayNode()
|
||||||
self.topPanelNode.clipsToBounds = false
|
self.topPanelNode.clipsToBounds = false
|
||||||
@ -1544,7 +1545,7 @@ public final class VoiceChatController: ViewController {
|
|||||||
let listTopInset = layoutTopInset + 63.0
|
let listTopInset = layoutTopInset + 63.0
|
||||||
let listSize = CGSize(width: layout.size.width, height: layout.size.height - listTopInset - bottomPanelHeight)
|
let listSize = CGSize(width: layout.size.width, height: layout.size.height - listTopInset - bottomPanelHeight)
|
||||||
|
|
||||||
insets.top = max(0.0, listSize.height - 44.0 - floor(56.0 * 3.5))
|
insets.top = max(0.0, self.topInset ?? listSize.height)
|
||||||
|
|
||||||
transition.updateFrame(node: self.listNode, frame: CGRect(origin: CGPoint(x: 0.0, y: listTopInset), size: listSize))
|
transition.updateFrame(node: self.listNode, frame: CGRect(origin: CGPoint(x: 0.0, y: listTopInset), size: listSize))
|
||||||
|
|
||||||
@ -1687,9 +1688,10 @@ public final class VoiceChatController: ViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var topInset: CGFloat?
|
||||||
private var isFirstTime = true
|
private var isFirstTime = true
|
||||||
private func dequeueTransition() {
|
private func dequeueTransition() {
|
||||||
guard let _ = self.validLayout, let transition = self.enqueuedTransitions.first else {
|
guard let (layout, _) = self.validLayout, let transition = self.enqueuedTransitions.first else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.enqueuedTransitions.remove(at: 0)
|
self.enqueuedTransitions.remove(at: 0)
|
||||||
@ -1709,10 +1711,30 @@ public final class VoiceChatController: ViewController {
|
|||||||
var scrollToItem: ListViewScrollToItem?
|
var scrollToItem: ListViewScrollToItem?
|
||||||
if self.isFirstTime {
|
if self.isFirstTime {
|
||||||
self.isFirstTime = false
|
self.isFirstTime = false
|
||||||
scrollToItem = ListViewScrollToItem(index: 0, position: .bottom(0), animated: false, curve: .Default(duration: nil), directionHint: .Up)
|
// scrollToItem = ListViewScrollToItem(index: 0, position: .bottom(0), animated: false, curve: .Default(duration: nil), directionHint: .Up)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.listNode.transaction(deleteIndices: transition.deletions, insertIndicesAndItems: transition.insertions, updateIndicesAndItems: transition.updates, options: options, scrollToItem: scrollToItem, updateSizeAndInsets: nil, updateOpaqueState: nil, completion: { [weak self] _ in
|
var itemsHeight: CGFloat = 46.0 + CGFloat(transition.count - 1) * 56.0
|
||||||
|
|
||||||
|
let bottomAreaHeight: CGFloat = 268.0
|
||||||
|
let layoutTopInset: CGFloat = max(layout.statusBarHeight ?? 0.0, layout.safeInsets.top)
|
||||||
|
|
||||||
|
let sideInset: CGFloat = 16.0
|
||||||
|
var insets = UIEdgeInsets()
|
||||||
|
insets.left = layout.safeInsets.left + sideInset
|
||||||
|
insets.right = layout.safeInsets.right + sideInset
|
||||||
|
|
||||||
|
let bottomPanelHeight = bottomAreaHeight + layout.intrinsicInsets.bottom
|
||||||
|
let listTopInset = layoutTopInset + 63.0
|
||||||
|
let listSize = CGSize(width: layout.size.width, height: layout.size.height - listTopInset - bottomPanelHeight)
|
||||||
|
|
||||||
|
insets.top = max(0.0, max(listSize.height - itemsHeight, listSize.height - 46.0 - floor(56.0 * 3.5)))
|
||||||
|
self.topInset = insets.top
|
||||||
|
|
||||||
|
let (duration, curve) = listViewAnimationDurationAndCurve(transition: .animated(duration: 0.4, curve: .spring))
|
||||||
|
let updateSizeAndInsets = ListViewUpdateSizeAndInsets(size: listSize, insets: insets, duration: duration, curve: curve)
|
||||||
|
|
||||||
|
self.listNode.transaction(deleteIndices: transition.deletions, insertIndicesAndItems: transition.insertions, updateIndicesAndItems: transition.updates, options: options, scrollToItem: scrollToItem, updateSizeAndInsets: updateSizeAndInsets, updateOpaqueState: nil, completion: { [weak self] _ in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -56,20 +56,24 @@ public final class VoiceChatOverlayController: ViewController {
|
|||||||
transition.updateSublayerTransformOffset(layer: actionButton.layer, offset: CGPoint(x: slideOffset, y: 0.0))
|
transition.updateSublayerTransformOffset(layer: actionButton.layer, offset: CGPoint(x: slideOffset, 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] finished in
|
||||||
|
if finished {
|
||||||
actionButton?.isHidden = true
|
actionButton?.isHidden = true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
actionButton.isHidden = false
|
||||||
if slide {
|
if slide {
|
||||||
transition.updateSublayerTransformOffset(layer: actionButton.layer, offset: CGPoint())
|
transition.updateSublayerTransformOffset(layer: actionButton.layer, offset: CGPoint())
|
||||||
} else {
|
} else {
|
||||||
actionButton.layer.removeAllAnimations()
|
actionButton.layer.removeAllAnimations()
|
||||||
actionButton.isHidden = false
|
|
||||||
actionButton.layer.animateSpring(from: 0.01 as NSNumber, to: 1.0 as NSNumber, keyPath: "transform.scale", duration: 0.4)
|
actionButton.layer.animateSpring(from: 0.01 as NSNumber, to: 1.0 as NSNumber, keyPath: "transform.scale", duration: 0.4)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
actionButton.isHidden = hidden
|
||||||
|
actionButton.layer.removeAllAnimations()
|
||||||
if hidden {
|
if hidden {
|
||||||
if slide {
|
if slide {
|
||||||
actionButton.layer.sublayerTransform = CATransform3DMakeTranslation(slideOffset, 0.0, 0.0)
|
actionButton.layer.sublayerTransform = CATransform3DMakeTranslation(slideOffset, 0.0, 0.0)
|
||||||
|
@ -7071,7 +7071,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
|
|
||||||
if let controller = voiceChatOverlayController {
|
if let controller = voiceChatOverlayController {
|
||||||
var hidden = false
|
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.forwardMessageIds != nil || self.presentationInterfaceState.interfaceState.composeInputState.inputText.string.count > 0 {
|
||||||
hidden = true
|
hidden = true
|
||||||
}
|
}
|
||||||
controller.update(hidden: hidden, slide: false, animated: true)
|
controller.update(hidden: hidden, slide: false, animated: true)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user