-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlbumDetailView.swift
57 lines (48 loc) · 1.59 KB
/
AlbumDetailView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
See the LICENSE.txt file for this sample’s licensing information.
Abstract:
A view that displays detail information and interactions for a media album.
*/
import AppIntents
import SwiftUI
struct AlbumDetailView: View {
// MARK: Properties
let album: Album
@State private var isNameSheetPresented = false
@State private var isAssetPickerPresented = false
@Environment(MediaLibrary.self) private var library
@Environment(\.dismiss) private var dismiss
// MARK: Lifecycle
var body: some View {
VStack {
AssetGrid(assets: album.assets, album: album)
}
.toolbar {
ToolbarItem {
Menu {
Button("Select Photos", systemImage: "photo.badge.checkmark") {
isAssetPickerPresented = true
}
Button("Rename Album", systemImage: "pencil") {
isNameSheetPresented = true
}
Divider()
Button("Delete", systemImage: "trash", role: .destructive) {
Task {
try await library.deleteAlbums([album])
dismiss()
}
}
} label: {
Image(systemName: "ellipsis")
}
}
}
.sheet(isPresented: $isNameSheetPresented) {
AlbumNameView(album: album)
}
.sheet(isPresented: $isAssetPickerPresented) {
AlbumAssetPicker(album: album)
}
}
}