Share Library controls and use native navigation
This commit is contained in:
1 parent
89e81f0eb0
commit
de617ad1d2
4 files changed
+183
-215
No files matched your search
@@ -44,7 +44,6 @@ final class LibraryArtistsViewModel: ObservableObject {
|
||||
}
|
||||
|
||||
struct LibraryArtistsView: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@StateObject private var model: LibraryArtistsViewModel
|
||||
|
||||
private let columns = [GridItem(.flexible(), spacing: 14), GridItem(.flexible(), spacing: 14)]
|
||||
@@ -56,13 +55,6 @@ struct LibraryArtistsView: View {
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
topBar
|
||||
|
||||
Text("Artists")
|
||||
.font(.system(size: 34, weight: .bold))
|
||||
.padding(.top, 22)
|
||||
.padding(.bottom, 18)
|
||||
|
||||
content
|
||||
}
|
||||
.padding(.horizontal, 20)
|
||||
@@ -71,54 +63,26 @@ struct LibraryArtistsView: View {
|
||||
.scrollIndicators(.hidden)
|
||||
.background(Color.black.ignoresSafeArea())
|
||||
.foregroundStyle(.white)
|
||||
.toolbar(.hidden, for: .navigationBar)
|
||||
.navigationTitle("Artists")
|
||||
.navigationBarTitleDisplayMode(.large)
|
||||
.toolbar(.visible, for: .navigationBar)
|
||||
.refreshable { await model.load(forceRefresh: true) }
|
||||
.task { await model.load() }
|
||||
}
|
||||
|
||||
private var topBar: some View {
|
||||
HStack {
|
||||
Button(action: { dismiss() }) {
|
||||
Image(systemName: "chevron.left")
|
||||
.font(.system(size: 20, weight: .medium))
|
||||
.frame(width: 48, height: 48)
|
||||
.background(.ultraThinMaterial, in: Circle())
|
||||
.overlay(Circle().stroke(.white.opacity(0.12), lineWidth: 1))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.accessibilityLabel("Back to Library")
|
||||
Spacer()
|
||||
}
|
||||
.padding(.top, 4)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var content: some View {
|
||||
if model.isLoading && model.artists.isEmpty {
|
||||
ProgressView("Loading your artists…")
|
||||
.tint(.red)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.top, 44)
|
||||
} else if let errorMessage = model.errorMessage, model.artists.isEmpty {
|
||||
ContentUnavailableView {
|
||||
Label("Couldn't Load Artists", systemImage: "wifi.exclamationmark")
|
||||
} description: {
|
||||
Text(errorMessage)
|
||||
} actions: {
|
||||
Button("Try Again") {
|
||||
Task { await model.load(forceRefresh: true) }
|
||||
}
|
||||
.tint(.red)
|
||||
}
|
||||
.padding(.top, 28)
|
||||
} else if model.artists.isEmpty {
|
||||
ContentUnavailableView(
|
||||
"No Saved Artists",
|
||||
systemImage: "mic",
|
||||
description: Text("Artists from songs you add to your Library will appear here.")
|
||||
)
|
||||
.padding(.top, 28)
|
||||
} else {
|
||||
LibraryCollectionContent(
|
||||
isLoading: model.isLoading,
|
||||
isEmpty: model.artists.isEmpty,
|
||||
errorMessage: model.errorMessage,
|
||||
loadingMessage: "Loading your artists…",
|
||||
errorTitle: "Couldn't Load Artists",
|
||||
emptyTitle: "No Saved Artists",
|
||||
emptySymbol: "mic",
|
||||
emptyDescription: "Artists from songs you add to your Library will appear here.",
|
||||
onRetry: { Task { await model.load(forceRefresh: true) } }
|
||||
) {
|
||||
LazyVGrid(columns: columns, alignment: .leading, spacing: 20) {
|
||||
ForEach(model.artists) { artist in
|
||||
NavigationLink {
|
||||
|
||||
Reference in new issue
Block a user