Skip to content

Commit e8bb02a

Browse files
committed
empty list adjustments
1 parent 4aa7576 commit e8bb02a

File tree

3 files changed

+157
-153
lines changed

3 files changed

+157
-153
lines changed

Django Files/Views/AlbumList.swift

Lines changed: 120 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -25,148 +25,143 @@ struct AlbumListView: View {
2525
@State private var showingAlbumCreator: Bool = false
2626

2727
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)
7964
}
65+
.padding()
66+
Spacer()
67+
}
68+
.listRowSeparator(.hidden)
8069
}
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+
}
88105
}
89-
.tint(.red)
90106
}
91107

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+
}
98112
}
99113
}
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")
105117
}
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()
124122
}
125123
}
126124
}
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")
134133
}
135134
}
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+
}
141144
}
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)
148157
}
149158
}
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"))\"?")
155159
}
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"))\"?")
170165
}
171166
}
172167
.onAppear {

Django Files/Views/FileList.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,25 @@ struct FileListView: View {
178178

179179
var body: some View {
180180
List {
181+
if files.count == 0 {
182+
HStack {
183+
Spacer()
184+
VStack {
185+
Spacer()
186+
Image(systemName: "document.on.document.fill")
187+
.font(.system(size: 50))
188+
.padding(.bottom)
189+
Text("No files found")
190+
.font(.headline)
191+
Text("Upload a file to get start")
192+
.foregroundColor(.secondary)
193+
}
194+
.padding()
195+
Spacer()
196+
}
197+
.listRowSeparator(.hidden)
198+
}
199+
181200
ForEach(files, id: \.id) { file in
182201
Button {
183202
selectedFile = file

Django Files/Views/ShortList.swift

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ struct ShortListView: View {
2525
if server.wrappedValue != nil {
2626
NavigationStack {
2727
List {
28+
if shorts.isEmpty {
29+
HStack {
30+
Spacer()
31+
VStack {
32+
Spacer()
33+
Image(systemName: "personalhotspot.slash")
34+
.font(.system(size: 50))
35+
.padding(.bottom)
36+
Text("No shorts found")
37+
.font(.headline)
38+
Text("Create a short URL to get started.")
39+
.foregroundColor(.secondary)
40+
}
41+
.padding()
42+
Spacer()
43+
}
44+
.listRowSeparator(.hidden)
45+
}
2846
ForEach(shorts) { short in
2947
ShortRow(short: short)
3048
.onTapGesture {
@@ -38,10 +56,6 @@ struct ShortListView: View {
3856
await refreshShorts()
3957
}
4058
.overlay {
41-
if shorts.isEmpty && !isLoading {
42-
emptyView
43-
}
44-
4559
if let error = error {
4660
errorView(message: error)
4761
}
@@ -87,30 +101,6 @@ struct ShortListView: View {
87101
.frame(maxWidth: .infinity, maxHeight: .infinity)
88102
}
89103

90-
private var emptyView: some View {
91-
VStack(spacing: 16) {
92-
Image(systemName: "personalhotspot.slash")
93-
.font(.system(size: 60))
94-
.foregroundColor(.secondary)
95-
96-
Text("No short URLs found")
97-
.font(.headline)
98-
99-
Text("Create your first short URL to get started")
100-
.foregroundColor(.secondary)
101-
.multilineTextAlignment(.center)
102-
.padding(.horizontal)
103-
104-
Button("Create Short URL") {
105-
// TODO: Implement create new short URL action
106-
}
107-
.buttonStyle(.borderedProminent)
108-
.padding(.top)
109-
}
110-
.frame(maxWidth: .infinity, maxHeight: .infinity)
111-
.background(Color(UIColor.systemBackground))
112-
}
113-
114104
private func errorView(message: String) -> some View {
115105
VStack(spacing: 16) {
116106
Image(systemName: "exclamationmark.triangle")

0 commit comments

Comments
 (0)