mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-29 12:46:58 +02:00
#4096 - Voice message playback view theme support.
This commit is contained in:
@@ -82,6 +82,8 @@ class VoiceMessagePlaybackView: UIView, VoiceMessageAudioPlayerDelegate {
|
||||
|
||||
super.init(coder: coder)
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(handleThemeDidChange), name: .themeServiceDidChangeTheme, object: nil)
|
||||
|
||||
audioPlayer.delegate = self
|
||||
|
||||
displayLink = CADisplayLink(target: self, selector: #selector(handleDisplayLinkTick))
|
||||
@@ -124,7 +126,20 @@ class VoiceMessagePlaybackView: UIView, VoiceMessageAudioPlayerDelegate {
|
||||
|
||||
private func updateUI() {
|
||||
playButton.isEnabled = (state != .error)
|
||||
playButton.setImage((state == .playing ? Asset.Images.voiceMessagePauseButton.image : Asset.Images.voiceMessagePlayButton.image), for: .normal)
|
||||
|
||||
if ThemeService.shared().isCurrentThemeDark() {
|
||||
playButton.setImage((state == .playing ? Asset.Images.voiceMessagePauseButtonDark.image : Asset.Images.voiceMessagePlayButtonDark.image), for: .normal)
|
||||
backgroundView.backgroundColor = UIColor(rgb: 0x394049)
|
||||
waveformView.primarylineColor = ThemeService.shared().theme.colors.quarterlyContent
|
||||
waveformView.secondaryLineColor = ThemeService.shared().theme.colors.secondaryContent
|
||||
elapsedTimeLabel.textColor = UIColor(rgb: 0x8E99A4)
|
||||
} else {
|
||||
playButton.setImage((state == .playing ? Asset.Images.voiceMessagePauseButtonLight.image : Asset.Images.voiceMessagePlayButtonLight.image), for: .normal)
|
||||
backgroundView.backgroundColor = UIColor(rgb: 0xE3E8F0)
|
||||
waveformView.primarylineColor = ThemeService.shared().theme.colors.quarterlyContent
|
||||
waveformView.secondaryLineColor = ThemeService.shared().theme.colors.secondaryContent
|
||||
elapsedTimeLabel.textColor = UIColor(rgb: 0x737D8C)
|
||||
}
|
||||
|
||||
switch state {
|
||||
case .stopped:
|
||||
@@ -212,4 +227,8 @@ class VoiceMessagePlaybackView: UIView, VoiceMessageAudioPlayerDelegate {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@objc private func handleThemeDidChange() {
|
||||
updateUI()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="GL1-b8-dZK">
|
||||
<rect key="frame" x="8" y="6" width="32" height="32"/>
|
||||
<state key="normal" image="voice_message_play_button"/>
|
||||
<state key="normal" image="voice_message_play_button_light"/>
|
||||
<connections>
|
||||
<action selector="onPlayButtonTap" destination="cGR-49-HWB" eventType="touchUpInside" id="B5j-st-pUp"/>
|
||||
</connections>
|
||||
@@ -74,6 +74,6 @@
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="voice_message_play_button" width="32" height="32"/>
|
||||
<image name="voice_message_play_button_light" width="32" height="32"/>
|
||||
</resources>
|
||||
</document>
|
||||
|
||||
@@ -19,13 +19,14 @@ import UIKit
|
||||
class VoiceMessageWaveformView: UIView {
|
||||
|
||||
private let lineWidth: CGFloat = 2.0
|
||||
private let primarylineColor = UIColor.lightGray
|
||||
private let secondaryLineColor = UIColor.darkGray
|
||||
private let linePadding: CGFloat = 2.0
|
||||
|
||||
private var samples: [Float] = []
|
||||
private var barViews: [CALayer] = []
|
||||
|
||||
var primarylineColor = UIColor.lightGray
|
||||
var secondaryLineColor = UIColor.darkGray
|
||||
|
||||
var progress = 0.0 {
|
||||
didSet {
|
||||
updateBarViews()
|
||||
|
||||
Reference in New Issue
Block a user