-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] SpeechService 개선 #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -34,11 +34,17 @@ struct HomeView: View { | |||||
| Button( | ||||||
| action: { | ||||||
| if speechService.isSpeaking { | ||||||
| speechService.stop() | ||||||
| // 재생 중 → 일시정지 | ||||||
| viewModel.pausePlayback() | ||||||
| } else if viewModel.isPaused { | ||||||
| // 일시정지 상태 → 이어서 재생 | ||||||
| viewModel.resumePlayback() | ||||||
| } else { | ||||||
| // 홈 피드가 있으면 첫 번째 피드 아이템 재생 | ||||||
| // 정지 상태 → 처음부터 재생 | ||||||
| if !viewModel.homeFeedItems.isEmpty { | ||||||
| viewModel.playFirstFeedItem() | ||||||
| } else { | ||||||
| SpeechService.shared.speak(text: "아직 구독한 페이지가 없거나 새로운 글이 없습니다.") | ||||||
| } | ||||||
| } | ||||||
| }, | ||||||
|
|
@@ -50,7 +56,7 @@ struct HomeView: View { | |||||
| .padding(20) | ||||||
| } | ||||||
| ) | ||||||
| .accessibilityLabel(speechService.isSpeaking ? "재생 중단" : "재생 시작") | ||||||
| .accessibilityLabel(speechService.isSpeaking ? "일시정지" : viewModel.isPaused ? "이어서 재생" : "재생 시작") | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| .padding(.bottom, 60) | ||||||
|
|
||||||
| Spacer() | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ class MainViewModel: ObservableObject { | |
| @Published var recentAlerts: [Alert] = [] | ||
| @Published var homeFeedItems: [HomeFeedItemResponse] = [] | ||
| @Published var isLoading: Bool = false | ||
| @Published var isPaused: Bool = false | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
제안:
이렇게 하면 상태 관리가 단순해지고 잠재적인 버그를 예방할 수 있습니다. |
||
| @Published var errorMessage: String? | ||
|
|
||
| private let apiService: APIService | ||
|
|
@@ -163,12 +164,25 @@ class MainViewModel: ObservableObject { | |
| playCurrentGroup() | ||
| } | ||
|
|
||
| /// 일시정지 | ||
| func pausePlayback() { | ||
| SpeechService.shared.pause() | ||
| isPaused = true | ||
| } | ||
|
|
||
| /// 이어서 재생 | ||
| func resumePlayback() { | ||
| SpeechService.shared.resume() | ||
| isPaused = false | ||
| } | ||
|
|
||
| /// 재생 중단 시 큐 초기화 | ||
| func stopPlayback() { | ||
| SpeechService.shared.stop() | ||
| playbackQueue = [] | ||
| currentGroupIndex = 0 | ||
| currentItemIndex = 0 | ||
| isPaused = false | ||
| } | ||
|
|
||
| /// 현재 그룹 재생 (카테고리명 먼저, 그 다음 summary들) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MainViewModel의 중복된isPaused상태 대신,SpeechService의 상태를 직접 사용하는 것이 상태 관리 측면에서 더 안전하고 명확합니다.