@@ -25,148 +25,143 @@ struct AlbumListView: View {
25
25
@State private var showingAlbumCreator : Bool = false
26
26
27
27
var body : some View {
28
- ZStack {
29
- if isLoading && albums. isEmpty {
30
- LoadingView ( )
31
- . frame ( width: 100 , height: 100 )
32
- } else if let error = errorMessage {
33
- VStack {
34
- Text ( " Error loading albums " )
35
- . font ( . headline)
36
- . padding ( . bottom, 4 )
37
- Text ( error)
38
- . foregroundColor ( . secondary)
39
- Button ( " Retry " ) {
40
- loadAlbums ( )
41
- }
42
- . padding ( . top)
43
- . buttonStyle ( . bordered)
44
- }
45
- . padding ( )
46
- . background ( Color ( . systemBackground) )
47
- . cornerRadius ( 10 )
48
- . shadow ( radius: 5 )
49
- } else if albums. isEmpty {
50
- VStack {
51
- Image ( systemName: " photo.stack.fill " )
52
- . font ( . system( size: 50 ) )
53
- . padding ( . bottom)
54
- Text ( " No albums found " )
55
- . font ( . headline)
56
- Text ( " Create an album to get started " )
57
- . foregroundColor ( . secondary)
58
- }
59
- . padding ( )
60
- } else {
61
- NavigationStack ( path: $navigationPath) {
62
- List {
63
- ForEach ( albums, id: \. id) { album in
64
- NavigationLink ( value: album) {
65
- AlbumRowView ( album: album)
66
- . contextMenu {
67
- Button ( action: {
68
- UIPasteboard . general. string = album. url
69
- } ) {
70
- Label ( " Copy Link " , systemImage: " link " )
71
- }
72
-
73
- Button ( role: . destructive, action: {
74
- albumToDelete = album
75
- showDeleteConfirmation = true
76
- } ) {
77
- Label ( " Delete Album " , systemImage: " trash " )
78
- }
28
+ NavigationStack ( path: $navigationPath) {
29
+ ZStack {
30
+ if isLoading && albums. isEmpty {
31
+ LoadingView ( )
32
+ . frame ( width: 100 , height: 100 )
33
+ } else if let error = errorMessage {
34
+ VStack {
35
+ Text ( " Error loading albums " )
36
+ . font ( . headline)
37
+ . padding ( . bottom, 4 )
38
+ Text ( error)
39
+ . foregroundColor ( . secondary)
40
+ Button ( " Retry " ) {
41
+ loadAlbums ( )
42
+ }
43
+ . padding ( . top)
44
+ . buttonStyle ( . bordered)
45
+ }
46
+ . padding ( )
47
+ . background ( Color ( . systemBackground) )
48
+ . cornerRadius ( 10 )
49
+ . shadow ( radius: 5 )
50
+ } else {
51
+ List {
52
+ if albums. isEmpty {
53
+ HStack {
54
+ Spacer ( )
55
+ VStack {
56
+ Spacer ( )
57
+ Image ( systemName: " photo.stack.fill " )
58
+ . font ( . system( size: 50 ) )
59
+ . padding ( . bottom)
60
+ Text ( " No albums found " )
61
+ . font ( . headline)
62
+ Text ( " Create an album to get started " )
63
+ . foregroundColor ( . secondary)
79
64
}
65
+ . padding ( )
66
+ Spacer ( )
67
+ }
68
+ . listRowSeparator ( . hidden)
80
69
}
81
- . id ( album. id)
82
- . swipeActions ( edge: . trailing, allowsFullSwipe: true ) {
83
- Button ( ) {
84
- albumToDelete = album
85
- showDeleteConfirmation = true
86
- } label: {
87
- Label ( " Delete " , systemImage: " trash " )
70
+ ForEach ( albums, id: \. id) { album in
71
+ NavigationLink ( value: album) {
72
+ AlbumRowView ( album: album)
73
+ . contextMenu {
74
+ Button ( action: {
75
+ UIPasteboard . general. string = album. url
76
+ } ) {
77
+ Label ( " Copy Link " , systemImage: " link " )
78
+ }
79
+
80
+ Button ( role: . destructive, action: {
81
+ albumToDelete = album
82
+ showDeleteConfirmation = true
83
+ } ) {
84
+ Label ( " Delete Album " , systemImage: " trash " )
85
+ }
86
+ }
87
+ }
88
+ . id ( album. id)
89
+ . swipeActions ( edge: . trailing, allowsFullSwipe: true ) {
90
+ Button ( ) {
91
+ albumToDelete = album
92
+ showDeleteConfirmation = true
93
+ } label: {
94
+ Label ( " Delete " , systemImage: " trash " )
95
+ }
96
+ . tint ( . red)
97
+ }
98
+
99
+ if hasNextPage && album. id == albums. last? . id {
100
+ Color . clear
101
+ . frame ( height: 20 )
102
+ . onAppear {
103
+ loadNextPage ( )
104
+ }
88
105
}
89
- . tint ( . red)
90
106
}
91
107
92
- if hasNextPage && album. id == albums. last? . id {
93
- Color . clear
94
- . frame ( height: 20 )
95
- . onAppear {
96
- loadNextPage ( )
97
- }
108
+ if isLoading && hasNextPage {
109
+ HStack {
110
+ ProgressView ( )
111
+ }
98
112
}
99
113
}
100
-
101
- if isLoading && hasNextPage {
102
- HStack {
103
- ProgressView ( )
104
- }
114
+ . navigationDestination ( for: DFAlbum . self) { album in
115
+ FileListView ( server: server, albumID: album. id, navigationPath: $navigationPath, albumName: album. name)
116
+ . navigationTitle ( " test " )
105
117
}
106
- }
107
- . navigationDestination ( for: DFAlbum . self) { album in
108
- FileListView ( server: server, albumID: album. id, navigationPath: $navigationPath, albumName: album. name)
109
- . navigationTitle ( " test " )
110
- }
111
- . listStyle ( . plain)
112
- . refreshable {
113
- Task {
114
- await refreshAlbumsAsync ( )
115
- }
116
- }
117
- . navigationTitle ( server. wrappedValue != nil ? " Albums ( \( URL ( string: server. wrappedValue!. url) ? . host ?? " unknown " ) ) " : " Albums " )
118
- . toolbar {
119
- ToolbarItem ( placement: . navigationBarTrailing) {
120
- Button ( action: {
121
- showingAlbumCreator = true
122
- } ) {
123
- Label ( " Create Album " , systemImage: " plus " )
118
+ . listStyle ( . plain)
119
+ . refreshable {
120
+ Task {
121
+ await refreshAlbumsAsync ( )
124
122
}
125
123
}
126
124
}
127
- }
128
- . sheet ( isPresented: $showingAlbumCreator) {
129
- if let serverInstance = server. wrappedValue {
130
- CreateAlbumView ( server: serverInstance)
131
- . onDisappear {
132
- showingAlbumCreator = false
133
- }
125
+
126
+ }
127
+ . toolbar {
128
+ ToolbarItem ( placement: . navigationBarTrailing) {
129
+ Button ( action: {
130
+ showingAlbumCreator = true
131
+ } ) {
132
+ Label ( " Create Album " , systemImage: " plus " )
134
133
}
135
134
}
136
- . onChange ( of: selectedAlbum) { oldValue, newValue in
137
- if let album = newValue {
138
- navigationPath. append ( album)
139
- selectedAlbum = nil // Reset after navigation
140
- }
135
+ }
136
+ . navigationTitle ( server. wrappedValue != nil ? " Albums ( \( URL ( string: server. wrappedValue!. url) ? . host ?? " unknown " ) ) " : " Albums " )
137
+
138
+ . sheet ( isPresented: $showingAlbumCreator) {
139
+ if let serverInstance = server. wrappedValue {
140
+ CreateAlbumView ( server: serverInstance)
141
+ . onDisappear {
142
+ showingAlbumCreator = false
143
+ }
141
144
}
142
- . confirmationDialog ( " Are you sure? " , isPresented: $showDeleteConfirmation) {
143
- Button ( " Delete " , role: . destructive) {
144
- if let album = albumToDelete {
145
- Task {
146
- await deleteAlbum ( album)
147
- }
145
+ }
146
+ . onChange ( of: selectedAlbum) { oldValue, newValue in
147
+ if let album = newValue {
148
+ navigationPath. append ( album)
149
+ selectedAlbum = nil // Reset after navigation
150
+ }
151
+ }
152
+ . confirmationDialog ( " Are you sure? " , isPresented: $showDeleteConfirmation) {
153
+ Button ( " Delete " , role: . destructive) {
154
+ if let album = albumToDelete {
155
+ Task {
156
+ await deleteAlbum ( album)
148
157
}
149
158
}
150
- Button ( " Cancel " , role: . cancel) {
151
- // Optional: No action needed for cancel
152
- }
153
- } message: {
154
- Text ( " Are you sure you want to delete \" \( String ( describing: albumToDelete? . name ?? " Unknown Album " ) ) \" ? " )
155
159
}
156
- // .alert("Delete Album", isPresented: $showDeleteConfirmation) {
157
- // Button("Cancel", role: .cancel) {
158
- // albumToDelete = nil
159
- // }
160
- // Button("Delete", role: .destructive) {
161
- // if let album = albumToDelete {
162
- // Task {
163
- // await deleteAlbum(album)
164
- // }
165
- // }
166
- // }
167
- // } message: {
168
- // Text("Are you sure you want to delete this album? This action cannot be undone.")
169
- // }
160
+ Button ( " Cancel " , role: . cancel) {
161
+ // Optional: No action needed for cancel
162
+ }
163
+ } message: {
164
+ Text ( " Are you sure you want to delete \" \( String ( describing: albumToDelete? . name ?? " Unknown Album " ) ) \" ? " )
170
165
}
171
166
}
172
167
. onAppear {
0 commit comments