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
2ac3467f00
commit
16eae46449
@ -230,6 +230,17 @@ 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()
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
@ -342,7 +353,15 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.backgroundNode.connectingColor = presentationData.theme.chatList.unreadBadgeInactiveBackgroundColor
|
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 {
|
||||||
|
@ -132,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
|
||||||
}
|
}
|
||||||
@ -209,6 +209,31 @@ final class VoiceChatActionButton: HighlightTrackingButtonNode {
|
|||||||
self.wasActiveWhenPressed = false
|
self.wasActiveWhenPressed = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
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)
|
||||||
@ -217,6 +242,7 @@ final class VoiceChatActionButton: HighlightTrackingButtonNode {
|
|||||||
self.backgroundNode.glowHidden = snap
|
self.backgroundNode.glowHidden = snap
|
||||||
self.backgroundNode.updateColors()
|
self.backgroundNode.updateColors()
|
||||||
self.applyParams(animated: animated)
|
self.applyParams(animated: animated)
|
||||||
|
self.applyIconParams()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,27 +251,24 @@ final class VoiceChatActionButton: HighlightTrackingButtonNode {
|
|||||||
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.applyIconParams()
|
||||||
|
|
||||||
self.backgroundNode.isDark = dark
|
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()
|
||||||
|
@ -837,7 +837,15 @@ public final class VoiceChatController: ViewController {
|
|||||||
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
|
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.presentationData = presentationData
|
strongSelf.presentationData = presentationData
|
||||||
strongSelf.actionButton.connectingColor = presentationData.theme.chatList.unreadBadgeInactiveBackgroundColor
|
|
||||||
|
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
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user