iOS 2.5.0 - Apple Music Integration
This commit is contained in:
@@ -122,6 +122,7 @@ struct SessionsList: View {
|
||||
{
|
||||
Section {
|
||||
ActiveSessionBanner(session: activeSession, gym: gym)
|
||||
.environmentObject(MusicService.shared)
|
||||
.padding(.horizontal, 16)
|
||||
.listRowInsets(EdgeInsets(top: 16, leading: 0, bottom: 24, trailing: 0))
|
||||
.listRowBackground(Color.clear)
|
||||
@@ -178,6 +179,17 @@ struct ActiveSessionBanner: View {
|
||||
let gym: Gym
|
||||
@EnvironmentObject var dataManager: ClimbingDataManager
|
||||
@State private var navigateToDetail = false
|
||||
|
||||
// Access MusicService via DataManager if possible, or EnvironmentObject if injected
|
||||
// Since DataManager holds MusicService, we can access it through there if we expose it or inject it.
|
||||
// In SettingsView we saw .environmentObject(dataManager.musicService).
|
||||
// We should probably inject it here too or access via dataManager if it's public.
|
||||
// Let's check ClimbingDataManager again. It has `let musicService = MusicService.shared`.
|
||||
// But it's not @Published so it won't trigger updates unless we observe the service itself.
|
||||
// The best way is to use @EnvironmentObject var musicService: MusicService
|
||||
// and ensure it's injected in the parent view.
|
||||
|
||||
@EnvironmentObject var musicService: MusicService
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
@@ -201,6 +213,19 @@ struct ActiveSessionBanner: View {
|
||||
.foregroundColor(.secondary)
|
||||
.monospacedDigit()
|
||||
}
|
||||
|
||||
if musicService.isMusicEnabled && musicService.isAuthorized {
|
||||
Button(action: {
|
||||
musicService.togglePlayback()
|
||||
}) {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: musicService.isPlaying ? "pause.fill" : "play.fill")
|
||||
.font(.caption)
|
||||
}
|
||||
.foregroundColor(.pink)
|
||||
.padding(.top, 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.contentShape(Rectangle())
|
||||
|
||||
Reference in New Issue
Block a user