-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add QueueView and delete other examples
- Loading branch information
Showing
42 changed files
with
79 additions
and
2,240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// QueueView.swift | ||
// SwiftAudio | ||
// | ||
// Created by David Chavez on 4/12/24. | ||
// | ||
|
||
import SwiftUI | ||
import SwiftAudioEx | ||
|
||
struct QueueView: View { | ||
let controller = AudioController.shared | ||
@Environment(\.dismiss) var dismiss | ||
|
||
var body: some View { | ||
NavigationStack { | ||
VStack { | ||
List { | ||
if controller.player.currentItem != nil { | ||
Section(header: Text("Playing Now")) { | ||
QueueItemView( | ||
title: controller.player.currentItem?.getTitle() ?? "", | ||
artist: controller.player.currentItem?.getArtist() ?? "" | ||
) | ||
} | ||
} | ||
Section(header: Text("Up Next")) { | ||
ForEach(controller.player.nextItems as! [DefaultAudioItem]) { item in | ||
QueueItemView( | ||
title: item.getTitle() ?? "", | ||
artist: item.getArtist() ?? "" | ||
) | ||
} | ||
} | ||
} | ||
} | ||
.navigationTitle("Queue") | ||
.toolbar { | ||
Button("Close") { | ||
dismiss() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct QueueItemView: View { | ||
let title: String | ||
let artist: String | ||
|
||
var body: some View { | ||
VStack(alignment: .leading) { | ||
Text(title) | ||
.fontWeight(.semibold) | ||
Text(artist) | ||
.fontWeight(.light) | ||
} | ||
} | ||
} | ||
|
||
|
||
#Preview { | ||
QueueView() | ||
} | ||
|
Oops, something went wrong.