From c2779767798bee57b885a940ff80e4e4158dc572 Mon Sep 17 00:00:00 2001 From: yuncheol-AHN Date: Thu, 5 Dec 2024 11:29:33 +0900 Subject: [PATCH 1/3] feat: audio controller stop design changed --- .../View/CreateAudioViewController.swift | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/Audio/Audio/View/CreateAudioViewController.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/Audio/Audio/View/CreateAudioViewController.swift index 6ff5c4c..0465d71 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/Audio/Audio/View/CreateAudioViewController.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/Audio/Audio/View/CreateAudioViewController.swift @@ -25,8 +25,8 @@ final class CreateAudioViewController: UIViewController { private let audioRecordersettings: [String: Any] = [ AVFormatIDKey: Int(kAudioFormatMPEG4AAC), AVSampleRateKey: 44100, - AVNumberOfChannelsKey: 2, - AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue + AVNumberOfChannelsKey: 1, + AVEncoderAudioQualityKey: AVAudioQuality.medium.rawValue ] // MARK: - UI Component @@ -233,7 +233,7 @@ final class CreateAudioViewController: UIViewController { audioButton.layer.cornerRadius = 24 audioButton.setWidthAndHeight(width: 48, height: 48) audioButton.setCenter(view: audioButtonBackground) - NSLayoutConstraint.activate(audioButtonConstraints) +// NSLayoutConstraint.activate(audioButtonConstraints) timeTextLabel.setAnchor( top: meteringBackgroundView.bottomAnchor, constantTop: 10, @@ -288,13 +288,17 @@ final class CreateAudioViewController: UIViewController { private func startRecording() { try? audioSession.setActive(true) + timeTextLabel.text = "00:00" + audioRecorder?.prepareToRecord() audioRecorder?.record() // timer about audio metering level meteringLevelTimer?.invalidate() meteringLevelTimer = Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { [weak self] _ in Task { - await self?.updateAudioMetering() + if await (self?.audioRecorder?.isRecording ?? true) { + await self?.updateAudioMetering() + } } } // timer about audio record time @@ -307,6 +311,7 @@ final class CreateAudioViewController: UIViewController { } // audio button to start + audioButtonSetStartImage() audioButton.layer.cornerRadius = 6 NSLayoutConstraint.deactivate(audioButton.constraints) audioButton.setWidthAndHeight(width: 32, height: 32) @@ -323,10 +328,9 @@ final class CreateAudioViewController: UIViewController { recordTimer?.invalidate() recordingSeconds = 0 - timeTextLabel.text = "00:00" // audio button to stop - audioButton.layer.cornerRadius = 24 + audioButtonSetRotateImage() NSLayoutConstraint.deactivate(audioButton.constraints) audioButton.setWidthAndHeight(width: 48, height: 48) audioButton.setCenter(view: audioButtonBackground) @@ -335,6 +339,24 @@ final class CreateAudioViewController: UIViewController { saveButton.isEnabled = true } + private func audioButtonSetRotateImage() { + let image = UIImage( + systemName: "arrow.clockwise", + withConfiguration: UIImage.SymbolConfiguration(pointSize: 36) + ) + audioButton.setImage(image, for: .normal) + audioButton.tintColor = .black + + audioButton.backgroundColor = .white + audioButtonBackground.layer.borderColor = UIColor.white.cgColor + } + + private func audioButtonSetStartImage() { + audioButton.setImage(nil, for: .normal) + audioButton.backgroundColor = .red + audioButtonBackground.layer.borderColor = UIColor.gray.cgColor + } + private func updateAudioMetering() { guard let recorder = audioRecorder else { return } recorder.updateMeters() From 7c4c687226c74f461e2113b090602a7db790d350 Mon Sep 17 00:00:00 2001 From: yuncheol-AHN Date: Thu, 5 Dec 2024 11:50:07 +0900 Subject: [PATCH 2/3] chore: delete comment --- .../Source/Audio/Audio/View/CreateAudioViewController.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/Audio/Audio/View/CreateAudioViewController.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/Audio/Audio/View/CreateAudioViewController.swift index 0465d71..c368e96 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/Audio/Audio/View/CreateAudioViewController.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/Audio/Audio/View/CreateAudioViewController.swift @@ -233,7 +233,6 @@ final class CreateAudioViewController: UIViewController { audioButton.layer.cornerRadius = 24 audioButton.setWidthAndHeight(width: 48, height: 48) audioButton.setCenter(view: audioButtonBackground) -// NSLayoutConstraint.activate(audioButtonConstraints) timeTextLabel.setAnchor( top: meteringBackgroundView.bottomAnchor, constantTop: 10, From f027ed6b5c9d07aa8680e55c1825b5de37d0562a Mon Sep 17 00:00:00 2001 From: yuncheol-AHN Date: Thu, 5 Dec 2024 15:10:37 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=EC=98=A4=EB=94=94=EC=98=A4=20?= =?UTF-8?q?=EC=A4=91=EB=8B=A8=20&=20=EC=9E=AC=EC=8B=9C=EC=9E=91=20?= =?UTF-8?q?=EC=8B=9C=20,=20=EC=9D=8C=EC=84=B1=20=ED=91=9C=EC=8B=9C=20?= =?UTF-8?q?=EB=B0=94=EA=B0=80=20=EC=B4=88=EA=B8=B0=ED=99=94=EB=90=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/CreateAudioViewController.swift | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/Audio/Audio/View/CreateAudioViewController.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/Audio/Audio/View/CreateAudioViewController.swift index c368e96..77a9974 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/Audio/Audio/View/CreateAudioViewController.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/Audio/Audio/View/CreateAudioViewController.swift @@ -161,6 +161,27 @@ final class CreateAudioViewController: UIViewController { } } + private func setupBarsDefault() { + let width = 300 / numberOfBars - 5 + let barSpacing = 5 + + for index in 0..