mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-20 16:42:44 +02:00
#4096 - Various small UI tweaks and bug fixes.
This commit is contained in:
@@ -99,11 +99,8 @@ class VoiceMessageAudioPlayer: NSObject {
|
||||
func play() {
|
||||
isStopped = false
|
||||
|
||||
let audioSession = AVAudioSession.sharedInstance()
|
||||
|
||||
do {
|
||||
try audioSession.setCategory(AVAudioSession.Category.playAndRecord, mode: .default, options: .defaultToSpeaker)
|
||||
try audioSession.setActive(true, options: .notifyOthersOnDeactivation)
|
||||
try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback)
|
||||
} catch {
|
||||
MXLog.error("Could not redirect audio playback to speakers.")
|
||||
}
|
||||
|
||||
@@ -45,7 +45,8 @@ class VoiceMessagePlaybackView: UIView, VoiceMessageAudioPlayerDelegate {
|
||||
|
||||
var attachment: MXKAttachment? {
|
||||
didSet {
|
||||
if oldValue?.contentURL == attachment?.contentURL {
|
||||
if oldValue?.contentURL == attachment?.contentURL &&
|
||||
oldValue?.eventSentState == attachment?.eventSentState {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -104,6 +105,10 @@ class VoiceMessagePlaybackView: UIView, VoiceMessageAudioPlayerDelegate {
|
||||
|
||||
// MARK: - VoiceMessageAudioPlayerDelegate
|
||||
|
||||
func audioPlayerDidFinishLoading(_ audioPlayer: VoiceMessageAudioPlayer) {
|
||||
updateUI()
|
||||
}
|
||||
|
||||
func audioPlayerDidStartPlaying(_ audioPlayer: VoiceMessageAudioPlayer) {
|
||||
state = .playing
|
||||
}
|
||||
@@ -143,7 +148,7 @@ class VoiceMessagePlaybackView: UIView, VoiceMessageAudioPlayerDelegate {
|
||||
|
||||
switch state {
|
||||
case .stopped:
|
||||
elapsedTimeLabel.text = timeFormatter.string(from: Date(timeIntervalSinceReferenceDate: 0.0))
|
||||
elapsedTimeLabel.text = timeFormatter.string(from: Date(timeIntervalSinceReferenceDate: audioPlayer.duration))
|
||||
waveformView.progress = 0.0
|
||||
default:
|
||||
elapsedTimeLabel.text = timeFormatter.string(from: Date(timeIntervalSinceReferenceDate: audioPlayer.currentTime))
|
||||
|
||||
@@ -35,6 +35,7 @@ class VoiceMessageToolbarView: PassthroughView, Themable, UIGestureRecognizerDel
|
||||
@IBOutlet private var secondaryRecordButton: UIButton!
|
||||
|
||||
@IBOutlet private var recordingChromeContainerView: UIView!
|
||||
@IBOutlet private var recordingIndicatorView: UIView!
|
||||
|
||||
@IBOutlet private var slideToCancelContainerView: UIView!
|
||||
@IBOutlet private var slideToCancelLabel: UILabel!
|
||||
@@ -59,6 +60,7 @@ class VoiceMessageToolbarView: PassthroughView, Themable, UIGestureRecognizerDel
|
||||
case .recording:
|
||||
let convertedFrame = self.convert(slideToCancelLabel.frame, from: slideToCancelContainerView)
|
||||
cancelLabelToRecordButtonDistance = recordButtonsContainerView.frame.minX - convertedFrame.maxX
|
||||
startAnimatingRecordingIndicator()
|
||||
case .idle:
|
||||
cancelDrag()
|
||||
}
|
||||
@@ -132,10 +134,10 @@ class VoiceMessageToolbarView: PassthroughView, Themable, UIGestureRecognizerDel
|
||||
|
||||
let translation = gestureRecognizer.translation(in: self)
|
||||
|
||||
recordButtonsContainerView.transform = CGAffineTransform(translationX: min(translation.x, 0.0), y: 0.0)
|
||||
secondaryRecordButton.transform = CGAffineTransform(translationX: min(translation.x, 0.0), y: 0.0)
|
||||
slideToCancelContainerView.transform = CGAffineTransform(translationX: min(translation.x + cancelLabelToRecordButtonDistance, 0.0), y: 0.0)
|
||||
|
||||
if abs(translation.x) > self.bounds.width / 2.0 {
|
||||
if abs(translation.x - recordButtonsContainerView.frame.width / 2.0) > self.bounds.width / 2.0 {
|
||||
cancelDrag()
|
||||
}
|
||||
}
|
||||
@@ -155,8 +157,6 @@ class VoiceMessageToolbarView: PassthroughView, Themable, UIGestureRecognizerDel
|
||||
self.primaryRecordButton.alpha = 1.0
|
||||
self.secondaryRecordButton.alpha = 0.0
|
||||
self.recordingChromeContainerView.alpha = 0.0
|
||||
self.recordButtonsContainerView.transform = .identity
|
||||
self.slideToCancelContainerView.transform = .identity
|
||||
case .recording:
|
||||
self.backgroundView.alpha = 1.0
|
||||
self.primaryRecordButton.alpha = 0.0
|
||||
@@ -171,10 +171,35 @@ class VoiceMessageToolbarView: PassthroughView, Themable, UIGestureRecognizerDel
|
||||
self.backgroundView.backgroundColor = theme.backgroundColor
|
||||
self.slideToCancelGradient.tintColor = theme.backgroundColor
|
||||
|
||||
self.primaryRecordButton.tintColor = theme.textSecondaryColor
|
||||
self.primaryRecordButton.tintColor = theme.textTertiaryColor
|
||||
self.slideToCancelLabel.textColor = theme.textSecondaryColor
|
||||
self.slideToCancelChevron.tintColor = theme.textSecondaryColor
|
||||
self.elapsedTimeLabel.textColor = theme.textSecondaryColor
|
||||
} completion: { _ in
|
||||
switch self.state {
|
||||
case .idle:
|
||||
self.secondaryRecordButton.transform = .identity
|
||||
self.slideToCancelContainerView.transform = .identity
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func startAnimatingRecordingIndicator() {
|
||||
if self.state != .recording {
|
||||
return
|
||||
}
|
||||
|
||||
UIView.animate(withDuration: 0.5) {
|
||||
if self.recordingIndicatorView.alpha > 0.0 {
|
||||
self.recordingIndicatorView.alpha = 0.0
|
||||
} else {
|
||||
self.recordingIndicatorView.alpha = 1.0
|
||||
}
|
||||
} completion: { [weak self] _ in
|
||||
self?.startAnimatingRecordingIndicator()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
<outlet property="primaryRecordButton" destination="BDj-Sw-VQ5" id="dg3-fG-Bym"/>
|
||||
<outlet property="recordButtonsContainerView" destination="7OQ-1F-5qT" id="HDQ-r9-2Tu"/>
|
||||
<outlet property="recordingChromeContainerView" destination="dyu-ha-046" id="u7O-Vb-T2W"/>
|
||||
<outlet property="recordingIndicatorView" destination="miF-pM-B9J" id="zNy-ms-awL"/>
|
||||
<outlet property="secondaryRecordButton" destination="rel-Fo-ROL" id="KXM-gt-9hS"/>
|
||||
<outlet property="slideToCancelChevron" destination="82A-vC-KEp" id="Chg-EH-UBv"/>
|
||||
<outlet property="slideToCancelContainerView" destination="6FH-4Q-Z5e" id="qCc-rl-vQX"/>
|
||||
|
||||
Reference in New Issue
Block a user