mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 17:30:12 +00:00
Voice Chat UI improvements
This commit is contained in:
parent
c053f853d1
commit
ed28ef6b5b
@ -6,14 +6,27 @@ public enum ImpactHapticFeedbackStyle: Hashable {
|
|||||||
case light
|
case light
|
||||||
case medium
|
case medium
|
||||||
case heavy
|
case heavy
|
||||||
|
case soft
|
||||||
|
case rigid
|
||||||
|
case veryLight
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOSApplicationExtension 10.0, iOS 10.0, *)
|
@available(iOSApplicationExtension 10.0, iOS 10.0, *)
|
||||||
private final class HapticFeedbackImpl {
|
private final class HapticFeedbackImpl {
|
||||||
private lazy var impactGenerator: [ImpactHapticFeedbackStyle : UIImpactFeedbackGenerator] = {
|
private lazy var impactGenerator: [ImpactHapticFeedbackStyle : UIImpactFeedbackGenerator] = {
|
||||||
[.light: UIImpactFeedbackGenerator(style: .light),
|
if #available(iOSApplicationExtension 13.0, iOS 13.0, *) {
|
||||||
|
return [.light: UIImpactFeedbackGenerator(style: .light),
|
||||||
.medium: UIImpactFeedbackGenerator(style: .medium),
|
.medium: UIImpactFeedbackGenerator(style: .medium),
|
||||||
.heavy: UIImpactFeedbackGenerator(style: .heavy)] }()
|
.heavy: UIImpactFeedbackGenerator(style: .heavy),
|
||||||
|
.soft: UIImpactFeedbackGenerator(style: .soft),
|
||||||
|
.rigid: UIImpactFeedbackGenerator(style: .rigid),
|
||||||
|
.veryLight: UIImpactFeedbackGenerator()]
|
||||||
|
} else {
|
||||||
|
return [.light: UIImpactFeedbackGenerator(style: .light),
|
||||||
|
.medium: UIImpactFeedbackGenerator(style: .medium),
|
||||||
|
.heavy: UIImpactFeedbackGenerator(style: .heavy)]
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
private lazy var selectionGenerator: UISelectionFeedbackGenerator? = {
|
private lazy var selectionGenerator: UISelectionFeedbackGenerator? = {
|
||||||
let generator = UISelectionFeedbackGenerator()
|
let generator = UISelectionFeedbackGenerator()
|
||||||
@ -64,9 +77,13 @@ private final class HapticFeedbackImpl {
|
|||||||
|
|
||||||
func impact(_ style: ImpactHapticFeedbackStyle) {
|
func impact(_ style: ImpactHapticFeedbackStyle) {
|
||||||
if let impactGenerator = self.impactGenerator[style] {
|
if let impactGenerator = self.impactGenerator[style] {
|
||||||
|
if #available(iOSApplicationExtension 13.0, iOS 13.0, *), case .veryLight = style {
|
||||||
|
impactGenerator.impactOccurred(intensity: 0.3)
|
||||||
|
} else {
|
||||||
impactGenerator.impactOccurred()
|
impactGenerator.impactOccurred()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func success() {
|
func success() {
|
||||||
if let notificationGenerator = self.notificationGenerator {
|
if let notificationGenerator = self.notificationGenerator {
|
||||||
|
|||||||
@ -86,6 +86,8 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
|
|||||||
|
|
||||||
private var callState: PresentationGroupCallState?
|
private var callState: PresentationGroupCallState?
|
||||||
|
|
||||||
|
private let hapticFeedback = HapticFeedback()
|
||||||
|
|
||||||
private var currentData: GroupCallPanelData?
|
private var currentData: GroupCallPanelData?
|
||||||
private var validLayout: (CGSize, CGFloat, CGFloat)?
|
private var validLayout: (CGSize, CGFloat, CGFloat)?
|
||||||
|
|
||||||
@ -195,11 +197,15 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
switch gestureRecognizer.state {
|
switch gestureRecognizer.state {
|
||||||
case .began:
|
case .began:
|
||||||
|
self.hapticFeedback.impact(.veryLight)
|
||||||
|
|
||||||
self.actionButtonPressGestureStartTime = CACurrentMediaTime()
|
self.actionButtonPressGestureStartTime = CACurrentMediaTime()
|
||||||
if callState.muteState != nil {
|
if callState.muteState != nil {
|
||||||
call.setIsMuted(action: .muted(isPushToTalkActive: true))
|
call.setIsMuted(action: .muted(isPushToTalkActive: true))
|
||||||
}
|
}
|
||||||
case .ended, .cancelled:
|
case .ended, .cancelled:
|
||||||
|
self.hapticFeedback.impact(.veryLight)
|
||||||
|
|
||||||
let timestamp = CACurrentMediaTime()
|
let timestamp = CACurrentMediaTime()
|
||||||
if callState.muteState != nil || timestamp - self.actionButtonPressGestureStartTime < 0.1 {
|
if callState.muteState != nil || timestamp - self.actionButtonPressGestureStartTime < 0.1 {
|
||||||
call.toggleIsMuted()
|
call.toggleIsMuted()
|
||||||
|
|||||||
@ -791,6 +791,8 @@ public final class VoiceChatController: ViewController {
|
|||||||
}
|
}
|
||||||
switch gestureRecognizer.state {
|
switch gestureRecognizer.state {
|
||||||
case .began:
|
case .began:
|
||||||
|
self.hapticFeedback.impact(.veryLight)
|
||||||
|
|
||||||
self.actionButtonPressGestureStartTime = CACurrentMediaTime()
|
self.actionButtonPressGestureStartTime = CACurrentMediaTime()
|
||||||
self.actionButton.pressing = true
|
self.actionButton.pressing = true
|
||||||
if callState.muteState != nil {
|
if callState.muteState != nil {
|
||||||
@ -801,6 +803,8 @@ public final class VoiceChatController: ViewController {
|
|||||||
self.containerLayoutUpdated(layout, navigationHeight: navigationHeight, transition: .animated(duration: 0.3, curve: .spring))
|
self.containerLayoutUpdated(layout, navigationHeight: navigationHeight, transition: .animated(duration: 0.3, curve: .spring))
|
||||||
}
|
}
|
||||||
case .ended, .cancelled:
|
case .ended, .cancelled:
|
||||||
|
self.hapticFeedback.impact(.veryLight)
|
||||||
|
|
||||||
self.pushingToTalk = false
|
self.pushingToTalk = false
|
||||||
self.actionButton.pressing = false
|
self.actionButton.pressing = false
|
||||||
let timestamp = CACurrentMediaTime()
|
let timestamp = CACurrentMediaTime()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user