From 126d79446bfefef5e75472b67fbeb130d98f89fe Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 21 Oct 2022 16:23:27 +0800 Subject: [PATCH] Clean up body of expanded audio player, remove dead code --- .../Views/AudioPlayer/ExpandedPlayer.swift | 129 +++++++++--------- 1 file changed, 62 insertions(+), 67 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/ExpandedPlayer.swift b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/ExpandedPlayer.swift index f6d20c9f0..39384a6cf 100644 --- a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/ExpandedPlayer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/ExpandedPlayer.swift @@ -12,8 +12,6 @@ @Environment(\.dismiss) private var dismiss @State var showVoiceSheet = false - @State var showLanguageSheet = false - @State var tabIndex: Int = 0 var isPresented: Bool { @@ -237,6 +235,63 @@ } } + var scrubber: some View { + Group { + ScrubberView(value: $audioController.timeElapsed, + maxValue: $audioController.duration, + onEditingChanged: { scrubStarted in + if scrubStarted { + self.audioController.scrubState = .scrubStarted + } else { + self.audioController.scrubState = .scrubEnded(self.audioController.timeElapsed) + } + }) + + HStack { + Text(audioController.timeElapsedString ?? "0:00") + .font(.appCaptionTwo) + .foregroundColor(.appGrayText) + Spacer() + Text(audioController.durationString ?? "0:00") + .font(.appCaptionTwo) + .foregroundColor(.appGrayText) + } + } + .padding(.leading, 16) + .padding(.trailing, 16) + } + + var audioButtons: some View { + HStack(alignment: .center) { + Spacer() + + Button( + action: { self.audioController.skipBackwards(seconds: 30) }, + label: { + Image(systemName: "gobackward.30") + .font(.appTitleTwo) + } + ) + + Spacer() + + playPauseButtonItem + .frame(width: 56, height: 56) + + Spacer() + + Button( + action: { self.audioController.skipForward(seconds: 30) }, + label: { + Image(systemName: "goforward.30") + .font(.appTitleTwo) + } + ) + Spacer() + + }.padding(.bottom, 16) + } + func playerContent(_: LinkedItemAudioProperties) -> some View { VStack(spacing: 0) { header @@ -245,58 +300,9 @@ Spacer() - Group { - ScrubberView(value: $audioController.timeElapsed, - maxValue: $audioController.duration, - onEditingChanged: { scrubStarted in - if scrubStarted { - self.audioController.scrubState = .scrubStarted - } else { - self.audioController.scrubState = .scrubEnded(self.audioController.timeElapsed) - } - }) + scrubber - HStack { - Text(audioController.timeElapsedString ?? "0:00") - .font(.appCaptionTwo) - .foregroundColor(.appGrayText) - Spacer() - Text(audioController.durationString ?? "0:00") - .font(.appCaptionTwo) - .foregroundColor(.appGrayText) - } - } - .padding(.leading, 16) - .padding(.trailing, 16) - - HStack(alignment: .center) { - Spacer() - - Button( - action: { self.audioController.skipBackwards(seconds: 30) }, - label: { - Image(systemName: "gobackward.30") - .font(.appTitleTwo) - } - ) - - Spacer() - - playPauseButtonItem - .frame(width: 56, height: 56) - - Spacer() - - Button( - action: { self.audioController.skipForward(seconds: 30) }, - label: { - Image(systemName: "goforward.30") - .font(.appTitleTwo) - } - ) - Spacer() - - }.padding(.bottom, 16) + audioButtons } .padding(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0)) .onAppear { @@ -319,24 +325,13 @@ .tint(.appGrayTextContrast) })) } - }.sheet(isPresented: $showLanguageSheet) { - NavigationView { - TextToSpeechLanguageView() - .navigationBarTitle("Language") - .navigationBarTitleDisplayMode(.inline) - .navigationBarItems(leading: Button(action: { self.showLanguageSheet = false }, label: { - Image(systemName: "chevron.backward") - .font(.appNavbarIcon) - .tint(.appGrayTextContrast) - })) - } } } func playbackRateButton(rate: Double, title: String, selected: Bool) -> some View { Button(action: { audioController.playbackRate = rate - }) { + }, label: { HStack { Text(title) Spacer() @@ -345,8 +340,8 @@ } } .contentShape(Rectangle()) - } - .buttonStyle(PlainButtonStyle()) + }) + .buttonStyle(PlainButtonStyle()) } public var body: some View {