edit loading
This commit is contained in:
parent
0a7d519567
commit
128ed5723a
@ -25,18 +25,6 @@ struct BlockedUsersView: View {
|
||||
emptyState
|
||||
} else {
|
||||
usersSection
|
||||
if isLoading {
|
||||
Section {
|
||||
ProgressView()
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
}
|
||||
} else if let errorMessage = errorMessageDown {
|
||||
Text(errorMessage)
|
||||
.foregroundColor(.red)
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowBackground(Color.clear)
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle(NSLocalizedString("Заблокированные", comment: ""))
|
||||
@ -92,44 +80,59 @@ struct BlockedUsersView: View {
|
||||
|
||||
private var usersSection: some View {
|
||||
Section(header: Text(NSLocalizedString("Заблокированные", comment: ""))) {
|
||||
ForEach(blockedUsers) {
|
||||
user in
|
||||
HStack(spacing: 12) {
|
||||
Circle()
|
||||
.fill(Color.accentColor.opacity(0.15))
|
||||
.frame(width: 44, height: 44)
|
||||
.overlay(
|
||||
Text(user.initials)
|
||||
.font(.headline)
|
||||
.foregroundColor(.accentColor)
|
||||
)
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text(user.displayName)
|
||||
.font(.body)
|
||||
if let handle = user.handle {
|
||||
Text(handle)
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
ForEach(blockedUsers) { user in
|
||||
userRow(user)
|
||||
}
|
||||
if isLoading {
|
||||
ProgressView()
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.listRowBackground(Color.clear)
|
||||
.listRowSeparator(.hidden)
|
||||
} else if let errorMessage = errorMessageDown {
|
||||
Text(errorMessage)
|
||||
.foregroundColor(.red)
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.listRowBackground(Color.clear)
|
||||
.listRowSeparator(.hidden)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func userRow(_ user: BlockedUser) -> some View {
|
||||
HStack(spacing: 12) {
|
||||
Circle()
|
||||
.fill(Color.accentColor.opacity(0.15))
|
||||
.frame(width: 44, height: 44)
|
||||
.overlay(
|
||||
Text(user.initials)
|
||||
.font(.headline)
|
||||
.foregroundColor(.accentColor)
|
||||
)
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text(user.displayName)
|
||||
.font(.body)
|
||||
if let handle = user.handle {
|
||||
Text(handle)
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.padding(.vertical, 0)
|
||||
.swipeActions(edge: .trailing) {
|
||||
Button(role: .destructive) {
|
||||
pendingUnblock = user
|
||||
showUnblockConfirmation = true
|
||||
} label: {
|
||||
Label(NSLocalizedString("Разблокировать", comment: ""), systemImage: "person.crop.circle.badge.xmark")
|
||||
}
|
||||
.disabled(removingUserIds.contains(user.id))
|
||||
}
|
||||
.onAppear {
|
||||
if user.id == blockedUsers.last?.id {
|
||||
Task {
|
||||
await loadBlockedUsers()
|
||||
}
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.padding(.vertical, 0)
|
||||
.swipeActions(edge: .trailing) {
|
||||
Button(role: .destructive) {
|
||||
pendingUnblock = user
|
||||
showUnblockConfirmation = true
|
||||
} label: {
|
||||
Label(NSLocalizedString("Разблокировать", comment: ""), systemImage: "person.crop.circle.badge.xmark")
|
||||
}
|
||||
.disabled(removingUserIds.contains(user.id))
|
||||
}
|
||||
.onAppear {
|
||||
if user.id == blockedUsers.last?.id {
|
||||
Task {
|
||||
await loadBlockedUsers()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user