|
|
@@ -28,6 +28,7 @@ class LNEditVoicePanel: LNPopupView {
|
|
|
private var recordTaskId: String?
|
|
|
|
|
|
private let editView = UIView()
|
|
|
+ private let editPlayButton = UIButton()
|
|
|
private let editDurationLabel = UILabel()
|
|
|
private var curUrl: URL?
|
|
|
private var curDuration: Double?
|
|
|
@@ -89,6 +90,7 @@ extension LNEditVoicePanel {
|
|
|
} else if myVoiceBarInfo.status == .done,
|
|
|
!myUserInfo.voiceBar.isEmpty {
|
|
|
curState = .play
|
|
|
+ playDurationLabel.text = Double(myVoiceBarInfo.voiceBarDuration).durationDisplay
|
|
|
} else {
|
|
|
curState = .record
|
|
|
}
|
|
|
@@ -130,6 +132,7 @@ extension LNEditVoicePanel: LNVoicePlayerNotify {
|
|
|
if !editView.isHidden {
|
|
|
let intDuration = Int(curDuration)
|
|
|
editDurationLabel.text = String(format: "%02d:%02d", intDuration / 60, intDuration % 60)
|
|
|
+ editPlayButton.setImage(.icVoiceEditPlay, for: .normal)
|
|
|
} else if !displayView.isHidden {
|
|
|
playDurationLabel.text = curDuration.durationDisplay
|
|
|
playIcon.image = .icVoicePlay
|
|
|
@@ -141,6 +144,8 @@ extension LNEditVoicePanel: LNVoicePlayerNotify {
|
|
|
|
|
|
if !displayView.isHidden {
|
|
|
playIcon.image = .icVoicePause
|
|
|
+ } else if !editView.isHidden {
|
|
|
+ editPlayButton.setImage(.icVoiceEditPause, for: .normal)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -185,7 +190,13 @@ extension LNEditVoicePanel {
|
|
|
}
|
|
|
|
|
|
private func setupViews() {
|
|
|
- containerHeight = .height(326)
|
|
|
+ let fakeView = UIView()
|
|
|
+ fakeView.isUserInteractionEnabled = false
|
|
|
+ container.addSubview(fakeView)
|
|
|
+ fakeView.snp.makeConstraints { make in
|
|
|
+ make.edges.equalToSuperview()
|
|
|
+ make.height.equalTo(326)
|
|
|
+ }
|
|
|
|
|
|
let titleView = buildTitle()
|
|
|
container.addSubview(titleView)
|
|
|
@@ -347,15 +358,18 @@ extension LNEditVoicePanel {
|
|
|
let playView = UIView()
|
|
|
stackView.addArrangedSubview(playView)
|
|
|
|
|
|
- let playButton = UIButton()
|
|
|
- playButton.setImage(.icVoiceEditPlay, for: .normal)
|
|
|
- playButton.addAction(UIAction(handler: { [weak self] _ in
|
|
|
+ editPlayButton.setImage(.icVoiceEditPlay, for: .normal)
|
|
|
+ editPlayButton.addAction(UIAction(handler: { [weak self] _ in
|
|
|
guard let self else { return }
|
|
|
guard let curUrl else { return }
|
|
|
- LNVoicePlayer.shared.play(path: curUrl.path)
|
|
|
+ if LNVoicePlayer.shared.isPlaying {
|
|
|
+ LNVoicePlayer.shared.stop()
|
|
|
+ } else {
|
|
|
+ LNVoicePlayer.shared.play(path: curUrl.path)
|
|
|
+ }
|
|
|
}), for: .touchUpInside)
|
|
|
- playView.addSubview(playButton)
|
|
|
- playButton.snp.makeConstraints { make in
|
|
|
+ playView.addSubview(editPlayButton)
|
|
|
+ editPlayButton.snp.makeConstraints { make in
|
|
|
make.centerX.equalToSuperview()
|
|
|
make.leading.greaterThanOrEqualToSuperview()
|
|
|
make.top.equalToSuperview()
|
|
|
@@ -370,7 +384,7 @@ extension LNEditVoicePanel {
|
|
|
playLabel.snp.makeConstraints { make in
|
|
|
make.horizontalEdges.equalToSuperview()
|
|
|
make.bottom.equalToSuperview()
|
|
|
- make.top.equalTo(playButton.snp.bottom).offset(12)
|
|
|
+ make.top.equalTo(editPlayButton.snp.bottom).offset(12)
|
|
|
}
|
|
|
|
|
|
let confirmButton = UIButton()
|
|
|
@@ -446,6 +460,8 @@ extension LNEditVoicePanel {
|
|
|
private func buildDisplayView() -> UIView {
|
|
|
let button = UIButton()
|
|
|
button.setBackgroundImage(.primary_7, for: .normal)
|
|
|
+ button.layer.cornerRadius = 16
|
|
|
+ button.clipsToBounds = true
|
|
|
displayView.addSubview(button)
|
|
|
button.snp.makeConstraints { make in
|
|
|
make.centerX.equalToSuperview()
|
|
|
@@ -463,6 +479,7 @@ extension LNEditVoicePanel {
|
|
|
}
|
|
|
|
|
|
voiceWaveView.isUserInteractionEnabled = false
|
|
|
+ voiceWaveView.build()
|
|
|
button.addSubview(voiceWaveView)
|
|
|
voiceWaveView.snp.makeConstraints { make in
|
|
|
make.centerY.equalToSuperview()
|
|
|
@@ -480,27 +497,26 @@ extension LNEditVoicePanel {
|
|
|
}
|
|
|
|
|
|
button.addAction(UIAction(handler: { [weak self] _ in
|
|
|
- guard let self else { return }
|
|
|
+ guard self != nil else { return }
|
|
|
if LNVoicePlayer.shared.isPlaying {
|
|
|
LNVoicePlayer.shared.stop()
|
|
|
- } else if let url = curUrl?.absoluteString {
|
|
|
- LNVoicePlayer.shared.play(url)
|
|
|
+ } else if !myUserInfo.voiceBar.isEmpty {
|
|
|
+ LNVoicePlayer.shared.play(myUserInfo.voiceBar)
|
|
|
}
|
|
|
}), for: .touchUpInside)
|
|
|
|
|
|
let confirmButton = UIButton()
|
|
|
- confirmButton.setTitle(.init(key: "A00240"), for: .normal)
|
|
|
- confirmButton.setTitleColor(.text_1, for: .normal)
|
|
|
+ confirmButton.setTitle(.init(key: "B00107"), for: .normal)
|
|
|
+ confirmButton.setTitleColor(.text_6, for: .normal)
|
|
|
confirmButton.titleLabel?.font = .heading_h3
|
|
|
confirmButton.layer.cornerRadius = 23.5
|
|
|
- confirmButton.setBackgroundImage(.primary_8, for: .normal)
|
|
|
+ confirmButton.setBackgroundImage(.primary_7, for: .normal)
|
|
|
confirmButton.clipsToBounds = true
|
|
|
confirmButton.addAction(UIAction(handler: { [weak self] _ in
|
|
|
guard let self else { return }
|
|
|
LNVoicePlayer.shared.stop()
|
|
|
|
|
|
- LNProfileManager.shared.setMyVoiceBar(url: "", duration: 0)
|
|
|
- { [weak self] success in
|
|
|
+ LNProfileManager.shared.cleanVoiceBar { [weak self] success in
|
|
|
guard let self else { return }
|
|
|
guard success else { return }
|
|
|
resetRecord()
|
|
|
@@ -514,6 +530,15 @@ extension LNEditVoicePanel {
|
|
|
make.height.equalTo(47)
|
|
|
}
|
|
|
|
|
|
+ let cover = UIView()
|
|
|
+ cover.layer.cornerRadius = 22
|
|
|
+ cover.backgroundColor = .fill
|
|
|
+ cover.isUserInteractionEnabled = false
|
|
|
+ confirmButton.insertSubview(cover, at: 0)
|
|
|
+ cover.snp.makeConstraints { make in
|
|
|
+ make.edges.equalToSuperview().inset(1)
|
|
|
+ }
|
|
|
+
|
|
|
return displayView
|
|
|
}
|
|
|
}
|