mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 09:20:08 +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 medium
|
||||
case heavy
|
||||
case soft
|
||||
case rigid
|
||||
case veryLight
|
||||
}
|
||||
|
||||
@available(iOSApplicationExtension 10.0, iOS 10.0, *)
|
||||
private final class HapticFeedbackImpl {
|
||||
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),
|
||||
.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? = {
|
||||
let generator = UISelectionFeedbackGenerator()
|
||||
@ -64,9 +77,13 @@ private final class HapticFeedbackImpl {
|
||||
|
||||
func impact(_ style: ImpactHapticFeedbackStyle) {
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func success() {
|
||||
if let notificationGenerator = self.notificationGenerator {
|
||||
|
||||
@ -86,6 +86,8 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
|
||||
|
||||
private var callState: PresentationGroupCallState?
|
||||
|
||||
private let hapticFeedback = HapticFeedback()
|
||||
|
||||
private var currentData: GroupCallPanelData?
|
||||
private var validLayout: (CGSize, CGFloat, CGFloat)?
|
||||
|
||||
@ -195,11 +197,15 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
|
||||
}
|
||||
switch gestureRecognizer.state {
|
||||
case .began:
|
||||
self.hapticFeedback.impact(.veryLight)
|
||||
|
||||
self.actionButtonPressGestureStartTime = CACurrentMediaTime()
|
||||
if callState.muteState != nil {
|
||||
call.setIsMuted(action: .muted(isPushToTalkActive: true))
|
||||
}
|
||||
case .ended, .cancelled:
|
||||
self.hapticFeedback.impact(.veryLight)
|
||||
|
||||
let timestamp = CACurrentMediaTime()
|
||||
if callState.muteState != nil || timestamp - self.actionButtonPressGestureStartTime < 0.1 {
|
||||
call.toggleIsMuted()
|
||||
|
||||
@ -791,6 +791,8 @@ public final class VoiceChatController: ViewController {
|
||||
}
|
||||
switch gestureRecognizer.state {
|
||||
case .began:
|
||||
self.hapticFeedback.impact(.veryLight)
|
||||
|
||||
self.actionButtonPressGestureStartTime = CACurrentMediaTime()
|
||||
self.actionButton.pressing = true
|
||||
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))
|
||||
}
|
||||
case .ended, .cancelled:
|
||||
self.hapticFeedback.impact(.veryLight)
|
||||
|
||||
self.pushingToTalk = false
|
||||
self.actionButton.pressing = false
|
||||
let timestamp = CACurrentMediaTime()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user