Skip to content

Commit b7d84f1

Browse files
committed
podcast fixed
1 parent ffe9c99 commit b7d84f1

File tree

5 files changed

+62
-18
lines changed

5 files changed

+62
-18
lines changed

iosApp/iosApp/FlareApp.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ struct FlareApp: SwiftUI.App {
5959

6060
// --- Global Floating Player Overlay ---
6161
if podcastManager.currentPodcast != nil {
62-
DraggablePlayerOverlay().animation(.spring(), value: podcastManager.currentPodcast?.id)
62+
DraggablePlayerOverlay()
63+
.animation(.spring(), value: podcastManager.currentPodcast?.id)
64+
.environmentObject(router)
6365
}
6466
}.environment(theme).withFlareTheme().applyTheme(theme).environment(theme)
6567
}

iosApp/iosApp/UI/Page/Home/View/SwiftUI/TabItemsViewSwiftUI.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ struct TabItemsViewSwiftUI: View {
2929
.fill(theme.tintColor)
3030
.frame(height: 2)
3131
.matchedGeometryEffect(id: "activeTab", in: tabNamespace)
32-
} else if selection == "" {
32+
} else if selection == "", item.key == items.first?.key {
3333
// first key , show active tab ,home
34-
if item.key == items.first?.key {
35-
Rectangle()
36-
.fill(theme.tintColor)
37-
.frame(height: 2)
38-
.matchedGeometryEffect(id: "activeTab", in: tabNamespace)
39-
}
34+
35+
Rectangle()
36+
.fill(theme.tintColor)
37+
.frame(height: 2)
38+
.matchedGeometryEffect(id: "activeTab", in: tabNamespace)
39+
4040
} else {
4141
Rectangle()
4242
.fill(Color.clear)

iosApp/iosApp/UI/Page/Space/LiveFloatingPlayerView.swift

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ import SwiftUI
44

55
struct LiveFloatingPlayerView: View {
66
@StateObject private var manager = IOSPodcastManager.shared
7+
@EnvironmentObject private var router: FlareRouter
8+
9+
@State private var showPodcastSheet: Bool = false
710

811
private var isFailedState: Bool {
912
if case .failed = manager.playbackState { true } else { false }
1013
}
1114

1215
var body: some View {
13-
Group {
16+
HStack {
1417
if let podcast = manager.currentPodcast {
1518
VStack(spacing: 0) {
1619
playerControls(podcast: podcast)
@@ -22,6 +25,28 @@ struct LiveFloatingPlayerView: View {
2225
.padding(.horizontal)
2326
.padding(.bottom, 5)
2427
.transition(.move(edge: .bottom).combined(with: .opacity))
28+
.onTapGesture {
29+
showPodcastSheet = true
30+
// router
31+
// .navigate(
32+
// to:
33+
// .podcastSheet(
34+
// accountType: UserManager.shared
35+
// .getCurrentAccountType()!,
36+
// podcastId: podcast.id
37+
// )
38+
// )
39+
}.sheet(isPresented: $showPodcastSheet) {
40+
if let podcastId = manager.currentPodcast?.id {
41+
PodcastSheetView(
42+
accountType: UserManager.shared.getCurrentAccountType()!,
43+
podcastId: podcastId
44+
)
45+
} else {
46+
// Handle the case where podcastId is nil, perhaps show an error or an empty state
47+
Text("Error: Podcast ID not available.")
48+
}
49+
}
2550
// .onChange(of: manager.currentTime) { ... }
2651
// .onAppear { ... }
2752
// .onChange(of: manager.currentPodcast?.id) { ... }

iosApp/iosApp/UI/Page/Space/PodcastSheetView.swift

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,29 @@ struct PodcastDetailContent: View {
115115
Spacer()
116116

117117
// Action Button
118-
Button {
119-
IOSPodcastManager.shared.playPodcast(podcast: podcast)
120-
router.dismissSheet()
121-
} label: {
122-
Label("Start Listening", systemImage: "headphones")
123-
.frame(maxWidth: .infinity)
118+
if IOSPodcastManager.shared.currentPodcast != nil, IOSPodcastManager.shared.currentPodcast?.playbackUrl == podcast.playbackUrl {
119+
Button {
120+
IOSPodcastManager.shared.stopPodcast()
121+
router.dismissSheet()
122+
} label: {
123+
Label("Stop Listening ", systemImage: "headphones")
124+
.frame(maxWidth: .infinity)
125+
}
126+
.buttonStyle(.borderedProminent)
127+
.disabled(podcast.playbackUrl == "" || podcast.playbackUrl == nil)
128+
.tint(.pink)
129+
} else {
130+
Button {
131+
IOSPodcastManager.shared.playPodcast(podcast: podcast)
132+
router.dismissSheet()
133+
} label: {
134+
Label("Start Listening", systemImage: "headphones")
135+
.frame(maxWidth: .infinity)
136+
}
137+
.buttonStyle(.borderedProminent)
138+
.disabled(podcast.playbackUrl == "" || podcast.playbackUrl == nil)
139+
.tint(.pink)
124140
}
125-
.buttonStyle(.borderedProminent)
126-
.disabled(podcast.playbackUrl == "" || podcast.playbackUrl == nil)
127-
.tint(.pink)
128141

129142
if podcast.ended {
130143
Text("This podcast url not available.")

iosApp/iosApp/UI/Page/Space/iOSPodcastManager.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ class IOSPodcastManager: ObservableObject {
6464
removePlayerItemDidPlayToEndObserver()
6565
}
6666

67+
func getPlayingPodcast() -> UiPodcast? {
68+
currentPodcast
69+
}
70+
6771
func playPodcast(podcast: UiPodcast) {
6872
print("=========================================")
6973
print("[iOSPodcastManager] Request received: playPodcast")

0 commit comments

Comments
 (0)