This commit is contained in:
Jin
2026-05-14 17:50:06 +08:00
parent 63e29be346
commit fdde6c51ce
25 changed files with 2970 additions and 295 deletions
+35 -34
View File
@@ -22,48 +22,49 @@ struct FavoritesView: View {
#endif
var body: some View {
NavigationStack {
Group {
if favorites.isEmpty {
emptyState
} else {
ScrollView {
LazyVGrid(columns: columns, spacing: 16) {
//
ForEach(favorites) { item in
NavigationLink(value: movieVideo(from: item)) {
favoriteCard(item)
}
.buttonStyle(.plain)
.contextMenu {
Button(role: .destructive) {
modelContext.delete(item)
do {
try modelContext.save()
} catch {
print("删除收藏失败: \(error)")
}
} label: {
Label("取消收藏", systemImage: "heart.slash")
favoritesContent
}
/// NavigationStack
/// iOS ProfileView/SettingsView NavigationStack
/// macOS ContentView NavigationSplitView detail 使 NavigationStack
private var favoritesContent: some View {
Group {
if favorites.isEmpty {
emptyState
} else {
ScrollView {
LazyVGrid(columns: columns, spacing: 16) {
//
ForEach(favorites) { item in
NavigationLink(destination: DetailView(video: movieVideo(from: item))) {
favoriteCard(item)
}
.buttonStyle(.plain)
.contextMenu {
Button(role: .destructive) {
modelContext.delete(item)
do {
try modelContext.save()
} catch {
print("删除收藏失败: \(error)")
}
} label: {
Label("取消收藏", systemImage: "heart.slash")
}
}
}
.padding(.horizontal, 20)
.padding(.vertical, 12)
}
.padding(.horizontal, 20)
.padding(.vertical, 12)
}
}
.background(Color(red: 0.08, green: 0.08, blue: 0.1))
.navigationTitle("收藏")
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
#endif
// Movie.Video /
.navigationDestination(for: Movie.Video.self) { video in
DetailView(video: video)
}
}
.background(Color(red: 0.08, green: 0.08, blue: 0.1))
.navigationTitle("收藏")
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
#endif
}
///